mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 15:04:06 +08:00
默认命令处理优化
This commit is contained in:
parent
4151e1ac89
commit
384f52eb4c
@ -171,9 +171,7 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
this.utools.putDB(statisticsData, "cfg_statisticsData");
|
this.utools.putDB(statisticsData, "cfg_statisticsData");
|
||||||
// 删掉数据库内的默认命令
|
// 删掉数据库内的默认命令
|
||||||
this.utools
|
this.utools.delAll("qc_default");
|
||||||
.getDocs("qc_default")
|
|
||||||
.forEach((x) => this.utools.delDB(x._id));
|
|
||||||
this.utools.setStorage("st_v300Inited", true);
|
this.utools.setStorage("st_v300Inited", true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -205,7 +205,6 @@ import ConfigurationMenu from "components/ConfigurationMenu.vue";
|
|||||||
import CommandRunResult from "components/CommandRunResult.vue";
|
import CommandRunResult from "components/CommandRunResult.vue";
|
||||||
import importAll from "../js/common/importAll.js";
|
import importAll from "../js/common/importAll.js";
|
||||||
import pinyinMatch from "pinyin-match";
|
import pinyinMatch from "pinyin-match";
|
||||||
import defaultProfile from "../js/options/defaultProfile.js";
|
|
||||||
import CommandEditor from "components/CommandEditor";
|
import CommandEditor from "components/CommandEditor";
|
||||||
|
|
||||||
// 默认命令
|
// 默认命令
|
||||||
@ -322,12 +321,6 @@ export default {
|
|||||||
setTimeout(this.getActivatedFeatures, 0);
|
setTimeout(this.getActivatedFeatures, 0);
|
||||||
setTimeout(this.getAllQuickCommands, 0);
|
setTimeout(this.getAllQuickCommands, 0);
|
||||||
},
|
},
|
||||||
importDefaultCommands() {
|
|
||||||
this.allQuickCommands = Object.assign(
|
|
||||||
_.cloneDeep(defaultCommands),
|
|
||||||
this.allQuickCommands
|
|
||||||
);
|
|
||||||
},
|
|
||||||
// 获取所有已启用的命令的 features 以及面板名称
|
// 获取所有已启用的命令的 features 以及面板名称
|
||||||
getActivatedFeatures() {
|
getActivatedFeatures() {
|
||||||
let features = utools.getFeatures();
|
let features = utools.getFeatures();
|
||||||
@ -344,11 +337,10 @@ export default {
|
|||||||
},
|
},
|
||||||
// 获取所有的快捷命令(导出的格式)
|
// 获取所有的快捷命令(导出的格式)
|
||||||
getAllQuickCommands() {
|
getAllQuickCommands() {
|
||||||
this.allQuickCommands = {};
|
this.allQuickCommands = _.cloneDeep(defaultCommands);
|
||||||
this.$root.utools
|
this.$root.utools
|
||||||
.getDocs("qc_")
|
.getAll("qc_")
|
||||||
.forEach((x) => (this.allQuickCommands[x.data.features.code] = x.data));
|
.forEach((x) => (this.allQuickCommands[x.data.features.code] = x.data));
|
||||||
this.importDefaultCommands();
|
|
||||||
},
|
},
|
||||||
// 监听命令变更事件
|
// 监听命令变更事件
|
||||||
commandChanged(event) {
|
commandChanged(event) {
|
||||||
@ -426,6 +418,10 @@ export default {
|
|||||||
importCommandFromClipboard() {
|
importCommandFromClipboard() {
|
||||||
return window.clipboardReadText();
|
return window.clipboardReadText();
|
||||||
},
|
},
|
||||||
|
// 是否为默认命令
|
||||||
|
isDefaultCommand(code) {
|
||||||
|
return code.slice(0, 8) === "default_";
|
||||||
|
},
|
||||||
// 导入命令
|
// 导入命令
|
||||||
importCommand(fromFile = true) {
|
importCommand(fromFile = true) {
|
||||||
let quickCommandInfo = fromFile
|
let quickCommandInfo = fromFile
|
||||||
@ -438,12 +434,15 @@ export default {
|
|||||||
// 单个命令导入
|
// 单个命令导入
|
||||||
let dataToPushed = {};
|
let dataToPushed = {};
|
||||||
if (parsedData.single) {
|
if (parsedData.single) {
|
||||||
|
if (this.isDefaultCommand(parsedData.qc.features.code))
|
||||||
|
return quickcommand.showMessageBox("默认命令不能导入!", "error");
|
||||||
dataToPushed[parsedData.qc.features.code] = parsedData.qc;
|
dataToPushed[parsedData.qc.features.code] = parsedData.qc;
|
||||||
// 多个
|
// 多个
|
||||||
} else {
|
} else {
|
||||||
dataToPushed = parsedData.qc;
|
dataToPushed = parsedData.qc;
|
||||||
}
|
}
|
||||||
for (var code of Object.keys(dataToPushed)) {
|
for (var code of Object.keys(dataToPushed)) {
|
||||||
|
if (this.isDefaultCommand(code)) continue;
|
||||||
this.$root.utools.putDB(dataToPushed[code], "qc_" + code);
|
this.$root.utools.putDB(dataToPushed[code], "qc_" + code);
|
||||||
}
|
}
|
||||||
Object.assign(this.allQuickCommands, dataToPushed);
|
Object.assign(this.allQuickCommands, dataToPushed);
|
||||||
@ -481,9 +480,8 @@ export default {
|
|||||||
};
|
};
|
||||||
let commandsToExport = _.cloneDeep(this.allQuickCommands);
|
let commandsToExport = _.cloneDeep(this.allQuickCommands);
|
||||||
// 不导出默认命令
|
// 不导出默认命令
|
||||||
if (!utools.isDev())
|
|
||||||
Object.keys(commandsToExport).forEach((code) => {
|
Object.keys(commandsToExport).forEach((code) => {
|
||||||
if (code.includes("default_")) delete commandsToExport[code];
|
if (this.isDefaultCommand(code)) delete commandsToExport[code];
|
||||||
});
|
});
|
||||||
let stringifyCommands = JSON.stringify(commandsToExport);
|
let stringifyCommands = JSON.stringify(commandsToExport);
|
||||||
if (saveAsFile) {
|
if (saveAsFile) {
|
||||||
@ -501,15 +499,9 @@ export default {
|
|||||||
if (!isConfirmed)
|
if (!isConfirmed)
|
||||||
return quickcommand.showMessageBox("取消操作", "info");
|
return quickcommand.showMessageBox("取消操作", "info");
|
||||||
this.exportAllCommands(false);
|
this.exportAllCommands(false);
|
||||||
this.$root.utools
|
this.$root.utools.delAll("qc_");
|
||||||
.getDocs("qc_")
|
|
||||||
.map((x) => x._id)
|
|
||||||
.forEach((y) => this.$root.utools.delDB(y));
|
|
||||||
this.clearAllFeatures();
|
this.clearAllFeatures();
|
||||||
Object.keys(this.allQuickCommands).forEach((featureCode) => {
|
this.allQuickCommands = _.cloneDeep(defaultCommands);
|
||||||
delete this.allQuickCommands[featureCode];
|
|
||||||
});
|
|
||||||
this.importDefaultCommands();
|
|
||||||
this.currentTag = "默认";
|
this.currentTag = "默认";
|
||||||
quickcommand.showMessageBox(
|
quickcommand.showMessageBox(
|
||||||
"清空完毕,为防止误操作,已将所有命令复制到剪贴板,可通过导入命令恢复"
|
"清空完毕,为防止误操作,已将所有命令复制到剪贴板,可通过导入命令恢复"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user