diff --git a/public/preload.js b/public/preload.js index e153f68..0793215 100644 --- a/public/preload.js +++ b/public/preload.js @@ -210,22 +210,22 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline, } let getCommandToLaunchTerminal = (cmdline, dir) => { - let cd = '' - if (utools.isWindows()) { - let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/') - // 直接 existsSync wt.exe 无效 - if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) { - cmdline = cmdline.replace(/"/g, `\\"`) - if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"` - command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"` + let cd = '' + if (utools.isWindows()) { + let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/') + // 直接 existsSync wt.exe 无效 + if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) { + cmdline = cmdline.replace(/"/g, `\\"`) + if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"` + command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"` + } else { + cmdline = cmdline.replace(/"/g, `^"`) + if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&` + command = `${cd} start "" cmd /k "${cmdline}"` + } } else { - cmdline = cmdline.replace(/"/g, `^"`) - if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&` - command = `${cd} start "" cmd /k "${cmdline}"` - } - } else { - cmdline = cmdline.replace(/"/g, `\\"`) - if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&` + cmdline = cmdline.replace(/"/g, `\\"`) + if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&` if (fs.existsSync('/Applications/iTerm.app')) { command = `osascript -e 'tell application "iTerm" create window with default profile @@ -493,10 +493,14 @@ window.getMatchedFilesFix = payload => { } window.saveFile = (content, file) => { - if (file instanceof Object) { - file = utools.showSaveDialog(file) + if (file instanceof Object) file = utools.showSaveDialog(file) + if (!file) return false + try { + fs.writeFileSync(file, content) + return true + } catch (error) { + return false } - file && fs.writeFileSync(file, content) } window.getSelectFile = hwnd => { @@ -578,4 +582,4 @@ window.runCodeFile = (cmd, option, terminal, callback) => { // let stderr = err_chunks.join(""); // callback(stdout, stderr) // }) -} +} \ No newline at end of file diff --git a/src/App.vue b/src/App.vue index dbf542a..7de9bc0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,6 @@ diff --git a/src/components/CommandEditor.vue b/src/components/CommandEditor.vue index d51346e..4e88183 100644 --- a/src/components/CommandEditor.vue +++ b/src/components/CommandEditor.vue @@ -186,7 +186,6 @@ export default { resultMaxLength: 10000, showSidebar: this.action.type !== "run", isRunCodePage: this.action.type === "run", - configurationPage: this.$root.$refs.configuration, commandString: this.$q.platform.is.mac ? "⌘" : "ctrl", }; }, @@ -198,9 +197,12 @@ export default { this.$refs.sidebar?.init(); }, computed: { + configurationPage() { + return this.$root.$refs.view; + }, allQuickCommandTags() { return _.without( - this.configurationPage?.allQuickCommandTags, + this.configurationPage.allQuickCommandTags, "默认", "未分类", "搜索结果" diff --git a/src/components/ConfigurationMenu.vue b/src/components/ConfigurationMenu.vue index ff9b688..afb5189 100644 --- a/src/components/ConfigurationMenu.vue +++ b/src/components/ConfigurationMenu.vue @@ -6,7 +6,10 @@ transition-hide="jump-down" > - + @@ -173,7 +176,7 @@ - + @@ -193,17 +196,23 @@ export default { }, data() { return { - configurationPage: this.$root.$refs.configuration, setCssVar: setCssVar, selectFile: ref(null), showAbout: false, showPanelConf: false, - panelConf: { - name: "", - description: "", - }, }; }, + computed: { + configurationPage() { + return this.$root.$refs.view; + }, + allQuickCommandsLength() { + return Object.keys(this.configurationPage.allQuickCommands).length; + }, + allFeaturesLength() { + return this.configurationPage.activatedQuickCommandFeatureCodes.length; + }, + }, mounted() { window.configurationMenu = this; }, diff --git a/src/components/PanelSetting.vue b/src/components/PanelSetting.vue index 737d4f1..374c09b 100644 --- a/src/components/PanelSetting.vue +++ b/src/components/PanelSetting.vue @@ -11,3 +11,16 @@ + + diff --git a/src/components/UserInfo.vue b/src/components/UserInfo.vue index 1c8eb0a..b56d5df 100644 --- a/src/components/UserInfo.vue +++ b/src/components/UserInfo.vue @@ -20,14 +20,14 @@
{{ - Object.keys(configurationPage.allQuickCommands).length + allQuickCommandsLength }} Quickcommands 当前拥有的「快捷命令」数 {{ - configurationPage.activatedQuickCommandFeatureCodes.length + allFeaturesLength }} Features 当前启用的「快捷命令」数 @@ -67,8 +67,11 @@ export default { number: 1, process: 0.4, }, - configurationPage: this.$root.$refs.configuration, }; }, + props: { + allFeaturesLength: Number, + allQuickCommandsLength: Number, + }, }; diff --git a/src/pages/ConfigurationPage.vue b/src/pages/ConfigurationPage.vue index 7dbe47a..9c124e5 100644 --- a/src/pages/ConfigurationPage.vue +++ b/src/pages/ConfigurationPage.vue @@ -478,8 +478,8 @@ export default { }); let stringifyCommands = JSON.stringify(commandsToExport); if (saveAsFile) { - window.saveFile(stringifyCommands, options); - quickcommand.showMessageBox("导出成功!"); + window.saveFile(stringifyCommands, options) && + quickcommand.showMessageBox("导出成功!"); } else { utools.copyText(stringifyCommands); }