mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-11 09:08:14 +08:00
👽️ 新增openSystemBrowser回调处理
This commit is contained in:
15
src/types/Plugins/JSBridge.d.ts
vendored
15
src/types/Plugins/JSBridge.d.ts
vendored
@@ -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
|
||||
|
||||
@@ -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<string>} arg - 事件参数
|
||||
* @returns {Promise<void>} - 返回值
|
||||
@@ -235,6 +235,11 @@ class TGClient {
|
||||
<TGApp.Plugins.JSBridge.Arg<TGApp.Plugins.JSBridge.OpenApplicationPayload>>argParse,
|
||||
);
|
||||
break;
|
||||
case "openSystemBrowser":
|
||||
await this.openSystemBrowser(
|
||||
<TGApp.Plugins.JSBrigde.Arg<TGApp.Plugins.JSBridge.OpenSystemBrowserPayload>>argParse,
|
||||
);
|
||||
break;
|
||||
case "pushPage":
|
||||
await this.pushPage(
|
||||
<TGApp.Plugins.JSBridge.Arg<TGApp.Plugins.JSBridge.PushPagePayload>>argParse,
|
||||
@@ -756,6 +761,19 @@ class TGClient {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @func openSystemBrowser
|
||||
* @since Beta v0.6.0
|
||||
* @desc 打开系统浏览器
|
||||
* @param {TGApp.Plugins.JSBridge.Arg<TGApp.Plugins.JSBridge.OpenSystemBrowserPayload>} arg - 方法参数
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async openSystemBrowser(arg: TGApp.Plugins.JSBridge.OpenSystemBrowserPayload): Promise<void> {
|
||||
console.log(`[openSystemBrowser] ${JSON.stringify(arg)}`);
|
||||
const url = arg.open_url;
|
||||
window.open(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @func pushPage
|
||||
* @since Beta v0.5.5
|
||||
|
||||
Reference in New Issue
Block a user