mirror of
https://github.com/certd/certd.git
synced 2026-05-17 22:07:34 +08:00
perf: 524错误时重试3次
This commit is contained in:
@@ -156,10 +156,11 @@ export function createAxiosService({ logger }: { logger: ILogger }) {
|
|||||||
|
|
||||||
config.retry = merge(
|
config.retry = merge(
|
||||||
{
|
{
|
||||||
status: [421],
|
status: [421, 524],
|
||||||
count: 0,
|
count: 0,
|
||||||
max: 3,
|
max: 3,
|
||||||
delay: 1000,
|
delay: 2000,
|
||||||
|
includes: ["[524]"],
|
||||||
},
|
},
|
||||||
config.retry
|
config.retry
|
||||||
);
|
);
|
||||||
@@ -278,7 +279,19 @@ export function createAxiosService({ logger }: { logger: ILogger }) {
|
|||||||
const originalRequest = error.config || {};
|
const originalRequest = error.config || {};
|
||||||
// logger.info(`config`, originalRequest);
|
// logger.info(`config`, originalRequest);
|
||||||
const retry = originalRequest.retry || {};
|
const retry = originalRequest.retry || {};
|
||||||
if (retry.status && retry.status.includes(status)) {
|
|
||||||
|
const isRetryStatus = retry.status && retry.status.includes(status);
|
||||||
|
let isRetryMessage = false;
|
||||||
|
if (retry.includes) {
|
||||||
|
for (const item of retry.includes) {
|
||||||
|
if (error.message?.includes(item)) {
|
||||||
|
isRetryMessage = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isRetryStatus || isRetryMessage) {
|
||||||
if (retry.max > 0 && retry.count < retry.max) {
|
if (retry.max > 0 && retry.count < retry.max) {
|
||||||
// 重试次数增加
|
// 重试次数增加
|
||||||
retry.count++;
|
retry.count++;
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ export type Notification = {
|
|||||||
options?: EmailOptions;
|
options?: EmailOptions;
|
||||||
notificationId: number;
|
notificationId: number;
|
||||||
title: string;
|
title: string;
|
||||||
|
id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type Pipeline = Runnable & {
|
export type Pipeline = Runnable & {
|
||||||
|
|||||||
@@ -20,5 +20,6 @@ export async function getTodayVipOrderCount() {
|
|||||||
return await request({
|
return await request({
|
||||||
url: "/sys/plus/getTodayVipOrderCount",
|
url: "/sys/plus/getTodayVipOrderCount",
|
||||||
method: "post",
|
method: "post",
|
||||||
|
showErrorNotify: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mt-10 vip-active-modal">
|
<div class="mt-10 vip-active-modal">
|
||||||
<div v-if="todayOrderCount.enabled" class="order-count hidden md:flex">
|
|
||||||
<div v-for="(stage, index) in todayOrderCount.stages" :key="index" class="status-item" :class="{ 'status-show': TodayVipOrderCountRef.current === index }">
|
|
||||||
<div class="background">
|
|
||||||
<img :src="stage.bg" alt="" />
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col order-count-text weight-bold">
|
|
||||||
<div class="count-text ml-4 flex items-center">
|
|
||||||
<fs-icon icon="noto:fire" class="fs-20 mr-2"></fs-icon>
|
|
||||||
<template v-if="stage.vipTotal > 0">
|
|
||||||
<span> 已有 </span>
|
|
||||||
<span class="count-number color-red font-bold text-2xl ml-1 mr-1"> {{ stage.vipTotal }} </span> 位小伙伴赞助,
|
|
||||||
<span>
|
|
||||||
{{ stage.title }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<span> 今日赞助 </span>
|
|
||||||
<span class="count-number color-red font-bold text-2xl ml-1 mr-1"> {{ stage.orderCount }} </span> 人,
|
|
||||||
<span>
|
|
||||||
{{ stage.title }}
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div v-if="productInfo.notice" class="mt-10">
|
<div v-if="productInfo.notice" class="mt-10">
|
||||||
<a-alert type="error" :message="productInfo.notice"></a-alert>
|
<a-alert type="error" :message="productInfo.notice"></a-alert>
|
||||||
</div>
|
</div>
|
||||||
@@ -248,73 +222,35 @@ const vipTypeDefine: any = {
|
|||||||
const TodayVipOrderCountRef: Ref = ref({ enabled: false, current: 0, stages: [] });
|
const TodayVipOrderCountRef: Ref = ref({ enabled: false, current: 0, stages: [] });
|
||||||
|
|
||||||
async function getTodayVipOrderCount() {
|
async function getTodayVipOrderCount() {
|
||||||
|
try {
|
||||||
const res = await api.getTodayVipOrderCount();
|
const res = await api.getTodayVipOrderCount();
|
||||||
if (res) {
|
if (res) {
|
||||||
TodayVipOrderCountRef.value = res;
|
TodayVipOrderCountRef.value = res;
|
||||||
TodayVipOrderCountRef.value.current = 0;
|
TodayVipOrderCountRef.value.current = 0;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const todayOrderCount = computed(() => {
|
const todayOrderCount = computed(() => {
|
||||||
const countInfo = TodayVipOrderCountRef.value;
|
const countInfo = TodayVipOrderCountRef.value;
|
||||||
const enabled = countInfo?.enabled || false;
|
|
||||||
const orderCount = countInfo?.orderCount || 0;
|
|
||||||
for (const stage of countInfo?.stages) {
|
|
||||||
stage.orderCount = stage.countGe || 0;
|
|
||||||
}
|
|
||||||
const lastStage = countInfo?.stages?.[countInfo?.stages?.length - 1] || {};
|
|
||||||
lastStage.orderCount = orderCount;
|
|
||||||
|
|
||||||
const vipTotal = countInfo?.vipTotal || 0;
|
const vipTotal = countInfo?.vipTotal || 0;
|
||||||
const showVipTotal = countInfo?.showVipTotal || false;
|
const showVipTotal = countInfo?.showVipTotal || false;
|
||||||
const userTotal = countInfo?.userTotal || 0;
|
const userTotal = countInfo?.userTotal || 0;
|
||||||
const stages: any = [];
|
|
||||||
stages.push({
|
|
||||||
title: countInfo.title,
|
|
||||||
vipTotal: countInfo?.vipTotal || 0,
|
|
||||||
orderCount: orderCount,
|
|
||||||
bg: lastStage.bg,
|
|
||||||
showVipTotal: showVipTotal,
|
|
||||||
});
|
|
||||||
if (lastStage.orderCount > 0) {
|
|
||||||
stages.push(lastStage);
|
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
enabled: enabled,
|
|
||||||
stages: stages,
|
|
||||||
showVipTotal: showVipTotal,
|
showVipTotal: showVipTotal,
|
||||||
vipTotal: vipTotal,
|
vipTotal: vipTotal,
|
||||||
userTotal: userTotal,
|
userTotal: userTotal,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
async function scrollOrderCount() {
|
|
||||||
const stages = todayOrderCount.value.stages;
|
|
||||||
if (stages.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let index = 0;
|
|
||||||
const doScroll = () => {
|
|
||||||
TodayVipOrderCountRef.value.current = index;
|
|
||||||
index++;
|
|
||||||
if (index >= stages.length) {
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
doScroll();
|
|
||||||
scrollOrderCountIntervalRef.value = setInterval(doScroll, 7000);
|
|
||||||
}
|
|
||||||
|
|
||||||
const scrollOrderCountIntervalRef: Ref = ref(null);
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getTodayVipOrderCount();
|
await getTodayVipOrderCount();
|
||||||
await nextTick();
|
|
||||||
await scrollOrderCount();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {});
|
||||||
clearInterval(scrollOrderCountIntervalRef.value);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
|
|||||||
@@ -93,6 +93,9 @@ export class OnePanelClient {
|
|||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
|
if (res?.message?.includes("record not found")){
|
||||||
|
throw new Error("没有找到证书,请确认证书在1panel上是否已被删除,如果被删除请重新选择新的证书id:"+ config.url);
|
||||||
|
}
|
||||||
throw new Error(res.message);
|
throw new Error(res.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,3 +40,4 @@ function randomStr(length, options?) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const RandomUtil = { randomStr };
|
export const RandomUtil = { randomStr };
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user