perf(admin): 实现切页即时导航与列表 loading 壳
非阻塞 session 刷新、侧边栏 chunk 预取、KeepAlive 对齐,以及按 tab 延迟加载重型列表页。
This commit is contained in:
@@ -88,8 +88,8 @@ async function loadRoles() {
|
||||
roles.value = (data.data ?? []) as RoleOption[];
|
||||
}
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
async function load(opts?: { silent?: boolean }) {
|
||||
if (!opts?.silent) loading.value = true;
|
||||
try {
|
||||
const { data } = await api.get('/admin/staff', {
|
||||
params: {
|
||||
@@ -104,7 +104,7 @@ async function load() {
|
||||
rows.value = [];
|
||||
total.value = 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
if (!opts?.silent) loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,8 +251,9 @@ onMounted(async () => {
|
||||
await loadRoles();
|
||||
await load();
|
||||
});
|
||||
// KeepAlive 激活时静默刷新
|
||||
onActivated(() => { if (rows.value.length > 0) void load(); });
|
||||
onActivated(() => {
|
||||
if (rows.value.length > 0) void load({ silent: true });
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user