This commit is contained in:
fofolee 2022-04-12 19:19:05 +08:00
parent 7264db7a5d
commit 8c5996bc93
7 changed files with 65 additions and 34 deletions

View File

@ -210,22 +210,22 @@ if (process.platform !== 'linux') quickcommand.runInTerminal = function(cmdline,
} }
let getCommandToLaunchTerminal = (cmdline, dir) => { let getCommandToLaunchTerminal = (cmdline, dir) => {
let cd = '' let cd = ''
if (utools.isWindows()) { if (utools.isWindows()) {
let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/') let appPath = path.join(utools.getPath('home'), '/AppData/Local/Microsoft/WindowsApps/')
// 直接 existsSync wt.exe 无效 // 直接 existsSync wt.exe 无效
if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) { if (fs.existsSync(appPath) && fs.readdirSync(appPath).includes('wt.exe')) {
cmdline = cmdline.replace(/"/g, `\\"`) cmdline = cmdline.replace(/"/g, `\\"`)
if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"` if (dir) cd = `-d "${dir.replace(/\\/g, '/')}"`
command = `${appPath}wt.exe ${cd} cmd /k "${cmdline}"` 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 { } else {
cmdline = cmdline.replace(/"/g, `^"`) cmdline = cmdline.replace(/"/g, `\\"`)
if (dir) cd = `cd /d "${dir.replace(/\\/g, '/')}" &&` if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
command = `${cd} start "" cmd /k "${cmdline}"`
}
} else {
cmdline = cmdline.replace(/"/g, `\\"`)
if (dir) cd = `cd ${dir.replace(/ /g, `\\\\ `)} &&`
if (fs.existsSync('/Applications/iTerm.app')) { if (fs.existsSync('/Applications/iTerm.app')) {
command = `osascript -e 'tell application "iTerm" command = `osascript -e 'tell application "iTerm"
create window with default profile create window with default profile
@ -493,10 +493,14 @@ window.getMatchedFilesFix = payload => {
} }
window.saveFile = (content, file) => { window.saveFile = (content, file) => {
if (file instanceof Object) { if (file instanceof Object) file = utools.showSaveDialog(file)
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 => { window.getSelectFile = hwnd => {

View File

@ -1,6 +1,6 @@
<template> <template>
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }">
<component :ref="$route.name" :is="Component" /> <component ref="view" :is="Component" />
</router-view> </router-view>
</template> </template>

View File

@ -186,7 +186,6 @@ export default {
resultMaxLength: 10000, resultMaxLength: 10000,
showSidebar: this.action.type !== "run", showSidebar: this.action.type !== "run",
isRunCodePage: this.action.type === "run", isRunCodePage: this.action.type === "run",
configurationPage: this.$root.$refs.configuration,
commandString: this.$q.platform.is.mac ? "⌘" : "ctrl", commandString: this.$q.platform.is.mac ? "⌘" : "ctrl",
}; };
}, },
@ -198,9 +197,12 @@ export default {
this.$refs.sidebar?.init(); this.$refs.sidebar?.init();
}, },
computed: { computed: {
configurationPage() {
return this.$root.$refs.view;
},
allQuickCommandTags() { allQuickCommandTags() {
return _.without( return _.without(
this.configurationPage?.allQuickCommandTags, this.configurationPage.allQuickCommandTags,
"默认", "默认",
"未分类", "未分类",
"搜索结果" "搜索结果"

View File

@ -6,7 +6,10 @@
transition-hide="jump-down" transition-hide="jump-down"
> >
<!-- 用户信息 --> <!-- 用户信息 -->
<UserInfo /> <UserInfo
:allQuickCommandsLength="allQuickCommandsLength"
:allFeaturesLength="allFeaturesLength"
/>
<!-- 菜单 --> <!-- 菜单 -->
<q-list> <q-list>
<!-- 导入 --> <!-- 导入 -->
@ -173,7 +176,7 @@
</q-dialog> </q-dialog>
<!-- 面板视图弹窗 --> <!-- 面板视图弹窗 -->
<q-dialog v-model="showPanelConf"> <q-dialog v-model="showPanelConf">
<PanelSetting /> <PanelSetting :isTagStared="isTagStared" />
</q-dialog> </q-dialog>
</q-menu> </q-menu>
</template> </template>
@ -193,17 +196,23 @@ export default {
}, },
data() { data() {
return { return {
configurationPage: this.$root.$refs.configuration,
setCssVar: setCssVar, setCssVar: setCssVar,
selectFile: ref(null), selectFile: ref(null),
showAbout: false, showAbout: false,
showPanelConf: 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() { mounted() {
window.configurationMenu = this; window.configurationMenu = this;
}, },

View File

@ -11,3 +11,16 @@
</q-card-actions> </q-card-actions>
</q-card> </q-card>
</template> </template>
<script>
export default {
data() {
return {
panelConf: {
name: "",
description: "",
},
};
},
};
</script>

View File

@ -20,14 +20,14 @@
<div class="column items-start q-gutter-xs"> <div class="column items-start q-gutter-xs">
<q-chip dense square> <q-chip dense square>
<q-avatar color="indigo" text-color="white">{{ <q-avatar color="indigo" text-color="white">{{
Object.keys(configurationPage.allQuickCommands).length allQuickCommandsLength
}}</q-avatar> }}</q-avatar>
Quickcommands Quickcommands
<q-tooltip>当前拥有的快捷命令</q-tooltip> <q-tooltip>当前拥有的快捷命令</q-tooltip>
</q-chip> </q-chip>
<q-chip dense square> <q-chip dense square>
<q-avatar color="green-8" text-color="white">{{ <q-avatar color="green-8" text-color="white">{{
configurationPage.activatedQuickCommandFeatureCodes.length allFeaturesLength
}}</q-avatar> }}</q-avatar>
Features Features
<q-tooltip>当前启用的快捷命令</q-tooltip> <q-tooltip>当前启用的快捷命令</q-tooltip>
@ -67,8 +67,11 @@ export default {
number: 1, number: 1,
process: 0.4, process: 0.4,
}, },
configurationPage: this.$root.$refs.configuration,
}; };
}, },
props: {
allFeaturesLength: Number,
allQuickCommandsLength: Number,
},
}; };
</script> </script>

View File

@ -478,8 +478,8 @@ export default {
}); });
let stringifyCommands = JSON.stringify(commandsToExport); let stringifyCommands = JSON.stringify(commandsToExport);
if (saveAsFile) { if (saveAsFile) {
window.saveFile(stringifyCommands, options); window.saveFile(stringifyCommands, options) &&
quickcommand.showMessageBox("导出成功!"); quickcommand.showMessageBox("导出成功!");
} else { } else {
utools.copyText(stringifyCommands); utools.copyText(stringifyCommands);
} }