feat(frontend): improve admin usability and light theme
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<div class="dashboard">
|
||||
<a-spin :loading="loading" class="dashboard-spin">
|
||||
<a-alert v-if="errorMessage" type="error" show-icon class="dashboard-alert">
|
||||
{{ errorMessage }}
|
||||
<template #action><a-button size="small" @click="loadOverview">重新加载</a-button></template>
|
||||
</a-alert>
|
||||
<div class="dashboard-meta">统计口径以服务端为准 · 更新时间:{{ updatedAt || '尚未加载' }}</div>
|
||||
<a-grid :cols="{ xs: 1, sm: 2, lg: 4 }" :col-gap="16" :row-gap="16">
|
||||
<a-grid-item v-for="item in cards" :key="item.key">
|
||||
<a-card :bordered="false" class="metric-card">
|
||||
@@ -58,6 +63,8 @@ const emptyOverview = (): DashboardOverview => ({
|
||||
order_statuses: [], product_statuses: [], payment_channels: [], recent_orders: [],
|
||||
});
|
||||
const loading = ref(false);
|
||||
const errorMessage = ref('');
|
||||
const updatedAt = ref('');
|
||||
const overview = ref<DashboardOverview>(emptyOverview());
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
@@ -110,8 +117,9 @@ const paymentChannelOption = computed<EChartsOption>(() => ({
|
||||
series: [{ type: 'bar', data: safeArray(overview.value.payment_channels).map((item) => centsToYuan(item.value)) }],
|
||||
}));
|
||||
|
||||
onMounted(async () => {
|
||||
async function loadOverview() {
|
||||
loading.value = true;
|
||||
errorMessage.value = '';
|
||||
try {
|
||||
const data = await platformApi.overview();
|
||||
overview.value = {
|
||||
@@ -124,17 +132,23 @@ onMounted(async () => {
|
||||
payment_channels: safeArray(data.payment_channels),
|
||||
recent_orders: safeArray(data.recent_orders),
|
||||
};
|
||||
updatedAt.value = new Date().toLocaleString('zh-CN', { hour12: false });
|
||||
} catch (error) {
|
||||
Message.error((error as Error).message);
|
||||
errorMessage.value = (error as Error).message;
|
||||
Message.error(errorMessage.value);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(loadOverview);
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.dashboard { padding: 20px; }
|
||||
.dashboard-spin { width: 100%; }
|
||||
.dashboard-alert { margin-bottom: 16px; }
|
||||
.dashboard-meta { margin-bottom: 12px; color: var(--color-text-3); font-size: 12px; text-align: right; }
|
||||
.metric-card { min-height: 120px; }
|
||||
.metric-hint { margin-top: 8px; color: var(--color-text-3); font-size: 12px; }
|
||||
.section-card { margin-top: 16px; }
|
||||
|
||||
Reference in New Issue
Block a user