Explorar o código

人才地图baseURL测试

Xiao_123 hai 1 día
pai
achega
e48becd3ff

+ 4 - 4
src/api/menduner/system/talentMap/duplicate.ts

@@ -6,7 +6,7 @@ export const talentDuplicateApi = {
 		return await request.get({ 
 			url: `/api/parse/get-duplicate-records`,
 			params,
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -14,7 +14,7 @@ export const talentDuplicateApi = {
 	getDuplicateDetail: async (duplicate_id: number) => {
 		return await request.get({ 
 			url: `/api/parse/get-duplicate-record-detail/${duplicate_id}`,
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -23,7 +23,7 @@ export const talentDuplicateApi = {
 		return await request.post({ 
 			url: `/api/parse/process-duplicate-record/${duplicate_id}`, 
 			data, 
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	}
-}
+}

+ 2 - 2
src/api/menduner/system/talentMap/examine.ts

@@ -7,7 +7,7 @@ export const talentExamineApi = {
 		return await request.get({ 
 			url: `/api/parse/get-parsed-talents`,
 			params,
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	}
-}
+}

+ 11 - 11
src/api/menduner/system/talentMap/gather.ts

@@ -7,7 +7,7 @@ export const talentGatherApi = {
 		return await request.get({ 
 			url: `/api/parse/get-parse-tasks`,
 			params,
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -16,17 +16,17 @@ export const talentGatherApi = {
 		return await request.upload({ 
 			url: `/api/parse/add-parse-task`,
 			data,
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
 	// 获取任务详情
-	getTaskDetail: async (task_name: string) => {
-		return await request.get({
-			url: `/api/parse/get-parse-task-detail?task_name=${task_name}`,
-			baseURL: import.meta.env.VITE_BASE_URL
-		})
-	},
+	// getTaskDetail: async (task_name: string) => {
+	// 	return await request.get({
+	// 		url: `/api/parse/get-parse-task-detail?task_name=${task_name}`,
+	// 		baseURL: ''
+	// 	})
+	// },
 
 	// 任务解析
 	taskAnalysis: async (data: any) => {
@@ -34,7 +34,7 @@ export const talentGatherApi = {
 			url: '/api/parse/execute-parse-task',
 			data,
 			timeout: 300000, // 5min
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -44,7 +44,7 @@ export const talentGatherApi = {
 			url: '/api/parse/add-parsed-talents',
 			data,
 			timeout: 300000,
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	}
-}
+}

+ 42 - 42
src/api/menduner/system/talentMap/hotel.ts

@@ -1,40 +1,40 @@
 import request from '@/config/axios'
 
-export const talentHotelApi = {
-	// 标签列表
-	getTalentTagList: async () => {
-		return await request.get({ 
-			url: `/api/parse/get-talent-tag-list`, 
-			baseURL: import.meta.env.VITE_BASE_URL 
-		})
-	},
+// export const talentHotelApi = {
+// 	// 标签列表
+// 	getTalentTagList: async () => {
+// 		return await request.get({ 
+// 			url: `/api/parse/get-talent-tag-list`, 
+// 			baseURL: '' 
+// 		})
+// 	},
 
-	// 创建人才标签
-	createTalentTag: async (data: any) => {
-		return await request.post({ 
-			url: `/api/parse/create-talent-tag`, 
-			data, 
-			baseURL: import.meta.env.VITE_BASE_URL
-		})
-	},
+// 	// 创建人才标签
+// 	createTalentTag: async (data: any) => {
+// 		return await request.post({ 
+// 			url: `/api/parse/create-talent-tag`, 
+// 			data, 
+// 			baseURL: ''
+// 		})
+// 	},
 
-	// 更新人才标签
-	updateTalentTag: async (tag_id: number, data: any) => {
-		return await request.put({ 
-			url: `/api/parse/update-talent-tag/${tag_id}`, 
-			data, 
-			baseURL: import.meta.env.VITE_BASE_URL 
-		})
-	},
+// 	// 更新人才标签
+// 	updateTalentTag: async (tag_id: number, data: any) => {
+// 		return await request.put({ 
+// 			url: `/api/parse/update-talent-tag/${tag_id}`, 
+// 			data, 
+// 			baseURL: '' 
+// 		})
+// 	},
 
-	// 删除人才标签
-	deleteTalentTag: async (tag_id: number) => {
-		return await request.delete({ 
-			url: `/api/parse/delete-talent-tag/${tag_id}`, 
-			baseURL: import.meta.env.VITE_BASE_URL 
-		})
-	}
-}
+// 	// 删除人才标签
+// 	deleteTalentTag: async (tag_id: number) => {
+// 		return await request.delete({ 
+// 			url: `/api/parse/delete-talent-tag/${tag_id}`, 
+// 			baseURL: '' 
+// 		})
+// 	}
+// }
 
 // 酒店集团品牌管理
 export const talentHotelGroupBrandApi = {
@@ -42,24 +42,24 @@ export const talentHotelGroupBrandApi = {
 	getData: async () => {
 		return await request.get({ 
 			url: `/api/parse/get-hotel-group-brands-list`, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: '' 
 		})
 	},
 
 	// 查询指定品牌记录(根据ID查询指定品牌记录)
-	getDetail: async (brand_id: number) => {
-		return await request.get({ 
-			url: `/api/parse/query-hotel-group-brands/${brand_id}`, 
-			baseURL: import.meta.env.VITE_BASE_URL 
-		})
-	},
+	// getDetail: async (brand_id: number) => {
+	// 	return await request.get({ 
+	// 		url: `/api/parse/query-hotel-group-brands/${brand_id}`, 
+	// 		baseURL: '' 
+	// 	})
+	// },
 
 	// 新增品牌记录
 	create: async (data: any) => {
 		return await request.post({ 
 			url: `/api/parse/add-hotel-group-brands`, 
 			data, 
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -68,7 +68,7 @@ export const talentHotelGroupBrandApi = {
 		return await request.put({ 
 			url: `/api/parse/update-hotel-group-brands/${brand_id}`, 
 			data, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: '' 
 		})
 	},
 
@@ -76,7 +76,7 @@ export const talentHotelGroupBrandApi = {
 	delete: async (brand_id: number) => {
 		return await request.delete({ 
 			url: `/api/parse/delete-hotel-group-brands/${brand_id}`, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: '' 
 		})
 	}
 }

+ 53 - 53
src/api/menduner/system/talentMap/labeling.ts

@@ -5,7 +5,7 @@ export const talentLabelingApi = {
 	getCardList: async () => {
 		return await request.get({ 
 			url: `/api/parse/get-business-cards`, 
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -13,7 +13,7 @@ export const talentLabelingApi = {
 	getTalentTagById: async (talent_id: number) => {
 		return await request.get({ 
 			url: `/api/parse/talent-get-tags/${talent_id}`, 
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -22,7 +22,7 @@ export const talentLabelingApi = {
 		return await request.post({ 
 			url: `/api/parse/talent-update-tags`, 
 			data, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: '' 
 		})
 	},
 
@@ -31,84 +31,84 @@ export const talentLabelingApi = {
 		return await request.put({ 
 			url: `/api/parse/update-business-cards/${talent_id}/status`,
 			data,
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: '' 
 		})
 	},
 
 	// 获取人才名片
-	getTalentCardByImagePath: async (image_path: string) => {
-		return await request.download({ 
-			url: `/api/parse/business-cards/image/${image_path}`,
-			baseURL: import.meta.env.VITE_BASE_URL 
-		})
-	},
+	// getTalentCardByImagePath: async (image_path: string) => {
+	// 	return await request.download({ 
+	// 		url: `/api/parse/business-cards/image/${image_path}`,
+	// 		baseURL: '' 
+	// 	})
+	// },
 
 	// 获取网页解析原始markdown
-	getTalentMarkdown: async (image_path: string) => {
-		return await request.downloadMarkdown({ 
-			url: `/api/parse/business-cards/image/${image_path}`,
-			baseURL: import.meta.env.VITE_BASE_URL 
-		})
-	},
+	// getTalentMarkdown: async (image_path: string) => {
+	// 	return await request.downloadMarkdown({ 
+	// 		url: `/api/parse/business-cards/image/${image_path}`,
+	// 		baseURL: '' 
+	// 	})
+	// },
 
   // 非结构化数据源 名片解析
-	businessCardParse: async (data: any) => {
-		return await request.upload({ 
-			url: `/api/parse/business-card-parse`,
-			baseURL: import.meta.env.VITE_BASE_URL,
-			data 
-		})
-	},
+	// businessCardParse: async (data: any) => {
+	// 	return await request.upload({ 
+	// 		url: `/api/parse/business-card-parse`,
+	// 		baseURL: '',
+	// 		data 
+	// 	})
+	// },
 
 	// 非结构化数据源 创建名片
-	createBusinessCard: async (data: any) => {
-		return await request.upload({ 
-			url: `/api/parse/add-business-card`,
-			baseURL: import.meta.env.VITE_BASE_URL,
-			data
-		})
-	},
+	// createBusinessCard: async (data: any) => {
+	// 	return await request.upload({ 
+	// 		url: `/api/parse/add-business-card`,
+	// 		baseURL: '',
+	// 		data
+	// 	})
+	// },
 
 	// 结构化数据源 创建名片(不传递文件)
-	createBusinessCardPost: async (data: any) => {
-		return await request.post({ 
-			url: `/api/parse/add-business-card`,
-			baseURL: import.meta.env.VITE_BASE_URL,
-			data
-		})
-	},
+	// createBusinessCardPost: async (data: any) => {
+	// 	return await request.post({ 
+	// 		url: `/api/parse/add-business-card`,
+	// 		baseURL: '',
+	// 		data
+	// 	})
+	// },
 
 	// 非结构化数据源 更新名片
 	updateBusinessCard: async (data: any, id: any) => {
 		return await request.put({ 
 			url: `/api/parse/business-cards/${id}`,
-			baseURL: import.meta.env.VITE_BASE_URL,
+			baseURL: '',
 			data
 		})
 	},
 
 	// 非结构化数据源 更新名片状态
-	updateBusinessCardStatus: async (data: any, id: any) => {
-		return await request.put({ 
-			url: `/api/parse/update-business-cards/${id}/status`,
-			baseURL: import.meta.env.VITE_BASE_URL,
-			data
-		})
-	},
+	// updateBusinessCardStatus: async (data: any, id: any) => {
+	// 	return await request.put({ 
+	// 		url: `/api/parse/update-business-cards/${id}/status`,
+	// 		baseURL: '',
+	// 		data
+	// 	})
+	// },
 
 	// 非结构化数据源 获取名片图片
-	getBusinessCardImage: async (path: any) => {
-		return await request.download({ 
-			url: `/api/parse/business-cards/image/${path}`,
-			baseURL: import.meta.env.VITE_BASE_URL
-		})
-	},
+	// getBusinessCardImage: async (path: any) => {
+	// 	return await request.download({ 
+	// 		url: `/api/parse/business-cards/image/${path}`,
+	// 		baseURL: ''
+	// 	})
+	// },
 
 	// 删除名片记录
 	deleteBusinessCard: async (id: any) => {
 		return await request.delete({ 
 			url: `/api/parse/delete-business-card/${id}`,
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	}
-}
+}

+ 5 - 5
src/api/menduner/system/talentMap/position.ts

@@ -5,7 +5,7 @@ export const talentPositionApi = {
 	getTHotelPositionsList: async () => {
 		return await request.get({ 
 			url: `/api/parse/get-hotel-positions-list`, 
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -14,7 +14,7 @@ export const talentPositionApi = {
 		return await request.post({ 
 			url: `/api/parse/add-hotel-positions`, 
 			data, 
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -23,7 +23,7 @@ export const talentPositionApi = {
 		return await request.put({ 
 			url: `/api/parse/update-hotel-positions/${position_id}`, 
 			data, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: '' 
 		})
 	},
 
@@ -31,7 +31,7 @@ export const talentPositionApi = {
 	deleteHotelPosition: async (position_id: number) => {
 		return await request.delete({ 
 			url: `/api/parse/delete-hotel-positions/${position_id}`, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: '' 
 		})
 	}
-}
+}

+ 3 - 3
src/api/menduner/system/talentMap/search.ts

@@ -7,7 +7,7 @@ export const talentSearchApi = {
 			url: `/api/parse/query-kg`,
 			data,
 			signal,
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: '' 
 		})
 	},
 
@@ -15,7 +15,7 @@ export const talentSearchApi = {
 	getBusinessCardDetails: async (talent_id: number) => {
 		return await request.get({ 
 			url: `/api/parse/get-business-card/${talent_id}`, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: '' 
 		})
 	}
-}
+}

+ 6 - 6
src/api/menduner/system/talentMap/tag.ts

@@ -4,8 +4,8 @@ export const talentTagApi = {
 	// 标签列表
 	getTalentTagList: async () => {
 		return await request.get({ 
-			url: `/api/parse/get-talent-tag-list`, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			url: `/api/parse/get-talent-tag-list`,
+			baseURL: ''
 		})
 	},
 
@@ -14,7 +14,7 @@ export const talentTagApi = {
 		return await request.post({ 
 			url: `/api/parse/create-talent-tag`, 
 			data, 
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	},
 
@@ -23,7 +23,7 @@ export const talentTagApi = {
 		return await request.put({ 
 			url: `/api/parse/update-talent-tag/${tag_id}`, 
 			data, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: ''
 		})
 	},
 
@@ -31,7 +31,7 @@ export const talentTagApi = {
 	deleteTalentTag: async (tag_id: number) => {
 		return await request.delete({ 
 			url: `/api/parse/delete-talent-tag/${tag_id}`, 
-			baseURL: import.meta.env.VITE_BASE_URL 
+			baseURL: ''
 		})
 	}
-}
+}

+ 2 - 2
src/api/menduner/system/talentMap/webParsing.ts

@@ -7,7 +7,7 @@ export const talentWebParsingApi = {
 			url: '/api/parse/process-urls',
 			data,
 			timeout: 60000,
-			baseURL: import.meta.env.VITE_BASE_URL
+			baseURL: ''
 		})
 	}
-}
+}

+ 4 - 1
src/config/axios/index.ts

@@ -6,13 +6,16 @@ const { default_headers } = config
 
 const request = (option: any) => {
   const { url, method, params, data, headersType, responseType, baseURL, ...config } = option
+  // 如果 baseURL 为空字符串,保持为空字符串,这样 axios 会覆盖实例的默认 baseURL
+  // 使用相对路径,从而走 Vite 代理
+  // 如果 baseURL 为 undefined,则使用实例的默认 baseURL
   return service({
     url: url,
     method,
     params,
     data,
     ...config,
-    baseURL,
+    baseURL: baseURL === '' ? '' : baseURL, // 空字符串会覆盖默认 baseURL
     responseType: responseType,
     headers: {
       'Content-Type': headersType || default_headers

+ 4 - 0
src/config/axios/service.ts

@@ -43,6 +43,10 @@ const service: AxiosInstance = axios.create({
 // request拦截器
 service.interceptors.request.use(
   (config: InternalAxiosRequestConfig) => {
+    // 如果 baseURL 是空字符串,设置为当前域名,这样相对路径会走 Vite 代理
+    if (config.baseURL === '') {
+      config.baseURL = window.location.origin
+    }
     // 是否需要设置 token
     let isToken = (config!.headers || {}).isToken === false
     whiteList.some((v) => {

+ 1 - 1
vite.config.ts

@@ -40,7 +40,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
 
       proxy: {
         '/api': {
-          target: 'http://192.168.3.143:5500',
+          target: 'http://192.168.3.143:6600',
           // target: 'https://company.citupro.com:18183',
           secure: false, // 是否支持 https,默认 false
           changeOrigin: true, // 是否支持跨域