perf(admin): 实现切页即时导航与列表 loading 壳

非阻塞 session 刷新、侧边栏 chunk 预取、KeepAlive 对齐,以及按 tab 延迟加载重型列表页。
This commit is contained in:
2026-06-18 16:45:01 +08:00
parent f2f6927a75
commit c5a5e66bbd
21 changed files with 321 additions and 117 deletions

View File

@@ -1,5 +1,8 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue';
defineOptions({ name: 'AgentBets' });
import { ref } from 'vue';
import { useStaleListLifecycle } from '../../composables/useStaleList';
import { useAdminLocale } from '../../composables/useAdminLocale';
import api from '../../api';
import { formatAmount } from '../../utils/format-amount';
@@ -22,8 +25,6 @@ const total = ref(0);
const page = ref(1);
const pageSize = ref(10);
onMounted(load);
async function load() {
const { data } = await api.get('/agent/bets', {
params: { page: page.value, pageSize: pageSize.value },
@@ -32,15 +33,17 @@ async function load() {
total.value = data.data.total ?? 0;
}
const { loading, runLoad } = useStaleListLifecycle(() => bets.value.length > 0, load);
function onPageChange(p: number) {
page.value = p;
load();
void runLoad(true);
}
function onSizeChange(size: number) {
pageSize.value = size;
page.value = 1;
load();
void runLoad(true);
}
</script>
@@ -51,7 +54,7 @@ function onSizeChange(size: number) {
<span class="page-desc">{{ t('page.agent_bets.desc') }}</span>
</div>
<el-card class="data-card" shadow="never">
<el-card v-loading="loading" class="data-card" shadow="never">
<div class="table-wrap">
<el-table :data="bets" stripe>
<el-table-column prop="id" :label="t('bet.col.serial')" width="56" align="center" />