meixioacomponent 1.1.38 → 1.1.40

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.
Files changed (49) hide show
  1. package/lib/components/base/baseGuide/GuideControl.d.ts +44 -44
  2. package/lib/components/base/baseGuide/GuideControl.js +238 -238
  3. package/lib/components/dynamicmount/DynamicMountClass.d.ts +15 -15
  4. package/lib/components/dynamicmount/DynamicMountClass.js +65 -65
  5. package/lib/components/dynamicmount/index.d.ts +4 -4
  6. package/lib/components/dynamicmount/index.js +71 -71
  7. package/lib/components/index.d.ts +104 -104
  8. package/lib/components/index.js +221 -221
  9. package/lib/config/LinkViewClass.d.ts +56 -56
  10. package/lib/config/LinkViewClass.js +154 -154
  11. package/lib/config/componentConfig.d.ts +3 -3
  12. package/lib/config/componentConfig.js +71 -71
  13. package/lib/config/uploadRequest.d.ts +2 -2
  14. package/lib/config/uploadRequest.js +87 -87
  15. package/lib/config/use/UseGuide.d.ts +8 -8
  16. package/lib/config/use/UseGuide.js +33 -33
  17. package/lib/config/use/UseImg.d.ts +9 -9
  18. package/lib/config/use/UseImg.js +41 -41
  19. package/lib/config/use/UseUpload.d.ts +12 -12
  20. package/lib/config/use/UseUpload.js +79 -79
  21. package/lib/config/use/UseViewVideo.d.ts +11 -11
  22. package/lib/config/use/UseViewVideo.js +41 -41
  23. package/lib/config/use/WaitPlugin.d.ts +25 -25
  24. package/lib/config/use/WaitPlugin.js +106 -106
  25. package/lib/config/use/useWait.d.ts +4 -4
  26. package/lib/config/use/useWait.js +21 -21
  27. package/lib/meixioacomponent.common.js +41937 -41938
  28. package/lib/meixioacomponent.umd.js +41971 -41972
  29. package/lib/meixioacomponent.umd.min.js +28 -28
  30. package/lib/typings/type.d.ts +394 -394
  31. package/lib/typings/type.js +2 -2
  32. package/lib/useType/useType.d.ts +27 -27
  33. package/lib/useType/useType.js +89 -89
  34. package/package.json +1 -1
  35. package/packages/components/base/baseNumberInput/index.vue +9 -13
  36. package/packages/components/base/baseText/index.vue +2 -1
  37. package/packages/components/dynamicmount/DynamicMountClass.js +64 -64
  38. package/packages/components/dynamicmount/index.js +69 -69
  39. package/packages/components/index.js +218 -218
  40. package/packages/config/LinkViewClass.js +152 -152
  41. package/packages/config/componentConfig.js +68 -68
  42. package/packages/config/use/UseGuide.js +43 -43
  43. package/packages/config/use/UseImg.js +41 -41
  44. package/packages/config/use/UseUpload.js +80 -80
  45. package/packages/config/use/UseViewVideo.js +40 -40
  46. package/packages/config/use/WaitPlugin.js +106 -106
  47. package/packages/config/use/useWait.js +18 -18
  48. package/packages/typings/type.js +2 -2
  49. package/packages/useType/useType.js +90 -90
