From bd999ecc09fcacf4016edcba85caf9b9696d2140 Mon Sep 17 00:00:00 2001
From: lrj <owen.stl@gmail.com>
Date: 星期六, 04 十月 2025 18:40:31 +0800
Subject: [PATCH] feat: 同步本地改动(认证/评审/用户/选手模块更新;新增/调整 GraphQL schema;小程序个人信息与评审相关页面、配置与资源等)

---
 web/src/api/judge.js |   69 +++++++++++++---------------------
 1 files changed, 26 insertions(+), 43 deletions(-)

diff --git a/web/src/api/judge.js b/web/src/api/judge.js
index de2a207..988cd13 100644
--- a/web/src/api/judge.js
+++ b/web/src/api/judge.js
@@ -1,6 +1,6 @@
 // 璇勫绠$悊 API
 
-const GRAPHQL_ENDPOINT = 'http://localhost:8080/api/graphql';
+import { API_CONFIG, graphqlRequest } from '../config/api.ts';
 
 // GraphQL 鏌ヨ璇彞
 const GET_ALL_JUDGES_QUERY = `
@@ -93,88 +93,71 @@
   }
 `;
 
-// GraphQL 璇锋眰鍑芥暟
-const graphqlRequest = async (query, variables = {}) => {
-  const response = await fetch(GRAPHQL_ENDPOINT, {
-    method: 'POST',
-    headers: {
-      'Content-Type': 'application/json',
-    },
-    body: JSON.stringify({
-      query,
-      variables
-    })
-  });
-
-  const result = await response.json();
-  if (result.errors) {
-    throw new Error(result.errors[0].message);
-  }
-  return result.data;
-};
+// 浣跨敤缁熶竴鐨凣raphQL璇锋眰鍑芥暟
 
 // API 鍑芥暟
 export const getAllJudges = async () => {
-  const data = await graphqlRequest(GET_ALL_JUDGES_QUERY);
-  return data.judges || [];
+  const result = await graphqlRequest(GET_ALL_JUDGES_QUERY);
+  return result.data.judges;
 };
 
 export const getJudge = async (id) => {
-  const data = await graphqlRequest(GET_JUDGE_QUERY, { id });
-  return data.judge;
+  const result = await graphqlRequest(GET_JUDGE_QUERY, { id });
+  return result.data.judge;
 };
 
 // JudgeApi 瀵硅薄
 export const JudgeApi = {
   // 鑾峰彇鎵�鏈夎瘎濮�
   getJudges: async () => {
-    const data = await graphqlRequest(GET_ALL_JUDGES_QUERY);
-    return data.judges || [];
+    const result = await graphqlRequest(GET_ALL_JUDGES_QUERY);
+    return result.data.judges || [];
   },
 
   // 鑾峰彇鍗曚釜璇勫
   getJudge: async (id) => {
-    const data = await graphqlRequest(GET_JUDGE_QUERY, { id });
-    return data.judge;
+    const result = await graphqlRequest(GET_JUDGE_QUERY, { id });
+    return result.data.judge;
   },
 
   // 鎼滅储璇勫
   searchJudges: async (name) => {
-    // 鍏堣幏鍙栨墍鏈夎瘎濮旓紝鐒跺悗鍦ㄥ鎴风杩囨护锛堝疄闄呴」鐩腑搴旇鍦ㄥ悗绔疄鐜帮級
-    const judges = await JudgeApi.getJudges();
-    return judges.filter(judge => 
-      judge.name && judge.name.toLowerCase().includes(name.toLowerCase())
-    );
+    const result = await graphqlRequest(`
+      query SearchJudges($name: String!) {
+        searchJudges(name: $name) { id name title company }
+      }
+    `, { name });
+    return result.data.searchJudges || [];
   },
 
   // 淇濆瓨璇勫
   saveJudge: async (input) => {
-    const data = await graphqlRequest(SAVE_JUDGE_MUTATION, { input });
-    return data.saveJudge;
+    const result = await graphqlRequest(SAVE_JUDGE_MUTATION, { input });
+    return result.data.saveJudge;
   },
 
   // 鍒犻櫎璇勫
   deleteJudge: async (id) => {
-    const data = await graphqlRequest(DELETE_JUDGE_MUTATION, { id });
-    return data.deleteJudge;
+    const result = await graphqlRequest(DELETE_JUDGE_MUTATION, { id });
+    return result.data.deleteJudge;
   },
 
   // 鑾峰彇鎵�鏈夋爣绛�
   getTags: async () => {
-    const data = await graphqlRequest(GET_TAGS_QUERY);
-    return data.tags || [];
+    const result = await graphqlRequest(GET_TAGS_QUERY);
+    return result.data.tags || [];
   },
 
   // 鏍规嵁绫诲埆鑾峰彇鏍囩
   getTagsByCategory: async (category) => {
-    const data = await graphqlRequest(GET_TAGS_BY_CATEGORY_QUERY, { category });
-    return data.tagsByCategory || [];
+    const result = await graphqlRequest(GET_TAGS_BY_CATEGORY_QUERY, { category });
+    return result.data.tagsByCategory || [];
   },
 
   // 淇濆瓨濯掍綋
   saveMedia: async (input) => {
-    const data = await graphqlRequest(SAVE_MEDIA_MUTATION, { input });
-    return data.saveMedia;
+    const result = await graphqlRequest(SAVE_MEDIA_MUTATION, { input });
+    return result.data.saveMedia;
   }
 };
 

--
Gitblit v1.8.0