refactor: 重命名 LogAPI 接口及类型定义以优化语义

This commit is contained in:
Ray.Hao
2026-04-05 16:29:40 +08:00
parent a65050f4ea
commit ca3711e66d
2 changed files with 14 additions and 18 deletions

View File

@@ -35,8 +35,8 @@ const LogAPI = {
*
* @returns 访问概览数据
*/
getVisitStats() {
return request<VisitStats>({
getVisitOverview() {
return request<VisitOverview>({
url: `${LOG_BASE_URL}/analytics/overview`,
method: "GET",
});
@@ -103,8 +103,6 @@ export interface VisitTrend {
pvList: number[];
/** 访客数(UV) */
uvList: number[];
/** IP数 */
ipList: number[];
}
/** 访问趋势查询参数 */
@@ -116,7 +114,7 @@ export interface VisitTrendQuery {
}
/** 访问统计 */
export interface VisitStats {
export interface VisitOverview {
/** 今日访客数(UV) */
todayUvCount: number;
/** 总访客数 */

View File

@@ -52,7 +52,7 @@
<view class="stat-card__dot stat-card__dot--green"></view>
</view>
<text class="stat-card__num stat-card__num--green">
{{ visitStatsData.todayUvCount }}
{{ visitOverviewData.todayUvCount }}
</text>
</view>
<view class="stat-card gradient-bg--primary">
@@ -62,7 +62,7 @@
<view class="stat-card__dot stat-card__dot--blue"></view>
</view>
<text class="stat-card__num stat-card__num--blue">
{{ visitStatsData.todayPvCount }}
{{ visitOverviewData.todayPvCount }}
</text>
</view>
</view>
@@ -102,14 +102,14 @@ import { useRouter } from "uni-mini-router";
import { useUserStore } from "@/store";
import { menuConfig } from "@/config/menu";
import { checkLogin, isLoggedIn } from "@/utils/auth";
import LogAPI, { type VisitStats as ApiVisitStats, type VisitTrend } from "@/api/log";
import LogAPI, { type VisitOverview as ApiVisitOverview, type VisitTrend } from "@/api/log";
import NoticeAPI, { type NoticeItem } from "@/api/notice";
// ============================================================================
// 类型定义
// ============================================================================
type VisitStatsVO = ApiVisitStats;
type VisitOverviewVO = ApiVisitOverview;
interface NavItem {
icon: string;
@@ -135,7 +135,7 @@ const recentDaysRange = ref(7);
const swiperList = ref(["https://www.youlai.tech/storage/blog/banner9.png"]);
const visitStatsData = ref<VisitStatsVO>({
const visitOverviewData = ref<VisitOverviewVO>({
todayUvCount: 0,
uvGrowthRate: 0,
totalUvCount: 0,
@@ -257,9 +257,9 @@ async function loadNoticeData() {
}
}
async function loadVisitStatsData() {
async function loadVisitOverviewData() {
try {
visitStatsData.value = await LogAPI.getVisitStats();
visitOverviewData.value = await LogAPI.getVisitOverview();
} catch {
// ignore
}
@@ -323,11 +323,9 @@ function handleNoticeClick() {
router.push({ path: "/pages/work/notice/index" });
}
function handleSwiperClick(_e: any) {
}
function handleSwiperClick(_e: any) {}
function handleSwiperChange(_e: any) {
}
function handleSwiperChange(_e: any) {}
function handleDataRangeChange({ value }: { value: number }) {
recentDaysRange.value = value;
@@ -341,13 +339,13 @@ function handleDataRangeChange({ value }: { value: number }) {
onReady(() => {
loadAppVersion();
loadNoticeData();
loadVisitStatsData();
loadVisitOverviewData();
loadVisitTrendData();
});
// 每次页面显示时刷新数据(登录后跳转回来也能更新)
onShow(() => {
loadVisitStatsData();
loadVisitOverviewData();
loadVisitTrendData();
});
</script>