@@ -1,154 +1,154 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const utils_1 = require("../utils/utils");
7
- const componentConfig_1 = __importDefault(require("./componentConfig"));
8
- class LinkViewClass {
9
- constructor(params) {
10
- this.delFn = null;
11
- this.exportFn = null;
12
- this.tableData = [];
13
- this.pageProps = {
14
- size: 15, total: 100, current: 1,
15
- };
16
- this.pageConfig = null;
17
- this.activeIndex = 0;
18
- this.tablePermission = {
19
- key: "", value: true,
20
- };
21
- this.editPermission = {
22
- key: "", value: true,
23
- };
24
- this.delPermission = {
25
- key: "", value: true,
26
- };
27
- this.addPermission = {
28
- key: "", value: true,
29
- };
30
- this.refreshTableData = null;
31
- this.drawerInstance = null;
32
- this.superDrawerMountedCallback = null;
33
- this.isLocalTablePagination = null;
34
- this.init(params);
35
- this.setPermissions(params);
36
- }
37
- setPermissions(param) {
38
- const { permissions } = param;
39
- if (permissions) {
40
- this.tablePermission.key = permissions[0];
41
- this.addPermission.key = permissions[1];
42
- this.editPermission.key = permissions[2];
43
- this.delPermission.key = permissions[3];
44
- }
45
- this.jugePermission();
46
- }
47
- jugePermission() {
48
- const { tablePermission, addPermission, editPermission, delPermission } = this;
49
- const permissionList = componentConfig_1.default.store[`getters`]["permissions"];
50
- tablePermission.value = (0, utils_1.judgeButtonPermission)(permissionList, tablePermission.key);
51
- editPermission.value = (0, utils_1.judgeButtonPermission)(permissionList, editPermission.key);
52
- delPermission.value = (0, utils_1.judgeButtonPermission)(permissionList, delPermission.key);
53
- addPermission.value = (0, utils_1.judgeButtonPermission)(permissionList, addPermission.key);
54
- }
55
- init(params) {
56
- this.tableData = [];
57
- this.activeIndex = 0;
58
- this.refreshTableData = null;
59
- this.setPageProps(params);
60
- this.pageConfig = {
61
- size: "size", page: "current", total: "total",
62
- };
63
- }
64
- setPageProps(params) {
65
- try {
66
- const isLocalTablePagination = params[`isLocalTablePagination`];
67
- if (!isLocalTablePagination) {
68
- this.setDefaultPageProps();
69
- }
70
- else {
71
- this.isLocalTablePagination = isLocalTablePagination;
72
- const localTablePagination = window.localStorage.getItem('LocalTablePagination');
73
- if (localTablePagination) {
74
- const localTablePaginationObj = JSON.parse(localTablePagination);
75
- const value = localTablePaginationObj[`${isLocalTablePagination}`];
76
- if (value) {
77
- this.pageProps = {
78
- size: value, total: 100, current: 1,
79
- };
80
- }
81
- else {
82
- this.setDefaultPageProps();
83
- this.setLocalPagination(localTablePaginationObj);
84
- }
85
- }
86
- else {
87
- this.setDefaultPageProps();
88
- const value = {};
89
- this.setLocalPagination(value);
90
- }
91
- }
92
- }
93
- catch (error) { }
94
- }
95
- setLocalPagination(value) {
96
- value[`${this.isLocalTablePagination}`] = this.pageProps.size;
97
- window.localStorage.setItem('LocalTablePagination', JSON.stringify(value));
98
- }
99
- setDefaultPageProps() {
100
- this.pageProps = {
101
- size: 15, total: 100, current: 1,
102
- };
103
- }
104
- onHandNextData() {
105
- if (this.hasNextTableData()) {
106
- this.activeIndex += 1;
107
- return;
108
- }
109
- this.activeIndex = this.tableData.length - 1;
110
- }
111
- onHandPreData() {
112
- if (this.hasPreTableData()) {
113
- this.activeIndex -= 1;
114
- }
115
- else {
116
- this.activeIndex = 0;
117
- }
118
- }
119
- hasNextTableData() {
120
- return this.tableData.length > 0 ? this.activeIndex !== this.tableData.length - 1 : false;
121
- }
122
- hasPreTableData() {
123
- return this.activeIndex > 0;
124
- }
125
- getTableDataForActiveIndex() {
126
- return this.tableData[this.activeIndex];
127
- }
128
- getPageProps() {
129
- return this.pageProps;
130
- }
131
- getTableData() {
132
- return {
133
- _class: this, tableData: this.tableData,
134
- };
135
- }
136
- getPageConfig() {
137
- return this.pageConfig;
138
- }
139
- getPermission(key) {
140
- return this[`${key}`].value;
141
- }
142
- setActiveIndex(index) {
143
- this.activeIndex = index;
144
- }
145
- deleteTableDataItemByProperty(property, value) {
146
- let index = this.tableData.findIndex((item) => {
147
- return item[`${property}`] === value;
148
- });
149
- if (index > -1) {
150
- this.tableData.splice(index, 1);
151
- }
152
- }
153
- }
154
- exports.default = LinkViewClass;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const utils_1 = require("../utils/utils");
7
+ const componentConfig_1 = __importDefault(require("./componentConfig"));
8
+ class LinkViewClass {
9
+ constructor(params) {
10
+ this.delFn = null;
11
+ this.exportFn = null;
12
+ this.tableData = [];
13
+ this.pageProps = {
14
+ size: 15, total: 100, current: 1,
15
+ };
16
+ this.pageConfig = null;
17
+ this.activeIndex = 0;
18
+ this.tablePermission = {
19
+ key: "", value: true,
20
+ };
21
+ this.editPermission = {
22
+ key: "", value: true,
23
+ };
24
+ this.delPermission = {
25
+ key: "", value: true,
26
+ };
27
+ this.addPermission = {
28
+ key: "", value: true,
29
+ };
30
+ this.refreshTableData = null;
31
+ this.drawerInstance = null;
32
+ this.superDrawerMountedCallback = null;
33
+ this.isLocalTablePagination = null;
34
+ this.init(params);
35
+ this.setPermissions(params);
36
+ }
37
+ setPermissions(param) {
38
+ const { permissions } = param;
39
+ if (permissions) {
40
+ this.tablePermission.key = permissions[0];
41
+ this.addPermission.key = permissions[1];
42
+ this.editPermission.key = permissions[2];
43
+ this.delPermission.key = permissions[3];
44
+ }
45
+ this.jugePermission();
46
+ }
47
+ jugePermission() {
48
+ const { tablePermission, addPermission, editPermission, delPermission } = this;
49
+ const permissionList = componentConfig_1.default.store[`getters`]["permissions"];
50
+ tablePermission.value = (0, utils_1.judgeButtonPermission)(permissionList, tablePermission.key);
51
+ editPermission.value = (0, utils_1.judgeButtonPermission)(permissionList, editPermission.key);
52
+ delPermission.value = (0, utils_1.judgeButtonPermission)(permissionList, delPermission.key);
53
+ addPermission.value = (0, utils_1.judgeButtonPermission)(permissionList, addPermission.key);
54
+ }
55
+ init(params) {
56
+ this.tableData = [];
57
+ this.activeIndex = 0;
58
+ this.refreshTableData = null;
59
+ this.setPageProps(params);
60
+ this.pageConfig = {
61
+ size: "size", page: "current", total: "total",
62
+ };
63
+ }
64
+ setPageProps(params) {
65
+ try {
66
+ const isLocalTablePagination = params[`isLocalTablePagination`];
67
+ if (!isLocalTablePagination) {
68
+ this.setDefaultPageProps();
69
+ }
70
+ else {
71
+ this.isLocalTablePagination = isLocalTablePagination;
72
+ const localTablePagination = window.localStorage.getItem('LocalTablePagination');
73
+ if (localTablePagination) {
74
+ const localTablePaginationObj = JSON.parse(localTablePagination);
75
+ const value = localTablePaginationObj[`${isLocalTablePagination}`];
76
+ if (value) {
77
+ this.pageProps = {
78
+ size: value, total: 100, current: 1,
79
+ };
80
+ }
81
+ else {
82
+ this.setDefaultPageProps();
83
+ this.setLocalPagination(localTablePaginationObj);
84
+ }
85
+ }
86
+ else {
87
+ this.setDefaultPageProps();
88
+ const value = {};
89
+ this.setLocalPagination(value);
90
+ }
91
+ }
92
+ }
93
+ catch (error) { }
94
+ }
95
+ setLocalPagination(value) {
96
+ value[`${this.isLocalTablePagination}`] = this.pageProps.size;
97
+ window.localStorage.setItem('LocalTablePagination', JSON.stringify(value));
98
+ }
99
+ setDefaultPageProps() {
100
+ this.pageProps = {
101
+ size: 15, total: 100, current: 1,
102
+ };
103
+ }
104
+ onHandNextData() {
105
+ if (this.hasNextTableData()) {
106
+ this.activeIndex += 1;
107
+ return;
108
+ }
109
+ this.activeIndex = this.tableData.length - 1;
110
+ }
111
+ onHandPreData() {
112
+ if (this.hasPreTableData()) {
113
+ this.activeIndex -= 1;
114
+ }
115
+ else {
116
+ this.activeIndex = 0;
117
+ }
118
+ }
119
+ hasNextTableData() {
120
+ return this.tableData.length > 0 ? this.activeIndex !== this.tableData.length - 1 : false;
121
+ }
122
+ hasPreTableData() {
123
+ return this.activeIndex > 0;
124
+ }
125
+ getTableDataForActiveIndex() {
126
+ return this.tableData[this.activeIndex];
127
+ }
128
+ getPageProps() {
129
+ return this.pageProps;
130
+ }
131
+ getTableData() {
132
+ return {
133
+ _class: this, tableData: this.tableData,
134
+ };
135
+ }
136
+ getPageConfig() {
137
+ return this.pageConfig;
138
+ }
139
+ getPermission(key) {
140
+ return this[`${key}`].value;
141
+ }
142
+ setActiveIndex(index) {
143
+ this.activeIndex = index;
144
+ }
145
+ deleteTableDataItemByProperty(property, value) {
146
+ let index = this.tableData.findIndex((item) => {
147
+ return item[`${property}`] === value;
148
+ });
149
+ if (index > -1) {
150
+ this.tableData.splice(index, 1);
151
+ }
152
+ }
153
+ }
154
+ exports.default = LinkViewClass;
@@ -1,4 +1,4 @@
1
- import { componentConfigType } from "../typings/type";
2
- declare const componentConfig: componentConfigType;
3
- export default componentConfig;
1
+ import { componentConfigType } from "../typings/type";
2
+ declare const componentConfig: componentConfigType;
3
+ export default componentConfig;
4
4
  //# sourceMappingURL=componentConfig.d.ts.map
