Initial commit: restore project after Git corruption
This commit is contained in:
30
web/src/apps/muse/videos/modules/config.ts
Normal file
30
web/src/apps/muse/videos/modules/config.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
export const getConfig = () => {
|
||||
// 从localStorage获取配置,如果不存在则使用默认值
|
||||
const getFromLocalStorage = (key: string, defaultValue: string) => {
|
||||
try {
|
||||
return localStorage.getItem(key) || defaultValue;
|
||||
} catch (error) {
|
||||
console.warn(`Failed to read ${key} from localStorage:`, error);
|
||||
return defaultValue;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
VOLCENGINE_AUC_APPID: getFromLocalStorage('VOLCENGINE_AUC_APPID', ''),
|
||||
VOLCENGINE_AUC_TOKEN: getFromLocalStorage('VOLCENGINE_AUC_TOKEN', ''),
|
||||
};
|
||||
};
|
||||
|
||||
export const setConfig = (config: { VOLCENGINE_AUC_APPID?: string; VOLCENGINE_AUC_TOKEN?: string }) => {
|
||||
// 将配置保存到localStorage
|
||||
try {
|
||||
if (config.VOLCENGINE_AUC_APPID !== undefined) {
|
||||
localStorage.setItem('VOLCENGINE_AUC_APPID', config.VOLCENGINE_AUC_APPID);
|
||||
}
|
||||
if (config.VOLCENGINE_AUC_TOKEN !== undefined) {
|
||||
localStorage.setItem('VOLCENGINE_AUC_TOKEN', config.VOLCENGINE_AUC_TOKEN);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn('Failed to save config to localStorage:', error);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user