支持从加密聊天打开隔离浏览器链接
This commit is contained in:
1 parent
f4ea1f8e03
commit
6786158a3e
8 files changed
+54
-8
No files matched your search
+5
-3
@@ -2,7 +2,7 @@ import { app, BrowserWindow, ipcMain, protocol, safeStorage, session } from 'ele
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { join } from 'node:path'
|
||||
import { signChallenge, signMls } from './identity'
|
||||
import { openBrowser, registerBrowserHandlers } from './browser'
|
||||
import { openBrowser, registerBrowserHandlers, website } from './browser'
|
||||
|
||||
const appURL = 'xhchat://app/'
|
||||
app.enableSandbox()
|
||||
@@ -102,9 +102,11 @@ async function start() {
|
||||
return key
|
||||
})
|
||||
registerBrowserHandlers(trusted)
|
||||
ipcMain.handle('browser:open', (event) => {
|
||||
ipcMain.handle('browser:open', (event, url: unknown) => {
|
||||
if (!trustedSender(event)) throw new Error('浏览器入口来源无效')
|
||||
openBrowser(trusted)
|
||||
const initial = typeof url === 'string' && url.length <= 4096 ? website(url) : undefined
|
||||
if (url !== undefined && !initial) throw new Error('网页地址无效')
|
||||
openBrowser(trusted, false, initial)
|
||||
})
|
||||
await win.loadURL(appURL)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user