Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/presenter/configPresenter/shortcutKeySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export const rendererShortcutKey = {
DeleteConversation: `${CommandKey}+D`,
SwitchNextTab: `${CommandKey}+Tab`,
SwitchPrevTab: `${CommandKey}+${ShiftKey}+Tab`,
SwtichToLastTab: `${CommandKey}+9`
SwtichToLastTab: `${CommandKey}+9`,
NumberTabs: `${CommandKey}+1...8`
}

// System-level shortcut keys
Expand Down
16 changes: 9 additions & 7 deletions src/main/presenter/shortcutPresenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,15 @@ export class ShortcutPresenter implements IShortcutPresenter {
}

// 注册标签页数字快捷键 (1-8)
for (let i = 1; i <= 8; i++) {
globalShortcut.register(`${CommandKey}+${i}`, () => {
const focusedWindow = presenter.windowPresenter.getFocusedWindow()
if (focusedWindow?.isFocused()) {
this.switchToTabByIndex(focusedWindow.id, i - 1) // 索引从0开始
}
})
if (this.shortcutKeys.NumberTabs) {
for (let i = 1; i <= 8; i++) {
globalShortcut.register(`${CommandKey}+${i}`, () => {
const focusedWindow = presenter.windowPresenter.getFocusedWindow()
if (focusedWindow?.isFocused()) {
this.switchToTabByIndex(focusedWindow.id, i - 1) // 索引从0开始
}
})
}
}

// Command+9 或 Ctrl+9 切换到最后一个标签页
Expand Down
27 changes: 19 additions & 8 deletions src/renderer/settings/components/ShortcutSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<Icon icon="lucide:pencil" class="h-4 w-4" />
</Button>
<Button
v-if="!shortcut.disabled && shortcut.key.length"
v-if="shortcut.key.length && (!shortcut.disabled || shortcut.isNumberTabs)"
Comment thread
zerob13 marked this conversation as resolved.
variant="ghost"
size="icon"
class="h-8 w-8 text-muted-foreground hover:text-destructive"
Expand Down Expand Up @@ -250,13 +250,20 @@ const shortcuts = computed(() => {
}

try {
return Object.entries(shortcutMapping).map(([key, value]) => ({
id: key,
icon: value.icon,
label: value.label,
key: formatShortcut(shortcutKeys.value[key] || value.key),
disabled: value.disabled
}))
return Object.entries(shortcutMapping).map(([key, value]) => {
const savedKey = shortcutKeys.value?.[key as ShortcutKey]
const rawKey = savedKey ?? value.key ?? ''
const formattedKey = formatShortcut(rawKey)

return {
id: key as ShortcutKey,
icon: value.icon,
label: value.label,
key: formattedKey,
disabled: value.disabled,
isNumberTabs: key === 'NumberTabs'
}
})
} catch (error) {
console.error('Parse shortcut key error', error)
return []
Expand Down Expand Up @@ -439,6 +446,10 @@ const clearShortcut = async (shortcutId: string) => {
if (!shortcutKeys.value) return

try {
if (recordingShortcutId.value === shortcutId) {
cancelRecording()
}

// 设置为空字符串
const shortcutKey = shortcutId as keyof typeof shortcutKeys.value
shortcutKeys.value[shortcutKey] = ''
Expand Down