mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2025-11-23 13:38:14 +00:00
Compare commits
2 Commits
387da5dbdd
...
e45a9af9ff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e45a9af9ff | ||
|
|
e7fbab12ed |
13
src/lib/config/clientRegistry.ts
Normal file
13
src/lib/config/clientRegistry.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
const getClientConfig = (key: string, defaultVal?: any) => {
|
||||||
|
return localStorage.getItem(key) ?? defaultVal ?? undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getTheme = () => getClientConfig('theme', 'dark')
|
||||||
|
|
||||||
|
export const getAutoImageSearch = () => Boolean(getClientConfig('autoImageSearch', 'true'))
|
||||||
|
|
||||||
|
export const getAutoVideoSearch = () => Boolean(getClientConfig('autoVideoSearch', 'true'))
|
||||||
|
|
||||||
|
export const getSystemInstructions = () => getClientConfig('systemInstructions', '')
|
||||||
@@ -68,11 +68,11 @@ class ConfigManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentConfig = this.migrateConfigNeeded(this.currentConfig);
|
this.currentConfig = this.migrateConfig(this.currentConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private migrateConfigNeeded(config: Config): Config {
|
private migrateConfig(config: Config): Config {
|
||||||
/* TODO: Add migrations */
|
/* TODO: Add migrations */
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@@ -132,6 +132,22 @@ class ConfigManager {
|
|||||||
|
|
||||||
this.saveConfig();
|
this.saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getConfig(key: string, defaultValue?: any): any {
|
||||||
|
const nested = key.split('.');
|
||||||
|
let obj: any = this.currentConfig;
|
||||||
|
|
||||||
|
for (let i = 0; i < nested.length; i++) {
|
||||||
|
const part = nested[i];
|
||||||
|
if (obj == null) return defaultValue;
|
||||||
|
|
||||||
|
obj = obj[part];
|
||||||
|
}
|
||||||
|
|
||||||
|
return obj === undefined ? defaultValue : obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new ConfigManager();
|
const configManager = new ConfigManager();
|
||||||
|
|
||||||
|
export default configManager
|
||||||
1
src/lib/config/serverRegistry.ts
Normal file
1
src/lib/config/serverRegistry.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/* TODO: add server opts */
|
||||||
Reference in New Issue
Block a user