mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-12 09:29:43 +08:00
🐛 fix(shortcuts): 调整新建查询默认快捷键
- 将新建查询页默认快捷键改为 macOS Cmd+N、Windows Ctrl+N - 将新建数据源默认快捷键顺延为 Cmd/Ctrl+Shift+N - 补充默认快捷键唯一性校验,避免动作默认撞键
This commit is contained in:
@@ -178,14 +178,27 @@ describe('shortcut defaults', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('keeps enabled default shortcuts unique per platform', () => {
|
||||
for (const platform of ['mac', 'windows'] as const) {
|
||||
const seen = new Map<string, string>();
|
||||
Object.entries(DEFAULT_SHORTCUT_OPTIONS).forEach(([action, bindings]) => {
|
||||
const binding = bindings[platform];
|
||||
if (!binding.enabled || !binding.combo) return;
|
||||
const existingAction = seen.get(binding.combo);
|
||||
expect(existingAction, `${platform} ${binding.combo} is shared by ${existingAction} and ${action}`).toBeUndefined();
|
||||
seen.set(binding.combo, action);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('uses Navicat-inspired defaults separately for macOS and Windows/Linux', () => {
|
||||
expect(DEFAULT_SHORTCUT_OPTIONS.runQuery).toEqual({
|
||||
mac: { combo: 'Meta+R', enabled: true },
|
||||
windows: { combo: 'Ctrl+R', enabled: true },
|
||||
});
|
||||
expect(DEFAULT_SHORTCUT_OPTIONS.newQueryTab).toEqual({
|
||||
mac: { combo: 'Meta+Y', enabled: true },
|
||||
windows: { combo: 'Ctrl+Q', enabled: true },
|
||||
mac: { combo: 'Meta+N', enabled: true },
|
||||
windows: { combo: 'Ctrl+N', enabled: true },
|
||||
});
|
||||
expect(DEFAULT_SHORTCUT_OPTIONS.toggleLogPanel).toEqual({
|
||||
mac: { combo: 'Meta+Shift+H', enabled: true },
|
||||
@@ -195,8 +208,8 @@ describe('shortcut defaults', () => {
|
||||
|
||||
it('registers connection and AI panel actions as real shortcuts', () => {
|
||||
expect(DEFAULT_SHORTCUT_OPTIONS.newConnection).toEqual({
|
||||
mac: { combo: 'Meta+N', enabled: true },
|
||||
windows: { combo: 'Ctrl+N', enabled: true },
|
||||
mac: { combo: 'Meta+Shift+N', enabled: true },
|
||||
windows: { combo: 'Ctrl+Shift+N', enabled: true },
|
||||
});
|
||||
expect(DEFAULT_SHORTCUT_OPTIONS.toggleAIPanel).toEqual({
|
||||
mac: { combo: 'Meta+J', enabled: true },
|
||||
@@ -215,21 +228,21 @@ describe('shortcut defaults', () => {
|
||||
mac: { combo: 'Ctrl+Shift+R', enabled: false },
|
||||
windows: { combo: 'Ctrl+Shift+R', enabled: false },
|
||||
});
|
||||
expect(options.newQueryTab.windows.combo).toBe('Ctrl+Q');
|
||||
expect(options.newQueryTab.windows.combo).toBe('Ctrl+N');
|
||||
});
|
||||
|
||||
it('sanitizes partial platform shortcut bindings without losing defaults', () => {
|
||||
const options = sanitizeShortcutOptions({
|
||||
newQueryTab: {
|
||||
mac: { combo: 'Meta+Y', enabled: false },
|
||||
mac: { combo: 'Meta+N', enabled: false },
|
||||
},
|
||||
sendAIChatMessage: {
|
||||
windows: { combo: 'A', enabled: true },
|
||||
},
|
||||
});
|
||||
|
||||
expect(options.newQueryTab.mac).toEqual({ combo: 'Meta+Y', enabled: false });
|
||||
expect(options.newQueryTab.windows).toEqual({ combo: 'Ctrl+Q', enabled: true });
|
||||
expect(options.newQueryTab.mac).toEqual({ combo: 'Meta+N', enabled: false });
|
||||
expect(options.newQueryTab.windows).toEqual({ combo: 'Ctrl+N', enabled: true });
|
||||
expect(options.saveQuery.windows).toEqual({ combo: 'Ctrl+S', enabled: true });
|
||||
expect(options.sendAIChatMessage.windows).toEqual({ combo: 'Enter', enabled: true });
|
||||
});
|
||||
@@ -237,13 +250,13 @@ describe('shortcut defaults', () => {
|
||||
it('resolves and displays platform-specific bindings', () => {
|
||||
const options = sanitizeShortcutOptions({
|
||||
newQueryTab: {
|
||||
mac: { combo: 'Meta+Y', enabled: true },
|
||||
windows: { combo: 'Ctrl+Q', enabled: true },
|
||||
mac: { combo: 'Meta+N', enabled: true },
|
||||
windows: { combo: 'Ctrl+N', enabled: true },
|
||||
},
|
||||
});
|
||||
|
||||
expect(resolveShortcutBinding(options, 'newQueryTab', 'mac')).toEqual({
|
||||
combo: 'Meta+Y',
|
||||
combo: 'Meta+N',
|
||||
enabled: true,
|
||||
});
|
||||
expect(getShortcutDisplayLabel('Meta+N', 'mac')).toBe('⌘N');
|
||||
@@ -257,7 +270,7 @@ describe('shortcut defaults', () => {
|
||||
expect(getPrimaryShortcutDisplayLabel('C', 'windows')).toBe('Ctrl+C');
|
||||
expect(getPrimaryShortcutDisplayLabel('Enter', 'mac')).toBe('⌘↵');
|
||||
expect(getPrimaryShortcutDisplayLabel('Enter', 'windows')).toBe('Ctrl+Enter');
|
||||
expect(resolveShortcutDisplay(options, 'newQueryTab', 'windows')).toBe('Ctrl+Q');
|
||||
expect(resolveShortcutDisplay(options, 'newQueryTab', 'windows')).toBe('Ctrl+N');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -191,13 +191,13 @@ export const DEFAULT_SHORTCUT_OPTIONS: ShortcutOptions = {
|
||||
windows: { combo: 'Ctrl+K', enabled: true },
|
||||
},
|
||||
newQueryTab: {
|
||||
mac: { combo: 'Meta+Y', enabled: true },
|
||||
windows: { combo: 'Ctrl+Q', enabled: true },
|
||||
},
|
||||
newConnection: {
|
||||
mac: { combo: 'Meta+N', enabled: true },
|
||||
windows: { combo: 'Ctrl+N', enabled: true },
|
||||
},
|
||||
newConnection: {
|
||||
mac: { combo: 'Meta+Shift+N', enabled: true },
|
||||
windows: { combo: 'Ctrl+Shift+N', enabled: true },
|
||||
},
|
||||
toggleAIPanel: {
|
||||
mac: { combo: 'Meta+J', enabled: true },
|
||||
windows: { combo: 'Ctrl+J', enabled: true },
|
||||
|
||||
Reference in New Issue
Block a user