diff --git a/assets/Plugins.meta b/assets/Plugins.meta new file mode 100644 index 0000000..37c2b43 --- /dev/null +++ b/assets/Plugins.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.2", + "uuid": "9e28a2e5-f683-4157-bfc5-f19dd02440b1", + "isBundle": false, + "bundleName": "", + "priority": 1, + "compressionType": {}, + "optimizeHotUpdate": {}, + "inlineSpriteFrames": {}, + "isRemoteBundle": {}, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Plugins/responsivevoice.js.meta b/assets/Plugins/responsivevoice.js.meta new file mode 100644 index 0000000..0a74a6c --- /dev/null +++ b/assets/Plugins/responsivevoice.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "9f49e939-dfca-4a26-81e2-e22c98a61c90", + "isPlugin": true, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": true, + "subMetas": {} +} \ No newline at end of file diff --git a/assets/Script/Manager.ts b/assets/Script/Manager.ts index f0f5e5f..2b640df 100644 --- a/assets/Script/Manager.ts +++ b/assets/Script/Manager.ts @@ -1,3 +1,5 @@ +import Text_to_Speech from "./Text_to_Speech"; + const { ccclass, property } = cc._decorator; @ccclass @@ -12,6 +14,12 @@ export default class Manager extends cc.Component { //#endregion + //#region private + + private _text_to_Speech: Text_to_Speech = new Text_to_Speech(); + + //#endregion + //#region Lifecycle protected onLoad(): void { @@ -20,17 +28,14 @@ export default class Manager extends cc.Component { let data: any = e.data; let method: string = data.method; let value: any = data.value; - if (method && self[method]) { - if (value) { - self[method](...value); - return; - } else if (self[method]) { - self[method](); - return; - } - } - console.log(`not function: ${method}, value: ${value}`); + self.Birdge(method, value) }, false); + + if (!window["Bridge"]) { + window["Bridge"] = function (method: string = "", value: string = ""): void { + self.Birdge(method, value) + }; + } let href: string = window.location.href; this.webview.url = `https://karolchang.github.io/jm-expense-vue-ts/?host=${href}&ignore=${Date.now()}`; @@ -41,6 +46,20 @@ export default class Manager extends cc.Component { this._resize(); } + public Birdge(method: string, value: string = ""): void { + let self: this = this; + if (method && self[method]) { + if (value) { + self[method](value); + return; + } else if (self[method]) { + self[method](); + return; + } + } + console.log(`not function: ${method}, value: ${value}`); + } + private _closeBG(): void { if (this.webview.node.opacity === 0) { this.BG.destroy(); @@ -54,6 +73,10 @@ export default class Manager extends cc.Component { console.log(msg); } + private _speak(msg: string): void { + this._text_to_Speech.speak(msg); + } + private _alert(msg: string): void { alert(msg); } diff --git a/assets/Script/Text_to_Speech.ts b/assets/Script/Text_to_Speech.ts index eefa2ba..3be2a97 100644 --- a/assets/Script/Text_to_Speech.ts +++ b/assets/Script/Text_to_Speech.ts @@ -1,36 +1,27 @@ -const { ccclass, property } = cc._decorator; +export default class Text_to_Speech { + //#region 外調參數 -@ccclass -export default class Text_to_Speech extends cc.Component { + private _responsiveVoice: any = window["responsiveVoice"]; - // LIFE-CYCLE CALLBACKS: + //#endregion - start(): void { + //#region Custom + + constructor() { + this._responsiveVoice.speak("hello world"); + } + + public speak(msg: string): void { let self: this = this; - - let url: string = window.location.search; - let request: object = []; - if (url.indexOf("?") !== -1) { - let str: string = url.substr(1); - let strs: string[] = str.split("&"); - for (let i: number = 0; i < strs.length; i++) { - request[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]); - } - } - - let ResponsiveVoice: any = responsiveVoice; - // var voicelist: any = ResponsiveVoice.getVoices(); - // let voice: string = this.EditBox.string; - // let voice: string = "傻B豆豆"; - let voice: string = request["voice"]; - ResponsiveVoice.speak(voice, "Chinese Female", { + this._responsiveVoice.speak(msg, "Chinese Female", { onstart: function (Callback: any): void { - // IsEnd = true; - self.node.getChildByName("Label").getComponent(cc.Label).string = voice; + console.log(`onstart msg: ${msg}`); + }, + onend: function (Callback: any): void { + console.log(`onstart msg: ${msg}`); }, - // onend: function (Callback: any): void { - // // IsEnd = true; - // }, }); } + + //#endregion } diff --git a/assets/Script/Text_to_Speech.ts.meta b/assets/Script/Text_to_Speech.ts.meta new file mode 100644 index 0000000..490c585 --- /dev/null +++ b/assets/Script/Text_to_Speech.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.8", + "uuid": "99fa9c05-c449-4a27-b629-42f77916556a", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file