f
This commit is contained in:
5
src/components.d.ts
vendored
5
src/components.d.ts
vendored
@@ -20,10 +20,5 @@ declare module 'vue' {
|
||||
RealNameAuthDialog: typeof import('./components/RealNameAuthDialog.vue')['default']
|
||||
SectionTitle: typeof import('./components/SectionTitle.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']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import type { Ref } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import { hasAcceptedPrivacyPolicy } from '@/composables/usePrivacyConsent'
|
||||
import { hasAcceptedPrivacyPolicy, shouldSilencePrivacyBlockedRequest } from '@/composables/usePrivacyConsent'
|
||||
import { envConfig } from '@/constants/env'
|
||||
import { useAgentStore } from '@/stores/agentStore'
|
||||
import { useUserStore } from '@/stores/userStore'
|
||||
@@ -190,7 +190,8 @@ async function executeJson<T>(
|
||||
hideLoading()
|
||||
const err = e instanceof Error ? e : new Error(String(e))
|
||||
errorRef.value = err
|
||||
uni.showToast({ title: '网络异常,请稍后再试', icon: 'none' })
|
||||
if (!shouldSilencePrivacyBlockedRequest())
|
||||
uni.showToast({ title: '网络异常,请稍后再试', icon: 'none' })
|
||||
return { data: dataRef, error: errorRef }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,11 @@ export function hasAcceptedPrivacyPolicy() {
|
||||
return getPrivacyDecision() === 'accepted'
|
||||
}
|
||||
|
||||
/** 未同意隐私时的请求失败:业务上预期行为,不向用户弹 toast */
|
||||
export function shouldSilencePrivacyBlockedRequest() {
|
||||
return !hasAcceptedPrivacyPolicy()
|
||||
}
|
||||
|
||||
export function setPrivacyDecision(decision: PrivacyDecision) {
|
||||
uni.setStorageSync(PRIVACY_DECISION_KEY, decision)
|
||||
}
|
||||
@@ -113,7 +118,6 @@ export function installPrivacyRequestGuard() {
|
||||
invoke(args) {
|
||||
if (hasAcceptedPrivacyPolicy())
|
||||
return args
|
||||
uni.showToast({ title: '请先阅读并处理隐私政策', icon: 'none' })
|
||||
return false
|
||||
},
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 轻量请求(非链式)。与 `useApiFetch` 共用 env,行为尽量一致。
|
||||
*/
|
||||
import { hasAcceptedPrivacyPolicy } from '@/composables/usePrivacyConsent'
|
||||
import { hasAcceptedPrivacyPolicy, shouldSilencePrivacyBlockedRequest } from '@/composables/usePrivacyConsent'
|
||||
import { envConfig } from '@/constants/env'
|
||||
import { clearAuthStorage, getToken } from '@/utils/storage'
|
||||
import { navigateLogin } from './navigate'
|
||||
@@ -63,7 +63,8 @@ export function request<T>(options: RequestOptions) {
|
||||
resolve(data)
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showToast({ title: '网络异常,请稍后再试', icon: 'none' })
|
||||
if (!shouldSilencePrivacyBlockedRequest())
|
||||
uni.showToast({ title: '网络异常,请稍后再试', icon: 'none' })
|
||||
reject(err)
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user