Просмотр исходного кода

fix: 修复 H5 环境下 Taro 模块导入问题

- H5 环境下启用 prebundle 以确保 ESM/CJS 模块正确解析
- 微信小程序环境保持关闭以满足 2MB 主包限制
- 暂时禁用薪资记录功能,等待后端数据库支持

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
yourname 4 недель назад
Родитель
Сommit
8da0adc0d0
3 измененных файлов с 29 добавлено и 11 удалено
  1. 4 2
      mini-talent/config/dev.ts
  2. 21 7
      mini-talent/src/pages/employment/index.tsx
  3. 4 2
      mini/config/dev.ts

+ 4 - 2
mini-talent/config/dev.ts

@@ -6,11 +6,13 @@ export default {
     stats: true
   },
   compiler: {
+    type: 'webpack5',
     // 关闭开发模式的依赖预编译,减少主包体积以支持微信小程序开发版预览(2MB限制)
+    // 注意:H5 环境下需要启用 prebundle 以确保 ESM/CJS 模块正确解析
     prebundle: {
-      enable: false
+      enable: process.env.TARO_ENV === 'weapp' ? false : true
     }
-  },
+  } as any,
   mini: {},
   h5: {
     devServer: {

+ 21 - 7
mini-talent/src/pages/employment/index.tsx

@@ -17,7 +17,8 @@ import { useRequireAuth } from '../../hooks'
 
 // 组件导入
 import { CurrentEmploymentStatus } from '../../components/CurrentEmploymentStatus'
-import { SalaryRecords } from '../../components/SalaryRecords'
+// 薪资记录组件暂时禁用 - 待后端数据库支持后启用
+// import { SalaryRecords } from '../../components/SalaryRecords'
 import { EmploymentHistory } from '../../components/EmploymentHistory'
 
 // API客户端导入
@@ -26,7 +27,7 @@ import { talentEmploymentClient } from '../../api'
 // 类型导入
 import {
   CurrentEmploymentStatus as CurrentEmploymentStatusType,
-  SalaryRecord,
+  // SalaryRecord, // 暂时禁用
   EmploymentHistoryItem,
   WorkStatus
 } from '../../types/employment'
@@ -56,7 +57,11 @@ const EmploymentPage: React.FC = () => {
     }
   })
 
-  // 获取薪资记录
+  /*
+   * 获取薪资记录 - 暂时禁用
+   * TODO: 待后端数据库支持后启用
+   */
+  /*
   const { data: salaryRecordsData, isLoading: salaryLoading, error: salaryError } = useQuery({
     queryKey: ['salary-records'],
     queryFn: async () => {
@@ -75,6 +80,7 @@ const EmploymentPage: React.FC = () => {
       return (data.data || []) as SalaryRecord[]
     }
   })
+  */
 
   // 获取就业历史
   const { data: employmentHistoryData, isLoading: historyLoading, error: historyError } = useQuery({
@@ -104,6 +110,8 @@ const EmploymentPage: React.FC = () => {
     }
   }, [statusError])
 
+  // 薪资记录错误处理 - 暂时禁用
+  /*
   React.useEffect(() => {
     if (salaryError) {
       Taro.showToast({
@@ -112,6 +120,7 @@ const EmploymentPage: React.FC = () => {
       })
     }
   }, [salaryError])
+  */
 
   React.useEffect(() => {
     if (historyError) {
@@ -122,13 +131,15 @@ const EmploymentPage: React.FC = () => {
     }
   }, [historyError])
 
-  // 处理查看全部薪资记录
+  /*
+   * 处理查看全部薪资记录 - 暂时禁用
   const handleViewAllSalaryRecords = () => {
     Taro.showToast({
       title: '全部薪资记录功能开发中',
       icon: 'none'
     })
   }
+  */
 
   return (
     <View className="h-screen bg-gray-100 flex flex-col">
@@ -156,15 +167,18 @@ const EmploymentPage: React.FC = () => {
           <CurrentEmploymentStatus status={currentStatus || null} loading={statusLoading} />
         </View>
 
-        {/* 薪资记录卡片 */}
-        <View className="px-4">
+        {/* 薪资记录卡片 - 暂时隐藏
+         * TODO: 后端数据库结构尚不支持薪资记录功能,待数据库结构支持后再启用
+         * 相关API: GET /api/v1/rencai/employment/salary-records
+         */}
+        {/* <View className="px-4">
           <SalaryRecords
             records={salaryRecordsData || []}
             loading={salaryLoading}
             onViewAll={handleViewAllSalaryRecords}
             showViewAll={true}
           />
-        </View>
+        </View> */}
 
         {/* 就业历史时间线 */}
         <View className="px-4 pb-4">

+ 4 - 2
mini/config/dev.ts

@@ -6,11 +6,13 @@ export default {
     stats: true
   },
   compiler: {
+    type: 'webpack5',
     // 关闭开发模式的依赖预编译,减少主包体积以支持微信小程序开发版预览(2MB限制)
+    // 注意:H5 环境下需要启用 prebundle 以确保 ESM/CJS 模块正确解析
     prebundle: {
-      enable: false
+      enable: process.env.TARO_ENV === 'weapp' ? false : true
     }
-  },
+  } as any,
   mini: {
     compile: {
       include: [