fix(daka): separate pull-refresh and list loading states

van-pull-refresh and van-list shared the same state.loading, causing
the loading spinner to never disappear when API calls completed.
Split into state.refreshing (pull-refresh) and state.loading (list).
Add try/finally to guarantee both states always reset.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-03 14:33:30 +08:00
parent c6788d210b
commit 994cf0c892
2 changed files with 14 additions and 7 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ export default defineComponent({
const badge_props: Partial<BadgeProps> = { showZero: false, max: 99 } const badge_props: Partial<BadgeProps> = { showZero: false, max: 99 }
onMounted(() => { onMounted(() => {
console.debug('[App.vue] deploy_ver=20260503.002'); console.debug('[App.vue] deploy_ver=20260503.003');
let vconsole = document.getElementById("__vconsole"); let vconsole = document.getElementById("__vconsole");
if (vconsole) { if (vconsole) {
vconsole.hidden = true; vconsole.hidden = true;
+13 -6
View File
@@ -11,7 +11,7 @@
<van-search shape="round" v-model.trim="state.keyword" /> <van-search shape="round" v-model.trim="state.keyword" />
</div> </div>
<div class="list"> <div class="list">
<van-pull-refresh v-model="state.loading" @refresh="onRefresh"> <van-pull-refresh v-model="state.refreshing" @refresh="onRefresh">
<van-list v-model:loading="state.loading" <van-list v-model:loading="state.loading"
:finished="state.finished" finished-text="没有更多数据了" :finished="state.finished" finished-text="没有更多数据了"
@load="onPage"> @load="onPage">
@@ -102,7 +102,9 @@ export default defineComponent({
const state = reactive({ const state = reactive({
keyword: '', keyword: '',
loading: false, finished: true, refreshing: false,
loading: false,
finished: true,
start_date: '', start_date: '',
page: 1, page: 1,
page_size: 10, page_size: 10,
@@ -123,14 +125,19 @@ export default defineComponent({
if (start_date) { if (start_date) {
params.start_date = start_date + " 00:00:00"; params.start_date = start_date + " 00:00:00";
} }
await query(params); try {
if (store.pages <= state.page) { await query(params);
state.finished = true; if (store.pages <= state.page) {
state.finished = true;
}
} finally {
state.loading = false;
state.refreshing = false;
} }
state.loading = false;
} }
const onRefresh = async () => { const onRefresh = async () => {
state.refreshing = true;
await search({page: 1, page_size: state.page_size}); await search({page: 1, page_size: state.page_size});
} }