编码设置界面调整

This commit is contained in:
fofolee 2022-03-30 11:57:31 +08:00
parent e78c05b67a
commit 3180596754

View File

@ -16,13 +16,13 @@
<img :src="'/logo/' + program + '.png'" /> <img :src="'/logo/' + program + '.png'" />
</q-avatar> </q-avatar>
</template> </template>
<template v-slot:option="{ itemProps, itemEvents, opt }"> <template v-slot:option="scope">
<q-item v-bind="itemProps" v-on="itemEvents"> <q-item v-bind="scope.itemProps">
<q-item-section avatar> <q-item-section avatar>
<img width="32" :src="'/logo/' + opt + '.png'" /> <img width="32" :src="'/logo/' + scope.opt + '.png'" />
</q-item-section> </q-item-section>
<q-item-section> <q-item-section>
<q-item-label v-html="opt" /> <q-item-label v-html="scope.opt" />
</q-item-section> </q-item-section>
</q-item> </q-item>
</template> </template>
@ -77,10 +77,10 @@
<q-btn <q-btn
color="primary" color="primary"
label="编码设置" label="编码设置"
@click="showCoding = true" @click="showCodingPage()"
v-show="program !== 'quickcommand'" v-show="program !== 'quickcommand'"
/> />
<q-btn color="primary" label="运行" /> <q-btn color="primary" @click="runCurrentCommand()" label="运行" />
</div> </div>
</div> </div>
</div> </div>
@ -98,52 +98,21 @@
" "
/> />
</div> </div>
<q-dialog v-model="showCoding" persistent>
<q-card style="min-width: 350px">
<q-card-section>
<div class="text-h5" align="center">编码设置</div>
</q-card-section>
<q-card-section class="q-gutter-sm">
<q-input
outlined
v-model="scriptCode"
label="脚本编码"
hint="未出现乱码问题请留空"
hide-hint
autofocus
@keyup.enter="showCoding = false"
/>
<q-input
outlined
v-model="outputCode"
label="输出编码"
hint="未出现乱码问题请留空"
hide-hint
@keyup.enter="showCoding = false"
/>
</q-card-section>
<q-card-actions align="right" class="text-primary">
<q-btn color="primary" label="帮助" @click="showSupportEncodings()" />
<q-btn color="primary" label="确定" v-close-popup />
</q-card-actions>
</q-card>
</q-dialog>
</div> </div>
</template> </template>
<script> <script>
import GlobalVars from "components/GlobalVars"; import globalVars from "components/GlobalVars";
import * as monaco from "monaco-editor"; import * as monaco from "monaco-editor";
export default { export default {
data() { data() {
return { return {
options: Object.keys(GlobalVars.programs), options: Object.keys(globalVars.programs),
program: "quickcommand", program: "quickcommand",
editor: null, editor: null,
customOptions: { bin: "", argv: "", ext: "" }, customOptions: { bin: "", argv: "", ext: "" },
scptarg: "", scptarg: "",
showCoding: false,
scriptCode: "", scriptCode: "",
outputCode: "", outputCode: "",
}; };
@ -174,15 +143,9 @@ export default {
}, },
} }
); );
this.editor.onDidChangeModelContent((e) => {
console.log(e);
});
},
getValue() {
this.editor.getValue();
}, },
matchLanguage() { matchLanguage() {
let language = Object.values(GlobalVars.programs).filter( let language = Object.values(globalVars.programs).filter(
(program) => program.ext === this.customOptions.ext (program) => program.ext === this.customOptions.ext
); );
if (language.length) { if (language.length) {
@ -190,7 +153,7 @@ export default {
} }
}, },
setLanguage(language) { setLanguage(language) {
let highlight = GlobalVars.programs[language].highlight; let highlight = globalVars.programs[language].highlight;
monaco.editor.setModelLanguage( monaco.editor.setModelLanguage(
this.editor.getModel(), this.editor.getModel(),
highlight ? highlight : language highlight ? highlight : language
@ -202,12 +165,15 @@ export default {
height: 920, height: 920,
}); });
}, },
showSupportEncodings() { showCodingPage() {
utools.ubrowser quickcommand.showInputBox(
.goto( ["文件编码", "输出编码"],
"https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings" "编码设置",
) ["基于iconv-lite进行编码无乱码请留空", "无乱码请留空"],
.run({ width: 1280, height: 920 }); (res) => {
if (res) [this.scriptCode, this.outputCode] = res;
}
);
}, },
}, },
}; };