fix: 修复获取用户语言时的潜在错误,确保安全访问用户属性
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 11s

This commit is contained in:
2025-09-23 00:38:51 +08:00
parent e1277ac9a7
commit 0f7cbb385a

View File

@ -28,8 +28,8 @@ export async function getUserLocales(): Promise<string[]> {
const token = cookieStore.get('token')?.value || '';
const refreshToken = cookieStore.get('refresh_token')?.value || '';
const user = (await getLoginUser({token, refreshToken})).data;
locales.push(user.language);
locales.push(user.language.split('-')[0]);
locales.push(user?.language || '');
locales.push((user?.language || '').split('-')[0]);
} catch {
}
const languageInCookie = cookieStore.get('language')?.value;