no message

This commit is contained in:
kuaifan 2022-12-02 10:23:54 +08:00
parent a925102881
commit bebeb49ae4
4 changed files with 61 additions and 42 deletions

33
electron/electron.js vendored
View File

@ -201,13 +201,9 @@ if (!getTheLock) {
} }
// 截图对象 // 截图对象
screenshotObj = new Screenshots({ 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 willQuitApp = true
}) })
app.on("will-quit",function(){
globalShortcut.unregisterAll();
})
app.on('browser-window-blur', () => { app.on('browser-window-blur', () => {
if (mainWindow) { if (mainWindow) {
mainWindow.webContents.send("browserWindowBlur", {}) mainWindow.webContents.send("browserWindowBlur", {})
@ -473,7 +473,10 @@ ipcMain.on('bindScreenshotKey', (event, args) => {
if (key) { if (key) {
screenshotKey = key screenshotKey = key
globalShortcut.register(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) => { ipcMain.on('openScreenshot', (event) => {
screenshotObj.startCapture().then(_ => {}) if (screenshotObj) {
screenshotObj.startCapture().then(_ => {})
}
event.returnValue = "ok"
})
/**
* 关闭截图
*/
ipcMain.on('closeScreenshot', (event) => {
if (screenshotObj && screenshotObj.window?.isFocused()) {
screenshotObj.endCapture().then(_ => {});
}
event.returnValue = "ok" event.returnValue = "ok"
}) })

View File

@ -118,7 +118,7 @@ export default {
}, 6000) }, 6000)
} }
// //
if (this.$openLog) { if ($A.openLog) {
$A.loadScript('js/vconsole.min.js', (e) => { $A.loadScript('js/vconsole.min.js', (e) => {
if (e !== null || typeof window.VConsole !== 'function') { if (e !== null || typeof window.VConsole !== 'function') {
$A.modalError("vConsole 组件加载失败!"); $A.modalError("vConsole 组件加载失败!");

View File

@ -135,6 +135,7 @@ Vue.prototype.goBack = function () {
}; };
// 全局对象/变量 // 全局对象/变量
$A.L = $L;
$A.Electron = null; $A.Electron = null;
$A.Platform = "web"; $A.Platform = "web";
$A.isMainElectron = false; $A.isMainElectron = false;
@ -148,35 +149,7 @@ if (isElectron) {
$A.isSubElectron = /\s+SubTaskWindow\//.test(window.navigator.userAgent); $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: '<App/>',
components: { App }
});
$A.goForward = app.goForward;
$A.goBack = app.goBack;
$A.Message = app.$Message;
$A.Notice = app.$Notice;
$A.Modal = app.$Modal;
$A.store = app.$store;
$A.L = app.$L;
$A.execMainDispatch = (action, data) => { $A.execMainDispatch = (action, data) => {
if ($A.isSubElectron) { if ($A.isSubElectron) {
$A.Electron.sendMessage('sendForwardMain', { $A.Electron.sendMessage('sendForwardMain', {
@ -193,6 +166,7 @@ $A.execMainCacheJudge = (key) => {
return val return val
}; };
// 绑定截图快捷键
$A.bindScreenshotKey = (data) => { $A.bindScreenshotKey = (data) => {
let key = ""; let key = "";
if (data.screenshot_key && (data.screenshot_mate || data.screenshot_shift)) { if (data.screenshot_key && (data.screenshot_mate || data.screenshot_shift)) {
@ -206,3 +180,28 @@ $A.bindScreenshotKey = (data) => {
} }
$A.Electron.sendMessage('bindScreenshotKey', {key}); $A.Electron.sendMessage('bindScreenshotKey', {key});
}; };
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.config.productionTip = false;
Vue.mixin(mixin)
const app = new Vue({
el: '#app',
router,
store,
template: '<App/>',
components: { App }
});
$A.goForward = app.goForward;
$A.goBack = app.goBack;
$A.Message = app.$Message;
$A.Notice = app.$Notice;
$A.Modal = app.$Modal;

View File

@ -12,7 +12,7 @@
</FormItem> </FormItem>
</Form> </Form>
<div class="setting-footer"> <div class="setting-footer">
<Button :loading="loadIng > 0" type="primary" @click="submitForm">{{$L('提交')}}</Button> <Button :loading="loadIng > 0" type="primary" @click="submitForm">{{$L('保存')}}</Button>
<Button :loading="loadIng > 0" @click="resetForm" style="margin-left: 8px">{{$L('重置')}}</Button> <Button :loading="loadIng > 0" @click="resetForm" style="margin-left: 8px">{{$L('重置')}}</Button>
</div> </div>
</div> </div>
@ -65,8 +65,13 @@ export default {
this.formData_bak = $A.cloneJSON(this.formData); this.formData_bak = $A.cloneJSON(this.formData);
}, },
onKeydown({key}) { onKeydown({key, keyCode}) {
this.formData.screenshot_key = key && key.length === 1 ? key.toUpperCase() : "" if (keyCode !== 8) {
key = key && key.length === 1 ? key.toUpperCase() : ""
if (key) {
this.formData.screenshot_key = key
}
}
}, },
submitForm() { submitForm() {