From c4a9cad1c50e89365e2a58b50e259af642ed3b8c Mon Sep 17 00:00:00 2001 From: Codex Assistant <codex@example.com> Date: 星期二, 07 十月 2025 16:12:20 +0800 Subject: [PATCH] feat(review): 调整评审详情展示顺序与样式,描述支持多行,项目信息列宽40/60 fix(auth): 登录页与首页循环跳转保护;api.ts 在登录页不再重定向;401分支在登录页不跳转 fix(router): /login 放行策略优化,避免死循环;评审列表跳转到 /project-review/:id/detail fix(frontend): 补齐 utils/appConfig.ts,避免启动白屏 fix(review): 详情页提交评分缺少stageId时回退使用项目详情的stageId feat(backend): ActivityPlayerDetailResponse.playerInfo 补充 avatarUrl/avatar,服务组装时填充用户头像 chore(dev): 启动脚本注入本地JWT密钥,重启前后端 --- web/src/api/rating.js | 227 ++++++++++++++++++++++++++------------------------------ 1 files changed, 107 insertions(+), 120 deletions(-) diff --git a/web/src/api/rating.js b/web/src/api/rating.js index a2a5d72..5be5ccc 100644 --- a/web/src/api/rating.js +++ b/web/src/api/rating.js @@ -1,138 +1,125 @@ -const GRAPHQL_ENDPOINT = 'http://localhost:8080/api/graphql' +import { API_CONFIG, graphqlRequest } from '@/config/api' -// GraphQL璇锋眰鍑芥暟 -async function graphqlRequest(query, variables = {}) { - const response = await fetch(GRAPHQL_ENDPOINT, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - query, - variables, - }), - }) +// 浣跨敤缁熶竴鐨凣raphQL璇锋眰鍑芥暟 - if (!response.ok) { - throw new Error(`HTTP error! status: ${response.status}`) +// GraphQL鏌ヨ璇彞 +const GET_RATING_SCHEMES_QUERY = ` + query GetRatingSchemes($page: Int!, $size: Int!, $name: String) { + ratingSchemes(page: $page, size: $size, name: $name) { + content { + id + name + description + totalScore + state + stateName + createTime + updateTime + } + totalElements + page + size + } } +` - const result = await response.json() - - if (result.errors) { - throw new Error(result.errors[0].message) +const GET_ALL_RATING_SCHEMES_QUERY = ` + query GetAllRatingSchemes { + allRatingSchemes { + id + name + description + totalScore + state + stateName + } } +` - return result.data -} +const GET_RATING_SCHEME_QUERY = ` + query GetRatingScheme($id: ID!) { + ratingScheme(id: $id) { + id + name + description + totalScore + state + stateName + createTime + updateTime + items { + id + name + maxScore + orderNo + } + } + } +` -// 鍒嗛〉鏌ヨ璇勫垎妯℃澘鍒楄〃 +const SAVE_RATING_SCHEME_MUTATION = ` + mutation SaveRatingScheme($input: RatingSchemeInput!) { + saveRatingScheme(input: $input) { + id + name + description + totalScore + state + stateName + createTime + updateTime + } + } +` + +const DELETE_RATING_SCHEME_MUTATION = ` + mutation DeleteRatingScheme($id: ID!) { + deleteRatingScheme(id: $id) + } +` + +// API鍑芥暟 export const getRatingSchemes = async (page = 0, size = 10, name = '') => { - const query = ` - query GetRatingSchemes($page: Int, $size: Int, $name: String) { - ratingSchemes(page: $page, size: $size, name: $name) { - content { - id - name - description - totalScore - createTime - updateTime - } - totalElements - totalPages - number - size - first - last - } - } - ` - - const variables = { page, size } - if (name) { - variables.name = name + try { + const result = await graphqlRequest(GET_RATING_SCHEMES_QUERY, { page, size, name }) + return result.data.ratingSchemes + } catch (error) { + throw new Error(error.message || '鑾峰彇璇勫垎鏂规鍒楄〃澶辫触') } - - const data = await graphqlRequest(query, variables) - return data.ratingSchemes } -// 鏍规嵁ID鑾峰彇璇勫垎妯℃澘璇︽儏 -export const getRatingScheme = async (id) => { - const query = ` - query GetRatingScheme($id: ID!) { - ratingScheme(id: $id) { - id - name - description - totalScore - items { - id - name - maxScore - orderNo - } - createTime - updateTime - } - } - ` - - const data = await graphqlRequest(query, { id }) - return data.ratingScheme -} - -// 鑾峰彇鎵�鏈夎瘎鍒嗘ā鏉匡紙鐢ㄤ簬涓嬫媺閫夋嫨锛� export const getAllRatingSchemes = async () => { - const query = ` - query GetAllRatingSchemes { - allRatingSchemes { - id - name - description - totalScore - } - } - ` - - const data = await graphqlRequest(query) - return data.allRatingSchemes + try { + const result = await graphqlRequest(GET_ALL_RATING_SCHEMES_QUERY) + return result.data.allRatingSchemes || [] + } catch (error) { + throw new Error(error.message || '鑾峰彇鎵�鏈夎瘎鍒嗘柟妗堝け璐�') + } } -// 淇濆瓨璇勫垎妯℃澘 -export const saveRatingScheme = async (input) => { - const mutation = ` - mutation SaveRatingScheme($input: RatingSchemeInput!) { - saveRatingScheme(input: $input) { - id - name - description - totalScore - items { - id - name - maxScore - orderNo - } - createTime - updateTime - } - } - ` - - const data = await graphqlRequest(mutation, { input }) - return data.saveRatingScheme +export const getRatingScheme = async (id) => { + try { + const result = await graphqlRequest(GET_RATING_SCHEME_QUERY, { id }) + return result.data.ratingScheme + } catch (error) { + throw new Error(error.message || '鑾峰彇璇勫垎鏂规璇︽儏澶辫触') + } } -// 鍒犻櫎璇勫垎妯℃澘 +export const saveRatingScheme = async (ratingSchemeData) => { + try { + const result = await graphqlRequest(SAVE_RATING_SCHEME_MUTATION, { input: ratingSchemeData }) + return result.data.saveRatingScheme + } catch (error) { + throw new Error(error.message || '淇濆瓨璇勫垎鏂规澶辫触') + } +} + export const deleteRatingScheme = async (id) => { - const mutation = ` - mutation DeleteRatingScheme($id: ID!) { - deleteRatingScheme(id: $id) - } - ` - - const data = await graphqlRequest(mutation, { id }) - return data.deleteRatingScheme + try { + const result = await graphqlRequest(DELETE_RATING_SCHEME_MUTATION, { id }) + return result.data.deleteRatingScheme + } catch (error) { + throw new Error(error.message || '鍒犻櫎璇勫垎鏂规澶辫触') + } } \ No newline at end of file -- Gitblit v1.8.0