feat: M5 外观特效选择+持久化(appearance:load/save IPC+config.json,鼠效 6 选格接 EffectEngine,重开恢复并接线)
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 } | null = null;
|
||||
private cache: { vault?: VaultMeta; appearance?: { themeId: string; params: Record<string, unknown>; effect: string } } | null = null;
|
||||
|
||||
constructor(userDataDir: string) {
|
||||
this.file = nodePath.join(userDataDir, 'config.json');
|
||||
}
|
||||
|
||||
private async read(): Promise<{ vault?: VaultMeta }> {
|
||||
private async read(): Promise<{ vault?: VaultMeta; appearance?: { themeId: string; params: Record<string, unknown>; effect: string } }> {
|
||||
if (this.cache) return this.cache;
|
||||
try {
|
||||
const raw = await fs.readFile(this.file, 'utf8');
|
||||
@@ -46,6 +46,15 @@ export class ConfigStore {
|
||||
return meta;
|
||||
}
|
||||
|
||||
async getAppearance(): Promise<{ themeId: string; params: Record<string, unknown>; effect: string } | null> {
|
||||
const c = await this.read();
|
||||
return c.appearance ?? null;
|
||||
}
|
||||
async saveAppearance(data: { themeId: string; params: Record<string, unknown>; effect: string }): Promise<void> {
|
||||
(await this.read()).appearance = data;
|
||||
await this.write();
|
||||
}
|
||||
|
||||
async setDefaultRoot(root: string): Promise<VaultMeta> {
|
||||
const meta = await this.getVaultMeta();
|
||||
meta.defaultRoot = root;
|
||||
|
||||
Reference in New Issue
Block a user