修复:区分通知加载失败与空列表
This commit is contained in:
1 parent
3d6d4deabb
commit
9b8124a4ea
3 files changed
+109
-5
No files matched your search
+11
-4
@@ -7,6 +7,7 @@ function i() {
|
||||
let i = useState(`mail-unread-count`, () => 0),
|
||||
a = useState(`mail-recent`, () => []),
|
||||
o = useState(`mail-types`, () => []),
|
||||
status = useState(`mail-status`, () => `idle`),
|
||||
s = useState(`mail-session`, () => null),
|
||||
c = useState(`mail-request-id`, () => 0),
|
||||
l = useAuth(),
|
||||
@@ -19,31 +20,37 @@ function i() {
|
||||
(c.value += 1),
|
||||
(i.value = 0),
|
||||
(a.value = []),
|
||||
(o.value = []));
|
||||
(o.value = []),
|
||||
(status.value = `idle`));
|
||||
},
|
||||
{
|
||||
immediate: !0,
|
||||
flush: `sync`,
|
||||
},
|
||||
);
|
||||
// 接口现有摘要位于 credit_limit 字段;失败保留本会话既有摘要,不中断页面主流程。
|
||||
// 失败可保留本会话摘要,但必须显式标为不可用;只有成功的空结果才是暂无通知。
|
||||
async function d() {
|
||||
if (!l.token) return;
|
||||
let e = l.token,
|
||||
t = ++c.value;
|
||||
status.value = `loading`;
|
||||
try {
|
||||
let n = await u.get(`/client_care/mail`);
|
||||
if (e !== l.token || t !== c.value) return;
|
||||
let r = n?.credit_limit;
|
||||
((i.value = Number(r?.count ?? 0)),
|
||||
(a.value = r?.list ?? []),
|
||||
(o.value = r?.type ?? []));
|
||||
} catch {}
|
||||
(o.value = r?.type ?? []),
|
||||
(status.value = `success`));
|
||||
} catch {
|
||||
if (e === l.token && t === c.value) status.value = `error`;
|
||||
}
|
||||
}
|
||||
return {
|
||||
count: i,
|
||||
recent: a,
|
||||
types: o,
|
||||
status,
|
||||
refresh: d,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user