This commit is contained in:
owenchen committed 2026-10-13 17:02:14 +08:00
1 parent 32f237c4bf
commit 8a2adb0a92
18 files changed
+418 -53

No files matched your search

+15 -2
View File
@@ -4,10 +4,10 @@
// 加密已抽到 @/common/pwd-crypto(wxmp-rsa 纯 JS 实现,H5/小程序/App 全端可用)
import type { LoginData } from "@/data/auto/loginData";
import type { LoginProfile } from "@/data/auto/loginProfile";
import { onLoad } from "@dcloudio/uni-app";
import { onLoad, onShow } from "@dcloudio/uni-app";
import { useLocale } from "uview-pro";
import { computed, ref } from "vue";
import { backendLocale, baseUrl } from "@/common/http.interceptor";
import { backendLocale, baseUrl, hasLoginSession } from "@/common/http.interceptor";
import { encryptLoginPassword } from "@/common/pwd-crypto";
import { LoginData as LoginDataClass } from "@/data/auto/loginData";
import { reloadLocales } from "@/locale";
@@ -35,6 +35,19 @@ onLoad((options) => {
}
});
/**
* 冷启动直接落在登录入口且本地已有登录会话 → 自动进 dashboard,
* 省掉"明明登录过还闪一下登录页"。令牌若已过期,dashboard 首个请求会触发请求层用
* RefreshToken 自动续期;续期失败再 goLogin 退回本页,不会卡在受保护页里。
* 被"有意送回登录页"的场景(401 去登录 / 403 重新登录)不必再设豁免:
* goLoginWithRedirect 已先清登录态,此刻 hasLoginSession 必为假,表单正常展示。
*/
onShow(() => {
if (hasLoginSession()) {
uni.reLaunch({ url: redirectUrl.value });
}
});
// 登录页中英文切换:走 uView Pro 语言包(t / setLocale),语言包 name 为 zh-CN / en-US
const { t, setLocale, currentLocale } = useLocale();
const isZh = computed(() => (currentLocale.value?.name ?? "zh-CN") !== "en-US");