fix(mpuniapp): 支持根路径登录鉴权分发与业务端到端操作闭环

这个提交包含在:
wikiboss
2026-09-21 11:35:36 +08:00
父节点 73e4283201
当前提交 603f3d3964
共有 6 个文件被更改,包括 66 次插入 和 2 次删除

查看文件

@@ -21,7 +21,7 @@
function routeOwnerHome() : void {
if (getAuthToken() != '') {
uni.switchTab({
url: '/pages/owner/hall/index'
url: '/pages/owner/card/index'
})
return
}
@@ -34,6 +34,18 @@
// #ifdef APP
routeOwnerHome()
// #endif
// #ifdef H5
if (typeof window !== 'undefined') {
const hash = window.location.hash
if (!hash || hash === '#' || hash === '#/' || hash === '') {
if (getAuthToken() != '') {
window.location.hash = '#/pages/owner/card/index'
} else {
window.location.hash = '#/pages/common/login'
}
}
}
// #endif
})
onAppShow((res : OnShowOptions) => {

查看文件

@@ -156,6 +156,11 @@ onLoad((options: CardHomePageOptions) => {
refreshCards(state);
applyQuotaHint();
});
onShow(() => {
refreshCards(state);
applyQuotaHint();
});
</script>
<style scoped>

查看文件

@@ -224,6 +224,10 @@ onLoad((options: LeadsPageOptions) => {
applyLeadsOptions(state, options);
refreshLeads(state);
});
onShow(() => {
refreshLeads(state);
});
</script>
<style scoped>

查看文件

@@ -134,6 +134,11 @@
</view>
</view>
<!-- Logout action card -->
<view class="section-card logout-card" @click="onLogout">
<text class="logout-text">{{ t('logout') }}</text>
</view>
<!-- Error feedback banner -->
<view v-if="state.errorMessage !== ''" class="error-banner">
<text class="error-banner-text">{{ state.errorMessage }}</text>
@@ -170,7 +175,7 @@ import {
} from './useProfile.uts';
import { OmniLocale } from '../../../common/locale.uts';
import { fetchCardQuota } from '../../../common/api.uts';
import { getTenantId } from '../../../common/request.uts';
import { getTenantId, clearAuthToken } from '../../../common/request.uts';
type LangOption = {
code: OmniLocale;
@@ -261,6 +266,23 @@ function onSaveSettings(): void {
}
}
function onLogout(): void {
clearAuthToken();
uni.showToast({
title: resolveProfileText('logout'),
icon: 'none',
});
// #ifdef H5
if (typeof window !== 'undefined') {
window.location.hash = '#/pages/common/login';
return;
}
// #endif
uni.reLaunch({
url: '/pages/common/login',
});
}
onShow(() => {
const loaded = loadProfileSettings();
state.account = loaded.account;
@@ -536,4 +558,19 @@ onShow(() => {
font-size: 15px;
font-weight: 600;
}
.logout-card {
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
border-color: #FEE4E2;
margin-top: 8px;
}
.logout-text {
font-size: 15px;
font-weight: 600;
color: #F04438;
}
</style>

查看文件

@@ -384,6 +384,8 @@ export function resolveProfileText(key: string): string {
return isZh ? '偏好设置' : 'Preferences';
case 'languageLabel':
return isZh ? '界面语言' : 'Display Language';
case 'logout':
return isZh ? '退出登录' : 'Log out';
case 'workspaceSection':
return isZh ? '工作台' : 'Workspace';
case 'nfcScan':

查看文件

@@ -101,6 +101,10 @@ onLoad((options: RadarPageOptions) => {
applyRadarOptions(state, options);
refreshTracks(state);
});
onShow(() => {
refreshTracks(state);
});
</script>
<style scoped>