完整流程加节流 + 高频重试
This commit is contained in:
@@ -37,8 +37,9 @@ http.interceptors.response.use(
|
||||
|
||||
if (error?.config?.url && String(error.config.url).startsWith('/api/v1/admin')) {
|
||||
const status = Number(error?.response?.status || 0)
|
||||
const errorCode = String(error?.response?.data?.errorCode || '').trim()
|
||||
|
||||
if (status === 401) {
|
||||
if (status === 401 && shouldClearAdminSession(errorCode)) {
|
||||
clearAdminSession()
|
||||
|
||||
if (window.location.hash.startsWith('#/admin') && !window.location.hash.startsWith('#/admin/login')) {
|
||||
@@ -81,6 +82,15 @@ function resolveFallbackHttpMessage(error: unknown) {
|
||||
return '接口请求失败'
|
||||
}
|
||||
|
||||
function shouldClearAdminSession(errorCode: string) {
|
||||
return [
|
||||
'admin_auth_required',
|
||||
'admin_auth_invalid',
|
||||
'admin_auth_expired',
|
||||
'admin_auth_user_invalid',
|
||||
].includes(errorCode)
|
||||
}
|
||||
|
||||
export function apiGet<T>(url: string, params?: Record<string, unknown>) {
|
||||
return http.get<ApiEnvelope<T>>(url, { params }) as unknown as Promise<ApiEnvelope<T>>
|
||||
}
|
||||
|
||||
@@ -311,6 +311,18 @@ export function fetchAdminCloudtentaclesBindUrl(payload: {
|
||||
return apiPost<Record<string, unknown>>('/api/v1/admin/platform-config/cloudtentacles/vn/bind-url', payload)
|
||||
}
|
||||
|
||||
export function runAdminCloudtentaclesFullFlow(payload: {
|
||||
baseUrl?: string
|
||||
token?: string
|
||||
deviceId?: string
|
||||
deviceType?: number
|
||||
skuId?: number
|
||||
skuCount?: number
|
||||
vnKey?: string
|
||||
}) {
|
||||
return apiPost<Record<string, unknown>>('/api/v1/admin/platform-config/cloudtentacles/debug/full-flow', payload)
|
||||
}
|
||||
|
||||
export function fetchAdminFulfillmentBindingConfigs() {
|
||||
return apiGet<{
|
||||
filePath: string
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
fetchAdminKhhaoSourceConfig,
|
||||
generateAdminCloudtentaclesVnLoginCode,
|
||||
queryAdminKhhaoOrders,
|
||||
runAdminCloudtentaclesFullFlow,
|
||||
saveAdminCloudtentaclesSourceConfig,
|
||||
saveAdminAgisoShopConfigs,
|
||||
saveAdminKhhaoSourceConfig,
|
||||
@@ -108,7 +109,7 @@ const cloudtentaclesForm = ref({
|
||||
token: '',
|
||||
vnKey: '1',
|
||||
vnId: 0,
|
||||
skuId: 0,
|
||||
skuId: 5,
|
||||
skuCount: 1,
|
||||
deviceId: '-',
|
||||
deviceType: 0,
|
||||
@@ -235,7 +236,7 @@ async function loadConfigs() {
|
||||
token: cloudtentaclesResponse.data.session?.token || '',
|
||||
vnKey: '1',
|
||||
vnId: 0,
|
||||
skuId: 0,
|
||||
skuId: 5,
|
||||
skuCount: 1,
|
||||
deviceId: cloudtentaclesResponse.data.source.deviceId || '-',
|
||||
deviceType: cloudtentaclesResponse.data.source.deviceType || 0,
|
||||
@@ -757,6 +758,16 @@ async function handleCloudtentaclesFetchBindUrl() {
|
||||
}))
|
||||
}
|
||||
|
||||
async function handleCloudtentaclesRunFullFlow() {
|
||||
if (!ensureCloudtentaclesToken()) return
|
||||
await runCloudtentaclesDebugAction('完整测试流程', () => runAdminCloudtentaclesFullFlow({
|
||||
...buildCloudtentaclesTokenPayload(),
|
||||
skuId: Number(cloudtentaclesForm.value.skuId || 0),
|
||||
skuCount: Number(cloudtentaclesForm.value.skuCount || 1),
|
||||
vnKey: cloudtentaclesForm.value.vnKey.trim(),
|
||||
}))
|
||||
}
|
||||
|
||||
onMounted(loadConfigs)
|
||||
</script>
|
||||
|
||||
@@ -1385,6 +1396,7 @@ onMounted(loadConfigs)
|
||||
<el-button :loading="cloudtentaclesDebugLoading" round @click="handleCloudtentaclesFetchVnCode">获取验证码</el-button>
|
||||
<el-button :loading="cloudtentaclesDebugLoading" round @click="handleCloudtentaclesVerifyVnCode">校验验证码</el-button>
|
||||
<el-button :loading="cloudtentaclesDebugLoading" round type="primary" @click="handleCloudtentaclesFetchBindUrl">兑换链接</el-button>
|
||||
<el-button :loading="cloudtentaclesDebugLoading" round type="success" @click="handleCloudtentaclesRunFullFlow">完整流程</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user