@@ -1,71 +1,71 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const selectStore_1 = __importDefault(require("./storeModule/selectStore"));
7
- const dialogCacheStore_1 = __importDefault(require("./storeModule/dialogCacheStore"));
8
- // @ts-ignore
9
- const index_vue_1 = __importDefault(require("../components/dialogCache/index.vue"));
10
- const LinkViewClass_1 = __importDefault(require("./LinkViewClass"));
11
- const componentConfig = {
12
- store: {},
13
- router: {},
14
- dynamicId: 0,
15
- uploadUrl: "",
16
- uploadPrefix: "",
17
- eventBus: null,
18
- selectStore: null,
19
- Vue: null,
20
- LinkViewClass: LinkViewClass_1.default,
21
- dialogCacheComponent: {},
22
- uploadStoreList: ["meixidev"],
23
- ossUploadEdAuthCallback: null,
24
- setDynamicId: () => {
25
- componentConfig.dynamicId += 1;
26
- },
27
- setUploadPrefix: (url) => {
28
- componentConfig.uploadPrefix = url;
29
- },
30
- setUploadUrl: (storeType, uploadType) => {
31
- // componentConfig.uploadUrl = `${componentConfig.uploadPrefix}/${componentConfig.uploadStoreList[storeType]}/${uploadType}/upload`
32
- componentConfig.uploadUrl = `${componentConfig.uploadPrefix}`;
33
- },
34
- setUploadCustomUrl: (url) => {
35
- componentConfig.uploadUrl = url;
36
- },
37
- setOssUploadEdAuthCallBack: (callback) => {
38
- componentConfig.ossUploadEdAuthCallback = callback;
39
- },
40
- initConfig: (_store, _router) => {
41
- // 动态注册vuex modules
42
- _store[`registerModule`]("selectStore", selectStore_1.default);
43
- // 注册vuex里面selectStore管理类
44
- _store[`commit`]("selectStore/CREATE_SELECTSTORE");
45
- componentConfig.store = _store;
46
- componentConfig.router = _router;
47
- componentConfig.selectStore =
48
- componentConfig.store[`getters`]["selectStore/getSelectStore"];
49
- componentConfig.registerModuleOfCacheDialog(_store);
50
- window["dayjs"] = require("dayjs");
51
- },
52
- registerModuleOfCacheDialog: (_store) => {
53
- _store[`registerModule`]("dialogCacheStore", dialogCacheStore_1.default);
54
- },
55
- // 生成隐藏dialog的容器
56
- createDialogCacheWrap: () => {
57
- const component = componentConfig.Vue.extend(index_vue_1.default);
58
- componentConfig.dialogCacheComponent = new component({
59
- // @ts-ignore
60
- store: componentConfig.store,
61
- router: componentConfig.router,
62
- });
63
- componentConfig.Vue.nextTick(() => {
64
- const cacheWrap = document.createElement("div");
65
- cacheWrap.setAttribute("class", "cacheWrap");
66
- document.body.appendChild(cacheWrap);
67
- componentConfig.dialogCacheComponent[`$mount`](cacheWrap);
68
- });
69
- },
70
- };
71
- exports.default = componentConfig;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const selectStore_1 = __importDefault(require("./storeModule/selectStore"));
7
+ const dialogCacheStore_1 = __importDefault(require("./storeModule/dialogCacheStore"));
8
+ // @ts-ignore
9
+ const index_vue_1 = __importDefault(require("../components/dialogCache/index.vue"));
10
+ const LinkViewClass_1 = __importDefault(require("./LinkViewClass"));
11
+ const componentConfig = {
12
+ store: {},
13
+ router: {},
14
+ dynamicId: 0,
15
+ uploadUrl: "",
16
+ uploadPrefix: "",
17
+ eventBus: null,
18
+ selectStore: null,
19
+ Vue: null,
20
+ LinkViewClass: LinkViewClass_1.default,
21
+ dialogCacheComponent: {},
22
+ uploadStoreList: ["meixidev"],
23
+ ossUploadEdAuthCallback: null,
24
+ setDynamicId: () => {
25
+ componentConfig.dynamicId += 1;
26
+ },
27
+ setUploadPrefix: (url) => {
28
+ componentConfig.uploadPrefix = url;
29
+ },
30
+ setUploadUrl: (storeType, uploadType) => {
31
+ // componentConfig.uploadUrl = `${componentConfig.uploadPrefix}/${componentConfig.uploadStoreList[storeType]}/${uploadType}/upload`
32
+ componentConfig.uploadUrl = `${componentConfig.uploadPrefix}`;
33
+ },
34
+ setUploadCustomUrl: (url) => {
35
+ componentConfig.uploadUrl = url;
36
+ },
37
+ setOssUploadEdAuthCallBack: (callback) => {
38
+ componentConfig.ossUploadEdAuthCallback = callback;
39
+ },
40
+ initConfig: (_store, _router) => {
41
+ // 动态注册vuex modules
42
+ _store[`registerModule`]("selectStore", selectStore_1.default);
43
+ // 注册vuex里面selectStore管理类
44
+ _store[`commit`]("selectStore/CREATE_SELECTSTORE");
45
+ componentConfig.store = _store;
46
+ componentConfig.router = _router;
47
+ componentConfig.selectStore =
48
+ componentConfig.store[`getters`]["selectStore/getSelectStore"];
49
+ componentConfig.registerModuleOfCacheDialog(_store);
50
+ window["dayjs"] = require("dayjs");
51
+ },
52
+ registerModuleOfCacheDialog: (_store) => {
53
+ _store[`registerModule`]("dialogCacheStore", dialogCacheStore_1.default);
54
+ },
55
+ // 生成隐藏dialog的容器
56
+ createDialogCacheWrap: () => {
57
+ const component = componentConfig.Vue.extend(index_vue_1.default);
58
+ componentConfig.dialogCacheComponent = new component({
59
+ // @ts-ignore
60
+ store: componentConfig.store,
61
+ router: componentConfig.router,
62
+ });
63
+ componentConfig.Vue.nextTick(() => {
64
+ const cacheWrap = document.createElement("div");
65
+ cacheWrap.setAttribute("class", "cacheWrap");
66
+ document.body.appendChild(cacheWrap);
67
+ componentConfig.dialogCacheComponent[`$mount`](cacheWrap);
68
+ });
69
+ },
70
+ };
71
+ exports.default = componentConfig;
@@ -1,3 +1,3 @@
1
- declare const _default: (params: any, uploadProgressFn: any, sourceToken: any, oss: any) => Promise<unknown>;
2
- export default _default;
1
+ declare const _default: (params: any, uploadProgressFn: any, sourceToken: any, oss: any) => Promise<unknown>;
2
+ export default _default;
3
3
  //# sourceMappingURL=uploadRequest.d.ts.map
