mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-07 21:46:12 +08:00
去掉 temporaryStore
This commit is contained in:
parent
6cfd054767
commit
015513ec45
@ -188,19 +188,6 @@ 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 {
|
||||
|
@ -57,6 +57,7 @@ export default {
|
||||
runResult: "",
|
||||
runResultStatus: true,
|
||||
subInputValue: "",
|
||||
listener: null,
|
||||
};
|
||||
},
|
||||
props: {
|
||||
@ -159,12 +160,10 @@ export default {
|
||||
setTimeout(() => {
|
||||
if (this.subInputValue) querySubInput();
|
||||
}, 100);
|
||||
let handler = (event) => {
|
||||
this.listener = (event) => {
|
||||
if (event.keyCode == 13) querySubInput();
|
||||
};
|
||||
let listener = ["keydown", handler, true];
|
||||
document.addEventListener(...listener);
|
||||
window.temporaryStore.listeners.subInputListener = listener;
|
||||
document.addEventListener("keydown", this.listener, true);
|
||||
},
|
||||
// payload 临时赋值
|
||||
async getTempPayload(currentCommand) {
|
||||
@ -209,13 +208,16 @@ export default {
|
||||
},
|
||||
stopRun() {
|
||||
this.runResult = "";
|
||||
if (window.temporaryStore.listeners.subInputListener) {
|
||||
if (!!this.listener) {
|
||||
this.subInputValue = "";
|
||||
utools.removeSubInput();
|
||||
window.temporaryStoreSoldOut();
|
||||
document.removeEventListener("keydown", this.listener, true);
|
||||
}
|
||||
},
|
||||
},
|
||||
unmounted() {
|
||||
this.stopRun();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -78,13 +78,16 @@ export default {
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
window.temporaryStore.updateSelectList = (opt, id) => {
|
||||
quickcommand.updateSelectList = (opt, id) => {
|
||||
if (typeof id === "undefined") this.items.push(opt);
|
||||
else this.items[id] = opt;
|
||||
};
|
||||
this.options.enableSearch && this.setSubInput();
|
||||
this.setUtoolsHeight(this.itemHeight * this.matchedItemsSize);
|
||||
},
|
||||
unmounted() {
|
||||
this.clear();
|
||||
},
|
||||
computed: {
|
||||
matchedItems() {
|
||||
let matchedItems = this.searchWords
|
||||
@ -188,7 +191,7 @@ export default {
|
||||
clear() {
|
||||
utools.removeSubInput();
|
||||
this.setUtoolsHeight(this.listMaxHeight);
|
||||
window.temporaryStoreSoldOut();
|
||||
quickcommand.updateSelectList = () => {};
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -112,11 +112,6 @@ const quickcommand = {
|
||||
console.log('取消')
|
||||
})
|
||||
}),
|
||||
|
||||
updateSelectList: (opt, id) => {
|
||||
if (!window.temporaryStore.updateSelectList) throw "请先初始化SelectList"
|
||||
window.temporaryStore.updateSelectList(opt, id)
|
||||
}
|
||||
}
|
||||
|
||||
export default quickcommand
|
||||
export default quickcommand
|
Loading…
x
Reference in New Issue
Block a user