feat: update package.json dependencies and enhance webview handling
- Removed the outdated @electron-toolkit/preload dependency and re-added it with the correct version. - Added a new event listener in WindowService to set the preload script for webviews. - Updated the openExternal method in preload to handle potential null values. - Enabled node integration for webviews in the MinApp component for improved functionality.
This commit is contained in:
parent
a6921b064d
commit
07199d0ed6
@ -53,7 +53,6 @@
|
||||
"@agentic/exa": "^7.3.3",
|
||||
"@agentic/searxng": "^7.3.3",
|
||||
"@agentic/tavily": "^7.3.3",
|
||||
"@electron-toolkit/preload": "^3.0.0",
|
||||
"@electron-toolkit/utils": "^3.0.0",
|
||||
"@electron/notarize": "^2.5.0",
|
||||
"@emotion/is-prop-valid": "^1.3.1",
|
||||
@ -96,6 +95,7 @@
|
||||
"@anthropic-ai/sdk": "^0.38.0",
|
||||
"@electron-toolkit/eslint-config-prettier": "^2.0.0",
|
||||
"@electron-toolkit/eslint-config-ts": "^1.0.1",
|
||||
"@electron-toolkit/preload": "^3.0.0",
|
||||
"@electron-toolkit/tsconfig": "^1.0.1",
|
||||
"@hello-pangea/dnd": "^16.6.0",
|
||||
"@kangfenmao/keyv-storage": "^0.1.0",
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
export const isMac = process.platform === 'darwin'
|
||||
export const isWin = process.platform === 'win32'
|
||||
export const isLinux = process.platform === 'linux'
|
||||
export const isDev = process.env.NODE_ENV === 'development'
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { is } from '@electron-toolkit/utils'
|
||||
import { isLinux, isWin } from '@main/constant'
|
||||
import { isDev, isLinux, isWin } from '@main/constant'
|
||||
import { getFilesDir } from '@main/utils/file'
|
||||
import { app, BrowserWindow, ipcMain, Menu, MenuItem, shell } from 'electron'
|
||||
import Logger from 'electron-log'
|
||||
@ -128,6 +128,13 @@ export class WindowService {
|
||||
this.contextMenu?.popup()
|
||||
})
|
||||
|
||||
// Dangerous API
|
||||
if (isDev) {
|
||||
mainWindow.webContents.on('will-attach-webview', (_, webPreferences) => {
|
||||
webPreferences.preload = join(__dirname, '../preload/index.js')
|
||||
})
|
||||
}
|
||||
|
||||
// Handle webview context menu
|
||||
mainWindow.webContents.on('did-attach-webview', (_, webContents) => {
|
||||
webContents.on('context-menu', () => {
|
||||
|
||||
@ -118,7 +118,7 @@ const api = {
|
||||
cleanup: () => ipcRenderer.invoke('mcp:cleanup')
|
||||
},
|
||||
shell: {
|
||||
openExternal: shell.openExternal
|
||||
openExternal: shell?.openExternal
|
||||
},
|
||||
|
||||
// Binary related APIs
|
||||
|
||||
@ -151,6 +151,7 @@ const PopupContainer: React.FC<Props> = ({ app, resolve }) => {
|
||||
style={WebviewStyle}
|
||||
allowpopups={'true' as any}
|
||||
partition="persist:webview"
|
||||
nodeintegration={true}
|
||||
/>
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user