diff --git a/public/preload.js b/public/preload.js index 8bfba5b..e153f68 100644 --- a/public/preload.js +++ b/public/preload.js @@ -177,6 +177,20 @@ if (process.platform == 'win32') quickcommand.runVbs = function(script) { }) } +window.temporaryStore = { + listeners: {} +} + +window.temporaryStoreSoldOut = () => { + _.forIn(temporaryStore.listeners, (listener, key) => { + document.removeEventListener(...listener) + }) + window.temporaryStore = { + listeners: {} + } +} + + // python -c window.runPythonCommand = py => { try { diff --git a/src/App.vue b/src/App.vue index 5356b30..dcfaea8 100644 --- a/src/App.vue +++ b/src/App.vue @@ -45,8 +45,7 @@ export default defineComponent({ // 切到空路由 this.$router.push("loading"); // 清空临时数据 - document.removeEventListener("keydown", this.$profile.tmp.handleEnter); - this.$profile.tmp = {}; + window.temporaryStoreSoldOut(); // 保存偏好 this.$utools.putDB( _.cloneDeep(this.$profile), @@ -63,7 +62,7 @@ export default defineComponent({ font-size: 11px; } :root { - --q-dark: #303133; - --q-dark-page: #303133; + --q-dark: #303133; + --q-dark-page: #303133; } diff --git a/src/boot/global.js b/src/boot/global.js index c73537a..ef2bde7 100644 --- a/src/boot/global.js +++ b/src/boot/global.js @@ -11,7 +11,6 @@ let defaultProfile = { defaultPrimaryColor: "#009688", backgroundImg: null, codeHistory: {}, - tmp: {} } let userProfile = UTOOLS.getDB( UTOOLS.DBPRE.CFG + "preferences" @@ -26,4 +25,4 @@ export default boot(async({ app.config.globalProperties.$utools = UTOOLS app.config.globalProperties.$programmings = programmings app.config.globalProperties.$profile = defaultProfile -}) \ No newline at end of file +}) diff --git a/src/components/CommandRunResult.vue b/src/components/CommandRunResult.vue index a7d247b..d6eafaf 100644 --- a/src/components/CommandRunResult.vue +++ b/src/components/CommandRunResult.vue @@ -157,10 +157,12 @@ export default { setTimeout(() => { if (this.subInputValue) querySubInput(); }, 100); - this.$profile.tmp.handleEnter = (event) => { + let handler = (event) => { if (event.keyCode == 13) querySubInput(); }; - document.addEventListener("keydown", this.$profile.tmp.handleEnter); + let listener = ["keydown", handler, true]; + document.addEventListener(...listener); + window.temporaryStore.listeners.subInputListener = listener; }, // payload 临时赋值 async getTempPayload(currentCommand) { @@ -204,10 +206,10 @@ export default { }); }, stopRun() { - if (this.$profile.tmp.handleEnter) { + if (window.temporaryStore.listeners.subInputListener) { this.subInputValue = ""; - document.removeEventListener("keydown", this.$profile.tmp.handleEnter); utools.removeSubInput(); + window.temporaryStoreSoldOut(); } }, }, diff --git a/src/components/quickcommandUI/SelectList.vue b/src/components/quickcommandUI/SelectList.vue index a943ed9..3967ed0 100644 --- a/src/components/quickcommandUI/SelectList.vue +++ b/src/components/quickcommandUI/SelectList.vue @@ -60,7 +60,7 @@ diff --git a/src/js/quickcommand.js b/src/js/quickcommand.js index 0d835a7..c256479 100644 --- a/src/js/quickcommand.js +++ b/src/js/quickcommand.js @@ -112,6 +112,11 @@ const quickcommand = { console.log('取消') }) }), + + updateSelectList: (opt, id) => { + if (!window.temporaryStore.updateSelectList) throw "请先初始化SelectList" + window.temporaryStore.updateSelectList(opt, id) + } } -export default quickcommand \ No newline at end of file +export default quickcommand diff --git a/src/router/routes.js b/src/router/routes.js index f1384de..1467124 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -1,41 +1,46 @@ const routes = [{ path: '/configuration', + name: 'configuration', component: () => - import ('pages/ConfigurationPage.vue') + import('pages/ConfigurationPage.vue') }, { path: '/code', + name: 'code', component: () => - import ('pages/RunCodePage.vue') + import('pages/RunCodePage.vue') }, { path: '/newcommand', component: () => - import ('pages/NewCommand.vue') + import('pages/NewCommand.vue') }, { path: '/:type(default|files|img|key|regex|window|professional)_:uid(\\w+)', + name: 'command', component: () => - import ('pages/CommandPage.vue') + import('pages/CommandPage.vue') }, { path: '/panel_:tags(\\w+)', + name: 'panel', component: () => - import ('pages/ConfigurationPage.vue') + import('pages/ConfigurationPage.vue') }, { path: '/needupdate', name: 'needupdate', props: true, component: () => - import ('pages/updateWarningPage.vue') + import('pages/updateWarningPage.vue') }, { path: '/loading', + name: 'loading', component: () => - import ('pages/LoadingPage.vue') + import('pages/LoadingPage.vue') } ] -export default routes \ No newline at end of file +export default routes