diff --git a/web/src/store/modules/auth.ts b/web/src/store/modules/auth.ts index 7059f686b6930b037f5fd273e16f69b5687c5ad5..c516e5c5e99332fcfbb1d042d813757b907fb2b3 100644 --- a/web/src/store/modules/auth.ts +++ b/web/src/store/modules/auth.ts @@ -107,6 +107,20 @@ export const useAuthStore = defineStore('auth', () => { * @param _data */ async function setPreferences(_data: any) { + if (!_data || typeof _data !== 'object') { + return; + } + + // 检查是否有有效的偏好设置数据 + const hasValidData = Object.keys(_data).some(key => { + const value = _data[key]; + return value !== undefined && value !== null && + (typeof value === 'object' ? Object.keys(value).length > 0 : true); + }); + + if (!hasValidData) { + return; // 没有有效数据,直接返回,不输出警告 + } const allowedKeys = ['theme', 'app']; const updateData: Record = {}; for (const key of allowedKeys) {