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