فهرست منبع

新任命抓取改为请求后端接口

Xiao_123 1 ماه پیش
والد
کامیت
8405384ef1

+ 6 - 15
src/api/menduner/system/talentMap/webParsing.ts

@@ -1,22 +1,13 @@
 import request from '@/config/axios'
 
 export const talentWebParsingApi = {
-	// 基于markdown格式解析人才信息
-	saveMarkdownContent: async (data: any) => {
-		return await request.post({ 
-			url: `/api/parse/webpage-parse`,
+	// 新任命网页内容抓取
+	processUrls: async (data: any) => {
+		return await request.post({
+			url: '/api/parse/process-urls',
 			data,
-			timeout: 300000,
+			timeout: 60000,
 			baseURL: import.meta.env.VITE_BASE_URL
 		})
-	},
-
-	// 网页解析-新增人才(多人)
-	webParsingTalentCreate: async (data: any) => {
-		return await request.post({ 
-			url: `/api/parse/add-webpage-talent`,
-			data,
-			baseURL: import.meta.env.VITE_BASE_URL
-		})
-	},
+	}
 }

+ 9 - 10
src/views/menduner/system/talentMap/maintenance/gather/components/webAnalysis.vue

@@ -240,11 +240,13 @@ const handleAnalysis = async () => {
 
 	if (urlArr.length > 1) return message.warning('只支持单个链接抓取')
 
-	const base_url = import.meta.env.VITE_NODE_BASE_URL
-	axios.post(`${base_url}/process-urls`, { urlArr }, { timeout: 60000 }).then(res => {
-		if (!res?.data || !res?.data?.contents || !res?.data?.contents.length) return
-		const list = res?.data?.contents
-		list.forEach(e => {
+  
+  try {
+    const data = await talentWebParsingApi.processUrls({ urlArr })
+    const list = data?.contents || []
+    if (!list || !list.length) return
+
+    list.forEach(e => {
 			contents.value.push({
 				...e,
 				publish_time: null,
@@ -257,12 +259,9 @@ const handleAnalysis = async () => {
 		})
 
     emit('analysis', contents.value)
-	}).catch(err => {
-		console.log(err, 'error');
-		message.error(err.message)
-	}).finally(_ => {
+  } finally {
     loading.close()
-	})
+  }
 }
 </script>
 

+ 5 - 5
vite.config.ts

@@ -52,11 +52,11 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
         //   changeOrigin: true,
         //   rewrite: (path) => path.replace(new RegExp(`^/weixin-article`), '')
         // },
-        '/process-urls': {
-          target: 'http://localhost:3300',
-          secure: true,
-          changeOrigin: true
-        }
+        // '/process-urls': {
+        //   target: 'http://localhost:3300',
+        //   secure: true,
+        //   changeOrigin: true
+        // }
       }
     },
     // 项目使用的vite插件。 单独提取到build/vite/plugin中管理