From eb96f548ea7411f251bc439732914d66f364a52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Thu, 3 Oct 2024 11:00:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20=E6=96=B0=E5=A2=9EopenS?= =?UTF-8?q?ystemBrowser=E5=9B=9E=E8=B0=83=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types/Plugins/JSBridge.d.ts | 15 +++++++++++++-- src/utils/TGClient.ts | 22 ++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/types/Plugins/JSBridge.d.ts b/src/types/Plugins/JSBridge.d.ts index caeb0558..66170473 100644 --- a/src/types/Plugins/JSBridge.d.ts +++ b/src/types/Plugins/JSBridge.d.ts @@ -1,12 +1,12 @@ /** * @file types/Plugins/JSBridge.d.ts * @description JSBridge 插件相关类型定义文件 - * @since Beta v0.3.9 + * @since Beta v0.6.0 */ /** * @description JSBridge 插件相关类型命名 - * @since Beta v0.3.9 + * @since Beta v0.6.0 * @namespace TGApp.Plugins.JSBridge * @memberof TGApp.Plugins */ @@ -173,6 +173,17 @@ declare namespace TGApp.Plugins.JSBridge { gameCenterId: number; } + /** + * @description 打开系统浏览器 + * @since Beta v0.6.0 + * @interface OpenSystemBrowserPayload + * @property {string} open_url - 打开的链接 + * @return OpenSystemBrowserPayload + */ + interface OpenSystemBrowserPayload { + open_url: string; + } + /** * @description pushPage 方法参数 * @since Beta v0.3.9 diff --git a/src/utils/TGClient.ts b/src/utils/TGClient.ts index c66cf2b5..33b5a46c 100644 --- a/src/utils/TGClient.ts +++ b/src/utils/TGClient.ts @@ -1,7 +1,7 @@ /** * @file utils/TGClient.ts * @desc 负责米游社客户端的 callback 处理 - * @since Beta v0.5.5 + * @since Beta v0.6.0 */ import { event, core, webviewWindow } from "@tauri-apps/api"; @@ -153,7 +153,7 @@ class TGClient { /** * @func handleCallback - * @since Beta v0.4.2 + * @since Beta v0.6.0 * @desc 处理米游社客户端的 callback * @param {Event} arg - 事件参数 * @returns {Promise} - 返回值 @@ -235,6 +235,11 @@ class TGClient { >argParse, ); break; + case "openSystemBrowser": + await this.openSystemBrowser( + >argParse, + ); + break; case "pushPage": await this.pushPage( >argParse, @@ -756,6 +761,19 @@ class TGClient { } } + /** + * @func openSystemBrowser + * @since Beta v0.6.0 + * @desc 打开系统浏览器 + * @param {TGApp.Plugins.JSBridge.Arg} arg - 方法参数 + * @returns {Promise} + */ + async openSystemBrowser(arg: TGApp.Plugins.JSBridge.OpenSystemBrowserPayload): Promise { + console.log(`[openSystemBrowser] ${JSON.stringify(arg)}`); + const url = arg.open_url; + window.open(url); + } + /** * @func pushPage * @since Beta v0.5.5