数据分析ui补充完善,接入数据库

This commit is contained in:
comlibmb
2026-01-31 21:47:42 +08:00
parent 8f181b2b6a
commit 6716398175
71 changed files with 6501 additions and 10593 deletions

View File

@@ -0,0 +1,5 @@
// types/analytics/common.uts
export type TimePeriod = { value: string; label: string }
export type ChartType = { value: string; label: string }
export type Metric = { key: string; label: string }

View File

@@ -0,0 +1,11 @@
// types/analytics/coupon.uts
export type CouponData = {
total_issued: number
issued_growth: number
total_used: number
usage_rate: number
gmv_increase: number
gmv_growth: number
roi: number
}

View File

@@ -0,0 +1,29 @@
// types/analytics/custom-report.uts
import type { Metric, TimePeriod, ChartType } from './common.uts'
export type CustomReport = {
id: string
name: string
description: string
metrics: Array<string>
charts: Array<string>
updated_at: string
period?: string
}
export type ReportForm = {
name: string
description: string
metrics: Array<string>
period: string
chartType: string
}
export type ReportFormErrors = {
name: string
description: string
metrics: string
period: string
chartType: string
}

View File

@@ -0,0 +1,7 @@
// types/analytics/dashboard.uts
export type TrendData = { x: Array<string>; gmv: Array<number>; orders: Array<number> }
export type SegmentItem = { name: string; value: number }
export type TrafficItem = { name: string; value: number }
export type TopProductItem = { id: string; rank: number; name: string; sales: number }
export type TopMerchantItem = { id: string; rank: number; name: string; sales: number; growth: number }

View File

@@ -0,0 +1,4 @@
// types/analytics/data-detail.uts
export type TableColumn = { key: string; label: string; type: string; sortable: boolean }
export type DrillDownItem = { id: string; label: string; value: string; type: string }

View File

@@ -0,0 +1,25 @@
// types/analytics/delivery.uts
/**
* Key Performance Indicators for the Delivery Analysis page.
*/
export type DeliveryData = {
avg_delivery_time: number;
time_growth: number;
total_fee: number;
avg_fee: number;
avg_orders_per_driver: number;
satisfaction_rate: number;
satisfaction_growth: number;
};
/**
* Represents a driver's ranking based on performance.
*/
export type DriverRank = {
id: string;
rank: number;
name: string;
orders: number;
rating: number
};

View File

@@ -0,0 +1,19 @@
// types/analytics/insight.uts
export type InsightDetail = {
id: string
report_id: string
type: string
impact: string
title: string
content: string
created_at: string
}
export type RelatedReport = {
id: string
title: string
type: string
period: string
generated_at: string
}

View File

@@ -0,0 +1,9 @@
// types/analytics/market.uts
export type MarketTrendsResponse = {
trendRows: any
categoryRows: any
seasonalRows: any
priceRows: any
competitionRows: any
}

View File

@@ -0,0 +1,14 @@
// types/analytics/product.uts
export type ProductData = {
total_products: number
product_growth: number
hot_products: number
turnover_rate: number
turnover_growth: number
avg_stock: number
stock_growth: number
}
export type ProductRank = { id: string; rank: number; name: string; sales: number; growth: number }
export type ProductTrendRow = { date: string; gmv: number; qty: number; orders: number }

View File

@@ -0,0 +1,38 @@
// types/analytics/profile.uts
export type ReportStatus = 'pending' | 'ready' | 'failed' | 'scheduled' | 'shared' | string
export type RecentReport = {
id: string
title: string
description: string
status: ReportStatus
created_at: string
}
export type OverviewData = {
totalSales: string
salesGrowth: number
totalUsers: string
userGrowth: number
totalOrders: string
orderGrowth: number
conversionRate: number
conversionGrowth: number
}
export type ReportCounts = {
total: number
pending: number
scheduled: number
shared: number
}
export type TodayInsights = {
hotProduct: string
peakTraffic: string
conversionAnomaly: string
mobileRatio: number
}
export type TrendDatum = { label: string; sales: number; orders: number }

View File

@@ -0,0 +1,46 @@
// types/analytics/report-detail.uts
export type ReportType = {
id: string;
title: string;
type: string;
period: string;
generated_at: string;
description: string;
};
export type MetricType = {
key: string;
label: string;
value: number;
format: string;
icon: string;
color: string;
change: number;
};
export type ChartTabType = {
key: string;
label: string;
};
export type ChartLegendType = {
key: string;
label: string;
color: string;
};
export type TableColumnType = {
key: string;
title: string;
width: string;
type: string;
};
export type InsightType = {
id: string;
type: string;
title: string;
content: string;
impact: string;
};

22
types/analytics/sales.uts Normal file
View File

@@ -0,0 +1,22 @@
// types/analytics/sales.uts
// Re-exporting shared types from dashboard for semantic clarity in the sales context.
import type { TrendData, TopProductItem, TopMerchantItem } from './dashboard.uts'
export type SalesTrendData = TrendData
export type ProductRank = TopProductItem
export type MerchantRank = TopMerchantItem
/**
* Key Performance Indicators for the Sales Report page.
*/
export type SalesData = {
gmv: number
gmv_growth: number
orders: number
order_growth: number
conversion_rate: number
conversion_growth: number
avg_order_amount: number
avg_order_growth: number
}

25
types/analytics/user.uts Normal file
View File

@@ -0,0 +1,25 @@
// types/analytics/user.uts
/**
* Key Performance Indicators for the User Analysis page.
*/
export type UserData = {
total_users: number;
user_growth: number;
new_users: number;
new_user_growth: number;
active_users: number;
active_growth: number;
ordering_users: number;
ordering_growth: number;
paid_users: number;
paid_growth: number;
new_user_conversion_rate: number;
repurchase_rate: number;
repurchase_growth: number;
}
/**
* Represents a single step in a conversion funnel.
*/
export type FunnelStep = { step: string; value: number };