feat: 更新收益相关组件,优化数据获取逻辑,修复数据展示问题

This commit is contained in:
2026-01-11 00:51:55 +07:00
parent 7440cbd3a5
commit 4c8b68e67d
11 changed files with 159 additions and 377 deletions

View File

@@ -1,5 +1,7 @@
<script lang='ts' setup>
import type { RefresherCustomEvent } from "@ionic/vue";
import type { EaringsSummaryData } from "@/api/types";
import { client, safeClient } from "@/api";
import Overview from "./components/overview.vue";
import Recent from "./components/recent.vue";
import RevenueSource from "./components/revenue-source.vue";
@@ -8,24 +10,24 @@ import Trend from "./components/trend.vue";
const { t } = useI18n();
const { vibrate } = useHaptics();
const loading = ref(true);
const data = ref<EaringsSummaryData | null>(null);
async function loadIncomeData() {
loading.value = true;
useTimeoutFn(() => {
loading.value = false;
}, 800);
async function fetchData() {
const { data: fetchData } = await safeClient(client.api.earnings.summary.post({
now: new Date(),
}));
data.value = fetchData.value;
}
async function handleRefresh(event: RefresherCustomEvent) {
function handleRefresh(event: RefresherCustomEvent) {
vibrate();
useTimeoutFn(() => {
fetchData().finally(() => {
event.target.complete();
}, 800);
});
}
onMounted(() => {
loadIncomeData();
fetchData();
});
</script>
@@ -44,10 +46,10 @@ onMounted(() => {
</ion-refresher>
<div class="container">
<Overview />
<Overview :data="data" />
<Trend />
<RevenueSource />
<Recent />
<RevenueSource :data="data" />
<Recent :data="data" />
</div>
</ion-content>
</ion-page>