自动导入默认命令

This commit is contained in:
fofolee 2022-04-08 18:45:06 +08:00
parent 790c4a872c
commit 703f6b7097
2 changed files with 30 additions and 24 deletions

View File

@ -13,7 +13,7 @@
] ]
}, },
"program": "quickcommand", "program": "quickcommand",
"cmd": "var snippet = {}\nquickcommand.showTextArea(\"请输入代码片段\").then(code => {\n snippet.body = code.split(\"\\n\")\n quickcommand.showInputBox([\"代码片段的描述\", \"触发代码片段的关键词\"])\n .then(inputs => {\n snippet.prefix = inputs[1]\n snippet.description = inputs[0]\n var result = `\"${inputs[0]}\": ` + JSON.stringify(snippet, null, '\\t')\n console.log(result)\n utools.copyText(result)\n quickcommand.showMessageBox('已复制')\n })\n})", "cmd": "var snippet = {}\nquickcommand.showTextArea(\"请输入代码片段\").then(code => {\n snippet.body = code.split(\"\\n\")\n quickcommand.showInputBox([\"代码片段的描述\", \"触发代码片段的关键词\"])\n .then(inputs => {\n snippet.prefix = inputs[1]\n snippet.description = inputs[0]\n var result = `\"${inputs[0]}\": ` + JSON.stringify(snippet, null, '\\t')\n console.log(result+'\\n结果已复制')\n utools.copyText(result)})\n})",
"output": "text", "output": "text",
"hasSubInput": false, "hasSubInput": false,
"scptarg": "", "scptarg": "",

View File

@ -299,6 +299,12 @@ export default {
this.activatedQuickPanels = activatedFeatures.quickpanels; this.activatedQuickPanels = activatedFeatures.quickpanels;
// //
this.allQuickCommands = this.getAllQuickCommands(); this.allQuickCommands = this.getAllQuickCommands();
this.importDefaultCommands();
},
importDefaultCommands() {
for (var code of Object.keys(defaultCommands)) {
this.$utools.putDB(defaultCommands[code], this.$utools.DBPRE.QC + code);
}
Object.assign(this.allQuickCommands, defaultCommands); Object.assign(this.allQuickCommands, defaultCommands);
}, },
// features // features
@ -468,7 +474,7 @@ export default {
.getDocs(this.$utools.DBPRE.QC) .getDocs(this.$utools.DBPRE.QC)
.map((x) => x._id) .map((x) => x._id)
.forEach((y) => this.$utools.delDB(y)); .forEach((y) => this.$utools.delDB(y));
Object.assign(this.allQuickCommands, defaultCommands); this.importDefaultCommands();
this.clearAllFeatures(); this.clearAllFeatures();
Object.keys(this.allQuickCommands).forEach((featureCode) => { Object.keys(this.allQuickCommands).forEach((featureCode) => {
if (!featureCode.includes("default_")) if (!featureCode.includes("default_"))