diff --git a/electron/electron.js b/electron/electron.js
index a057dafde..e60cecb1b 100644
--- a/electron/electron.js
+++ b/electron/electron.js
@@ -201,13 +201,9 @@ if (!getTheLock) {
}
// 截图对象
screenshotObj = new Screenshots({
- singleWindow: true
+ singleWindow: true,
+ mainWindow: mainWindow
})
- globalShortcut.register("esc", () => {
- if (screenshotObj.$win?.isFocused()) {
- screenshotObj.endCapture().then(_ => {});
- }
- });
})
}
@@ -229,6 +225,10 @@ app.on('before-quit', () => {
willQuitApp = true
})
+app.on("will-quit",function(){
+ globalShortcut.unregisterAll();
+})
+
app.on('browser-window-blur', () => {
if (mainWindow) {
mainWindow.webContents.send("browserWindowBlur", {})
@@ -473,7 +473,10 @@ ipcMain.on('bindScreenshotKey', (event, args) => {
if (key) {
screenshotKey = key
globalShortcut.register(key, () => {
- screenshotObj.startCapture().then(_ => {})
+ screenshotObj.startCapture().then(_ => {
+ screenshotObj.view.webContents.executeJavaScript('if(typeof window.__initializeShortcuts===\'undefined\'){window.__initializeShortcuts=true;document.addEventListener(\'keydown\',function(e){console.log(e);if(e.keyCode===27){window.screenshots.cancel()}})}', true).catch(() => {});
+ screenshotObj.view.webContents.focus()
+ })
})
}
}
@@ -483,8 +486,20 @@ ipcMain.on('bindScreenshotKey', (event, args) => {
/**
* 执行截图
*/
-ipcMain.on('onScreenshot', (event) => {
- screenshotObj.startCapture().then(_ => {})
+ipcMain.on('openScreenshot', (event) => {
+ if (screenshotObj) {
+ screenshotObj.startCapture().then(_ => {})
+ }
+ event.returnValue = "ok"
+})
+
+/**
+ * 关闭截图
+ */
+ipcMain.on('closeScreenshot', (event) => {
+ if (screenshotObj && screenshotObj.window?.isFocused()) {
+ screenshotObj.endCapture().then(_ => {});
+ }
event.returnValue = "ok"
})
diff --git a/resources/assets/js/App.vue b/resources/assets/js/App.vue
index 6325d8b49..6d97018f7 100755
--- a/resources/assets/js/App.vue
+++ b/resources/assets/js/App.vue
@@ -118,7 +118,7 @@ export default {
}, 6000)
}
//
- if (this.$openLog) {
+ if ($A.openLog) {
$A.loadScript('js/vconsole.min.js', (e) => {
if (e !== null || typeof window.VConsole !== 'function') {
$A.modalError("vConsole 组件加载失败!");
diff --git a/resources/assets/js/app.js b/resources/assets/js/app.js
index a9a2f28eb..e28592450 100644
--- a/resources/assets/js/app.js
+++ b/resources/assets/js/app.js
@@ -135,6 +135,7 @@ Vue.prototype.goBack = function () {
};
// 全局对象/变量
+$A.L = $L;
$A.Electron = null;
$A.Platform = "web";
$A.isMainElectron = false;
@@ -148,35 +149,7 @@ if (isElectron) {
$A.isSubElectron = /\s+SubTaskWindow\//.test(window.navigator.userAgent);
}
-Vue.prototype.$A = $A;
-Vue.prototype.$L = $L;
-Vue.prototype.$Electron = $A.Electron;
-Vue.prototype.$Platform = $A.Platform;
-Vue.prototype.$isMainElectron = $A.isMainElectron;
-Vue.prototype.$isSubElectron = $A.isSubElectron;
-Vue.prototype.$isEEUiApp = $A.isEEUiApp;
-Vue.prototype.$openLog = $A.openLog;
-
-Vue.config.productionTip = false;
-Vue.mixin(mixin)
-
-const app = new Vue({
- el: '#app',
- router,
- store,
- template: '