Add config loader tools
This commit is contained in:
16
tools/config.ts
Normal file
16
tools/config.ts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
export function loadConfig(path: string): Config | null {
|
||||||
|
const item = localStorage.getItem(path);
|
||||||
|
if (!item) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return JSON.parse(item) as Config;
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Config {
|
||||||
|
searchBar: boolean,
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user