mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 14:34:13 +08:00
新增 window.temporaryStore
This commit is contained in:
parent
8df2305879
commit
a02392d7b5
@ -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
|
// python -c
|
||||||
window.runPythonCommand = py => {
|
window.runPythonCommand = py => {
|
||||||
try {
|
try {
|
||||||
|
@ -45,8 +45,7 @@ export default defineComponent({
|
|||||||
// 切到空路由
|
// 切到空路由
|
||||||
this.$router.push("loading");
|
this.$router.push("loading");
|
||||||
// 清空临时数据
|
// 清空临时数据
|
||||||
document.removeEventListener("keydown", this.$profile.tmp.handleEnter);
|
window.temporaryStoreSoldOut();
|
||||||
this.$profile.tmp = {};
|
|
||||||
// 保存偏好
|
// 保存偏好
|
||||||
this.$utools.putDB(
|
this.$utools.putDB(
|
||||||
_.cloneDeep(this.$profile),
|
_.cloneDeep(this.$profile),
|
||||||
@ -63,7 +62,7 @@ export default defineComponent({
|
|||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
}
|
}
|
||||||
:root {
|
:root {
|
||||||
--q-dark: #303133;
|
--q-dark: #303133;
|
||||||
--q-dark-page: #303133;
|
--q-dark-page: #303133;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -11,7 +11,6 @@ let defaultProfile = {
|
|||||||
defaultPrimaryColor: "#009688",
|
defaultPrimaryColor: "#009688",
|
||||||
backgroundImg: null,
|
backgroundImg: null,
|
||||||
codeHistory: {},
|
codeHistory: {},
|
||||||
tmp: {}
|
|
||||||
}
|
}
|
||||||
let userProfile = UTOOLS.getDB(
|
let userProfile = UTOOLS.getDB(
|
||||||
UTOOLS.DBPRE.CFG + "preferences"
|
UTOOLS.DBPRE.CFG + "preferences"
|
||||||
@ -26,4 +25,4 @@ export default boot(async({
|
|||||||
app.config.globalProperties.$utools = UTOOLS
|
app.config.globalProperties.$utools = UTOOLS
|
||||||
app.config.globalProperties.$programmings = programmings
|
app.config.globalProperties.$programmings = programmings
|
||||||
app.config.globalProperties.$profile = defaultProfile
|
app.config.globalProperties.$profile = defaultProfile
|
||||||
})
|
})
|
||||||
|
@ -157,10 +157,12 @@ export default {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.subInputValue) querySubInput();
|
if (this.subInputValue) querySubInput();
|
||||||
}, 100);
|
}, 100);
|
||||||
this.$profile.tmp.handleEnter = (event) => {
|
let handler = (event) => {
|
||||||
if (event.keyCode == 13) querySubInput();
|
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 临时赋值
|
// payload 临时赋值
|
||||||
async getTempPayload(currentCommand) {
|
async getTempPayload(currentCommand) {
|
||||||
@ -204,10 +206,10 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
stopRun() {
|
stopRun() {
|
||||||
if (this.$profile.tmp.handleEnter) {
|
if (window.temporaryStore.listeners.subInputListener) {
|
||||||
this.subInputValue = "";
|
this.subInputValue = "";
|
||||||
document.removeEventListener("keydown", this.$profile.tmp.handleEnter);
|
|
||||||
utools.removeSubInput();
|
utools.removeSubInput();
|
||||||
|
window.temporaryStoreSoldOut();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -60,7 +60,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import pinyinMatch from "pinyin-match"
|
import pinyinMatch from "pinyin-match";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@ -77,7 +77,7 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
window.SelectList = this;
|
window.SelectList = this;
|
||||||
quickcommand.updateSelectList = (opt, id) => {
|
window.temporaryStore.updateSelectList = (opt, id) => {
|
||||||
if (typeof id === "undefined") this.items.push(opt);
|
if (typeof id === "undefined") this.items.push(opt);
|
||||||
else this.items[id] = opt;
|
else this.items[id] = opt;
|
||||||
};
|
};
|
||||||
@ -122,11 +122,11 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onDialogHide() {
|
onDialogHide() {
|
||||||
|
this.clear();
|
||||||
this.$emit("hide");
|
this.$emit("hide");
|
||||||
},
|
},
|
||||||
|
|
||||||
onOKClick() {
|
onOKClick() {
|
||||||
utools.removeSubInput();
|
|
||||||
let selected =
|
let selected =
|
||||||
this.options.optionType === "json"
|
this.options.optionType === "json"
|
||||||
? this.matchedItems[this.currentIndex]
|
? this.matchedItems[this.currentIndex]
|
||||||
@ -139,8 +139,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onCancelClick() {
|
onCancelClick() {
|
||||||
this.setUtoolsHeight(this.listMaxHeight);
|
|
||||||
utools.removeSubInput();
|
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -185,6 +183,12 @@ export default {
|
|||||||
setUtoolsHeight(height) {
|
setUtoolsHeight(height) {
|
||||||
utools.setExpendHeight(Math.min(height, this.listMaxHeight));
|
utools.setExpendHeight(Math.min(height, this.listMaxHeight));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
utools.removeSubInput();
|
||||||
|
this.setUtoolsHeight(this.listMaxHeight);
|
||||||
|
window.temporaryStoreSoldOut();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -112,6 +112,11 @@ const quickcommand = {
|
|||||||
console.log('取消')
|
console.log('取消')
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
updateSelectList: (opt, id) => {
|
||||||
|
if (!window.temporaryStore.updateSelectList) throw "请先初始化SelectList"
|
||||||
|
window.temporaryStore.updateSelectList(opt, id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default quickcommand
|
export default quickcommand
|
||||||
|
@ -1,41 +1,46 @@
|
|||||||
const routes = [{
|
const routes = [{
|
||||||
path: '/configuration',
|
path: '/configuration',
|
||||||
|
name: 'configuration',
|
||||||
component: () =>
|
component: () =>
|
||||||
import ('pages/ConfigurationPage.vue')
|
import('pages/ConfigurationPage.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/code',
|
path: '/code',
|
||||||
|
name: 'code',
|
||||||
component: () =>
|
component: () =>
|
||||||
import ('pages/RunCodePage.vue')
|
import('pages/RunCodePage.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/newcommand',
|
path: '/newcommand',
|
||||||
component: () =>
|
component: () =>
|
||||||
import ('pages/NewCommand.vue')
|
import('pages/NewCommand.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/:type(default|files|img|key|regex|window|professional)_:uid(\\w+)',
|
path: '/:type(default|files|img|key|regex|window|professional)_:uid(\\w+)',
|
||||||
|
name: 'command',
|
||||||
component: () =>
|
component: () =>
|
||||||
import ('pages/CommandPage.vue')
|
import('pages/CommandPage.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/panel_:tags(\\w+)',
|
path: '/panel_:tags(\\w+)',
|
||||||
|
name: 'panel',
|
||||||
component: () =>
|
component: () =>
|
||||||
import ('pages/ConfigurationPage.vue')
|
import('pages/ConfigurationPage.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/needupdate',
|
path: '/needupdate',
|
||||||
name: 'needupdate',
|
name: 'needupdate',
|
||||||
props: true,
|
props: true,
|
||||||
component: () =>
|
component: () =>
|
||||||
import ('pages/updateWarningPage.vue')
|
import('pages/updateWarningPage.vue')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/loading',
|
path: '/loading',
|
||||||
|
name: 'loading',
|
||||||
component: () =>
|
component: () =>
|
||||||
import ('pages/LoadingPage.vue')
|
import('pages/LoadingPage.vue')
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
export default routes
|
export default routes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user