@yilianjituan/yilian_dgerm 0.0.1-alpha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +50 -0
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/commonAxios/Axios.d.ts +42 -0
- package/dist/commonAxios/Axios.js +300 -0
- package/dist/commonAxios/http.d.ts +3 -0
- package/dist/commonAxios/http.js +23 -0
- package/dist/commonAxios/index.d.ts +2 -0
- package/dist/commonAxios/index.js +177 -0
- package/dist/commonAxios/juicer.d.ts +8 -0
- package/dist/commonAxios/juicer.js +58 -0
- package/dist/commonData/address.d.ts +22 -0
- package/dist/commonData/address.js +1 -0
- package/dist/commonImg/ic_im_no_archives_new.png +0 -0
- package/dist/commonType/globalEnum.d.ts +398 -0
- package/dist/commonType/globalEnum.js +527 -0
- package/dist/commonType/globalFun.d.ts +31 -0
- package/dist/commonType/globalFun.js +104 -0
- package/dist/components/BigImage/index.d.ts +4 -0
- package/dist/components/BigImage/index.interface.d.ts +25 -0
- package/dist/components/BigImage/index.interface.js +1 -0
- package/dist/components/BigImage/index.js +36 -0
- package/dist/components/DropDownSelect/index.d.ts +4 -0
- package/dist/components/DropDownSelect/index.interface.d.ts +62 -0
- package/dist/components/DropDownSelect/index.interface.js +1 -0
- package/dist/components/DropDownSelect/index.js +211 -0
- package/dist/components/EmptyDom/index.d.ts +4 -0
- package/dist/components/EmptyDom/index.interface.d.ts +17 -0
- package/dist/components/EmptyDom/index.interface.js +1 -0
- package/dist/components/EmptyDom/index.js +22 -0
- package/dist/components/Entry/index.d.ts +5 -0
- package/dist/components/Entry/index.interface.d.ts +7 -0
- package/dist/components/Entry/index.interface.js +1 -0
- package/dist/components/Entry/index.js +8 -0
- package/dist/components/Entry/index.scss +3 -0
- package/dist/components/ExportExcels/ExportExcels.scss +12 -0
- package/dist/components/ExportExcels/index.d.ts +10 -0
- package/dist/components/ExportExcels/index.interface.d.ts +12 -0
- package/dist/components/ExportExcels/index.interface.js +1 -0
- package/dist/components/ExportExcels/index.js +31 -0
- package/dist/components/FilterRadio/index.d.ts +5 -0
- package/dist/components/FilterRadio/index.interface.d.ts +62 -0
- package/dist/components/FilterRadio/index.interface.js +1 -0
- package/dist/components/FilterRadio/index.js +76 -0
- package/dist/components/FilterRadio/index.scss +60 -0
- package/dist/components/MyBtn/index.d.ts +4 -0
- package/dist/components/MyBtn/index.interface.d.ts +13 -0
- package/dist/components/MyBtn/index.interface.js +1 -0
- package/dist/components/MyBtn/index.js +12 -0
- package/dist/components/NumberInput/index.d.ts +5 -0
- package/dist/components/NumberInput/index.interface.d.ts +3 -0
- package/dist/components/NumberInput/index.interface.js +1 -0
- package/dist/components/NumberInput/index.js +47 -0
- package/dist/components/NumberInput/index.scss +3 -0
- package/dist/components/PageTemplate/index.d.ts +5 -0
- package/dist/components/PageTemplate/index.interface.d.ts +54 -0
- package/dist/components/PageTemplate/index.interface.js +1 -0
- package/dist/components/PageTemplate/index.js +340 -0
- package/dist/components/PageTemplate/index.scss +72 -0
- package/dist/components/SelectMax/index.d.ts +4 -0
- package/dist/components/SelectMax/index.interface.d.ts +21 -0
- package/dist/components/SelectMax/index.interface.js +1 -0
- package/dist/components/SelectMax/index.js +63 -0
- package/dist/components/SuperCascader/index.d.ts +4 -0
- package/dist/components/SuperCascader/index.interface.d.ts +13 -0
- package/dist/components/SuperCascader/index.interface.js +1 -0
- package/dist/components/SuperCascader/index.js +26 -0
- package/dist/components/SuperInput/index.d.ts +4 -0
- package/dist/components/SuperInput/index.interface.d.ts +11 -0
- package/dist/components/SuperInput/index.interface.js +1 -0
- package/dist/components/SuperInput/index.js +70 -0
- package/dist/components/VideoProgressModal/index.d.ts +5 -0
- package/dist/components/VideoProgressModal/index.interface.d.ts +11 -0
- package/dist/components/VideoProgressModal/index.interface.js +1 -0
- package/dist/components/VideoProgressModal/index.js +16 -0
- package/dist/components/VideoProgressModal/index.scss +27 -0
- package/dist/components/YLModal/drag.d.ts +3 -0
- package/dist/components/YLModal/drag.js +56 -0
- package/dist/components/YLModal/index.d.ts +4 -0
- package/dist/components/YLModal/index.interface.d.ts +21 -0
- package/dist/components/YLModal/index.interface.js +1 -0
- package/dist/components/YLModal/index.js +35 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -0
- package/dist/react-app-env.d.ts +18 -0
- package/dist/utils/common.d.ts +14 -0
- package/dist/utils/common.js +105 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/notificationHelper.d.ts +7 -0
- package/dist/utils/notificationHelper.js +27 -0
- package/dist/utils/responseMessage.d.ts +50 -0
- package/dist/utils/responseMessage.js +56 -0
- package/dist/utils/userSessionActions.d.ts +31 -0
- package/dist/utils/userSessionActions.js +37 -0
- package/package.json +113 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: require.resolve('@umijs/lint/dist/config/eslint'),
|
|
3
|
+
parser: "@typescript-eslint/parser",
|
|
4
|
+
extends: ["plugin:@typescript-eslint/recommended"],
|
|
5
|
+
globals: {
|
|
6
|
+
requirePlugin: true
|
|
7
|
+
},
|
|
8
|
+
plugins: ["@typescript-eslint", "react"],
|
|
9
|
+
root: true,
|
|
10
|
+
rules: {
|
|
11
|
+
"no-unused-vars": ["off"],
|
|
12
|
+
"react/sort-comp": 0,
|
|
13
|
+
"import/no-commonjs": 0,
|
|
14
|
+
"import/prefer-default-export": 0,
|
|
15
|
+
"import/no-unresolved": 0,
|
|
16
|
+
"no-debugger": "error",
|
|
17
|
+
"no-empty": "error",
|
|
18
|
+
"no-extra-semi": "error",
|
|
19
|
+
"semi": ["error", "always"],
|
|
20
|
+
"no-unreachable": "error",
|
|
21
|
+
"eqeqeq": "error",
|
|
22
|
+
"no-empty-function": "error",
|
|
23
|
+
"no-multi-spaces": "error",
|
|
24
|
+
// "max-len": ["error", { "code": 140 }],
|
|
25
|
+
"no-multiple-empty-lines": ["error", { "max": 1 }],
|
|
26
|
+
"arrow-spacing": "error",
|
|
27
|
+
// "spaced-comment": ["error", "always"],
|
|
28
|
+
"block-spacing": "error",
|
|
29
|
+
"keyword-spacing": "error",
|
|
30
|
+
"semi-spacing": ["error", { "before": false, "after": true }],
|
|
31
|
+
"no-undef-init": "error",
|
|
32
|
+
"no-multi-str": "error",
|
|
33
|
+
"key-spacing": ["error", { "beforeColon": false, "afterColon": true }],
|
|
34
|
+
"no-regex-spaces": "error",
|
|
35
|
+
"no-eval": "error",
|
|
36
|
+
"camelcase": "error",
|
|
37
|
+
"indent": "off",
|
|
38
|
+
// "indent": ["error", 4], // ?? switch case 的 indent 异常
|
|
39
|
+
// "no-console": "error",
|
|
40
|
+
"space-infix-ops": "error",
|
|
41
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
42
|
+
"@typescript-eslint/explicit-module-boundary-types": "off",
|
|
43
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
44
|
+
"spaced-comment": "off",
|
|
45
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
46
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
47
|
+
//未用到的变量可以使用_
|
|
48
|
+
"@typescript-eslint/no-unused-vars": ["warn", { "varsIgnorePattern": "_" }]
|
|
49
|
+
}
|
|
50
|
+
};
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# yilian_dgerm
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.org/package/node_modules)
|
|
4
|
+
[](https://npmjs.org/package/node_modules)
|
|
5
|
+
|
|
6
|
+
A react library developed with dumi
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
TODO
|
|
11
|
+
|
|
12
|
+
## Options
|
|
13
|
+
|
|
14
|
+
TODO
|
|
15
|
+
|
|
16
|
+
## Development
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# install dependencies
|
|
20
|
+
$ yarn install
|
|
21
|
+
|
|
22
|
+
# develop library by docs demo
|
|
23
|
+
$ yarn start
|
|
24
|
+
|
|
25
|
+
# build library source code
|
|
26
|
+
$ yarn run build
|
|
27
|
+
|
|
28
|
+
# build library source code in watch mode
|
|
29
|
+
$ yarn run build:watch
|
|
30
|
+
|
|
31
|
+
# build docs
|
|
32
|
+
$ yarn run docs:build
|
|
33
|
+
|
|
34
|
+
# Locally preview the production build.
|
|
35
|
+
$ yarn run docs:preview
|
|
36
|
+
|
|
37
|
+
# check your project for potential problems
|
|
38
|
+
$ yarn run doctor
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## LICENSE
|
|
42
|
+
|
|
43
|
+
MIT
|
|
44
|
+
|
|
45
|
+
# 2024.10.17 更新日志
|
|
46
|
+
1 构建dumi项目 执行组件库
|
|
47
|
+
2 引用发布后的组件,可执行
|
|
48
|
+
|
|
49
|
+
# 2024.10.18 更新日志
|
|
50
|
+
1 配置dumi组件库,执行jenkins 编译成功
|
|
51
|
+
2 配置dumi组件库目录 配置路径指向
|
|
52
|
+
3 截止目前,该组件库可正常开发与使用
|
|
53
|
+
|
|
54
|
+
# 2024.10.21 更新日志
|
|
55
|
+
1、添加自动API配置及说明
|
|
56
|
+
2、添加导航及入口配置
|
|
57
|
+
3、首页配置调整
|
|
58
|
+
4、FilterRadio组件封装
|
|
59
|
+
5、SelectMax组件封装
|
|
60
|
+
6、ExportExcels组件封装
|
|
61
|
+
7、发布插件:依赖引用修改
|
|
62
|
+
|
|
63
|
+
# 2024.10.22 更新日志
|
|
64
|
+
1、更新文档使用说明
|
|
65
|
+
2、解决dayjs引用路径的问题
|
|
66
|
+
3、解决宿主插件引用报错的问题
|
|
67
|
+
4、SelectMax宿主引用组件调试
|
|
68
|
+
5、解决ant-design/icons打包报错的问题
|
|
69
|
+
6、更换样式插件,统一使用sass
|
|
70
|
+
7、PageTemplate组件封装
|
|
71
|
+
8、PageTemplate宿主引用与调试
|
|
72
|
+
|
|
73
|
+
# 2024.10.23 更新日志
|
|
74
|
+
1、EmptyDom 组件封装
|
|
75
|
+
2、EmptyDom 宿主引用与调试
|
|
76
|
+
3、SuperInput 组件封装
|
|
77
|
+
4、SuperInput 宿主引用与调试
|
|
78
|
+
5、DropDownSelect 组件封装
|
|
79
|
+
6、DropDownSelect 宿主引用与调试
|
|
80
|
+
7、公共方法引入处理
|
|
81
|
+
8、删除调试组件
|
|
82
|
+
9、YLModal 组件封装
|
|
83
|
+
10、YLModal 宿主引用与调试
|
|
84
|
+
|
|
85
|
+
# 2024.10.24 更新日志
|
|
86
|
+
1、SuperCascader 组件封装
|
|
87
|
+
2、SuperCascader 宿主引用与调试
|
|
88
|
+
3、BigImage 组件封装
|
|
89
|
+
4、BigImage 宿主引用与调试
|
|
90
|
+
5、解决rc-viewer插件打包报错的问题
|
|
91
|
+
6、组件文档调整
|
|
92
|
+
|
|
93
|
+
# 2024.10.28 更新日志
|
|
94
|
+
1、VideoProgressModal 组件封装
|
|
95
|
+
2、VideoProgressModal 宿主引用与调试
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { AxiosInstance, AxiosRequestConfig } from "axios";
|
|
2
|
+
interface ResponseResult<T> {
|
|
3
|
+
code: string;
|
|
4
|
+
message: string;
|
|
5
|
+
result: T;
|
|
6
|
+
application: string;
|
|
7
|
+
traceId: string;
|
|
8
|
+
}
|
|
9
|
+
type HttpMethodType = <T>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig, requestConfigData?: requestConfigData) => Promise<ResponseResult<T>>;
|
|
10
|
+
type HttpTestType = <T>(url: string, data?: Record<string, any>, useFetch?: boolean) => Promise<ResponseResult<T>>;
|
|
11
|
+
interface requestConfigData {
|
|
12
|
+
errorToast?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export default class Axios {
|
|
15
|
+
config: AxiosRequestConfig;
|
|
16
|
+
instance: AxiosInstance;
|
|
17
|
+
constructor(config: AxiosRequestConfig);
|
|
18
|
+
private defaultOptions;
|
|
19
|
+
private interceptor;
|
|
20
|
+
/**
|
|
21
|
+
* 通用请求方法
|
|
22
|
+
* @param config
|
|
23
|
+
* http.request({method:'get',params:{id:"xxx"}})
|
|
24
|
+
*/
|
|
25
|
+
request<T, D = ResponseResult<T>>(config: AxiosRequestConfig): Promise<D>;
|
|
26
|
+
private requestByMethod;
|
|
27
|
+
/**
|
|
28
|
+
* 根据method类型返回请求
|
|
29
|
+
* @param method
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
private generateFun;
|
|
33
|
+
get: HttpMethodType;
|
|
34
|
+
put: HttpMethodType;
|
|
35
|
+
post: HttpMethodType;
|
|
36
|
+
delete: HttpMethodType;
|
|
37
|
+
test: HttpTestType;
|
|
38
|
+
upload(url: string, data: Record<string, any>): Promise<import("axios").AxiosResponse<any, any>>;
|
|
39
|
+
private interceptorRequest;
|
|
40
|
+
private interceptorResponse;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
import axios from "axios";
|
|
14
|
+
import { callBackMessage } from "../utils";
|
|
15
|
+
import { userSessionActions } from "../utils";
|
|
16
|
+
import { notificationHelper } from "../utils";
|
|
17
|
+
import qs from "qs";
|
|
18
|
+
import juicer from "./juicer";
|
|
19
|
+
// 参数过滤默认规则
|
|
20
|
+
var defaultRulesOptions = {
|
|
21
|
+
noEmoji: false,
|
|
22
|
+
// 默认不过滤表情
|
|
23
|
+
noEmptyString: true // 默认过滤空字符串
|
|
24
|
+
};
|
|
25
|
+
var Axios = /*#__PURE__*/function () {
|
|
26
|
+
function Axios(config) {
|
|
27
|
+
_classCallCheck(this, Axios);
|
|
28
|
+
_defineProperty(this, "instance", void 0);
|
|
29
|
+
_defineProperty(this, "defaultOptions", {
|
|
30
|
+
errorToast: true // 是否自动抛出异常
|
|
31
|
+
});
|
|
32
|
+
_defineProperty(this, "get", this.generateFun("get"));
|
|
33
|
+
_defineProperty(this, "put", this.generateFun("put"));
|
|
34
|
+
_defineProperty(this, "post", this.generateFun("post"));
|
|
35
|
+
_defineProperty(this, "delete", this.generateFun("delete"));
|
|
36
|
+
_defineProperty(this, "test", function (url, params, useFetch) {
|
|
37
|
+
if (useFetch) {
|
|
38
|
+
var host = "http://127.0.0.1:3002/";
|
|
39
|
+
return fetch(host + url).then( /*#__PURE__*/function () {
|
|
40
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(r) {
|
|
41
|
+
var result;
|
|
42
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
43
|
+
while (1) switch (_context.prev = _context.next) {
|
|
44
|
+
case 0:
|
|
45
|
+
_context.next = 2;
|
|
46
|
+
return r.json();
|
|
47
|
+
case 2:
|
|
48
|
+
result = _context.sent;
|
|
49
|
+
return _context.abrupt("return", {
|
|
50
|
+
code: "OK",
|
|
51
|
+
message: url,
|
|
52
|
+
result: result,
|
|
53
|
+
application: "",
|
|
54
|
+
traceId: ""
|
|
55
|
+
});
|
|
56
|
+
case 4:
|
|
57
|
+
case "end":
|
|
58
|
+
return _context.stop();
|
|
59
|
+
}
|
|
60
|
+
}, _callee);
|
|
61
|
+
}));
|
|
62
|
+
return function (_x) {
|
|
63
|
+
return _ref.apply(this, arguments);
|
|
64
|
+
};
|
|
65
|
+
}());
|
|
66
|
+
}
|
|
67
|
+
return new Promise(function (resove) {
|
|
68
|
+
setTimeout(function () {
|
|
69
|
+
resove({
|
|
70
|
+
code: "OK",
|
|
71
|
+
message: url,
|
|
72
|
+
result: params,
|
|
73
|
+
application: "",
|
|
74
|
+
traceId: ""
|
|
75
|
+
});
|
|
76
|
+
}, 0);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
this.config = config;
|
|
80
|
+
this.instance = axios.create(config);
|
|
81
|
+
this.interceptor();
|
|
82
|
+
}
|
|
83
|
+
_createClass(Axios, [{
|
|
84
|
+
key: "interceptor",
|
|
85
|
+
value: function interceptor() {
|
|
86
|
+
this.interceptorRequest();
|
|
87
|
+
this.interceptorResponse();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* 通用请求方法
|
|
92
|
+
* @param config
|
|
93
|
+
* http.request({method:'get',params:{id:"xxx"}})
|
|
94
|
+
*/
|
|
95
|
+
}, {
|
|
96
|
+
key: "request",
|
|
97
|
+
value: (function () {
|
|
98
|
+
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(config) {
|
|
99
|
+
var response;
|
|
100
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
101
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
102
|
+
case 0:
|
|
103
|
+
_context2.next = 2;
|
|
104
|
+
return this.instance.request(config);
|
|
105
|
+
case 2:
|
|
106
|
+
response = _context2.sent;
|
|
107
|
+
return _context2.abrupt("return", response.data);
|
|
108
|
+
case 4:
|
|
109
|
+
case "end":
|
|
110
|
+
return _context2.stop();
|
|
111
|
+
}
|
|
112
|
+
}, _callee2, this);
|
|
113
|
+
}));
|
|
114
|
+
function request(_x2) {
|
|
115
|
+
return _request.apply(this, arguments);
|
|
116
|
+
}
|
|
117
|
+
return request;
|
|
118
|
+
}())
|
|
119
|
+
}, {
|
|
120
|
+
key: "requestByMethod",
|
|
121
|
+
value: function () {
|
|
122
|
+
var _requestByMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(method, url, params, config, requestDefaultOptions) {
|
|
123
|
+
var axiosMethod, response;
|
|
124
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
125
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
126
|
+
case 0:
|
|
127
|
+
this.defaultOptions = _objectSpread(_objectSpread({}, this.defaultOptions), requestDefaultOptions);
|
|
128
|
+
axiosMethod = this.instance[method];
|
|
129
|
+
if (!axiosMethod) {
|
|
130
|
+
_context3.next = 9;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
_context3.next = 5;
|
|
134
|
+
return axiosMethod(url, params, config);
|
|
135
|
+
case 5:
|
|
136
|
+
response = _context3.sent;
|
|
137
|
+
return _context3.abrupt("return", response.data);
|
|
138
|
+
case 9:
|
|
139
|
+
throw new Error("Invalid method: ".concat(method));
|
|
140
|
+
case 10:
|
|
141
|
+
case "end":
|
|
142
|
+
return _context3.stop();
|
|
143
|
+
}
|
|
144
|
+
}, _callee3, this);
|
|
145
|
+
}));
|
|
146
|
+
function requestByMethod(_x3, _x4, _x5, _x6, _x7) {
|
|
147
|
+
return _requestByMethod.apply(this, arguments);
|
|
148
|
+
}
|
|
149
|
+
return requestByMethod;
|
|
150
|
+
}()
|
|
151
|
+
/**
|
|
152
|
+
* 根据method类型返回请求
|
|
153
|
+
* @param method
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
156
|
+
}, {
|
|
157
|
+
key: "generateFun",
|
|
158
|
+
value: function generateFun(method) {
|
|
159
|
+
var _this = this;
|
|
160
|
+
return function (url, data, config, requestConfig) {
|
|
161
|
+
var params;
|
|
162
|
+
if (["options", "get", "delete"].includes(method) && data) {
|
|
163
|
+
params = data.params ? data : {
|
|
164
|
+
params: data
|
|
165
|
+
};
|
|
166
|
+
} else {
|
|
167
|
+
params = data;
|
|
168
|
+
}
|
|
169
|
+
return _this.requestByMethod(method, url, params, config, requestConfig);
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "upload",
|
|
174
|
+
value: function upload(url, data) {
|
|
175
|
+
var formData = new FormData();
|
|
176
|
+
for (var key in data) {
|
|
177
|
+
if (data.hasOwnProperty(key)) {
|
|
178
|
+
formData.append(key, data[key]);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return axios({
|
|
182
|
+
method: "post",
|
|
183
|
+
url: this.config.baseURL + url,
|
|
184
|
+
data: formData,
|
|
185
|
+
headers: {
|
|
186
|
+
token: sessionStorage.getItem("X_ACCESS_TOKEN"),
|
|
187
|
+
product: process.env.REACT_APP_PRODUCT,
|
|
188
|
+
"Content-Type": "multipart/form-data"
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
}, {
|
|
193
|
+
key: "interceptorRequest",
|
|
194
|
+
value: function interceptorRequest() {
|
|
195
|
+
this.instance.interceptors.request.use(function (config) {
|
|
196
|
+
var params = config.params;
|
|
197
|
+
// console.log(this.defaultOptions);
|
|
198
|
+
|
|
199
|
+
// 接受rules
|
|
200
|
+
var rules = params && params.rules ? _objectSpread(_objectSpread({}, defaultRulesOptions), params.rules) : _objectSpread({}, defaultRulesOptions);
|
|
201
|
+
|
|
202
|
+
// 在发送请求之前做些什么
|
|
203
|
+
var token = sessionStorage.getItem("X_ACCESS_TOKEN");
|
|
204
|
+
if (token) config.headers["token"] = token;
|
|
205
|
+
if (config.data && !(config.data instanceof FormData)) {
|
|
206
|
+
config.data = JSON.stringify(config.data);
|
|
207
|
+
}
|
|
208
|
+
if (config.method === "get") {
|
|
209
|
+
// 处理get请求传参数为数组
|
|
210
|
+
config.paramsSerializer = function (params) {
|
|
211
|
+
return qs.stringify(params, {
|
|
212
|
+
arrayFormat: 'comma'
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
config.params = _objectSpread({
|
|
216
|
+
_t: Date.parse(new Date().toString()) / 1000
|
|
217
|
+
}, config.params);
|
|
218
|
+
}
|
|
219
|
+
config.withCredentials = true;
|
|
220
|
+
|
|
221
|
+
// 参数拦截处理
|
|
222
|
+
config.params = juicer(_objectSpread({}, config.params), rules);
|
|
223
|
+
|
|
224
|
+
// 删除携带的rules
|
|
225
|
+
delete config.params.rules;
|
|
226
|
+
return config;
|
|
227
|
+
}, function (error) {
|
|
228
|
+
// 对请求错误做些什么
|
|
229
|
+
return Promise.reject(error);
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}, {
|
|
233
|
+
key: "interceptorResponse",
|
|
234
|
+
value: function interceptorResponse() {
|
|
235
|
+
var _this2 = this;
|
|
236
|
+
this.instance.interceptors.response.use(function (response) {
|
|
237
|
+
// 2xx 范围内的状态码都会触发该函数。
|
|
238
|
+
// 对响应数据做点什么
|
|
239
|
+
// return response;
|
|
240
|
+
if (response.config.responseType === "blob") {
|
|
241
|
+
return response;
|
|
242
|
+
}
|
|
243
|
+
if (response.data.code === "OK") {
|
|
244
|
+
return response;
|
|
245
|
+
} else {
|
|
246
|
+
switch (response.data.code) {
|
|
247
|
+
case "USER_LOCKED":
|
|
248
|
+
case "DMS_STORE_LOCKED_ERROR":
|
|
249
|
+
case "AGENCY_NOT_FOUND_ERROR":
|
|
250
|
+
notificationHelper.error(response.data.message);
|
|
251
|
+
break;
|
|
252
|
+
case "AUTH_TOKEN_NOT_FOUND":
|
|
253
|
+
case "TOKEN_VALIDATE_ERROR":
|
|
254
|
+
case "TOKEN_REQUIRED":
|
|
255
|
+
window.location.href = userSessionActions["DEF_USER"];
|
|
256
|
+
break;
|
|
257
|
+
case "Method Not Allowed":
|
|
258
|
+
case "Data Validate Error":
|
|
259
|
+
case "balance_not_enough":
|
|
260
|
+
case "duplicate_data":
|
|
261
|
+
notificationHelper.error(response.data.message);
|
|
262
|
+
break;
|
|
263
|
+
case "Not Found":
|
|
264
|
+
notificationHelper.error(response.data.message);
|
|
265
|
+
break;
|
|
266
|
+
|
|
267
|
+
// 短信验证码抛错
|
|
268
|
+
case "sendSmsFrequently":
|
|
269
|
+
case "the number of sms messages sent from a single mobile number every day exceeds the upper limit":
|
|
270
|
+
case "verify_code_empty":
|
|
271
|
+
case "verify_code_failure":
|
|
272
|
+
case "verify_code_expired":
|
|
273
|
+
notificationHelper.error(response.data.message);
|
|
274
|
+
break;
|
|
275
|
+
case "MEMBER_NOT_FOUND":
|
|
276
|
+
break;
|
|
277
|
+
case "REPEAT_UPLOAD_FILE_ERROR":
|
|
278
|
+
break;
|
|
279
|
+
default:
|
|
280
|
+
{
|
|
281
|
+
var key = response.data.code;
|
|
282
|
+
if (_this2.defaultOptions.errorToast) {
|
|
283
|
+
notificationHelper.error(callBackMessage[key] ? callBackMessage[key] : response.data.message);
|
|
284
|
+
}
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return response;
|
|
289
|
+
}
|
|
290
|
+
}, function (error) {
|
|
291
|
+
//debugger;
|
|
292
|
+
// 超出 2xx 范围的状态码都会触发该函数。
|
|
293
|
+
// 对响应错误做点什么
|
|
294
|
+
return Promise.reject(error);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
}]);
|
|
298
|
+
return Axios;
|
|
299
|
+
}();
|
|
300
|
+
export { Axios as default };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Axios from "./Axios";
|
|
2
|
+
export var http = new Axios({
|
|
3
|
+
baseURL: process.env.REACT_APP_WEB_PLATFORM_TITLE,
|
|
4
|
+
timeout: 10000,
|
|
5
|
+
withCredentials: true,
|
|
6
|
+
headers: {
|
|
7
|
+
"Content-Type": "application/json;charset=UTF-8",
|
|
8
|
+
"Accept": "application/json, text/javascript, */*; q=0.01",
|
|
9
|
+
"terminal": "WEBPC"
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
// 统计服务请求api baseURL
|
|
14
|
+
export var httpStatistic = new Axios({
|
|
15
|
+
baseURL: process.env.REACT_APP_WEB_PLATFORM_STATISTIC,
|
|
16
|
+
timeout: 10000,
|
|
17
|
+
withCredentials: true,
|
|
18
|
+
headers: {
|
|
19
|
+
"Content-Type": "application/json;charset=UTF-8",
|
|
20
|
+
"Accept": "application/json, text/javascript, */*; q=0.01",
|
|
21
|
+
"terminal": "WEBPC"
|
|
22
|
+
}
|
|
23
|
+
});
|