perf: 优化客户端

This commit is contained in:
kuaifan 2024-12-21 11:03:02 +08:00
parent f9540b08cd
commit a99c2f6944
3 changed files with 10 additions and 13 deletions

1
electron/build.js vendored
View File

@ -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

View File

@ -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);

View File

@ -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})
},
/** *****************************************************************************************/