mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 14:34:13 +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
|
// python -c
|
||||||
window.runPythonCommand = py => {
|
window.runPythonCommand = py => {
|
||||||
try {
|
try {
|
||||||
|
@ -57,6 +57,7 @@ export default {
|
|||||||
runResult: "",
|
runResult: "",
|
||||||
runResultStatus: true,
|
runResultStatus: true,
|
||||||
subInputValue: "",
|
subInputValue: "",
|
||||||
|
listener: null,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -159,12 +160,10 @@ export default {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (this.subInputValue) querySubInput();
|
if (this.subInputValue) querySubInput();
|
||||||
}, 100);
|
}, 100);
|
||||||
let handler = (event) => {
|
this.listener = (event) => {
|
||||||
if (event.keyCode == 13) querySubInput();
|
if (event.keyCode == 13) querySubInput();
|
||||||
};
|
};
|
||||||
let listener = ["keydown", handler, true];
|
document.addEventListener("keydown", this.listener, true);
|
||||||
document.addEventListener(...listener);
|
|
||||||
window.temporaryStore.listeners.subInputListener = listener;
|
|
||||||
},
|
},
|
||||||
// payload 临时赋值
|
// payload 临时赋值
|
||||||
async getTempPayload(currentCommand) {
|
async getTempPayload(currentCommand) {
|
||||||
@ -209,13 +208,16 @@ export default {
|
|||||||
},
|
},
|
||||||
stopRun() {
|
stopRun() {
|
||||||
this.runResult = "";
|
this.runResult = "";
|
||||||
if (window.temporaryStore.listeners.subInputListener) {
|
if (!!this.listener) {
|
||||||
this.subInputValue = "";
|
this.subInputValue = "";
|
||||||
utools.removeSubInput();
|
utools.removeSubInput();
|
||||||
window.temporaryStoreSoldOut();
|
document.removeEventListener("keydown", this.listener, true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
unmounted() {
|
||||||
|
this.stopRun();
|
||||||
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -78,13 +78,16 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
window.temporaryStore.updateSelectList = (opt, id) => {
|
quickcommand.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;
|
||||||
};
|
};
|
||||||
this.options.enableSearch && this.setSubInput();
|
this.options.enableSearch && this.setSubInput();
|
||||||
this.setUtoolsHeight(this.itemHeight * this.matchedItemsSize);
|
this.setUtoolsHeight(this.itemHeight * this.matchedItemsSize);
|
||||||
},
|
},
|
||||||
|
unmounted() {
|
||||||
|
this.clear();
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
matchedItems() {
|
matchedItems() {
|
||||||
let matchedItems = this.searchWords
|
let matchedItems = this.searchWords
|
||||||
@ -188,7 +191,7 @@ export default {
|
|||||||
clear() {
|
clear() {
|
||||||
utools.removeSubInput();
|
utools.removeSubInput();
|
||||||
this.setUtoolsHeight(this.listMaxHeight);
|
this.setUtoolsHeight(this.listMaxHeight);
|
||||||
window.temporaryStoreSoldOut();
|
quickcommand.updateSelectList = () => {};
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -112,11 +112,6 @@ 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
|
Loading…
x
Reference in New Issue
Block a user