no message

This commit is contained in:
kuaifan 2024-02-06 21:23:16 +08:00 committed by Pang
parent 897fc51ce3
commit f42408a363
5 changed files with 42 additions and 13 deletions

28
electron/electron.js vendored
View File

@ -24,6 +24,7 @@ let enablePlugins = false;
let mainWindow = null, let mainWindow = null,
mainTray = null, mainTray = null,
subWindow = [], subWindow = [],
storageBrowser = null,
isReady = false, isReady = false,
willQuitApp = false, willQuitApp = false,
devloadUrl = "", devloadUrl = "",
@ -491,6 +492,33 @@ ipcMain.on('windowMax', (event) => {
event.returnValue = "ok" event.returnValue = "ok"
}) })
/**
* 创建子窗口存储浏览器
* @param args {url}
*/
ipcMain.on('storageBrowser', (event, args) => {
if (utils.isJson(args) && allowedUrls.test(args.url)) {
if (storageBrowser === null) {
storageBrowser = new BrowserWindow({
show: false,
frame: false,
transparent: true,
webPreferences: {
preload: path.join(__dirname, 'electron-preload.js'),
webSecurity: true,
nodeIntegration: true,
contextIsolation: true,
nativeWindowOpen: true
},
})
}
storageBrowser.loadURL(args.url).then(_ => {
})
}
event.returnValue = "ok"
})
/** /**
* 给主窗口发送信息 * 给主窗口发送信息
* @param args {channel, data} * @param args {channel, data}

View File

@ -135,7 +135,7 @@ export default {
// //
window.localStorage.setItem("__system:userId__", this.userId) window.localStorage.setItem("__system:userId__", this.userId)
window.localStorage.setItem("__system:userToken__", this.userToken) window.localStorage.setItem("__system:userToken__", this.userToken)
$A.storageBySubWeb({ $A.storageByBrowser({
userId: this.userId, userId: this.userId,
userToken: this.userToken, userToken: this.userToken,
}) })

View File

@ -920,31 +920,32 @@ import {MarkdownPreview} from "../store/markdown";
* 通过结果存储同步本地数据 * 通过结果存储同步本地数据
* @param json * @param json
*/ */
storageBySubWeb(json) { storageByBrowser(json) {
if ($A.isSoftware) { if ($A.isSoftware) {
json = Object.assign({}, this.__storageBySubWeb, json) json = Object.assign({}, this.__storageByBrowser, json)
const obj = {} const obj = {}
Object.keys(json).sort().map(item => { Object.keys(json).sort().map(item => {
obj[item] = json[item] obj[item] = json[item]
}) })
if (JSON.stringify(obj) == JSON.stringify(this.__storageBySubWeb)) { if (JSON.stringify(obj) == JSON.stringify(this.__storageByBrowser)) {
return return
} }
this.__storageBySubWeb = obj this.__storageByBrowser = obj
const value = encodeURIComponent(JSON.stringify(this.__storageBySubWeb)) const value = encodeURIComponent(JSON.stringify(this.__storageByBrowser))
const url = $A.apiUrl(`../storage/synch?value=${value}`) const url = $A.apiUrl(`../storage/synch?value=${value}`)
console.log(url);
if ($A.isEEUiApp) { if ($A.isEEUiApp) {
$A.eeuiAppSendMessage({ $A.eeuiAppSendMessage({
action: 'subWeb', action: 'storageBrowser',
url, url,
}); });
} else { } else {
$A.loadIframe(url, 15000).catch(_ => {}) $A.Electron.sendMessage('storageBrowser', {
url
});
} }
} }
}, },
__storageBySubWeb: {} __storageByBrowser: {}
}); });
/** /**

View File

@ -85,7 +85,7 @@ export default {
`language/web/key.js`, `language/web/key.js`,
`language/web/${languageName}.js`, `language/web/${languageName}.js`,
]) ])
$A.storageBySubWeb({languageName}) $A.storageByBrowser({languageName})
resolve(action) resolve(action)
}) })
@ -522,7 +522,7 @@ export default {
themeName: state.themeName, themeName: state.themeName,
}); });
} }
$A.storageBySubWeb({themeConf: state.themeConf}) $A.storageByBrowser({themeConf: state.themeConf})
}, },
/** /**

@ -1 +1 @@
Subproject commit 771933b49d280bc4ada4c16fd9d36a4aef115634 Subproject commit bf09ca1248d05de4af09c96d8d27ee77e553028d