This commit is contained in:
2026-06-03 17:00:37 +08:00
parent 453008a83e
commit 4f041ffa37
4 changed files with 11 additions and 10 deletions

5
src/components.d.ts vendored
View File

@@ -20,10 +20,5 @@ declare module 'vue' {
RealNameAuthDialog: typeof import('./components/RealNameAuthDialog.vue')['default'] RealNameAuthDialog: typeof import('./components/RealNameAuthDialog.vue')['default']
SectionTitle: typeof import('./components/SectionTitle.vue')['default'] SectionTitle: typeof import('./components/SectionTitle.vue')['default']
VipBanner: typeof import('./components/VipBanner.vue')['default'] VipBanner: typeof import('./components/VipBanner.vue')['default']
WdButton: typeof import('wot-design-uni/components/wd-button/wd-button.vue')['default']
WdNavbar: typeof import('wot-design-uni/components/wd-navbar/wd-navbar.vue')['default']
WdPopup: typeof import('wot-design-uni/components/wd-popup/wd-popup.vue')['default']
WdTabbar: typeof import('wot-design-uni/components/wd-tabbar/wd-tabbar.vue')['default']
WdTabbarItem: typeof import('wot-design-uni/components/wd-tabbar-item/wd-tabbar-item.vue')['default']
} }
} }

View File

@@ -4,7 +4,7 @@
*/ */
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { ref } from 'vue' import { ref } from 'vue'
import { hasAcceptedPrivacyPolicy } from '@/composables/usePrivacyConsent' import { hasAcceptedPrivacyPolicy, shouldSilencePrivacyBlockedRequest } from '@/composables/usePrivacyConsent'
import { envConfig } from '@/constants/env' import { envConfig } from '@/constants/env'
import { useAgentStore } from '@/stores/agentStore' import { useAgentStore } from '@/stores/agentStore'
import { useUserStore } from '@/stores/userStore' import { useUserStore } from '@/stores/userStore'
@@ -190,6 +190,7 @@ async function executeJson<T>(
hideLoading() hideLoading()
const err = e instanceof Error ? e : new Error(String(e)) const err = e instanceof Error ? e : new Error(String(e))
errorRef.value = err errorRef.value = err
if (!shouldSilencePrivacyBlockedRequest())
uni.showToast({ title: '网络异常,请稍后再试', icon: 'none' }) uni.showToast({ title: '网络异常,请稍后再试', icon: 'none' })
return { data: dataRef, error: errorRef } return { data: dataRef, error: errorRef }
} }

View File

@@ -22,6 +22,11 @@ export function hasAcceptedPrivacyPolicy() {
return getPrivacyDecision() === 'accepted' return getPrivacyDecision() === 'accepted'
} }
/** 未同意隐私时的请求失败:业务上预期行为,不向用户弹 toast */
export function shouldSilencePrivacyBlockedRequest() {
return !hasAcceptedPrivacyPolicy()
}
export function setPrivacyDecision(decision: PrivacyDecision) { export function setPrivacyDecision(decision: PrivacyDecision) {
uni.setStorageSync(PRIVACY_DECISION_KEY, decision) uni.setStorageSync(PRIVACY_DECISION_KEY, decision)
} }
@@ -113,7 +118,6 @@ export function installPrivacyRequestGuard() {
invoke(args) { invoke(args) {
if (hasAcceptedPrivacyPolicy()) if (hasAcceptedPrivacyPolicy())
return args return args
uni.showToast({ title: '请先阅读并处理隐私政策', icon: 'none' })
return false return false
}, },
}) })

View File

@@ -1,7 +1,7 @@
/** /**
* 轻量请求(非链式)。与 `useApiFetch` 共用 env行为尽量一致。 * 轻量请求(非链式)。与 `useApiFetch` 共用 env行为尽量一致。
*/ */
import { hasAcceptedPrivacyPolicy } from '@/composables/usePrivacyConsent' import { hasAcceptedPrivacyPolicy, shouldSilencePrivacyBlockedRequest } from '@/composables/usePrivacyConsent'
import { envConfig } from '@/constants/env' import { envConfig } from '@/constants/env'
import { clearAuthStorage, getToken } from '@/utils/storage' import { clearAuthStorage, getToken } from '@/utils/storage'
import { navigateLogin } from './navigate' import { navigateLogin } from './navigate'
@@ -63,6 +63,7 @@ export function request<T>(options: RequestOptions) {
resolve(data) resolve(data)
}, },
fail: (err) => { fail: (err) => {
if (!shouldSilencePrivacyBlockedRequest())
uni.showToast({ title: '网络异常,请稍后再试', icon: 'none' }) uni.showToast({ title: '网络异常,请稍后再试', icon: 'none' })
reject(err) reject(err)
}, },