异步读取feature和command

This commit is contained in:
fofolee 2022-05-15 14:44:14 +08:00
parent b0091e429e
commit 6250e085a4

View File

@ -224,7 +224,7 @@ export default {
lastTag: "", lastTag: "",
activatedQuickCommandFeatureCodes: [], activatedQuickCommandFeatureCodes: [],
activatedQuickPanels: [], activatedQuickPanels: [],
allQuickCommands: [], allQuickCommands: {},
commandSearchKeyword: "", commandSearchKeyword: "",
isCommandEditorShow: false, isCommandEditorShow: false,
commandEditorAction: {}, commandEditorAction: {},
@ -317,25 +317,15 @@ export default {
else this.editCommand(JSON.parse(this.$root.enterData.payload)); else this.editCommand(JSON.parse(this.$root.enterData.payload));
this.$router.push("/configuration"); this.$router.push("/configuration");
} }
// features
let activatedFeatures = this.getActivatedFeatures();
// featureCode
this.activatedQuickCommandFeatureCodes =
activatedFeatures.quickcommand.map((f) => f.code);
//
this.activatedQuickPanels = activatedFeatures.quickpanels;
//
this.allQuickCommands = this.getAllQuickCommands();
this.importDefaultCommands();
if (this.$route.params.tags) { if (this.$route.params.tags) {
this.currentTag = window.hexDecode(this.$route.params.tags); this.currentTag = window.hexDecode(this.$route.params.tags);
this.commandCardStyle = "mini"; this.commandCardStyle = "mini";
} }
//
setTimeout(this.getActivatedFeatures, 0);
setTimeout(this.getAllQuickCommands, 0);
}, },
importDefaultCommands() { importDefaultCommands() {
for (var code of Object.keys(defaultCommands)) {
this.$root.utools.putDB(defaultCommands[code], "qc_" + code);
}
Object.assign(this.allQuickCommands, defaultCommands); Object.assign(this.allQuickCommands, defaultCommands);
}, },
// features // features
@ -348,18 +338,17 @@ export default {
? quickpanels.push(window.hexDecode(x.code.slice(6))) ? quickpanels.push(window.hexDecode(x.code.slice(6)))
: currentFts.push(x) : currentFts.push(x)
); );
return { this.activatedQuickCommandFeatureCodes = currentFts.map((f) => f.code);
quickcommand: currentFts, //
quickpanels: quickpanels, this.activatedQuickPanels = quickpanels;
};
}, },
// //
getAllQuickCommands() { getAllQuickCommands() {
let allQcs = {}; this.allQuickCommands = {};
this.$root.utools this.$root.utools
.getDocs("qc_") .getDocs("qc_")
.forEach((x) => (allQcs[x.data.features.code] = x.data)); .forEach((x) => (this.allQuickCommands[x.data.features.code] = x.data));
return allQcs; this.importDefaultCommands();
}, },
// //
commandChanged(event) { commandChanged(event) {