fix: 统一管理后台 401 与加载失败处理
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
useDialog,
|
||||
} from "naive-ui";
|
||||
import PageHeader from "@/components/PageHeader.vue";
|
||||
import LoadFailed from "@/components/LoadFailed.vue";
|
||||
import {
|
||||
addGroupMembers,
|
||||
createGroup,
|
||||
@@ -31,6 +32,7 @@ import { message } from "@/utils/notify";
|
||||
|
||||
const dialog = useDialog();
|
||||
const loading = ref(false);
|
||||
const loadError = ref("");
|
||||
const rows = ref<GroupSummary[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
@@ -48,11 +50,14 @@ const addMembers = ref("");
|
||||
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
loadError.value = "";
|
||||
try {
|
||||
const cursor = page.value > 1 ? String((page.value - 1) * pageSize.value) : "";
|
||||
const res = await listGroups(query.value.trim() || undefined, cursor, pageSize.value);
|
||||
rows.value = res.items;
|
||||
total.value = res.total;
|
||||
} catch (e) {
|
||||
loadError.value = e instanceof Error ? e.message : "加载失败";
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -241,6 +246,8 @@ async function onTransfer(endpointId: string) {
|
||||
</template>
|
||||
</PageHeader>
|
||||
<div class="page-body">
|
||||
<LoadFailed v-if="loadError" :description="loadError" @retry="load" />
|
||||
<template v-else>
|
||||
<n-space style="margin-bottom: 12px">
|
||||
<n-input v-model:value="query" placeholder="名称/编号" style="width: 200px" @keyup.enter="page = 1; load()" />
|
||||
<n-button @click="page = 1; load()">查询</n-button>
|
||||
@@ -262,6 +269,7 @@ async function onTransfer(endpointId: string) {
|
||||
},
|
||||
}"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<n-modal v-model:show="createOpen" preset="card" title="新建群" style="width: 480px">
|
||||
|
||||
Reference in New Issue
Block a user