Browse Source

Merge remote-tracking branch 'origin/xq'

# Conflicts:
#	jshERP-web/src/utils/util.js
13660505945 1 week ago
parent
commit
02652c5bab
3 changed files with 14 additions and 10 deletions
  1. 1 1
      jshERP-web/.env.development
  2. 1 1
      jshERP-web/.env.staging
  3. 12 8
      jshERP-web/src/utils/util.js

+ 1 - 1
jshERP-web/.env.development

@@ -2,7 +2,7 @@
 # 开发环境配置
 ENV = 'development'
 
-NODE_ENV = development
+NODE_ENV = 'development'
 
 # ERP管理系统/开发环境
 VUE_APP_BASE_API = '/stage-api'

+ 1 - 1
jshERP-web/.env.staging

@@ -1,7 +1,7 @@
 # 页面标题
 VUE_APP_TITLE = ERP系统
 
-NODE_ENV = production
+NODE_ENV = 'production'
 
 # 测试环境配置
 ENV = 'staging'

+ 12 - 8
jshERP-web/src/utils/util.js

@@ -103,16 +103,20 @@ function generateChildRouters(data) {
   for (let item of data) {
     let componentPath = ''
     item.route = '1'
-    if (item.component.indexOf('layouts') >= 0) {
-      componentPath = (resolve) => require([`@/components${item.component}`], resolve)
+    if (process.env.NODE_ENV === 'production') {
+      if (item.component.indexOf('layouts') >= 0) {
+        componentPath = () => import('@/components' + item.component)
+      } else {
+        componentPath = () => import('@/views' + item.component)
+      }
     } else {
-      componentPath = (resolve) => require([`@/views${item.component}`], resolve)
+      if (item.component.indexOf('layouts') >= 0) {
+        componentPath = (resolve) => require([`@/components${item.component}`], resolve)
+      } else {
+        componentPath = (resolve) => require([`@/views${item.component}`], resolve)
+      }
     }
-    // if (item.component.indexOf('layouts') >= 0) {
-    //   componentPath = () => import('@/components' + item.component)
-    // } else {
-    //   componentPath = () => import('@/views' + item.component)
-    // }
+
     // eslint-disable-next-line
     let URL = (item.url || '').replace(/{{([^}}]+)?}}/g, (s1, s2) => eval(s2)) // URL支持{{ window.xxx }}占位符变量
     if (isURL(URL)) {