增加翻译器自动保存到文件夹功能
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-11-17 09:00:24 +08:00
parent 98c771cab4
commit 22a0cf46fb
3 changed files with 49 additions and 9 deletions

View File

@@ -67,8 +67,7 @@ export const getLocalStorageOperator = <T extends z.ZodTypeAny>(
return {
get: (): z.infer<T> => {
try {
if (!localStorage) return [];
const item = localStorage.getItem(key);
const item = globalThis.localStorage.getItem(key);
if (!item) return [];
@@ -90,8 +89,8 @@ export const getLocalStorageOperator = <T extends z.ZodTypeAny>(
}
},
set: (data: z.infer<T>) => {
if (!localStorage) return;
localStorage.setItem(key, JSON.stringify(data));
if (!globalThis.localStorage) return;
globalThis.localStorage.setItem(key, JSON.stringify(data));
return data;
},
};