first commit
This commit is contained in:
commit
db5762abd4
687 files changed
+171307
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { watch } from "vue";
|
||||
import { useState } from "#app";
|
||||
import { useApi } from "~/lib/auth.js";
|
||||
import { useAuth } from "~/lib/auth.js";
|
||||
function i() {
|
||||
let i = useState(`mail-unread-count`, () => 0),
|
||||
a = useState(`mail-recent`, () => []),
|
||||
o = useState(`mail-types`, () => []),
|
||||
s = useState(`mail-session`, () => null),
|
||||
c = useState(`mail-request-id`, () => 0),
|
||||
l = useAuth(),
|
||||
u = useApi();
|
||||
watch(
|
||||
() => l.token,
|
||||
(e) => {
|
||||
s.value !== e &&
|
||||
((s.value = e),
|
||||
(c.value += 1),
|
||||
(i.value = 0),
|
||||
(a.value = []),
|
||||
(o.value = []));
|
||||
},
|
||||
{
|
||||
immediate: !0,
|
||||
flush: `sync`,
|
||||
},
|
||||
);
|
||||
async function d() {
|
||||
if (!l.token) return;
|
||||
let e = l.token,
|
||||
t = ++c.value;
|
||||
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 {}
|
||||
}
|
||||
return {
|
||||
count: i,
|
||||
recent: a,
|
||||
types: o,
|
||||
refresh: d,
|
||||
};
|
||||
}
|
||||
export { i as t };
|
||||
Reference in new issue
Block a user