feat: 快捷键录入重绑(FR-K3,keymap:load/save IPC+config.json,SettingsPanel 录入 UI+冲突检测,use-hotkeys 读 store 实时生效,重开恢复)
This commit is contained in:
@@ -6,13 +6,13 @@ import { RECENT_VAULT_MAX } from '@hunter/shared';
|
||||
|
||||
export class ConfigStore {
|
||||
private file: string;
|
||||
private cache: { vault?: VaultMeta; appearance?: { themeId: string; params: Record<string, unknown>; effect: string } } | null = null;
|
||||
private cache: { vault?: VaultMeta; appearance?: { themeId: string; params: Record<string, unknown>; effect: string }; keymaps?: { id: string; combo: string }[] } | null = null;
|
||||
|
||||
constructor(userDataDir: string) {
|
||||
this.file = nodePath.join(userDataDir, 'config.json');
|
||||
}
|
||||
|
||||
private async read(): Promise<{ vault?: VaultMeta; appearance?: { themeId: string; params: Record<string, unknown>; effect: string } }> {
|
||||
private async read(): Promise<{ vault?: VaultMeta; appearance?: { themeId: string; params: Record<string, unknown>; effect: string }; keymaps?: { id: string; combo: string }[] }> {
|
||||
if (this.cache) return this.cache;
|
||||
try {
|
||||
const raw = await fs.readFile(this.file, 'utf8');
|
||||
@@ -55,6 +55,15 @@ export class ConfigStore {
|
||||
await this.write();
|
||||
}
|
||||
|
||||
async getKeymaps(): Promise<{ id: string; combo: string }[] | null> {
|
||||
const c = await this.read();
|
||||
return c.keymaps ?? null;
|
||||
}
|
||||
async saveKeymaps(data: { id: string; combo: string }[]): Promise<void> {
|
||||
(await this.read()).keymaps = data;
|
||||
await this.write();
|
||||
}
|
||||
|
||||
async setDefaultRoot(root: string): Promise<VaultMeta> {
|
||||
const meta = await this.getVaultMeta();
|
||||
meta.defaultRoot = root;
|
||||
|
||||
@@ -52,4 +52,6 @@ export class VaultService {
|
||||
async setDefaultRoot(root: string): Promise<void> { await this.config.setDefaultRoot(root); }
|
||||
getAppearance() { return this.config.getAppearance(); }
|
||||
saveAppearance(data: { themeId: string; params: Record<string, unknown>; effect: string }) { return this.config.saveAppearance(data); }
|
||||
getKeymaps() { return this.config.getKeymaps(); }
|
||||
saveKeymaps(data: { id: string; combo: string }[]) { return this.config.saveKeymaps(data); }
|
||||
}
|
||||
Reference in New Issue
Block a user