mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 13:02:46 +08:00
数据存储结构调整
This commit is contained in:
parent
431906a1bb
commit
1d63940749
@ -10,21 +10,16 @@ let defaultProfile = {
|
|||||||
primaryColor: "#009688",
|
primaryColor: "#009688",
|
||||||
defaultPrimaryColor: "#009688",
|
defaultPrimaryColor: "#009688",
|
||||||
backgroundImg: null,
|
backgroundImg: null,
|
||||||
|
codeHistory: {}
|
||||||
}
|
}
|
||||||
let userProfile = UTOOLS.getDB(
|
let userProfile = UTOOLS.getDB(
|
||||||
UTOOLS.DBPRE.CFG + "preferences"
|
UTOOLS.DBPRE.CFG + "preferences"
|
||||||
);
|
);
|
||||||
Object.assign(defaultProfile, userProfile)
|
Object.assign(defaultProfile, userProfile)
|
||||||
utools.onPluginOut(() => {
|
|
||||||
UTOOLS.putDB(
|
|
||||||
defaultProfile,
|
|
||||||
UTOOLS.DBPRE.CFG + "preferences"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// "async" is optional;
|
// "async" is optional;
|
||||||
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files
|
// more info on params: https://v2.quasar.dev/quasar-cli/boot-files
|
||||||
export default boot(async ({
|
export default boot(async({
|
||||||
app
|
app
|
||||||
}) => {
|
}) => {
|
||||||
app.config.globalProperties.$utools = UTOOLS
|
app.config.globalProperties.$utools = UTOOLS
|
||||||
|
@ -145,10 +145,7 @@
|
|||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<!-- 运行结果 -->
|
<!-- 运行结果 -->
|
||||||
<CommandRunResult
|
<CommandRunResult :action="runResultAction" ref="result"></CommandRunResult>
|
||||||
:action="runResultAction"
|
|
||||||
ref="result"
|
|
||||||
></CommandRunResult>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -214,7 +211,8 @@ export default {
|
|||||||
this.bindKeys();
|
this.bindKeys();
|
||||||
let quickCommandInfo =
|
let quickCommandInfo =
|
||||||
this.action.type === "run"
|
this.action.type === "run"
|
||||||
? this.$utools.getDB(this.$utools.DBPRE.CFG + "codeHistory")
|
? this.$utools.getDB(this.$utools.DBPRE.CFG + "preferences")
|
||||||
|
?.codeHistory
|
||||||
: this.action.data;
|
: this.action.data;
|
||||||
_.merge(this.quickcommandInfo, quickCommandInfo);
|
_.merge(this.quickcommandInfo, quickCommandInfo);
|
||||||
// monoca 相关
|
// monoca 相关
|
||||||
@ -224,16 +222,8 @@ export default {
|
|||||||
if (this.quickcommandInfo.tags?.includes("默认") && !utools.isDev()) {
|
if (this.quickcommandInfo.tags?.includes("默认") && !utools.isDev()) {
|
||||||
this.canCommandSave = false;
|
this.canCommandSave = false;
|
||||||
}
|
}
|
||||||
// 只有 runCode 时才保存记录
|
if (this.action.type === "run")
|
||||||
if (this.action.type !== "run") return;
|
this.$profile.codeHistory = this.quickcommandInfo;
|
||||||
utools.onPluginOut(() => {
|
|
||||||
this.quickcommandInfo.cmd = this.$refs.editor.getEditorValue();
|
|
||||||
// 保存本次编辑记录
|
|
||||||
this.$utools.putDB(
|
|
||||||
_.cloneDeep(this.quickcommandInfo),
|
|
||||||
this.$utools.DBPRE.CFG + "codeHistory"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
// 绑定快捷键
|
// 绑定快捷键
|
||||||
bindKeys() {
|
bindKeys() {
|
||||||
@ -362,7 +352,6 @@ export default {
|
|||||||
},
|
},
|
||||||
// 运行
|
// 运行
|
||||||
runCurrentCommand() {
|
runCurrentCommand() {
|
||||||
this.quickcommandInfo.cmd = this.$refs.editor?.getEditorValue();
|
|
||||||
this.quickcommandInfo.output = this.$refs.menu?.currentCommand.output;
|
this.quickcommandInfo.output = this.$refs.menu?.currentCommand.output;
|
||||||
this.$refs.result.runCurrentCommand(this.quickcommandInfo);
|
this.$refs.result.runCurrentCommand(this.quickcommandInfo);
|
||||||
},
|
},
|
||||||
|
@ -34,11 +34,6 @@ export default {
|
|||||||
return this.$q.dark.isActive;
|
return this.$q.dark.isActive;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
isDark() {
|
|
||||||
this.setEditorTheme();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
initEditor() {
|
initEditor() {
|
||||||
let monacoEditorPreferences = {
|
let monacoEditorPreferences = {
|
||||||
@ -58,6 +53,7 @@ export default {
|
|||||||
this.loadTypes();
|
this.loadTypes();
|
||||||
this.registerLanguage();
|
this.registerLanguage();
|
||||||
this.setEditorTheme();
|
this.setEditorTheme();
|
||||||
|
this.listenEditroValue();
|
||||||
},
|
},
|
||||||
loadTypes() {
|
loadTypes() {
|
||||||
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
monaco.languages.typescript.javascriptDefaults.setDiagnosticsOptions({
|
||||||
@ -181,6 +177,11 @@ export default {
|
|||||||
destoryEditor() {
|
destoryEditor() {
|
||||||
this.rawEditor.dispose();
|
this.rawEditor.dispose();
|
||||||
},
|
},
|
||||||
|
listenEditroValue() {
|
||||||
|
this.rawEditor.onDidChangeModelContent(() => {
|
||||||
|
this.$parent.quickcommandInfo.cmd = this.getEditorValue();
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -15,6 +15,7 @@ export default {
|
|||||||
type: "fromUtools",
|
type: "fromUtools",
|
||||||
data: {},
|
data: {},
|
||||||
},
|
},
|
||||||
|
featureCode: this.$route.path.slice(1),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -22,16 +23,10 @@ export default {
|
|||||||
this.runCurrentCommand();
|
this.runCurrentCommand();
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
featureCode() {
|
|
||||||
return this.$route.params.type + "_" + this.$route.params.uid;
|
|
||||||
},
|
|
||||||
currentCommand() {
|
currentCommand() {
|
||||||
return this.$utools.whole.db.get("qc_" + this.featureCode).data;
|
return this.$utools.whole.db.get("qc_" + this.featureCode).data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
beforeRouteUpdate(to, from, next) {
|
|
||||||
this.runCurrentCommand();
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
runCurrentCommand() {
|
runCurrentCommand() {
|
||||||
this.$refs.result.runCurrentCommand(this.currentCommand);
|
this.$refs.result.runCurrentCommand(this.currentCommand);
|
||||||
|
@ -191,17 +191,25 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { defineAsyncComponent } from "vue";
|
||||||
import quickcommandParser from "../js/common/quickcommandParser.js";
|
import quickcommandParser from "../js/common/quickcommandParser.js";
|
||||||
import CommandCard from "components/CommandCard";
|
import CommandCard from "components/CommandCard";
|
||||||
import CommandEditor from "components/CommandEditor.vue";
|
|
||||||
import ConfigurationMenu from "components/ConfigurationMenu.vue";
|
import ConfigurationMenu from "components/ConfigurationMenu.vue";
|
||||||
import importAll from "../js/common/importAll.js";
|
import importAll from "../js/common/importAll.js";
|
||||||
|
|
||||||
|
const CommandEditor = defineAsyncComponent(() =>
|
||||||
|
import("components/CommandEditor.vue")
|
||||||
|
);
|
||||||
|
|
||||||
// 默认命令
|
// 默认命令
|
||||||
let defaultCommands = importAll(require.context("../json/", false, /\.json$/));
|
let defaultCommands = importAll(require.context("../json/", false, /\.json$/));
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { CommandCard, CommandEditor, ConfigurationMenu },
|
components: {
|
||||||
|
CommandCard,
|
||||||
|
ConfigurationMenu,
|
||||||
|
CommandEditor,
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
currentTag: "默认",
|
currentTag: "默认",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user