From b8b744d6166746c9036626cf3ef1655edc8b2e79 Mon Sep 17 00:00:00 2001 From: nashaofu Date: Fri, 17 Dec 2021 14:49:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E6=89=93=E5=BC=80=E9=97=AE=E9=A2=98=20(#395)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复应用不能打开问题 --- babel.config.js | 2 +- electron-builder.yml | 1 + package.json | 25 +- src/main/index.js | 7 - src/main/shortcut.js | 19 +- src/renderer/settingWin/App.vue | 13 +- .../components/keybinding/keybinding.vue | 6 +- yarn.lock | 830 ++++++++++-------- 8 files changed, 500 insertions(+), 403 deletions(-) diff --git a/babel.config.js b/babel.config.js index 5381a9c..10e18ac 100644 --- a/babel.config.js +++ b/babel.config.js @@ -4,7 +4,7 @@ module.exports = { '@babel/preset-env', { targets: { - electron: 15 + electron: 16 } } ] diff --git a/electron-builder.yml b/electron-builder.yml index 7778f25..7ce0126 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -46,6 +46,7 @@ linux: - arm64 - armv7l executableName: dingtalk + desktop: 钉钉 icon: './resources/icons' category: InstantMessaging;Network nsis: diff --git a/package.json b/package.json index c3df872..73418d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dingtalk", - "version": "2.1.14", + "version": "2.1.13", "description": "钉钉桌面版,基于electron和钉钉网页版开发,支持Windows、Linux和macOS", "author": "nashaofu ", "main": "dist/main.js", @@ -27,27 +27,28 @@ "Windows" ], "dependencies": { - "@babel/runtime": "^7.16.3", + "@babel/runtime": "^7.16.5", "@sentry/electron": "^2.5.4", "axios": "^0.24.0", + "electron-localshortcut": "^3.2.1", "electron-screenshots": "^0.1.3", - "electron-updater": "^4.3.9", + "electron-updater": "^4.6.1", "lodash": "^4.17.21", "normalize.css": "^8.0.1", "vue": "^2.6.14" }, "devDependencies": { - "@babel/core": "^7.16.0", - "@babel/eslint-parser": "^7.16.3", - "@babel/plugin-proposal-class-properties": "^7.16.0", - "@babel/plugin-proposal-export-default-from": "^7.16.0", - "@babel/plugin-transform-runtime": "^7.16.4", - "@babel/preset-env": "^7.16.4", + "@babel/core": "^7.16.5", + "@babel/eslint-parser": "^7.16.5", + "@babel/plugin-proposal-class-properties": "^7.16.5", + "@babel/plugin-proposal-export-default-from": "^7.16.5", + "@babel/plugin-transform-runtime": "^7.16.5", + "@babel/preset-env": "^7.16.5", "autoprefixer": "^10.4.0", "babel-loader": "^8.2.3", "css-loader": "^6.5.1", - "electron": "^14.2.2", - "electron-builder": "22.10.5", + "electron": "^16.0.5", + "electron-builder": "^22.14.5", "electron-debug": "^3.2.0", "electron-dev-webpack-plugin": "^1.0.5", "electron-devtools-installer": "^3.2.0", @@ -63,7 +64,7 @@ "less-loader": "^10.2.0", "mini-css-extract-plugin": "^2.4.5", "npm-run-all": "^4.1.5", - "postcss": "^8.4.4", + "postcss": "^8.4.5", "postcss-loader": "^6.2.1", "pug": "^3.0.2", "pug-plain-loader": "^1.1.0", diff --git a/src/main/index.js b/src/main/index.js index 3fb66e7..7223555 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,10 +1,3 @@ -import { app } from 'electron' import DingTalk from './dingtalk' -import debug from 'electron-debug' - -app.whenReady().then(() => { - // 生产环境添加开发者工具 - debug({ isEnabled: true, showDevTools: false }) -}) export default new DingTalk() diff --git a/src/main/shortcut.js b/src/main/shortcut.js index 1e0eb6d..521e8a0 100644 --- a/src/main/shortcut.js +++ b/src/main/shortcut.js @@ -1,4 +1,18 @@ -import { globalShortcut } from 'electron' +import { BrowserWindow, globalShortcut } from 'electron' +import localShortcut from 'electron-localshortcut' + +function toggleDevTools (win = BrowserWindow.getFocusedWindow()) { + if (!win) { + return + } + + const { webContents } = win + if (webContents.isDevToolsOpened()) { + webContents.closeDevTools() + } else { + webContents.openDevTools() + } +} export default dingtalk => () => { const actions = { @@ -15,4 +29,7 @@ export default dingtalk => () => { globalShortcut.register(keymap[key].join('+'), actions[key]) } }) + + localShortcut.register(process.platform === 'darwin' ? 'Command+Alt+I' : 'Control+Shift+I', toggleDevTools) + localShortcut.register('F12', toggleDevTools) } diff --git a/src/renderer/settingWin/App.vue b/src/renderer/settingWin/App.vue index 9b6a56c..1017c46 100644 --- a/src/renderer/settingWin/App.vue +++ b/src/renderer/settingWin/App.vue @@ -23,6 +23,7 @@ .app-item-button dt-button(@click="reset") 还原设置 dt-button( + tabIndex="1" type="primary" @click="save" ) 保存设置 @@ -43,9 +44,7 @@ export default { computed: { shortcutCapture: { get () { - return this.setting.keymap - ? this.setting.keymap['screenshots-capture'] - : [] + return this.setting.keymap ? this.setting.keymap['screenshots-capture'] : [] }, set (val) { const keymap = this.setting.keymap || {} @@ -117,12 +116,10 @@ export default {