From 2ec91cca26f7c23dada64c183780aeb126340427 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=8A=E5=B8=86?= <15818603+Osborn-lyf@user.noreply.gitee.com> Date: Mon, 2 Nov 2026 08:14:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=9C=80=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/manifest.json | 2 +- .../ble-reconnect-loading/index.vue | 2 +- src/pages/device/detail/device-detail.scss | 3 ++- src/pages/device/detail/index.vue | 6 +++-- src/pages/device/detail/use-device-detail.ts | 1 - src/pages/mine/privacy/use-privacy.ts | 26 +++++++++++++------ src/utils/auth-session.ts | 17 ++++++++++++ src/utils/z2-ble-protocol.ts | 2 ++ 8 files changed, 45 insertions(+), 14 deletions(-) diff --git a/src/manifest.json b/src/manifest.json index fa1dfca..f7027b4 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "name" : "虫子智家", "appid" : "__UNI__925D0CC", "description" : "", - "versionName" : "1.2.2", + "versionName" : "1.2.3", "versionCode" : "100", "transformPx" : false, /* 5+App特有相关 */ diff --git a/src/pages/device/detail/components/ble-reconnect-loading/index.vue b/src/pages/device/detail/components/ble-reconnect-loading/index.vue index 6422505..7b048c0 100644 --- a/src/pages/device/detail/components/ble-reconnect-loading/index.vue +++ b/src/pages/device/detail/components/ble-reconnect-loading/index.vue @@ -23,7 +23,7 @@ withDefaults( visible?: boolean title?: string desc?: string - /** 顶部留白(状态栏+导航),保证返回可点 */ + /** 顶部留白(状态栏+导航),保证返回/设置可点 */ topOffsetPx?: number }>(), { diff --git a/src/pages/device/detail/device-detail.scss b/src/pages/device/detail/device-detail.scss index 32edb6d..37098d4 100644 --- a/src/pages/device/detail/device-detail.scss +++ b/src/pages/device/detail/device-detail.scss @@ -34,7 +34,8 @@ .device-detail-hero__bar { position: relative; - z-index: 1; + /* 高于连接遮罩,保证加载中返回/设置可点 */ + z-index: 10001; height: 88rpx; display: flex; align-items: center; diff --git a/src/pages/device/detail/index.vue b/src/pages/device/detail/index.vue index 96b0b18..d9e4597 100644 --- a/src/pages/device/detail/index.vue +++ b/src/pages/device/detail/index.vue @@ -158,12 +158,12 @@ /> - + @@ -178,6 +178,8 @@ import RunModeExplainDialog from './components/run-mode-explain-dialog/index.vue import { useDeviceDetail } from './use-device-detail' const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight ?? 0) +/** 与 .device-detail-hero__bar 高度 88rpx 对齐,避免遮罩盖住设置按钮 */ +const navBarHeightPx = uni.upx2px(88) const { scrollStyle: detailScrollStyle } = usePageScrollHeight({ topSelector: '.device-detail-hero', }) diff --git a/src/pages/device/detail/use-device-detail.ts b/src/pages/device/detail/use-device-detail.ts index 34f2a3a..72039c5 100644 --- a/src/pages/device/detail/use-device-detail.ts +++ b/src/pages/device/detail/use-device-detail.ts @@ -288,7 +288,6 @@ export function useDeviceDetail() { } function onSettings() { - if (showReconnectLoading.value) return if (!deviceId.value) { uni.showToast({ title: '设备信息不完整', icon: 'none' }) return diff --git a/src/pages/mine/privacy/use-privacy.ts b/src/pages/mine/privacy/use-privacy.ts index 2ae9969..713700a 100644 --- a/src/pages/mine/privacy/use-privacy.ts +++ b/src/pages/mine/privacy/use-privacy.ts @@ -3,6 +3,10 @@ import { computed, ref } from 'vue' import { cancelAccount, logout } from '@/api/auth' import { fetchProfile } from '@/api/profile' import { getErrorMessage } from '@/utils/api-error' +import { + beginVoluntaryLogout, + endVoluntaryLogout, +} from '@/utils/auth-session' import { teardownMessageInbox } from '@/hooks/use-message-inbox' import { clearLocalUserData } from '@/utils/clear-local-user-data' import { clearAppFileCacheOnDevice } from '@/pages/mine/storage/storage.utils' @@ -86,9 +90,10 @@ export function usePrivacy() { async function onConfirmCancelAccount() { if (cancelingAccount.value) return cancelingAccount.value = true + beginVoluntaryLogout() try { - await cancelAccount() teardownMessageInbox() + await cancelAccount() clearLocalUserData() try { await clearAppFileCacheOnDevice() @@ -98,10 +103,13 @@ export function usePrivacy() { uni.showToast({ title: '账号已注销', icon: 'success' }) uni.reLaunch({ url: '/pages/login/index' }) } catch (err) { + endVoluntaryLogout() uni.showToast({ title: getErrorMessage(err, '注销失败'), icon: 'none' }) } finally { cancelingAccount.value = false } + // 成功跳转后稍后再关,避免在途 401 仍弹「登录状态异常」 + setTimeout(() => endVoluntaryLogout(), 1500) } function onLogout() { @@ -111,17 +119,19 @@ export function usePrivacy() { success: (res) => { if (!res.confirm) return void (async () => { + beginVoluntaryLogout() try { - await logout() - } catch (err) { - uni.showToast({ - title: getErrorMessage(err, '退出登录失败'), - icon: 'none', - }) - } finally { + // 先停消息通道,避免 logout 后在途请求 401 误报 teardownMessageInbox() + try { + await logout() + } catch { + // 服务端退出失败仍清本地登录态 + } clearLocalUserData() uni.reLaunch({ url: '/pages/login/index' }) + } finally { + setTimeout(() => endVoluntaryLogout(), 1500) } })() }, diff --git a/src/utils/auth-session.ts b/src/utils/auth-session.ts index 2037129..231f376 100644 --- a/src/utils/auth-session.ts +++ b/src/utils/auth-session.ts @@ -26,6 +26,20 @@ const PUBLIC_AUTH_API_PREFIXES = [ ] let sessionRedirecting = false +/** 用户主动退出 / 注销:抑制并发 401 触发的「登录状态异常」提示 */ +let voluntaryLogoutActive = false + +export function beginVoluntaryLogout(): void { + voluntaryLogoutActive = true +} + +export function endVoluntaryLogout(): void { + voluntaryLogoutActive = false +} + +export function isVoluntaryLogoutActive(): boolean { + return voluntaryLogoutActive +} export function isGuestAllowedRoute(route: string): boolean { const normalized = route.replace(/^\//, '') @@ -69,6 +83,8 @@ export function handleAuthSessionExpired(options?: { forceNavigateToLogin?: boolean }): void { if (options?.requestPath && isPublicAuthApi(options.requestPath)) return + // 主动退出/注销由页面自己清态跳转,勿再弹「登录状态异常」 + if (voluntaryLogoutActive) return const forceLogin = Boolean(options?.forceNavigateToLogin) if (sessionRedirecting && !forceLogin) return @@ -93,6 +109,7 @@ export function handleAuthSessionExpired(options?: { } export function notifyAuthSessionExpired(err: unknown, requestPath: string): void { + if (voluntaryLogoutActive) return if (!shouldForceLoginOnAuthError(requestPath, err)) return handleAuthSessionExpired({ message: resolveAuthSessionExpiredMessage(err), diff --git a/src/utils/z2-ble-protocol.ts b/src/utils/z2-ble-protocol.ts index 9e0f978..2b6741d 100644 --- a/src/utils/z2-ble-protocol.ts +++ b/src/utils/z2-ble-protocol.ts @@ -303,6 +303,8 @@ export function parseZ2NotifyLine(line: string): Partial { break case 'I': // 查询滤芯指令 I 的应答:I=xx + case 'L': + // 实机 I 应答:M=25;S=14;L=99(L 为滤芯寿命 0-100) case 'FL': case 'FILTER': case 'LIFE': {