fix(client/web): 语言跟随系统 + SSO 落地补 basePath + 移除账户页续费按钮
- 语言(#1):LocaleNotifier 首启无用户选择时读设备 locale(zh/ja/ko/ru/es 命中 对应语种,余回退英文),原来恒为固定默认 en、从不看系统语言。用户显式切换仍持久 化优先。 - 用户中心 SSO(#3):usercenter 运行在 basePath=/user,但 /sso 落地页用原生 window.location.replace('/') 跳转(Next 不补 basePath)→ 落到站点根=官网主页, 且换票已建立的会话看起来像未登录。改为 withBase() 统一补 /user 前缀,兑票成功 直达 /user/ 且保持登录态。(服务端 issue/exchange 流程实测均 200,非后端问题) - 账户页(#4):移除"续费/升级"按钮(免费卡片 + PRO 横幅两处)及其未用组件;购买入口 仍由"购买套餐"行保留,不影响下单路径。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FEVUXAbFT6bF1Qw27RHWoD
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
// app_providers.dart — 语言 / 主题 / 套餐视角等基础状态(Riverpod)
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -32,15 +34,29 @@ AppText appTextFor(AppLang lang) {
|
||||
}
|
||||
}
|
||||
|
||||
/// 当前语言(单显)。默认英文(国际化默认语种);用户选择持久化到
|
||||
/// shared_preferences(key `pg_lang`,存枚举 name),重启保留 —— 原来无持久化,
|
||||
/// 切了语言重启会丢。设置/账户页经 `.notifier).set(lang)` 切换。
|
||||
/// 当前语言。首启无用户选择时**跟随系统语言**(设备 locale → 支持的 AppLang,
|
||||
/// 命不中回退英文);用户在设置/账户页显式切换后持久化到 shared_preferences
|
||||
/// (key `pg_lang`,存枚举 name),此后一律以用户选择为准、不再看系统。
|
||||
class LocaleNotifier extends StateNotifier<AppLang> {
|
||||
LocaleNotifier() : super(AppLang.en) {
|
||||
LocaleNotifier() : super(_systemDefault()) {
|
||||
_load();
|
||||
}
|
||||
static const _key = 'pg_lang';
|
||||
|
||||
/// 设备语言 → 支持的 AppLang。取平台首选 locale 的语言码(zh/ja/ko/ru/es 命中
|
||||
/// 对应语种,其余一律英文)。构造期同步可用,无需 await。
|
||||
static AppLang _systemDefault() {
|
||||
try {
|
||||
final code = ui.PlatformDispatcher.instance.locale.languageCode.toLowerCase();
|
||||
for (final l in AppLang.values) {
|
||||
if (l.name == code) return l;
|
||||
}
|
||||
} catch (_) {
|
||||
/* 取系统 locale 失败 → 英文 */
|
||||
}
|
||||
return AppLang.en;
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
final saved = (await SharedPreferences.getInstance()).getString(_key);
|
||||
@@ -53,7 +69,7 @@ class LocaleNotifier extends StateNotifier<AppLang> {
|
||||
}
|
||||
}
|
||||
} catch (_) {
|
||||
/* 读失败保持默认 en */
|
||||
/* 读失败保持系统默认 */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user