From afeeed281e60466b576fbe74d339634cc5d07b82 Mon Sep 17 00:00:00 2001 From: Codex Assistant <codex@example.com> Date: 星期三, 08 十月 2025 08:56:42 +0800 Subject: [PATCH] 修复评审功能和用户认证问题 --- web/src/api/region.js | 69 ++++++++++++++++++++++------------ 1 files changed, 45 insertions(+), 24 deletions(-) diff --git a/web/src/api/region.js b/web/src/api/region.js index 87cbcdf..6a134e2 100644 --- a/web/src/api/region.js +++ b/web/src/api/region.js @@ -1,6 +1,6 @@ import { API_CONFIG, graphqlRequest } from '@/config/api' -// GraphQL璇锋眰鍑芥暟 - 浣跨敤缁熶竴鐨刧raphqlRequest +// GraphQL 璇锋眰鍑芥暟 - 缁熶竴浣跨敤 graphqlRequest // 鑾峰彇鎵�鏈夊湴鍖� export const getRegions = async () => { @@ -15,16 +15,16 @@ } } ` - + try { - const data = await graphqlRequest(query) - return data.regions || [] + const result = await graphqlRequest(query) + return result.data.regions || [] } catch (error) { throw new Error(error.message || '鑾峰彇鍦板尯鍒楄〃澶辫触') } } -// 鏍规嵁ID鑾峰彇鍦板尯 +// 鏍规嵁 ID 鑾峰彇鍦板尯璇︽儏 export const getRegion = async (id) => { const query = ` query GetRegion($id: ID!) { @@ -37,10 +37,10 @@ } } ` - + try { - const data = await graphqlRequest(query, { id }) - return data.region + const result = await graphqlRequest(query, { id }) + return result.data.region } catch (error) { throw new Error(error.message || '鑾峰彇鍦板尯璇︽儏澶辫触') } @@ -59,7 +59,7 @@ } } ` - + try { const data = await graphqlRequest(mutation, { input: regionData }) return data.saveRegion @@ -75,7 +75,7 @@ deleteRegion(id: $id) } ` - + try { const data = await graphqlRequest(mutation, { id }) return data.deleteRegion @@ -96,16 +96,16 @@ } } ` - + try { - const data = await graphqlRequest(query) - return data.provinces || [] + const result = await graphqlRequest(query) + return result.data.provinces || [] } catch (error) { throw new Error(error.message || '鑾峰彇鐪佷唤鍒楄〃澶辫触') } } -// 鏍规嵁鐪佷唤ID鑾峰彇鍩庡競 +// 鏍规嵁鐪佷唤 ID 鑾峰彇鍩庡競 export const getCities = async (provinceId) => { const query = ` query GetCities($provinceId: ID!) { @@ -117,16 +117,16 @@ } } ` - + try { - const data = await graphqlRequest(query, { provinceId }) - return data.cities || [] + const result = await graphqlRequest(query, { provinceId }) + return result.data.cities || [] } catch (error) { throw new Error(error.message || '鑾峰彇鍩庡競鍒楄〃澶辫触') } } -// 鏍规嵁鍩庡競ID鑾峰彇鍖哄幙 +// 鏍规嵁鍩庡競 ID 鑾峰彇鍖哄幙 export const getDistricts = async (cityId) => { const query = ` query GetDistricts($cityId: ID!) { @@ -138,16 +138,36 @@ } } ` - + try { - const data = await graphqlRequest(query, { cityId }) - return data.districts || [] + const result = await graphqlRequest(query, { cityId }) + return result.data.districts || [] } catch (error) { throw new Error(error.message || '鑾峰彇鍖哄幙鍒楄〃澶辫触') } } -// RegionApi 瀵硅薄锛屽寘鍚墍鏈夊尯鍩熺浉鍏崇殑API鏂规硶 +// 鑾峰彇鍙跺瓙鍦板尯鍒楄〃 +export const getLeafRegions = async () => { + const query = ` + query LeafRegions { + leafRegions { + id + name + leafFlag + } + } + ` + + try { + const result = await graphqlRequest(query) + return result.data.leafRegions || [] + } catch (error) { + throw new Error(error.message || '鑾峰彇鍙跺瓙鍦板尯鍒楄〃澶辫触') + } +} + +// RegionApi 瀵硅薄锛屽寘鍚墍鏈夊尯鍩熺浉鍏崇殑 API 鏂规硶 export const RegionApi = { getRegions, getRegion, @@ -155,5 +175,6 @@ deleteRegion, getProvinces, getCities, - getDistricts -} \ No newline at end of file + getDistricts, + getLeafRegions +} -- Gitblit v1.8.0