refactor: 重命名 LogAPI 接口及类型定义以优化语义
This commit is contained in:
@@ -35,8 +35,8 @@ const LogAPI = {
|
|||||||
*
|
*
|
||||||
* @returns 访问概览数据
|
* @returns 访问概览数据
|
||||||
*/
|
*/
|
||||||
getVisitStats() {
|
getVisitOverview() {
|
||||||
return request<VisitStats>({
|
return request<VisitOverview>({
|
||||||
url: `${LOG_BASE_URL}/analytics/overview`,
|
url: `${LOG_BASE_URL}/analytics/overview`,
|
||||||
method: "GET",
|
method: "GET",
|
||||||
});
|
});
|
||||||
@@ -103,8 +103,6 @@ export interface VisitTrend {
|
|||||||
pvList: number[];
|
pvList: number[];
|
||||||
/** 访客数(UV) */
|
/** 访客数(UV) */
|
||||||
uvList: number[];
|
uvList: number[];
|
||||||
/** IP数 */
|
|
||||||
ipList: number[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 访问趋势查询参数 */
|
/** 访问趋势查询参数 */
|
||||||
@@ -116,7 +114,7 @@ export interface VisitTrendQuery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 访问统计 */
|
/** 访问统计 */
|
||||||
export interface VisitStats {
|
export interface VisitOverview {
|
||||||
/** 今日访客数(UV) */
|
/** 今日访客数(UV) */
|
||||||
todayUvCount: number;
|
todayUvCount: number;
|
||||||
/** 总访客数 */
|
/** 总访客数 */
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
<view class="stat-card__dot stat-card__dot--green"></view>
|
<view class="stat-card__dot stat-card__dot--green"></view>
|
||||||
</view>
|
</view>
|
||||||
<text class="stat-card__num stat-card__num--green">
|
<text class="stat-card__num stat-card__num--green">
|
||||||
{{ visitStatsData.todayUvCount }}
|
{{ visitOverviewData.todayUvCount }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="stat-card gradient-bg--primary">
|
<view class="stat-card gradient-bg--primary">
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
<view class="stat-card__dot stat-card__dot--blue"></view>
|
<view class="stat-card__dot stat-card__dot--blue"></view>
|
||||||
</view>
|
</view>
|
||||||
<text class="stat-card__num stat-card__num--blue">
|
<text class="stat-card__num stat-card__num--blue">
|
||||||
{{ visitStatsData.todayPvCount }}
|
{{ visitOverviewData.todayPvCount }}
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -102,14 +102,14 @@ import { useRouter } from "uni-mini-router";
|
|||||||
import { useUserStore } from "@/store";
|
import { useUserStore } from "@/store";
|
||||||
import { menuConfig } from "@/config/menu";
|
import { menuConfig } from "@/config/menu";
|
||||||
import { checkLogin, isLoggedIn } from "@/utils/auth";
|
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";
|
import NoticeAPI, { type NoticeItem } from "@/api/notice";
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// 类型定义
|
// 类型定义
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
type VisitStatsVO = ApiVisitStats;
|
type VisitOverviewVO = ApiVisitOverview;
|
||||||
|
|
||||||
interface NavItem {
|
interface NavItem {
|
||||||
icon: string;
|
icon: string;
|
||||||
@@ -135,7 +135,7 @@ const recentDaysRange = ref(7);
|
|||||||
|
|
||||||
const swiperList = ref(["https://www.youlai.tech/storage/blog/banner9.png"]);
|
const swiperList = ref(["https://www.youlai.tech/storage/blog/banner9.png"]);
|
||||||
|
|
||||||
const visitStatsData = ref<VisitStatsVO>({
|
const visitOverviewData = ref<VisitOverviewVO>({
|
||||||
todayUvCount: 0,
|
todayUvCount: 0,
|
||||||
uvGrowthRate: 0,
|
uvGrowthRate: 0,
|
||||||
totalUvCount: 0,
|
totalUvCount: 0,
|
||||||
@@ -257,9 +257,9 @@ async function loadNoticeData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadVisitStatsData() {
|
async function loadVisitOverviewData() {
|
||||||
try {
|
try {
|
||||||
visitStatsData.value = await LogAPI.getVisitStats();
|
visitOverviewData.value = await LogAPI.getVisitOverview();
|
||||||
} catch {
|
} catch {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
@@ -323,11 +323,9 @@ function handleNoticeClick() {
|
|||||||
router.push({ path: "/pages/work/notice/index" });
|
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 }) {
|
function handleDataRangeChange({ value }: { value: number }) {
|
||||||
recentDaysRange.value = value;
|
recentDaysRange.value = value;
|
||||||
@@ -341,13 +339,13 @@ function handleDataRangeChange({ value }: { value: number }) {
|
|||||||
onReady(() => {
|
onReady(() => {
|
||||||
loadAppVersion();
|
loadAppVersion();
|
||||||
loadNoticeData();
|
loadNoticeData();
|
||||||
loadVisitStatsData();
|
loadVisitOverviewData();
|
||||||
loadVisitTrendData();
|
loadVisitTrendData();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 每次页面显示时刷新数据(登录后跳转回来也能更新)
|
// 每次页面显示时刷新数据(登录后跳转回来也能更新)
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
loadVisitStatsData();
|
loadVisitOverviewData();
|
||||||
loadVisitTrendData();
|
loadVisitTrendData();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user