소스 검색

优化用户界面体验-首页重构

wenkai 2 주 전
부모
커밋
34d45b677c
3개의 변경된 파일33개의 추가작업 그리고 79개의 파일을 삭제
  1. 2 2
      src/api/system/gameEvent/index.ts
  2. 5 0
      src/types/global.d.ts
  3. 26 77
      src/views/index.vue

+ 2 - 2
src/api/system/gameEvent/index.ts

@@ -80,9 +80,9 @@ export const getEventIdNameMap = () => {
  * @returns {*}
  */
 
-export const getEventCount = () => {
+export const getEventCount = (type: number) => {
   return request({
-    url: '/system/gameEvent/count',
+    url: '/system/gameEvent/count/' + type,
     method: 'get'
   });
 };

+ 5 - 0
src/types/global.d.ts

@@ -53,6 +53,7 @@ declare global {
     /** 其他参数 */
     [key: string]: any;
   }
+
   /**
    * 字典数据  数据配置
    */
@@ -81,13 +82,17 @@ declare global {
     queryParams: D;
     rules: ElFormRules;
   }
+
   /**
    * 分页查询参数
    */
   declare interface PageQuery {
     pageNum: number;
     pageSize: number;
+    orderByColumn: string;
+    isAsc: string;
   }
+
   declare interface LayoutSetting {
     /**
      * 是否显示顶部导航

+ 26 - 77
src/views/index.vue

@@ -288,7 +288,9 @@ const loadRecentEvents = async () => {
   try {
     const res = await listGameEvent({
       pageNum: 1,
-      pageSize: 4
+      pageSize: 4,
+      orderByColumn: 'update_time',
+      isAsc: 'desc'
     });
     if (res.code === 200 && res.total > 0) {
       recentEvents.value = res.rows;
@@ -309,7 +311,9 @@ const loadNotice = async () => {
       noticeTitle: undefined,
       createByName: undefined,
       status: undefined,
-      noticeType: undefined
+      noticeType: undefined,
+      orderByColumn: 'update_time',
+      isAsc: 'desc'
     });
     if (res.code === 200 && res.total > 0) {
       systemNotices.value = res.rows;
@@ -324,35 +328,25 @@ const loadNotice = async () => {
  */
 const loadEventStatus = async () => {
   try {
-    const res = await listGameEvent({
-      pageNum: 1,
-      pageSize: 1000 // 获取所有数据来统计
-    });
-    
-    if (res.code === 200 && res.rows) {
-      const now = new Date();
-      let upcoming = 0, ongoing = 0, completed = 0;
-      
-      res.rows.forEach(event => {
-        const startTime = new Date(event.startTime);
-        const endTime = new Date(event.endTime);
-        
-        if (now < startTime) {
-          upcoming++;
-        } else if (now >= startTime && now <= endTime) {
-          ongoing++;
-        } else {
-          completed++;
-        }
-      });
-      
-      eventStatus.value = {
-        upcoming,
-        ongoing,
-        completed,
-        total: res.total || res.rows.length
-      };
-    }
+    let upcoming = 0,
+      ongoing = 0,
+      completed = 0,
+      total = 0;
+    let res = await getEventCount(0);
+    total = res.data;
+    res = await getEventCount(1);
+    upcoming = res.data;
+    res = await getEventCount(2);
+    ongoing = res.data;
+    res = await getEventCount(3);
+    completed = res.data;
+
+    eventStatus.value = {
+      upcoming,
+      ongoing,
+      completed,
+      total
+    };
   } catch (error) {
     console.error('加载赛事状态失败:', error);
   }
@@ -364,7 +358,7 @@ const loadEventStatus = async () => {
 const loadStatistics = async () => {
   try {
     // 并行请求所有统计接口
-    const results = await Promise.allSettled([getArticleCount(), getTeamCount(), getEventCount(), getEventProjectCount(), getRefereeCount()]);
+    const results = await Promise.allSettled([getArticleCount(), getTeamCount(), getEventCount(0), getEventProjectCount(), getRefereeCount()]);
 
     let hasError = false;
 
@@ -448,7 +442,6 @@ const loadStatistics = async () => {
 
 const initCharts = () => {
   initPieChart();
-  initLineChart();
 };
 
 const initPieChart = () => {
@@ -489,50 +482,6 @@ const initPieChart = () => {
   myChart.setOption(option);
 };
 
-const initLineChart = () => {
-  const chartDom = document.getElementById('lineChart');
-  if (!chartDom) return;
-
-  const myChart = echarts.init(chartDom);
-  const option = {
-    tooltip: {
-      trigger: 'axis'
-    },
-    legend: {
-      data: ['注册数量', '赛事数量']
-    },
-    grid: {
-      left: '3%',
-      right: '4%',
-      bottom: '3%',
-      containLabel: true
-    },
-    xAxis: {
-      type: 'category',
-      boundaryGap: false,
-      data: ['1月', '2月', '3月', '4月', '5月', '6月']
-    },
-    yAxis: {
-      type: 'value'
-    },
-    series: [
-      {
-        name: '注册数量',
-        type: 'line',
-        stack: 'Total',
-        data: [120, 132, 101, 134, 90, 230]
-      },
-      {
-        name: '赛事数量',
-        type: 'line',
-        stack: 'Total',
-        data: [220, 182, 191, 234, 290, 330]
-      }
-    ]
-  };
-  myChart.setOption(option);
-};
-
 const handleQuickAction = (action: string) => {
   switch (action) {
     case 'addEvent':