From a99c2f6944906837a145df87c5e156b91f1029b1 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 21 Dec 2024 11:03:02 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/build.js | 1 + resources/assets/js/app.js | 4 ++-- resources/assets/js/store/actions.js | 18 +++++++----------- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/electron/build.js b/electron/build.js index 00846b83e..ddba909eb 100644 --- a/electron/build.js +++ b/electron/build.js @@ -512,6 +512,7 @@ async function startBuild(data) { fse.copySync(path.resolve(__dirname, "../public/language"), path.resolve(electronDir, "language")) // config.js fs.writeFileSync(electronDir + "/config.js", "window.systemInfo = " + JSON.stringify(systemInfo), 'utf8'); + fs.writeFileSync(electronDir + "/dark", '', 'utf8'); fs.writeFileSync(nativeCachePath, utils.formatUrl(data.url)); fs.writeFileSync(devloadCachePath, "", 'utf8'); // index.html diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js index 04a16beae..564d69ec5 100644 --- a/resources/assets/js/app.js +++ b/resources/assets/js/app.js @@ -1,4 +1,4 @@ -const isElectron = !!(window && window.process && window.process.type); +const isElectron = !!(window && window.process && window.process.type && window.electron); const isEEUiApp = window && window.navigator && /eeui/i.test(window.navigator.userAgent); const isSoftware = isElectron || isEEUiApp; @@ -192,7 +192,7 @@ $A.isElectron = isElectron; $A.isSoftware = isSoftware; $A.openLog = false; if (isElectron) { - $A.Electron = electron; + $A.Electron = window.electron; $A.Platform = /macintosh|mac os x/i.test(navigator.userAgent) ? "mac" : "win"; $A.isMainElectron = /\s+MainTaskWindow\//.test(window.navigator.userAgent); $A.isSubElectron = /\s+SubTaskWindow\//.test(window.navigator.userAgent); diff --git a/resources/assets/js/store/actions.js b/resources/assets/js/store/actions.js index c2ba05bf4..0f2f61480 100644 --- a/resources/assets/js/store/actions.js +++ b/resources/assets/js/store/actions.js @@ -1106,10 +1106,9 @@ export default { * @param dispatch * @param params */ - openChildWindow({dispatch}, params) { - dispatch("userUrl", params.path).then(path => { - $A.Electron.sendMessage('openChildWindow', Object.assign(params, {path})) - }) + async openChildWindow({dispatch}, params) { + const path = await dispatch("userUrl", params.path) + $A.Electron.sendMessage('openChildWindow', Object.assign(params, {path})) }, /** @@ -1117,14 +1116,11 @@ export default { * @param dispatch * @param url */ - openWebTabWindow({dispatch}, url) { - if ($A.getDomain(url) != $A.getDomain($A.mainUrl())) { - $A.Electron.sendMessage('openWebTabWindow', {url}) - return + async openWebTabWindow({dispatch}, url) { + if ($A.getDomain(url) == $A.getDomain($A.mainUrl())) { + url = await dispatch("userUrl", url) } - dispatch("userUrl", url).then(url => { - $A.Electron.sendMessage('openWebTabWindow', {url}) - }) + $A.Electron.sendMessage('openWebTabWindow', {url}) }, /** *****************************************************************************************/