35 lines
826 B
JavaScript
35 lines
826 B
JavaScript
function e(e) {
|
|
return (e ?? []).map((e) => ({
|
|
...e,
|
|
name_show: e.name_show?.trim() || e.billing_cycle,
|
|
}));
|
|
}
|
|
function t(e) {
|
|
if (!e || typeof e != `object` || !(`status` in e)) return !1;
|
|
let t = e.status;
|
|
return typeof t == `number`
|
|
? [0, 408, 429, 500, 502, 503, 504].includes(t)
|
|
? !0
|
|
: t === 400 &&
|
|
`message` in e &&
|
|
typeof e.message == `string` &&
|
|
/稍后重试|服务暂不可用|系统繁忙/u.test(e.message)
|
|
: !1;
|
|
}
|
|
function n(e) {
|
|
return t(e)
|
|
? `暂时无法获取续费价格,请重新获取或稍后重试`
|
|
: e instanceof Error
|
|
? e.message
|
|
: `获取续费信息失败`;
|
|
}
|
|
async function r(e, n) {
|
|
try {
|
|
return await e();
|
|
} catch (r) {
|
|
if (!n() || !t(r)) throw r;
|
|
return e();
|
|
}
|
|
}
|
|
export { n, e as r, r as t };
|