@@ -47,7 +50,7 @@
@@ -56,7 +59,7 @@
查看文档
脚本及输出编码设置
{
- var saveData = {
- cmd: this.$refs.editor.getEditorValue(),
- program: this.program,
- scptarg: this.scptarg,
- scriptCode: this.scriptCode,
- outputCode: this.outputCode,
- customOptions: JSON.parse(JSON.stringify(this.customOptions)),
- };
- // 保存
- this.$utools.putDB(saveData, this.$utools.DBPRE.CFG + "codeHistory");
+ this.quickcommandInfo.cmd = this.$refs.editor.getEditorValue();
+ // 保存本次编辑记录
+ this.$utools.putDB(
+ JSON.parse(JSON.stringify(this.quickcommandInfo)),
+ this.$utools.DBPRE.CFG + "codeHistory"
+ );
});
},
+ // 补充没有的键值
+ fillDefaultKeys(command) {
+ let commandKeys = Object.keys(command);
+ Object.keys(this.quickcommandInfo).forEach((key) => {
+ if (!commandKeys.includes(key))
+ command[key] = this.quickcommandInfo[key];
+ });
+ return command;
+ },
// 绑定快捷键
bindKeys() {
let that = this;
@@ -216,7 +243,7 @@ export default {
// 匹配编程语言
matchLanguage() {
let language = Object.values(this.$programmings).filter(
- (program) => program.ext === this.customOptions.ext
+ (program) => program.ext === this.quickcommandInfo.customOptions.ext
);
if (language.length) {
this.setLanguage(language[0].name);
@@ -241,12 +268,19 @@ export default {
{
labels: ["文件编码", "输出编码"],
hints: ["基于iconv-lite进行编码,无乱码请留空", "无乱码请留空"],
- values: [this.scriptCode, this.outputCode],
+ values: [
+ this.quickcommandInfo.charset?.scriptCode,
+ this.quickcommandInfo.charset?.outputCode,
+ ],
},
"编码设置"
)
.then((res) => {
- if (res) [this.scriptCode, this.outputCode] = res;
+ if (res)
+ [
+ this.quickcommandInfo.charset.scriptCode,
+ this.quickcommandInfo.charset.outputCode,
+ ] = res;
});
},
// 运行命令
@@ -267,24 +301,17 @@ export default {
utools.hideMainWindow();
break;
}
- if (this.program === "quickcommand") {
+ if (this.quickcommandInfo.program === "quickcommand") {
window.runCodeInVm(cmd, (stdout, stderr) => {
if (stderr) return this.showRunResult(stderr, raw, false);
this.showRunResult(stdout, raw, true);
});
} else {
let option = this.$programmings[this.program];
- if (this.program === "custom")
- option = {
- bin: this.customOptions.bin,
- argv: this.customOptions.argv,
- ext: this.customOptions.ext,
- };
- option.scptarg = this.scptarg;
- option.charset = {
- scriptCode: this.scriptCode,
- outputCode: this.outputCode,
- };
+ if (this.quickcommandInfo.program === "custom")
+ option = this.quickcommandInfo.customOptions;
+ option.scptarg = this.quickcommandInfo.scptarg;
+ option.charset = this.quickcommandInfo.charset;
window.runCodeFile(cmd, option, terminal, (stdout, stderr) => {
if (terminal) return;
if (stderr) return this.showRunResult(stderr, raw, false);
diff --git a/src/pages/ConfigurationPage.vue b/src/pages/ConfigurationPage.vue
index 1890f92..bf3cccc 100644
--- a/src/pages/ConfigurationPage.vue
+++ b/src/pages/ConfigurationPage.vue
@@ -147,7 +147,14 @@
-
+
@@ -355,6 +362,8 @@ export default {
methods: {
// 初始化
initPage() {
+ console.log(this.$route);
+ window.configuration = this;
// 已启用的 features
let activatedFeatures = this.getActivatedFeatures();
// 已启用的命令的 featureCode
@@ -368,7 +377,6 @@ export default {
this.$utools.DBPRE.CFG + "preferences"
);
this.commandCardStyle = userPreferences.commandCardStyle || "normal";
- console.log("ConfigurationPage", this);
utools.onPluginOut(() => {
userPreferences.commandCardStyle = this.commandCardStyle;
this.$utools.putDB(
@@ -587,6 +595,22 @@ export default {
.querySelectorAll(".q-toggle[aria-checked='true']")
.forEach((x) => x.click());
},
+ // 新建命令
+ addNewCommand() {
+ let routeData = {
+ from: "configuration",
+ action: "new",
+ data: {
+ currentTag: this.currentTag,
+ },
+ };
+ this.$router.push({
+ name: "code",
+ params: {
+ data: JSON.stringify(routeData),
+ },
+ });
+ },
},
};