@@ -1,87 +1,87 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const axios_1 = __importDefault(require("axios"));
16
- const utils_js_1 = require("../utils/utils.js");
17
- exports.default = (params, uploadProgressFn, sourceToken, oss) => {
18
- const ossInstance = (data, uploadProgressFn) => {
19
- // 创建 axios 实例
20
- const instance = axios_1.default.create({
21
- // API 请求的默认前缀
22
- baseURL: `${params.get('url')}`,
23
- });
24
- // 异常拦截处理器
25
- const errorHandler = (error) => {
26
- return Promise.reject(error);
27
- };
28
- // 响应异常拦截处理器
29
- const resErrorHandler = (error) => {
30
- // Message.error(`网络超时,请稍后重试`);
31
- // return errorHandler(error);
32
- throw error;
33
- };
34
- // request 拦截器
35
- instance.interceptors.request.use((config) => {
36
- // @ts-ignore
37
- config.headers['Content-Type'] = 'multipart/form-data';
38
- // @ts-ignore
39
- config.headers['type'] = 'application/octet-stream';
40
- if (!oss) {
41
- // @ts-ignore
42
- config.headers['authorization'] = `Bearer ${(0, utils_js_1.GetToken)('token')}`;
43
- }
44
- config.onUploadProgress = (progressEvent) => {
45
- if (uploadProgressFn) {
46
- // @ts-ignore
47
- const percent = (progressEvent.loaded / progressEvent.total) * 100 || 0;
48
- uploadProgressFn(percent);
49
- }
50
- };
51
- return config;
52
- }, errorHandler);
53
- // response 拦截器
54
- instance.interceptors.response.use((response) => __awaiter(void 0, void 0, void 0, function* () {
55
- return response;
56
- }), resErrorHandler);
57
- return instance(data);
58
- };
59
- return new Promise((resolve, reject) => {
60
- // await 后端接口
61
- ossInstance({
62
- url: '',
63
- data: params,
64
- method: 'post',
65
- cancelToken: sourceToken.token,
66
- }, uploadProgressFn)
67
- .then((res) => {
68
- const { status } = res;
69
- if (status == 200) {
70
- const { data } = res;
71
- if (data) {
72
- resolve(data.data.original);
73
- }
74
- else {
75
- // 返回oss的params;
76
- const url = params.get('url');
77
- const key = params.get('key');
78
- resolve(`${url}/${key}`);
79
- }
80
- }
81
- })
82
- .catch((error) => {
83
- var _a;
84
- reject((_a = error.response) === null || _a === void 0 ? void 0 : _a.data.msg);
85
- });
86
- });
87
- };
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const axios_1 = __importDefault(require("axios"));
16
+ const utils_js_1 = require("../utils/utils.js");
17
+ exports.default = (params, uploadProgressFn, sourceToken, oss) => {
18
+ const ossInstance = (data, uploadProgressFn) => {
19
+ // 创建 axios 实例
20
+ const instance = axios_1.default.create({
21
+ // API 请求的默认前缀
22
+ baseURL: `${params.get('url')}`,
23
+ });
24
+ // 异常拦截处理器
25
+ const errorHandler = (error) => {
26
+ return Promise.reject(error);
27
+ };
28
+ // 响应异常拦截处理器
29
+ const resErrorHandler = (error) => {
30
+ // Message.error(`网络超时,请稍后重试`);
31
+ // return errorHandler(error);
32
+ throw error;
33
+ };
34
+ // request 拦截器
35
+ instance.interceptors.request.use((config) => {
36
+ // @ts-ignore
37
+ config.headers['Content-Type'] = 'multipart/form-data';
38
+ // @ts-ignore
39
+ config.headers['type'] = 'application/octet-stream';
40
+ if (!oss) {
41
+ // @ts-ignore
42
+ config.headers['authorization'] = `Bearer ${(0, utils_js_1.GetToken)('token')}`;
43
+ }
44
+ config.onUploadProgress = (progressEvent) => {
45
+ if (uploadProgressFn) {
46
+ // @ts-ignore
47
+ const percent = (progressEvent.loaded / progressEvent.total) * 100 || 0;
48
+ uploadProgressFn(percent);
49
+ }
50
+ };
51
+ return config;
52
+ }, errorHandler);
53
+ // response 拦截器
54
+ instance.interceptors.response.use((response) => __awaiter(void 0, void 0, void 0, function* () {
55
+ return response;
56
+ }), resErrorHandler);
57
+ return instance(data);
58
+ };
59
+ return new Promise((resolve, reject) => {
60
+ // await 后端接口
61
+ ossInstance({
62
+ url: '',
63
+ data: params,
64
+ method: 'post',
65
+ cancelToken: sourceToken.token,
66
+ }, uploadProgressFn)
67
+ .then((res) => {
68
+ const { status } = res;
69
+ if (status == 200) {
70
+ const { data } = res;
71
+ if (data) {
72
+ resolve(data.data.original);
73
+ }
74
+ else {
75
+ // 返回oss的params;
76
+ const url = params.get('url');
77
+ const key = params.get('key');
78
+ resolve(`${url}/${key}`);
79
+ }
80
+ }
81
+ })
82
+ .catch((error) => {
83
+ var _a;
84
+ reject((_a = error.response) === null || _a === void 0 ? void 0 : _a.data.msg);
85
+ });
86
+ });
87
+ };
@@ -1,9 +1,9 @@
1
- import { DynamicMountInterface, UseGuideInterface, UseGuideParamsType } from "../../typings/type";
2
- declare class UseGuide implements UseGuideInterface {
3
- guideComponent: DynamicMountInterface | null;
4
- constructor();
5
- startGuide(params: UseGuideParamsType): void;
6
- }
7
- declare const useGuide: UseGuide;
8
- export default useGuide;
1
+ import { DynamicMountInterface, UseGuideInterface, UseGuideParamsType } from "../../typings/type";
2
+ declare class UseGuide implements UseGuideInterface {
3
+ guideComponent: DynamicMountInterface | null;
4
+ constructor();
5
+ startGuide(params: UseGuideParamsType): void;
6
+ }
7
+ declare const useGuide: UseGuide;
8
+ export default useGuide;
9
9
  //# sourceMappingURL=UseGuide.d.ts.map