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

1.0.75,修改 Common 中获取API的方法,增加Proxy

YangZhiJie 2 лет назад
Родитель
Сommit
9c689eb8c4
6 измененных файлов с 18 добавлено и 11 удалено
  1. 1 0
      .eslintrc.js
  2. 1 1
      .vscode/settings.json
  3. 1 1
      package.json
  4. 13 7
      packages/common/Common.js
  5. 1 1
      packages/common/Notify.js
  6. 1 1
      packages/components.js

+ 1 - 0
.eslintrc.js

@@ -79,5 +79,6 @@ module.exports = {
     'window': true,
     'BootstrapDialog': true,
     'moment': true,
+    'REMOTE_DEV_PORT': true
   },
 };

+ 1 - 1
.vscode/settings.json

@@ -12,7 +12,7 @@
       },
       // 保存后自动修复格式  
       "editor.codeActionsOnSave": {
-            "source.fixAll.eslint": true
+            "source.fixAll.eslint": "explicit"
       },
       // 添加vue支持  
       "eslint.validate": [

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pc-component-v3",
-  "version": "1.0.74",
+  "version": "1.0.75",
   "description": "",
   "main": "dist/pc-component-v3.js",
   "scripts": {

+ 13 - 7
packages/common/Common.js

@@ -60,12 +60,18 @@ export default {
   },
 
   getHostPageBaseURL: function () {
-    return this.getRootPath() + '/';
+    //return this.getRootPath() + '/';
+    // changed by jack 增加代理的配置。
+    if(typeof REMOTE_DEV_PORT !== 'undefined' && REMOTE_DEV_PORT != null){
+      return this.getRootPath() + '/proxy/' + REMOTE_DEV_PORT + '/';
+    }else{
+      return this.getRootPath() + '/';
+    }
   },
 
   // 获取图片路径url
   getFileServerUrl: function () {
-    return this.getRootPath() + '/';
+    return this.getHostPageBaseURL() + '/';
   },
 
   // 获取API的地址
@@ -80,12 +86,12 @@ export default {
    */
   getApiUrl2: function (apiName) {
     if (apiName === undefined || apiName === null || apiName.length === 0) {
-      return this.getRootPath();
+      return this.getHostPageBaseURL();
     }
     if (apiName[0] === '/') {
-      return this.getRootPath() + apiName;
+      return this.getHostPageBaseURL() + apiName;
     } else {
-      return this.getRootPath() + '/' + apiName;
+      return this.getHostPageBaseURL() + '/' + apiName;
     }
   },
 
@@ -204,9 +210,9 @@ export default {
   getRedirectUrl: function (url) {
     var href = window.location.href;
     if (href.indexOf('pcapp') >= 0) {
-      return this.getRootPath() + '/pcapp/' + url;
+      return this.getHostPageBaseURL() + '/pcapp/' + url;
     } else {
-      return this.getRootPath() + '/' + url;
+      return this.getHostPageBaseURL() + '/' + url;
     }
   },
 

+ 1 - 1
packages/common/Notify.js

@@ -1,4 +1,4 @@
-import ModalFix from '../modal/src/ModalFix.JS';
+import ModalFix from '../modal/src/ModalFix';
 
 export default {
   /**

+ 1 - 1
packages/components.js

@@ -1,6 +1,6 @@
 import Loading from './loading/index.js';
 import Modal from './modal/index.js';
-import DateTime from './dateTime/index.js';
+import DateTime from './datetime/index.js';
 import Date from './date/index.js';
 import Checkbox from './checkbox/index.js';
 import PageSizeSelect from './page-size-select/index.js';