数据存储结构调整

This commit is contained in:
fofolee 2022-04-09 01:21:39 +08:00
parent 431906a1bb
commit 1d63940749
5 changed files with 25 additions and 37 deletions

View File

@ -10,17 +10,12 @@ let defaultProfile = {
primaryColor: "#009688",
defaultPrimaryColor: "#009688",
backgroundImg: null,
codeHistory: {}
}
let userProfile = UTOOLS.getDB(
UTOOLS.DBPRE.CFG + "preferences"
);
Object.assign(defaultProfile, userProfile)
utools.onPluginOut(() => {
UTOOLS.putDB(
defaultProfile,
UTOOLS.DBPRE.CFG + "preferences"
);
});
// "async" is optional;
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files

View File

@ -145,10 +145,7 @@
}"
/>
<!-- 运行结果 -->
<CommandRunResult
:action="runResultAction"
ref="result"
></CommandRunResult>
<CommandRunResult :action="runResultAction" ref="result"></CommandRunResult>
</div>
</template>
@ -214,7 +211,8 @@ export default {
this.bindKeys();
let quickCommandInfo =
this.action.type === "run"
? this.$utools.getDB(this.$utools.DBPRE.CFG + "codeHistory")
? this.$utools.getDB(this.$utools.DBPRE.CFG + "preferences")
?.codeHistory
: this.action.data;
_.merge(this.quickcommandInfo, quickCommandInfo);
// monoca
@ -224,16 +222,8 @@ export default {
if (this.quickcommandInfo.tags?.includes("默认") && !utools.isDev()) {
this.canCommandSave = false;
}
// runCode
if (this.action.type !== "run") return;
utools.onPluginOut(() => {
this.quickcommandInfo.cmd = this.$refs.editor.getEditorValue();
//
this.$utools.putDB(
_.cloneDeep(this.quickcommandInfo),
this.$utools.DBPRE.CFG + "codeHistory"
);
});
if (this.action.type === "run")
this.$profile.codeHistory = this.quickcommandInfo;
},
//
bindKeys() {
@ -362,7 +352,6 @@ export default {
},
//
runCurrentCommand() {
this.quickcommandInfo.cmd = this.$refs.editor?.getEditorValue();
this.quickcommandInfo.output = this.$refs.menu?.currentCommand.output;
this.$refs.result.runCurrentCommand(this.quickcommandInfo);
},

View File

@ -34,11 +34,6 @@ export default {
return this.$q.dark.isActive;
},
},
watch: {
isDark() {
this.setEditorTheme();
},
},
methods: {
initEditor() {
let monacoEditorPreferences = {
@ -58,6 +53,7 @@ export default {
this.loadTypes();
this.registerLanguage();
this.setEditorTheme();
this.listenEditroValue();
},
loadTypes() {
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
@ -181,6 +177,11 @@ export default {
destoryEditor() {
this.rawEditor.dispose();
},
listenEditroValue() {
this.rawEditor.onDidChangeModelContent(() => {
this.$parent.quickcommandInfo.cmd = this.getEditorValue();
});
},
},
};
</script>

View File

@ -15,6 +15,7 @@ export default {
type: "fromUtools",
data: {},
},
featureCode: this.$route.path.slice(1),
};
},
mounted() {
@ -22,16 +23,10 @@ export default {
this.runCurrentCommand();
},
computed: {
featureCode() {
return this.$route.params.type + "_" + this.$route.params.uid;
},
currentCommand() {
return this.$utools.whole.db.get("qc_" + this.featureCode).data;
},
},
beforeRouteUpdate(to, from, next) {
this.runCurrentCommand();
},
methods: {
runCurrentCommand() {
this.$refs.result.runCurrentCommand(this.currentCommand);

View File

@ -191,17 +191,25 @@
</template>
<script>
import { defineAsyncComponent } from "vue";
import quickcommandParser from "../js/common/quickcommandParser.js";
import CommandCard from "components/CommandCard";
import CommandEditor from "components/CommandEditor.vue";
import ConfigurationMenu from "components/ConfigurationMenu.vue";
import importAll from "../js/common/importAll.js";
const CommandEditor = defineAsyncComponent(() =>
import("components/CommandEditor.vue")
);
//
let defaultCommands = importAll(require.context("../json/", false, /\.json$/));
export default {
components: { CommandCard, CommandEditor, ConfigurationMenu },
components: {
CommandCard,
ConfigurationMenu,
CommandEditor,
},
data() {
return {
currentTag: "默认",