mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-29 04:12:45 +08:00
编码设置界面调整
This commit is contained in:
parent
e78c05b67a
commit
3180596754
@ -16,13 +16,13 @@
|
||||
<img :src="'/logo/' + program + '.png'" />
|
||||
</q-avatar>
|
||||
</template>
|
||||
<template v-slot:option="{ itemProps, itemEvents, opt }">
|
||||
<q-item v-bind="itemProps" v-on="itemEvents">
|
||||
<template v-slot:option="scope">
|
||||
<q-item v-bind="scope.itemProps">
|
||||
<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-label v-html="opt" />
|
||||
<q-item-label v-html="scope.opt" />
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</template>
|
||||
@ -77,10 +77,10 @@
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="编码设置"
|
||||
@click="showCoding = true"
|
||||
@click="showCodingPage()"
|
||||
v-show="program !== 'quickcommand'"
|
||||
/>
|
||||
<q-btn color="primary" label="运行" />
|
||||
<q-btn color="primary" @click="runCurrentCommand()" label="运行" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -98,52 +98,21 @@
|
||||
"
|
||||
/>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import GlobalVars from "components/GlobalVars";
|
||||
import globalVars from "components/GlobalVars";
|
||||
import * as monaco from "monaco-editor";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
options: Object.keys(GlobalVars.programs),
|
||||
options: Object.keys(globalVars.programs),
|
||||
program: "quickcommand",
|
||||
editor: null,
|
||||
customOptions: { bin: "", argv: "", ext: "" },
|
||||
scptarg: "",
|
||||
showCoding: false,
|
||||
scriptCode: "",
|
||||
outputCode: "",
|
||||
};
|
||||
@ -174,15 +143,9 @@ export default {
|
||||
},
|
||||
}
|
||||
);
|
||||
this.editor.onDidChangeModelContent((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
getValue() {
|
||||
this.editor.getValue();
|
||||
},
|
||||
matchLanguage() {
|
||||
let language = Object.values(GlobalVars.programs).filter(
|
||||
let language = Object.values(globalVars.programs).filter(
|
||||
(program) => program.ext === this.customOptions.ext
|
||||
);
|
||||
if (language.length) {
|
||||
@ -190,7 +153,7 @@ export default {
|
||||
}
|
||||
},
|
||||
setLanguage(language) {
|
||||
let highlight = GlobalVars.programs[language].highlight;
|
||||
let highlight = globalVars.programs[language].highlight;
|
||||
monaco.editor.setModelLanguage(
|
||||
this.editor.getModel(),
|
||||
highlight ? highlight : language
|
||||
@ -202,12 +165,15 @@ export default {
|
||||
height: 920,
|
||||
});
|
||||
},
|
||||
showSupportEncodings() {
|
||||
utools.ubrowser
|
||||
.goto(
|
||||
"https://github.com/ashtuchkin/iconv-lite/wiki/Supported-Encodings"
|
||||
)
|
||||
.run({ width: 1280, height: 920 });
|
||||
showCodingPage() {
|
||||
quickcommand.showInputBox(
|
||||
["文件编码", "输出编码"],
|
||||
"编码设置",
|
||||
["基于iconv-lite进行编码,无乱码请留空", "无乱码请留空"],
|
||||
(res) => {
|
||||
if (res) [this.scriptCode, this.outputCode] = res;
|
||||
}
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user