feat(player): 注册账号、登录双模式与移动端性能优化
注册必填 7-32 位账号,手机号区号/本地号分存;登录默认账号模式并支持切换手机号登录;Player i18n 拆包与赛事接口优化。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { SUPPORTED_LOCALES, LOCALE_UI_LABELS } from '@thebet365/shared';
|
||||
import { SUPPORTED_LOCALES, LOCALE_UI_LABELS, type Locale } from '@thebet365/shared';
|
||||
import api from '../api';
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
import { ensurePlayerLocale } from '../i18n';
|
||||
|
||||
const STORAGE_KEY = 'locale';
|
||||
const COOKIE_MAX_AGE = 365 * 24 * 60 * 60;
|
||||
@@ -17,7 +18,8 @@ function persistLocale(code: string) {
|
||||
}
|
||||
|
||||
export function useAppLocale() {
|
||||
const { locale } = useI18n();
|
||||
const i18n = useI18n({ useScope: 'global' });
|
||||
const { locale } = i18n;
|
||||
const auth = useAuthStore();
|
||||
|
||||
function applyLocale(code: string) {
|
||||
@@ -41,6 +43,7 @@ export function useAppLocale() {
|
||||
/* 离线或 token 过期时仍保留本地语言 */
|
||||
}
|
||||
}
|
||||
await ensurePlayerLocale(i18n, code as Locale);
|
||||
applyLocale(code);
|
||||
}
|
||||
|
||||
@@ -58,8 +61,9 @@ export function useAppLocale() {
|
||||
}
|
||||
}
|
||||
|
||||
function initFromUser(userLocale?: string | null) {
|
||||
async function initFromUser(userLocale?: string | null) {
|
||||
if (userLocale && (SUPPORTED_LOCALES as readonly string[]).includes(userLocale)) {
|
||||
await ensurePlayerLocale(i18n, userLocale as Locale);
|
||||
applyLocale(userLocale);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user