修复Dashboard.vue编译错误
问题:
- Dashboard.vue中使用了错误的导入方式
- import { dashboardApi } 应该是 import * as dashboardAPI
- API调用方式不匹配实际的导出格式
修复:
- 修正导入语句为正确的命名导入
- 更新API调用使用正确的接口方法
- 清理重复的数据处理代码
- 确保与dashboard.js API文件兼容
现在前端可以正常编译和运行
This commit is contained in:
@@ -109,7 +109,7 @@
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, nextTick } from 'vue'
|
||||
import { dashboardApi } from '@/api/dashboard'
|
||||
import * as dashboardAPI from '@/api/dashboard'
|
||||
|
||||
// 动态加载ECharts
|
||||
const loadECharts = () => {
|
||||
@@ -145,19 +145,24 @@ export default {
|
||||
// 加载仪表盘数据
|
||||
const loadDashboardData = async () => {
|
||||
try {
|
||||
const response = await dashboardApi.getAllData()
|
||||
const data = response.data
|
||||
const [overviewRes, monthlyRes, conversionRes, ordersRes] = await Promise.all([
|
||||
dashboardAPI.getDashboardOverview(),
|
||||
dashboardAPI.getMonthlyRevenue(),
|
||||
dashboardAPI.getConversionRate(),
|
||||
dashboardAPI.getRecentOrders()
|
||||
])
|
||||
|
||||
overviewData.value = data.overview
|
||||
dailyActiveData.value = data.dailyActiveUsers.dailyData || []
|
||||
revenueData.value = data.revenueTrend.revenueData || []
|
||||
orderStatusData.value = data.orderStatusDistribution.statusData || []
|
||||
paymentMethodData.value = data.paymentMethodDistribution.methodData || []
|
||||
recentOrders.value = data.recentOrders.orders || []
|
||||
overviewData.value = overviewRes.data || {}
|
||||
revenueData.value = monthlyRes.data?.monthlyData || []
|
||||
recentOrders.value = ordersRes.data?.recentOrders || []
|
||||
|
||||
// 计算转化率
|
||||
if (conversionRes.data) {
|
||||
overviewData.value.conversionRate = conversionRes.data.conversionRate || 0
|
||||
}
|
||||
|
||||
// 等待DOM更新后初始化图表
|
||||
await nextTick()
|
||||
await initCharts()
|
||||
initCharts()
|
||||
} catch (error) {
|
||||
console.error('加载仪表盘数据失败:', error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user