从旧 WebVue 移植的地基部分: - 登录页(RSA+MD5 密码加密、redirect 回跳、中英文切换)与登录后落地页 - 401 / 403 / 404 错误页 + error-panel 通用外壳(文案走 ErrorPage 语言包) - 登录守卫双链路:uni.addInterceptor 拦站内跳转,页面级 onShow 复核冷启动深链 - 单一请求链路 common/http.interceptor:JWT 唯一来源、401 并发刷新单例、 业务异常识别、HTTP 403 跳无权限页 - H5 干净短地址:initRouter 前向 __uniRoutes 追加克隆记录(router/h5-clean-url) - 路由登记表 router/routes.ts(PAGE_PATHS / pageUrl / PAGE_PERMISSIONS) 与新增页面四步登记约定(src/md/page-routing.md) - i18n:uView Pro 语言包 + 后端词条合并,双取值(后端 zh-cn/en,包名 zh-CN/en-US) - 后端接口层 service/ 与数据模型 data/auto/ 为生成器产物,不手改 不入库的内容: - 摘除脚手架残留的 Harmony 签名密码(manifest.json signingConfigs 与 harmony-configs/build-profile.json5 的 keyPassword / storePassword 已置空) - 忽略 node_modules、dist、unpackage、.hbuilderx、.agents、pnpm-lock.yaml 及根目录临时截图
34 lines
1.5 KiB
TypeScript
34 lines
1.5 KiB
TypeScript
/**
|
|
* 语言 / Culture 取值:区分「后端 Culture 线值」与「uView Pro 语言包 name」两套
|
|
*
|
|
* - 后端(旧 CulturePolicy)严格字面:中文 "zh-cn"、英文 "en"。
|
|
* 发给后端的 locale 头 / 登录体 Culture 用这套,防止后端精确匹配失败。
|
|
* - uView Pro 内置语言包 name 固定为 "zh-CN" / "en-US"(大小写敏感)。
|
|
* 前端自定义语言包的 name 必须与之完全相同,config-provider 才能把自定义文案
|
|
* 与内置组件文案(picker / calendar / upload …)按 name 合并;
|
|
* 若写成 "zh-cn" 会被当成另一种语言,导致内置组件文案丢失 + 语言选择器出现重复项。
|
|
*/
|
|
|
|
/** 发给后端的 Culture 线值 */
|
|
export const BACKEND_LOCALE_ZH = "zh-cn";
|
|
export const BACKEND_LOCALE_EN = "en";
|
|
|
|
/** uView Pro 语言包 name(必须匹配内置大小写,勿改成 zh-cn / en) */
|
|
export const UI_LOCALE_ZH = "zh-CN";
|
|
export const UI_LOCALE_EN = "en-US";
|
|
|
|
/** 前端默认选中的语言包 name */
|
|
export const DEFAULT_LOCALE = UI_LOCALE_ZH;
|
|
|
|
/** 归一化任意 locale 变体(zh-Hans / zh-CN / en-US …)到后端 Culture 线值 */
|
|
export function toBackendLocale(value: string): string {
|
|
const l = String(value || "").toLowerCase();
|
|
return l.startsWith("en") ? BACKEND_LOCALE_EN : BACKEND_LOCALE_ZH;
|
|
}
|
|
|
|
/** 归一化任意 locale 变体(含 DB 的 Lang)到 uView 语言包 name */
|
|
export function toUiLocale(value: string): string {
|
|
const l = String(value || "").toLowerCase();
|
|
return l.startsWith("en") ? UI_LOCALE_EN : UI_LOCALE_ZH;
|
|
}
|