feat:最新
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"name" : "虫子智家",
|
"name" : "虫子智家",
|
||||||
"appid" : "__UNI__925D0CC",
|
"appid" : "__UNI__925D0CC",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.2.2",
|
"versionName" : "1.2.3",
|
||||||
"versionCode" : "100",
|
"versionCode" : "100",
|
||||||
"transformPx" : false,
|
"transformPx" : false,
|
||||||
/* 5+App特有相关 */
|
/* 5+App特有相关 */
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ withDefaults(
|
|||||||
visible?: boolean
|
visible?: boolean
|
||||||
title?: string
|
title?: string
|
||||||
desc?: string
|
desc?: string
|
||||||
/** 顶部留白(状态栏+导航),保证返回可点 */
|
/** 顶部留白(状态栏+导航),保证返回/设置可点 */
|
||||||
topOffsetPx?: number
|
topOffsetPx?: number
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,8 @@
|
|||||||
|
|
||||||
.device-detail-hero__bar {
|
.device-detail-hero__bar {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 1;
|
/* 高于连接遮罩,保证加载中返回/设置可点 */
|
||||||
|
z-index: 10001;
|
||||||
height: 88rpx;
|
height: 88rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -158,12 +158,12 @@
|
|||||||
/>
|
/>
|
||||||
<run-mode-explain-dialog v-model:visible="runModeExplainVisible" />
|
<run-mode-explain-dialog v-model:visible="runModeExplainVisible" />
|
||||||
|
|
||||||
<!-- 页面居中加载,挡住下方操作区;顶栏返回仍可点 -->
|
<!-- 页面居中加载,挡住下方操作区;顶栏返回/设置仍可点 -->
|
||||||
<ble-reconnect-loading
|
<ble-reconnect-loading
|
||||||
:visible="showReconnectLoading"
|
:visible="showReconnectLoading"
|
||||||
:title="reconnectLoadingTitle"
|
:title="reconnectLoadingTitle"
|
||||||
:desc="reconnectLoadingDesc"
|
:desc="reconnectLoadingDesc"
|
||||||
:top-offset-px="statusBarHeight + 44"
|
:top-offset-px="statusBarHeight + navBarHeightPx"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -178,6 +178,8 @@ import RunModeExplainDialog from './components/run-mode-explain-dialog/index.vue
|
|||||||
import { useDeviceDetail } from './use-device-detail'
|
import { useDeviceDetail } from './use-device-detail'
|
||||||
|
|
||||||
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight ?? 0)
|
const statusBarHeight = ref(uni.getSystemInfoSync().statusBarHeight ?? 0)
|
||||||
|
/** 与 .device-detail-hero__bar 高度 88rpx 对齐,避免遮罩盖住设置按钮 */
|
||||||
|
const navBarHeightPx = uni.upx2px(88)
|
||||||
const { scrollStyle: detailScrollStyle } = usePageScrollHeight({
|
const { scrollStyle: detailScrollStyle } = usePageScrollHeight({
|
||||||
topSelector: '.device-detail-hero',
|
topSelector: '.device-detail-hero',
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -288,7 +288,6 @@ export function useDeviceDetail() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSettings() {
|
function onSettings() {
|
||||||
if (showReconnectLoading.value) return
|
|
||||||
if (!deviceId.value) {
|
if (!deviceId.value) {
|
||||||
uni.showToast({ title: '设备信息不完整', icon: 'none' })
|
uni.showToast({ title: '设备信息不完整', icon: 'none' })
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -3,6 +3,10 @@ import { computed, ref } from 'vue'
|
|||||||
import { cancelAccount, logout } from '@/api/auth'
|
import { cancelAccount, logout } from '@/api/auth'
|
||||||
import { fetchProfile } from '@/api/profile'
|
import { fetchProfile } from '@/api/profile'
|
||||||
import { getErrorMessage } from '@/utils/api-error'
|
import { getErrorMessage } from '@/utils/api-error'
|
||||||
|
import {
|
||||||
|
beginVoluntaryLogout,
|
||||||
|
endVoluntaryLogout,
|
||||||
|
} from '@/utils/auth-session'
|
||||||
import { teardownMessageInbox } from '@/hooks/use-message-inbox'
|
import { teardownMessageInbox } from '@/hooks/use-message-inbox'
|
||||||
import { clearLocalUserData } from '@/utils/clear-local-user-data'
|
import { clearLocalUserData } from '@/utils/clear-local-user-data'
|
||||||
import { clearAppFileCacheOnDevice } from '@/pages/mine/storage/storage.utils'
|
import { clearAppFileCacheOnDevice } from '@/pages/mine/storage/storage.utils'
|
||||||
@@ -86,9 +90,10 @@ export function usePrivacy() {
|
|||||||
async function onConfirmCancelAccount() {
|
async function onConfirmCancelAccount() {
|
||||||
if (cancelingAccount.value) return
|
if (cancelingAccount.value) return
|
||||||
cancelingAccount.value = true
|
cancelingAccount.value = true
|
||||||
|
beginVoluntaryLogout()
|
||||||
try {
|
try {
|
||||||
await cancelAccount()
|
|
||||||
teardownMessageInbox()
|
teardownMessageInbox()
|
||||||
|
await cancelAccount()
|
||||||
clearLocalUserData()
|
clearLocalUserData()
|
||||||
try {
|
try {
|
||||||
await clearAppFileCacheOnDevice()
|
await clearAppFileCacheOnDevice()
|
||||||
@@ -98,10 +103,13 @@ export function usePrivacy() {
|
|||||||
uni.showToast({ title: '账号已注销', icon: 'success' })
|
uni.showToast({ title: '账号已注销', icon: 'success' })
|
||||||
uni.reLaunch({ url: '/pages/login/index' })
|
uni.reLaunch({ url: '/pages/login/index' })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
endVoluntaryLogout()
|
||||||
uni.showToast({ title: getErrorMessage(err, '注销失败'), icon: 'none' })
|
uni.showToast({ title: getErrorMessage(err, '注销失败'), icon: 'none' })
|
||||||
} finally {
|
} finally {
|
||||||
cancelingAccount.value = false
|
cancelingAccount.value = false
|
||||||
}
|
}
|
||||||
|
// 成功跳转后稍后再关,避免在途 401 仍弹「登录状态异常」
|
||||||
|
setTimeout(() => endVoluntaryLogout(), 1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLogout() {
|
function onLogout() {
|
||||||
@@ -111,17 +119,19 @@ export function usePrivacy() {
|
|||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (!res.confirm) return
|
if (!res.confirm) return
|
||||||
void (async () => {
|
void (async () => {
|
||||||
|
beginVoluntaryLogout()
|
||||||
try {
|
try {
|
||||||
await logout()
|
// 先停消息通道,避免 logout 后在途请求 401 误报
|
||||||
} catch (err) {
|
|
||||||
uni.showToast({
|
|
||||||
title: getErrorMessage(err, '退出登录失败'),
|
|
||||||
icon: 'none',
|
|
||||||
})
|
|
||||||
} finally {
|
|
||||||
teardownMessageInbox()
|
teardownMessageInbox()
|
||||||
|
try {
|
||||||
|
await logout()
|
||||||
|
} catch {
|
||||||
|
// 服务端退出失败仍清本地登录态
|
||||||
|
}
|
||||||
clearLocalUserData()
|
clearLocalUserData()
|
||||||
uni.reLaunch({ url: '/pages/login/index' })
|
uni.reLaunch({ url: '/pages/login/index' })
|
||||||
|
} finally {
|
||||||
|
setTimeout(() => endVoluntaryLogout(), 1500)
|
||||||
}
|
}
|
||||||
})()
|
})()
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -26,6 +26,20 @@ const PUBLIC_AUTH_API_PREFIXES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
let sessionRedirecting = false
|
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 {
|
export function isGuestAllowedRoute(route: string): boolean {
|
||||||
const normalized = route.replace(/^\//, '')
|
const normalized = route.replace(/^\//, '')
|
||||||
@@ -69,6 +83,8 @@ export function handleAuthSessionExpired(options?: {
|
|||||||
forceNavigateToLogin?: boolean
|
forceNavigateToLogin?: boolean
|
||||||
}): void {
|
}): void {
|
||||||
if (options?.requestPath && isPublicAuthApi(options.requestPath)) return
|
if (options?.requestPath && isPublicAuthApi(options.requestPath)) return
|
||||||
|
// 主动退出/注销由页面自己清态跳转,勿再弹「登录状态异常」
|
||||||
|
if (voluntaryLogoutActive) return
|
||||||
|
|
||||||
const forceLogin = Boolean(options?.forceNavigateToLogin)
|
const forceLogin = Boolean(options?.forceNavigateToLogin)
|
||||||
if (sessionRedirecting && !forceLogin) return
|
if (sessionRedirecting && !forceLogin) return
|
||||||
@@ -93,6 +109,7 @@ export function handleAuthSessionExpired(options?: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function notifyAuthSessionExpired(err: unknown, requestPath: string): void {
|
export function notifyAuthSessionExpired(err: unknown, requestPath: string): void {
|
||||||
|
if (voluntaryLogoutActive) return
|
||||||
if (!shouldForceLoginOnAuthError(requestPath, err)) return
|
if (!shouldForceLoginOnAuthError(requestPath, err)) return
|
||||||
handleAuthSessionExpired({
|
handleAuthSessionExpired({
|
||||||
message: resolveAuthSessionExpiredMessage(err),
|
message: resolveAuthSessionExpiredMessage(err),
|
||||||
|
|||||||
@@ -303,6 +303,8 @@ export function parseZ2NotifyLine(line: string): Partial<Z2DeviceState> {
|
|||||||
break
|
break
|
||||||
case 'I':
|
case 'I':
|
||||||
// 查询滤芯指令 I 的应答:I=xx
|
// 查询滤芯指令 I 的应答:I=xx
|
||||||
|
case 'L':
|
||||||
|
// 实机 I 应答:M=25;S=14;L=99(L 为滤芯寿命 0-100)
|
||||||
case 'FL':
|
case 'FL':
|
||||||
case 'FILTER':
|
case 'FILTER':
|
||||||
case 'LIFE': {
|
case 'LIFE': {
|
||||||
|
|||||||
Reference in New Issue
Block a user