浏览代码

添加一个测试页面

flyzto 4 月之前
父节点
当前提交
0426fb10d2

+ 2 - 1
web/apps/web-antd/src/locales/langs/en-US/page.json

@@ -13,7 +13,8 @@
   "match": {
     "title": "Match Management",
     "related": "Related Matches",
-    "centerOrder": "Center Order"
+    "centerOrder": "Center Order",
+    "dataTest": "Data Test"
   },
   "system": {
     "title": "System",

+ 2 - 1
web/apps/web-antd/src/locales/langs/zh-CN/page.json

@@ -13,7 +13,8 @@
   "match": {
     "title": "比赛管理",
     "related": "关联比赛",
-    "centerOrder": "中单记录"
+    "centerOrder": "中单记录",
+    "dataTest": "数据测试"
   },
   "system": {
     "title": "系统设置",

+ 1 - 1
web/apps/web-antd/src/preferences.ts

@@ -10,7 +10,7 @@ export const overridesPreferences = defineOverridesPreferences({
   app: {
     name: import.meta.env.VITE_APP_TITLE,
     enableRefreshToken: true,
-    defaultHomePath: '/workspace',
+    defaultHomePath: '/match',
   },
   theme: {
     mode: 'light'

+ 1 - 0
web/apps/web-antd/src/router/routes/modules/dashboard.ts

@@ -8,6 +8,7 @@ const routes: RouteRecordRaw[] = [
       icon: 'lucide:layout-dashboard',
       order: -1,
       title: $t('page.dashboard.title'),
+      hideInMenu: true,
     },
     name: 'Dashboard',
     path: '/dashboard',

+ 11 - 0
web/apps/web-antd/src/router/routes/modules/match.ts

@@ -11,6 +11,7 @@ const routes: RouteRecordRaw[] = [
     },
     name: 'Match',
     path: '/match',
+    redirect: '/match/solutions',
     children: [
       {
         name: 'RelatedMatch',
@@ -33,6 +34,16 @@ const routes: RouteRecordRaw[] = [
           roles: ['admin'], // Only users with admin role can access this page
         },
       },
+      {
+        name: 'DataTest',
+        path: 'data-test',
+        component: () => import('#/views/match/datatest/index.vue'),
+        meta: {
+          icon: 'ion:analytics-outline',
+          title: $t('page.match.dataTest'),
+          roles: ['admin'], // Only users with admin role can access this page
+        },
+      },
     ],
   },
 ];

+ 197 - 0
web/apps/web-antd/src/views/match/datatest/index.vue

@@ -0,0 +1,197 @@
+<template>
+  <div class="data-test-container">
+    <div class="page-header">
+      <h1>数据测试</h1>
+      <p>用于测试和验证比赛数据的页面</p>
+    </div>
+
+    <div class="content-area">
+      <div class="test-panel">
+        <h2>测试数据展示</h2>
+        <div class="data-display">
+          <div class="data-item">
+            <label>当前时间:</label>
+            <span>{{ currentTime }}</span>
+          </div>
+          <!-- <div class="data-item">
+            <label>测试状态:</label>
+            <span class="status-success">正常运行</span>
+          </div> -->
+          <div class="data-item">
+            <label>数据源:</label>
+            <span>比赛管理系统</span>
+          </div>
+        </div>
+
+        <div class="action-buttons">
+          <button class="btn btn-primary" @click="refreshData">
+            刷新数据
+          </button>
+          <button class="btn btn-secondary" @click="runTest">
+            运行测试
+          </button>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script setup>
+import { ref, onMounted } from 'vue';
+import { requestClient } from '#/api/request';
+
+const currentTime = ref('');
+const gamesRelation = ref([]);
+const gamesSolution = ref({});
+
+const updateTime = () => {
+  currentTime.value = new Date().toLocaleString('zh-CN')
+}
+
+const refreshData = () => {
+  updateTime();
+  Promise.all([
+    requestClient.get('/pstery/get_games_relation', { params: { mk: 1 } }),
+    requestClient.get('/pstery/get_solutions')
+  ])
+  .then(([relations, solutions]) => {
+    gamesRelation.value = relations;
+    gamesSolution.value = solutions;
+    console.log('数据已刷新');
+  });
+}
+
+const runTest = async () => {
+  gamesSolution.value.solutions.forEach((solution) => {
+    const { info: { id }} = solution;
+    const relation = gamesRelation.value.find((relation) => relation.id === id);
+    if (!relation) {
+      console.log('relation not found', id);
+    }
+    else {
+      if (!relation.solutions) {
+        relation.solutions = [];
+      }
+      relation.solutions.push(solution);
+    }
+  });
+  console.log('gamesRelation', gamesRelation);
+}
+
+// const currentTime = ref('')
+
+// const updateTime = () => {
+//   currentTime.value = new Date().toLocaleString('zh-CN')
+// }
+
+// const refreshData = () => {
+//   updateTime()
+//   console.log('数据已刷新')
+// }
+
+// const runTest = () => {
+//   console.log('开始运行测试...')
+//   // 这里可以添加具体的测试逻辑
+// }
+
+onMounted(() => {
+  refreshData();
+})
+</script>
+
+<style lang="scss" scoped>
+.data-test-container {
+  padding: 20px;
+
+  .page-header {
+    margin-bottom: 30px;
+
+    h1 {
+      font-size: 24px;
+      font-weight: bold;
+      margin-bottom: 8px;
+      color: #333;
+    }
+
+    p {
+      color: #666;
+      font-size: 14px;
+    }
+  }
+
+  .content-area {
+    .test-panel {
+      background: #fff;
+      border-radius: 8px;
+      padding: 24px;
+      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
+
+      h2 {
+        font-size: 18px;
+        font-weight: 600;
+        margin-bottom: 20px;
+        color: #333;
+      }
+
+      .data-display {
+        margin-bottom: 24px;
+
+        .data-item {
+          display: flex;
+          align-items: center;
+          margin-bottom: 12px;
+
+          label {
+            font-weight: 500;
+            color: #555;
+            min-width: 100px;
+          }
+
+          span {
+            color: #333;
+
+            &.status-success {
+              color: #52c41a;
+              font-weight: 500;
+            }
+          }
+        }
+      }
+
+      .action-buttons {
+        display: flex;
+        gap: 12px;
+
+        .btn {
+          padding: 8px 16px;
+          border-radius: 6px;
+          border: none;
+          cursor: pointer;
+          font-size: 14px;
+          transition: all 0.2s;
+
+          &.btn-primary {
+            background: #1890ff;
+            color: white;
+
+            &:hover {
+              background: #40a9ff;
+            }
+          }
+
+          &.btn-secondary {
+            background: #f5f5f5;
+            color: #333;
+            border: 1px solid #d9d9d9;
+
+            &:hover {
+              background: #e6f7ff;
+              border-color: #1890ff;
+            }
+          }
+        }
+      }
+    }
+  }
+}
+</style>

+ 0 - 1
web/apps/web-antd/src/views/match/solutions/index.vue

@@ -257,7 +257,6 @@ const formatEvents = (events, cprKeys) => {
       index = 1;
     }
     else if (type === 'ot') {
-      console.log('ot ratio', ratio);
       switch (ratio) {
         case '0':
           ratioKey = '0-1';