zlwu 11 mesiacov pred
rodič
commit
7aaeebccaa

BIN
art-design-pro/src/assets/img/favicon.ico


+ 52 - 1
art-design-pro/vite.config.ts

@@ -28,7 +28,58 @@ export default ({ mode }) => {
       proxy: {
         '/api': {
           target: VITE_API_URL,
-          changeOrigin: true
+          changeOrigin: true,
+          secure: false,
+          // 处理 FastAPI 的尾部斜杠重定向问题
+          configure: (proxy, options) => {
+            proxy.on('error', (err, req, res) => {
+              console.log('❌ Proxy error:', err)
+            })
+            proxy.on('proxyReq', (proxyReq, req, res) => {
+              // 处理 FastAPI 的尾部斜杠重定向问题
+              // FastAPI 的列表接口使用 @router.get("/"),需要尾部斜杠
+              // 例如:/api/plans -> /api/plans/
+              // 例如:/api/master-data/companies -> /api/master-data/companies/
+              const originalUrl = req.url || ''
+              if (originalUrl && !originalUrl.endsWith('/')) {
+                // 分离路径和查询参数
+                const [path, query] = originalUrl.split('?')
+                const pathParts = path.split('/').filter(Boolean)
+                
+                // 处理二级路径:/api/xxx(列表接口)
+                if (pathParts.length === 2 && pathParts[0] === 'api') {
+                  const resource = pathParts[1]
+                  // 列表接口资源:plans, inventory, weighing, users, companies, cargos
+                  const listResources = ['plans', 'inventory', 'weighing', 'users', 'companies', 'cargos']
+                  if (listResources.includes(resource)) {
+                    const newPath = path + '/' + (query ? '?' + query : '')
+                    proxyReq.path = newPath
+                    req.url = newPath
+                    console.log(`➡️  Proxying: ${req.method} ${originalUrl} -> ${VITE_API_URL}${newPath} (added trailing slash)`)
+                    return
+                  }
+                }
+                
+                // 处理三级路径:/api/master-data/xxx(基础资料模块)
+                if (pathParts.length === 3 && pathParts[0] === 'api' && pathParts[1] === 'master-data') {
+                  const resource = pathParts[2]
+                  // 基础资料模块的列表接口:companies, cargos
+                  const masterDataResources = ['companies', 'cargos']
+                  if (masterDataResources.includes(resource)) {
+                    const newPath = path + '/' + (query ? '?' + query : '')
+                    proxyReq.path = newPath
+                    req.url = newPath
+                    console.log(`➡️  Proxying: ${req.method} ${originalUrl} -> ${VITE_API_URL}${newPath} (added trailing slash)`)
+                    return
+                  }
+                }
+              }
+              console.log(`➡️  Proxying: ${req.method} ${req.url} -> ${VITE_API_URL}${req.url}`)
+            })
+            proxy.on('proxyRes', (proxyRes, req, res) => {
+              console.log(`⬅️  Response: ${req.url} -> ${proxyRes.statusCode}`)
+            })
+          }
         }
       },
       host: true

+ 4 - 1
mobile-h5/src/views/inventory/index.vue

@@ -375,7 +375,10 @@ const handleEdit = (record: InventoryRecord) => {
 const handleDelete = (id: number) => {
   showDialog({
     title: '确认删除',
-    message: '确定要删除这条记录吗?'
+    message: '确定要删除这条记录吗?',
+    showCancelButton: true,
+    cancelButtonText: '取消',
+    confirmButtonText: '确认'
   })
     .then(async () => {
       await inventoryApi.delete(id)

+ 8 - 2
mobile-h5/src/views/master-data/index.vue

@@ -258,7 +258,10 @@ const handleCompanyEdit = (item: Company) => {
 const handleCompanyDelete = (id: number) => {
   showDialog({
     title: '确认删除',
-    message: '确定要删除这个公司吗?'
+    message: '确定要删除这个公司吗?',
+    showCancelButton: true,
+    cancelButtonText: '取消',
+    confirmButtonText: '确认'
   })
     .then(async () => {
       await companyApi.delete(id)
@@ -279,7 +282,10 @@ const handleCargoEdit = (item: Cargo) => {
 const handleCargoDelete = (id: number) => {
   showDialog({
     title: '确认删除',
-    message: '确定要删除这个货物吗?'
+    message: '确定要删除这个货物吗?',
+    showCancelButton: true,
+    cancelButtonText: '取消',
+    confirmButtonText: '确认'
   })
     .then(async () => {
       await cargoApi.delete(id)

+ 4 - 1
mobile-h5/src/views/plans/index.vue

@@ -387,7 +387,10 @@ const handleViewRelated = async (record: Plan) => {
 const handleDelete = (id: number) => {
   showDialog({
     title: '确认删除',
-    message: '确定要删除这个计划吗?'
+    message: '确定要删除这个计划吗?',
+    showCancelButton: true,
+    cancelButtonText: '取消',
+    confirmButtonText: '确认'
   })
     .then(async () => {
       await planApi.delete(id)

+ 4 - 1
mobile-h5/src/views/user/index.vue

@@ -133,7 +133,10 @@ const handleDelete = (id: number, username: string) => {
 
   showDialog({
     title: '确认删除',
-    message: '确定要删除这个用户吗?'
+    message: '确定要删除这个用户吗?',
+    showCancelButton: true,
+    cancelButtonText: '取消',
+    confirmButtonText: '确认'
   })
     .then(async () => {
       await userApi.delete(id)

+ 8 - 2
mobile-h5/src/views/weighing/index.vue

@@ -362,7 +362,10 @@ const handleEdit = (record: WeighingRecord) => {
 const handleDelete = (id: number) => {
   showDialog({
     title: '确认删除',
-    message: '确定要删除这条记录吗?'
+    message: '确定要删除这条记录吗?',
+    showCancelButton: true,
+    cancelButtonText: '取消',
+    confirmButtonText: '确认'
   })
     .then(async () => {
       await weighingApi.delete(id)
@@ -375,7 +378,10 @@ const handleDelete = (id: number) => {
 const handleVoid = (id: number) => {
   showDialog({
     title: '确认作废',
-    message: '确定要作废这条地磅单吗?'
+    message: '确定要作废这条地磅单吗?',
+    showCancelButton: true,
+    cancelButtonText: '取消',
+    confirmButtonText: '确认'
   })
     .then(async () => {
       await weighingApi.void(id)

+ 38 - 0
mobile-h5/vite.config.ts

@@ -32,6 +32,44 @@ export default defineConfig(({ mode }) => {
               console.log('❌ Proxy error:', err)
             })
             proxy.on('proxyReq', (proxyReq, req, res) => {
+              // 处理 FastAPI 的尾部斜杠重定向问题
+              // FastAPI 的列表接口使用 @router.get("/"),需要尾部斜杠
+              // 例如:/api/plans -> /api/plans/
+              // 例如:/api/master-data/companies -> /api/master-data/companies/
+              const originalUrl = req.url || ''
+              if (originalUrl && !originalUrl.endsWith('/')) {
+                // 分离路径和查询参数
+                const [path, query] = originalUrl.split('?')
+                const pathParts = path.split('/').filter(Boolean)
+                
+                // 处理二级路径:/api/xxx(列表接口)
+                if (pathParts.length === 2 && pathParts[0] === 'api') {
+                  const resource = pathParts[1]
+                  // 列表接口资源:plans, inventory, weighing, users, companies, cargos
+                  const listResources = ['plans', 'inventory', 'weighing', 'users', 'companies', 'cargos']
+                  if (listResources.includes(resource)) {
+                    const newPath = path + '/' + (query ? '?' + query : '')
+                    proxyReq.path = newPath
+                    req.url = newPath
+                    console.log(`➡️  Proxying: ${req.method} ${originalUrl} -> ${apiBaseUrl}${newPath} (added trailing slash)`)
+                    return
+                  }
+                }
+                
+                // 处理三级路径:/api/master-data/xxx(基础资料模块)
+                if (pathParts.length === 3 && pathParts[0] === 'api' && pathParts[1] === 'master-data') {
+                  const resource = pathParts[2]
+                  // 基础资料模块的列表接口:companies, cargos
+                  const masterDataResources = ['companies', 'cargos']
+                  if (masterDataResources.includes(resource)) {
+                    const newPath = path + '/' + (query ? '?' + query : '')
+                    proxyReq.path = newPath
+                    req.url = newPath
+                    console.log(`➡️  Proxying: ${req.method} ${originalUrl} -> ${apiBaseUrl}${newPath} (added trailing slash)`)
+                    return
+                  }
+                }
+              }
               console.log(`➡️  Proxying: ${req.method} ${req.url} -> ${apiBaseUrl}${req.url}`)
             })
             proxy.on('proxyRes', (proxyRes, req, res) => {