diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f06c0413..501355df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: runs-on: ${{ matrix.os }} env: npm_config_disturl: https://atom.io/download/electron - npm_config_target: 11.4.5 + npm_config_target: 15.3.2 npm_config_runtime: "electron" steps: diff --git a/files/m1-11.4.2-pty.node b/files/m1-15.3.2-pty.node similarity index 59% rename from files/m1-11.4.2-pty.node rename to files/m1-15.3.2-pty.node index edfc225f..fd2c93b6 100755 Binary files a/files/m1-11.4.2-pty.node and b/files/m1-15.3.2-pty.node differ diff --git a/package.json b/package.json index 29503a33..5161a4b7 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,13 @@ "rebuild-pty": "electron-rebuild -f -w node-pty" }, "dependencies": { + "@electron/remote": "^2.0.1", "command-exists": "^1.2.9", "electron-context-menu": "^3.1.1", - "electron-log": "^4.3.5", + "electron-log": "^4.4.3", "electron-progressbar": "^2.0.1", "electron-store": "^5.2.0", - "electron-updater": "^4.3.9", + "electron-updater": "^4.6.1", "fs-extra": "^10.0.0", "http-proxy-agent": "^5.0.0", "https-proxy-agent": "^5.0.0", @@ -75,9 +76,9 @@ "crypto-js": "^3.3.0", "dayjs": "^1.10.5", "echarts": "^5.2.2", - "electron": "11.4.6", - "electron-builder": "^22.11.7", - "electron-notarize": "^1.0.0", + "electron": "15.3.2", + "electron-builder": "^22.14.5", + "electron-notarize": "^1.1.1", "eslint": "^7.11.0", "eslint-plugin-import": "^2.20.2", "eslint-plugin-node": "^11.1.0", diff --git a/scripts/install.bat b/scripts/install.bat index f065baa4..7e7aa434 100644 --- a/scripts/install.bat +++ b/scripts/install.bat @@ -1,5 +1,5 @@ set npm_config_disturl=https://atom.io/download/electron -set npm_config_target=11.4.6 +set npm_config_target=15.3.2 set npm_config_runtime="electron" yarn install diff --git a/scripts/install.sh b/scripts/install.sh index 6032d4db..d7908833 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,7 +1,7 @@ #!/bin/sh export npm_config_disturl=https://atom.io/download/electron -export npm_config_target=11.4.6 +export npm_config_target=15.3.2 export npm_config_runtime="electron" yarn install diff --git a/src/main/app.ts b/src/main/app.ts index 78ab9bf7..4590e67e 100644 --- a/src/main/app.ts +++ b/src/main/app.ts @@ -1,8 +1,9 @@ -import { protocol, app, BrowserWindow, Menu, Tray, powerMonitor, dialog, OpenDialogOptions, shell } from 'electron' +/* eslint-disable @typescript-eslint/no-var-requires */ +import { protocol, app, Menu, Tray, powerMonitor, dialog, OpenDialogOptions, shell, BrowserWindow } from 'electron' +import type TBrowserWindow from 'electron' import * as path from 'path' import * as os from 'os' import * as yargs from 'yargs' -import ElectronContextmenu from 'electron-context-menu' import server from './server' import { APP_NAME } from './constant' import { getTrayMenus, getMainMenus } from './menus' @@ -13,6 +14,9 @@ import { registerShortcut } from './shortcut' import { $t } from './i18n' import { getProxyAgent } from './proxy-agent' +const electronContextMenu = require('electron-context-menu') +const electronRemote = require('@electron/remote/main') + const isMacos = os.platform() === 'darwin' const isLinux = os.platform() === 'linux' @@ -22,7 +26,8 @@ const trayEnabled = !(yargs.argv['disable-tray']) const backendPort = Number(yargs.argv.port) || 3044 const devFrontendPort = 8066 -ElectronContextmenu({ +electronRemote.initialize() +electronContextMenu({ showLookUpSelection: true, showSearchWithGoogle: false, showCopyImage: true, @@ -36,7 +41,7 @@ ElectronContextmenu({ Menu.setApplicationMenu(getMainMenus()) let fullscreen = false -let win: BrowserWindow | null = null +let win: TBrowserWindow.BrowserWindow | null = null let tray: Tray | null = null const getUrl = (mode?: typeof urlMode) => { @@ -84,37 +89,37 @@ const createWindow = () => { webPreferences: { webSecurity: false, nodeIntegration: true, - enableRemoteModule: true, + contextIsolation: false, }, // for linux icon. ...(isLinux ? { icon: path.join(__dirname, './assets/icon.png') } : undefined) }) // win.maximize() - win.show() - win.setMenu(null) + win!.show() + win!.setMenu(null) // could not load js correctly when startup setTimeout(() => { win && win.loadURL(getUrl()) }, 0) - win.on('close', e => { + win!.on('close', e => { if (trayEnabled) { hideWindow() e.preventDefault() } }) - win.on('closed', () => { + win!.on('closed', () => { win = null }) - win.on('enter-full-screen', () => { + win!.on('enter-full-screen', () => { fullscreen = true }) - win.on('leave-full-screen', () => { + win!.on('leave-full-screen', () => { fullscreen = false }) } @@ -298,7 +303,10 @@ if (!gotTheLock) { }) app.on('web-contents-created', (_, webContents) => { - webContents.on('new-window', (e, url) => { + electronRemote.enable(webContents) + webContents.openDevTools() + + webContents.setWindowOpenHandler(({ url }) => { const allowList = [ `${APP_NAME}://`, `http://localhost:${backendPort}`, @@ -308,9 +316,11 @@ if (!gotTheLock) { ] if (!allowList.find(x => url.startsWith(x))) { - e.preventDefault() shell.openExternal(url) + return { action: 'deny' } } + + return { action: 'allow' } }) }) } diff --git a/src/renderer/components/ExportPanel.vue b/src/renderer/components/ExportPanel.vue index 2ee79e59..9b3babc7 100644 --- a/src/renderer/components/ExportPanel.vue +++ b/src/renderer/components/ExportPanel.vue @@ -74,7 +74,7 @@