mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 06:54:11 +08:00
修复parseVarInput在处理特殊字符时的BUG
This commit is contained in:
parent
8003497e71
commit
ebbc7b7661
@ -293,16 +293,11 @@ export default defineComponent({
|
||||
const value = this.getItemValue(option);
|
||||
this.$emit("update:modelValue", newVarInputVal("str", value));
|
||||
},
|
||||
escapePath(paths) {
|
||||
if (!paths) return null;
|
||||
if (typeof paths === "string") return paths.replace(/\\/g, "\\\\");
|
||||
return paths.map((path) => path.replace(/\\/g, "\\\\"));
|
||||
},
|
||||
handleFileOpen(dialog) {
|
||||
let { type, options } = window.lodashM.cloneDeep(dialog);
|
||||
if (!type) type = "open";
|
||||
if (type === "open") {
|
||||
const files = this.escapePath(utools.showOpenDialog(options));
|
||||
const files = utools.showOpenDialog(options);
|
||||
if (!files) return;
|
||||
if (files.length > 1) {
|
||||
this.$emit("update:modelValue", newVarInputVal("var", files));
|
||||
@ -310,7 +305,7 @@ export default defineComponent({
|
||||
this.$emit("update:modelValue", newVarInputVal("str", files[0]));
|
||||
}
|
||||
} else {
|
||||
const file = this.escapePath(utools.showSaveDialog(options));
|
||||
const file = utools.showSaveDialog(options);
|
||||
if (!file) return;
|
||||
this.$emit("update:modelValue", newVarInputVal("str", file));
|
||||
}
|
||||
|
@ -37,5 +37,10 @@ export const newEmptyVarInputVal = (type = "str") => {
|
||||
* @returns {string} 处理后的字符串
|
||||
*/
|
||||
export const stringifyVarInputVal = (argv) => {
|
||||
return argv.isString ? `"${argv.value}"` : argv.value;
|
||||
if (!argv.isString) return argv.value;
|
||||
try {
|
||||
return JSON.stringify(argv.value);
|
||||
} catch (e) {
|
||||
return `"${argv.value}"`;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user