From 8337c34fcc761d07acaad796d10f3e12e9bbe2d1 Mon Sep 17 00:00:00 2001
From: lrj <owen.stl@gmail.com>
Date: 星期日, 05 十月 2025 08:56:04 +0800
Subject: [PATCH] feat: 微信项目详情支持阶段评分时间轴
---
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 21ff463..988cd13 100644
--- a/web/src/api/judge.js
+++ b/web/src/api/judge.js
@@ -1,6 +1,6 @@
// 璇勫绠$悊 API
-const GRAPHQL_ENDPOINT = '/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