小程序修改

This commit is contained in:
2026-07-12 19:44:36 +08:00
parent 3b4833b51a
commit e2dfb08de3
45 changed files with 2028 additions and 347 deletions
+9 -4
View File
@@ -24,11 +24,16 @@ function currentPagePath(): string {
}
/** 跳转登录页;默认带回当前页作为 return */
export function goLogin(returnPath?: string) {
export function goLogin(returnPath?: string, extras?: Record<string, string>) {
const returnTo = returnPath ?? currentPagePath();
const url = returnTo
? `/pages/login/index?return=${encodeURIComponent(returnTo)}`
: '/pages/login/index';
const parts: string[] = [];
if (returnTo) parts.push(`return=${encodeURIComponent(returnTo)}`);
if (extras) {
for (const [key, value] of Object.entries(extras)) {
if (value) parts.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
}
}
const url = parts.length ? `/pages/login/index?${parts.join('&')}` : '/pages/login/index';
Taro.navigateTo({ url }).catch(() => {
Taro.redirectTo({ url });
});