ls-pro-common 3.0.80 → 3.0.82

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 (39) hide show
  1. package/dist/common.css +21 -0
  2. package/dist/common.js +1 -1
  3. package/dist/common.min.css +21 -0
  4. package/dist/common.min.js +1 -1
  5. package/es/components/common.less +23 -0
  6. package/es/hooks/useBaseDict.d.ts +35 -0
  7. package/es/hooks/useBaseDict.js +104 -0
  8. package/es/hooks/useDtl/index.js +7 -5
  9. package/es/hooks/useFilterBack.d.ts +9 -10
  10. package/es/hooks/useFilterBack.js +6 -6
  11. package/es/hooks/useSelectOptions.d.ts +81 -0
  12. package/es/hooks/useSelectOptions.js +210 -0
  13. package/es/hooks/useShowConfirm.d.ts +9 -0
  14. package/es/hooks/useShowConfirm.js +23 -0
  15. package/es/hooks/useSingle/index.js +5 -3
  16. package/es/index.d.ts +6 -2
  17. package/es/index.js +6 -2
  18. package/es/utils/exportProcess.d.ts +8 -0
  19. package/es/utils/exportProcess.js +153 -0
  20. package/es/utils/index.d.ts +2 -0
  21. package/es/utils/index.js +18 -0
  22. package/lib/components/common.less +23 -0
  23. package/lib/hooks/useBaseDict.d.ts +35 -0
  24. package/lib/hooks/useBaseDict.js +104 -0
  25. package/lib/hooks/useDtl/index.js +7 -5
  26. package/lib/hooks/useFilterBack.d.ts +9 -10
  27. package/lib/hooks/useFilterBack.js +6 -6
  28. package/lib/hooks/useSelectOptions.d.ts +81 -0
  29. package/lib/hooks/useSelectOptions.js +210 -0
  30. package/lib/hooks/useShowConfirm.d.ts +9 -0
  31. package/lib/hooks/useShowConfirm.js +23 -0
  32. package/lib/hooks/useSingle/index.js +5 -3
  33. package/lib/index.d.ts +6 -2
  34. package/lib/index.js +6 -2
  35. package/lib/utils/exportProcess.d.ts +8 -0
  36. package/lib/utils/exportProcess.js +153 -0
  37. package/lib/utils/index.d.ts +2 -0
  38. package/lib/utils/index.js +18 -0
  39. package/package.json +1 -1
@@ -0,0 +1,210 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
+ var _this = this;
6
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
7
+ /** @name 请求select的options */
8
+ import { useCallback, useEffect, useMemo, useState } from 'react';
9
+ import { httpGet, httpPost } from '../http';
10
+ import { showWarn } from '../utils';
11
+ /**
12
+ * @param fn
13
+ * @param delay
14
+ * @name 防抖
15
+ * @returns
16
+ */
17
+ export var debounce = function debounce(fn) {
18
+ var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 500;
19
+ var timer = null;
20
+ return function () {
21
+ for (var _len = arguments.length, rest = new Array(_len), _key = 0; _key < _len; _key++) {
22
+ rest[_key] = arguments[_key];
23
+ }
24
+ var args = rest;
25
+ if (timer) clearTimeout(timer);
26
+ timer = setTimeout(function () {
27
+ fn.apply(_this, args);
28
+ timer = null;
29
+ }, delay);
30
+ };
31
+ };
32
+ /**
33
+ * @param props
34
+ * @name 动态请求select的options
35
+ * @returns
36
+ */
37
+ export var useSelectOptions = function useSelectOptions(props) {
38
+ var beforeLoad = props.beforeLoad,
39
+ afterLoad = props.afterLoad,
40
+ name = props.name,
41
+ _props$debounceTime = props.debounceTime,
42
+ debounceTime = _props$debounceTime === void 0 ? 500 : _props$debounceTime,
43
+ _props$requestProps = props.requestProps,
44
+ requestProps = _props$requestProps === void 0 ? {} : _props$requestProps,
45
+ _props$autoLoad = props.autoLoad,
46
+ autoLoad = _props$autoLoad === void 0 ? true : _props$autoLoad;
47
+ var url = requestProps.url,
48
+ _requestProps$method = requestProps.method,
49
+ method = _requestProps$method === void 0 ? 'GET' : _requestProps$method,
50
+ dictValue = requestProps.dictValue,
51
+ dictLabel = requestProps.dictLabel,
52
+ changeParams = requestProps.changeParams,
53
+ _requestProps$needGat = requestProps.needGateWay,
54
+ needGateWay = _requestProps$needGat === void 0 ? true : _requestProps$needGat,
55
+ _requestProps$isJson = requestProps.isJson,
56
+ isJson = _requestProps$isJson === void 0 ? true : _requestProps$isJson;
57
+ var _useState = useState([]),
58
+ _useState2 = _slicedToArray(_useState, 2),
59
+ options = _useState2[0],
60
+ setOptions = _useState2[1];
61
+ var _useState3 = useState([]),
62
+ _useState4 = _slicedToArray(_useState3, 2),
63
+ localSearch = _useState4[0],
64
+ setLocalSearch = _useState4[1];
65
+ /** @name 下拉框请求数据 */
66
+ var requestOptions = /*#__PURE__*/function () {
67
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
68
+ var val,
69
+ res,
70
+ params,
71
+ data,
72
+ _res,
73
+ _args = arguments;
74
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
75
+ while (1) switch (_context.prev = _context.next) {
76
+ case 0:
77
+ val = _args.length > 0 && _args[0] !== undefined ? _args[0] : '';
78
+ _context.t0 = beforeLoad;
79
+ if (!_context.t0) {
80
+ _context.next = 7;
81
+ break;
82
+ }
83
+ _context.next = 5;
84
+ return beforeLoad(val, setOptions);
85
+ case 5:
86
+ _context.t1 = _context.sent;
87
+ _context.t0 = _context.t1 === false;
88
+ case 7:
89
+ if (!_context.t0) {
90
+ _context.next = 9;
91
+ break;
92
+ }
93
+ return _context.abrupt("return");
94
+ case 9:
95
+ if (url) {
96
+ _context.next = 12;
97
+ break;
98
+ }
99
+ showWarn('请配置url');
100
+ return _context.abrupt("return");
101
+ case 12:
102
+ params = {
103
+ page: 1,
104
+ pageSize: 20,
105
+ where: _defineProperty({}, name, val)
106
+ };
107
+ if (changeParams) {
108
+ params = changeParams(val);
109
+ }
110
+ if (!(method === 'GET')) {
111
+ _context.next = 20;
112
+ break;
113
+ }
114
+ _context.next = 17;
115
+ return httpGet(url, params, needGateWay);
116
+ case 17:
117
+ res = _context.sent;
118
+ _context.next = 24;
119
+ break;
120
+ case 20:
121
+ if (!(method === 'POST')) {
122
+ _context.next = 24;
123
+ break;
124
+ }
125
+ _context.next = 23;
126
+ return httpPost(url, params, isJson, needGateWay);
127
+ case 23:
128
+ res = _context.sent;
129
+ case 24:
130
+ data = [];
131
+ if (!afterLoad) {
132
+ _context.next = 31;
133
+ break;
134
+ }
135
+ _context.next = 28;
136
+ return afterLoad(res);
137
+ case 28:
138
+ data = _context.sent;
139
+ _context.next = 32;
140
+ break;
141
+ case 31:
142
+ if (dictValue && dictLabel) {
143
+ data = (((_res = res) === null || _res === void 0 ? void 0 : _res.rows) || []).map(function (item) {
144
+ return {
145
+ value: item === null || item === void 0 ? void 0 : item[dictValue],
146
+ text: item === null || item === void 0 ? void 0 : item[dictLabel],
147
+ label: (item === null || item === void 0 ? void 0 : item[dictValue]) + '→' + (item === null || item === void 0 ? void 0 : item[dictLabel]),
148
+ children: item === null || item === void 0 ? void 0 : item.children,
149
+ items: item
150
+ };
151
+ });
152
+ } else {
153
+ showWarn('请配置afterLoad或设置dictValue和dictLabel');
154
+ }
155
+ case 32:
156
+ setOptions(data);
157
+ case 33:
158
+ case "end":
159
+ return _context.stop();
160
+ }
161
+ }, _callee);
162
+ }));
163
+ return function requestOptions() {
164
+ return _ref.apply(this, arguments);
165
+ };
166
+ }();
167
+ /** @name 防抖函数 使用useCallback来缓存函数 */
168
+ var nameSearchFun = useCallback(debounce( /*#__PURE__*/function () {
169
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
170
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
171
+ while (1) switch (_context2.prev = _context2.next) {
172
+ case 0:
173
+ return _context2.abrupt("return", requestOptions(params));
174
+ case 1:
175
+ case "end":
176
+ return _context2.stop();
177
+ }
178
+ }, _callee2);
179
+ }));
180
+ return function (_x) {
181
+ return _ref2.apply(this, arguments);
182
+ };
183
+ }(), debounceTime), []);
184
+ useEffect(function () {
185
+ if (autoLoad) {
186
+ requestOptions();
187
+ }
188
+ }, [autoLoad]);
189
+ var totalDataAll = useMemo(function () {
190
+ var res = [].concat(_toConsumableArray(localSearch), _toConsumableArray(options)).reduce(function (acc, current) {
191
+ if (!acc.find(function (item) {
192
+ return item.value === current.value;
193
+ })) {
194
+ acc.push(current);
195
+ }
196
+ return acc;
197
+ }, []);
198
+ return res;
199
+ }, [localSearch, options]);
200
+ return {
201
+ options: options,
202
+ setOptions: setOptions,
203
+ nameSearchFun: nameSearchFun,
204
+ requestOptions: requestOptions,
205
+ localSearch: localSearch,
206
+ setLocalSearch: setLocalSearch,
207
+ totalDataAll: totalDataAll
208
+ };
209
+ };
210
+ export default useSelectOptions;
@@ -0,0 +1,9 @@
1
+ import { ModalFuncProps } from 'antd';
2
+ /**
3
+ * 语法糖实现
4
+ *
5
+ * @param propsFun 参数为关闭函数
6
+ * @name 函数确认框
7
+ */
8
+ export declare const showConfirmFun: (propsFun: (unmount: () => void) => ModalFuncProps) => void;
9
+ export default showConfirmFun;
@@ -0,0 +1,23 @@
1
+ import "antd/es/modal/style";
2
+ import _Modal from "antd/es/modal";
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import React from "react";
5
+ import ReactDOM from 'react-dom';
6
+ /**
7
+ * 语法糖实现
8
+ *
9
+ * @param propsFun 参数为关闭函数
10
+ * @name 函数确认框
11
+ */
12
+ export var showConfirmFun = function showConfirmFun(propsFun) {
13
+ var div = document.createElement('div');
14
+ document.body.appendChild(div);
15
+ var props = propsFun(function () {
16
+ ReactDOM.unmountComponentAtNode(div);
17
+ document.body.removeChild(div);
18
+ });
19
+ ReactDOM.render( /*#__PURE__*/React.createElement(_Modal, _extends({
20
+ visible: true
21
+ }, props), props.content), div);
22
+ };
23
+ export default showConfirmFun;
@@ -10,6 +10,7 @@ import React from "react";
10
10
  import { useState, useRef, useMemo, useCallback } from 'react';
11
11
  import { PlusCircleOutlined, EditOutlined, DeleteOutlined, ImportOutlined, ExportOutlined, AuditOutlined } from '@ant-design/icons';
12
12
  import { showConfirm, showWarn, showSuccess, showError } from '../../utils';
13
+ import exportProcess from '../../utils/exportProcess';
13
14
  import { httpPost } from '../../http';
14
15
  import usePermission from '../usePermission';
15
16
  /**
@@ -527,7 +528,7 @@ function useSingle(inParam) {
527
528
  var onExport = /*#__PURE__*/function () {
528
529
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(url, param) {
529
530
  var _param$exportColumns;
530
- var searchArr, arr, otherArr, whereArr, where, _result$flag4, result, _result$flag5, _result$flag6;
531
+ var searchArr, arr, otherArr, whereArr, where, _result$flag4, result, _result$flag5;
531
532
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
532
533
  while (1) switch (_context7.prev = _context7.next) {
533
534
  case 0:
@@ -600,10 +601,11 @@ function useSingle(inParam) {
600
601
  _context7.next = 19;
601
602
  break;
602
603
  }
603
- showSuccess(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retMsg) || '导出成功');
604
+ // showSuccess(result.flag?.retMsg || '导出成功');
605
+ exportProcess(result);
604
606
  return _context7.abrupt("return", true);
605
607
  case 19:
606
- showError(((_result$flag6 = result.flag) === null || _result$flag6 === void 0 ? void 0 : _result$flag6.retMsg) || '导出失败,请联系系统管理员');
608
+ showError(((_result$flag5 = result.flag) === null || _result$flag5 === void 0 ? void 0 : _result$flag5.retMsg) || '导出失败,请联系系统管理员');
607
609
  return _context7.abrupt("return", false);
608
610
  case 21:
609
611
  _context7.next = 28;
package/lib/index.d.ts CHANGED
@@ -20,12 +20,16 @@ import ViewOffice from './components/ViewOffice';
20
20
  import BaseService from './service/BaseService';
21
21
  import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions } from './http';
22
22
  import * as utils from './utils';
23
+ import exportProcess from './utils/exportProcess';
23
24
  /** Hooks */
24
25
  import useSingle from './hooks/useSingle';
25
26
  import useDtl from './hooks/useDtl';
26
27
  import usePermission from './hooks/usePermission';
27
28
  import useGetState from './hooks/useGetState';
28
- import { useFilterLocal } from './hooks/useFilterBack';
29
+ import useFilterLocal from './hooks/useFilterBack';
30
+ import useBaseDict from './hooks/useBaseDict';
31
+ import useSelectOptions from './hooks/useSelectOptions';
32
+ import showConfirmFun from './hooks/useShowConfirm';
29
33
  import useQueue from './hooks/useQueue';
30
34
  /** Type */
31
35
  import type { ApiResponse, TableToolbar, BaseApiType, MethodType } from './typing';
@@ -33,4 +37,4 @@ import type { DtlLyaoutProps } from './components/DtlLayout';
33
37
  import type { DescritionCardProps } from './components/DescritionCard';
34
38
  import type { PermissionProps } from './components/Permission';
35
39
  export type { ApiResponse, TableToolbar, BaseApiType, MethodType, DtlLyaoutProps, DescritionCardProps, PermissionProps, };
36
- export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, };
40
+ export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, showConfirmFun, exportProcess, };
package/lib/index.js CHANGED
@@ -20,11 +20,15 @@ import ViewOffice from './components/ViewOffice';
20
20
  import BaseService from './service/BaseService';
21
21
  import request, { httpGet, httpPut, httpPost, httpDelete, getDict, fetchOptions } from './http';
22
22
  import * as utils from './utils';
23
+ import exportProcess from './utils/exportProcess';
23
24
  /** Hooks */
24
25
  import useSingle from './hooks/useSingle';
25
26
  import useDtl from './hooks/useDtl';
26
27
  import usePermission from './hooks/usePermission';
27
28
  import useGetState from './hooks/useGetState';
28
- import { useFilterLocal } from './hooks/useFilterBack';
29
+ import useFilterLocal from './hooks/useFilterBack';
30
+ import useBaseDict from './hooks/useBaseDict';
31
+ import useSelectOptions from './hooks/useSelectOptions';
32
+ import showConfirmFun from './hooks/useShowConfirm';
29
33
  import useQueue from './hooks/useQueue';
30
- export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue };
34
+ export { DtlLayout, InputTable, Page404, Loading, IconSelector, ImageSelector, InputMultiLine, AreaCascader, AreaCascaderPanel, DescritionCard, Permission, GroupTip, ViewOffice, IconBack, IconText, IconBell, IconQuestion, IconSearch, TagCheck, BaseService, request, httpDelete, httpGet, httpPost, httpPut, getDict, fetchOptions, utils, useSingle, useDtl, usePermission, useGetState, useFilterLocal, useQueue, useBaseDict, useSelectOptions, showConfirmFun, exportProcess };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 导出进度查看
3
+ *
4
+ * @param apiResult 导出接口返回数据,
5
+ * @returns
6
+ */
7
+ declare const exportProcess: (apiResult: any) => void;
8
+ export default exportProcess;
@@ -0,0 +1,153 @@
1
+ import "antd/es/progress/style";
2
+ import _Progress from "antd/es/progress";
3
+ import "antd/es/notification/style";
4
+ import _notification from "antd/es/notification";
5
+ import React from "react";
6
+ import { showSuccess, showError, sleep, downloadFile } from '.';
7
+ import { httpGet } from '../http';
8
+ /**
9
+ * 导出进度查看
10
+ *
11
+ * @param apiResult 导出接口返回数据,
12
+ * @returns
13
+ */
14
+ var exportProcess = function exportProcess(apiResult) {
15
+ var taskId = apiResult.taskId,
16
+ flag = apiResult.flag;
17
+ if (!taskId) {
18
+ showSuccess((flag === null || flag === void 0 ? void 0 : flag.retMsg) || '导出成功');
19
+ return;
20
+ }
21
+ var time = 0;
22
+ var exit = false;
23
+ var win = top || window;
24
+ var errorTryCount = 3;
25
+ var key = 'task' + taskId;
26
+ var dom = null;
27
+ var moveState = {
28
+ isMove: false,
29
+ startLeft: 0,
30
+ startTop: 0,
31
+ startX: 0,
32
+ startY: 0,
33
+ h: 88,
34
+ w: 250 //组件宽度
35
+ };
36
+
37
+ var onMove = function onMove(e) {
38
+ requestAnimationFrame(function () {
39
+ var startLeft = moveState.startLeft,
40
+ startTop = moveState.startTop,
41
+ startX = moveState.startX,
42
+ startY = moveState.startY,
43
+ isMove = moveState.isMove,
44
+ h = moveState.h,
45
+ w = moveState.w;
46
+ if (!isMove || !dom) return;
47
+ // 通过计算鼠标的移动距离,计算出组件新的坐标。
48
+ var deltaX = document.body.clientWidth - (e.clientX - startX + startLeft) - w;
49
+ var deltaY = e.clientY - startY + startTop;
50
+ var top = Math.max(0, Math.min(document.body.clientHeight - h, deltaY));
51
+ var right = Math.max(0, Math.min(document.body.clientWidth - w - 30, deltaX));
52
+ dom.style.top = top + 'px';
53
+ dom.style.right = right + 'px';
54
+ });
55
+ };
56
+ var onUp = function onUp() {
57
+ moveState.isMove = false;
58
+ document.body.classList.remove('move-unselect');
59
+ document.removeEventListener('mouseup', onUp);
60
+ document.removeEventListener('mousemove', onMove);
61
+ };
62
+ var loading = function loading(percent) {
63
+ _notification.open({
64
+ className: 'export-process-notification',
65
+ placement: 'topRight',
66
+ key: key,
67
+ duration: 0,
68
+ message: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
69
+ className: "export-process-handle",
70
+ onMouseDown: function onMouseDown(e) {
71
+ dom = e.target.closest('.ant-notification-topRight');
72
+ if (!dom) return;
73
+ var rect = dom.getBoundingClientRect();
74
+ moveState.isMove = true;
75
+ moveState.startX = e.clientX;
76
+ moveState.startY = e.clientY;
77
+ moveState.startLeft = rect.left;
78
+ moveState.startTop = rect.top;
79
+ document.body.classList.add('move-unselect');
80
+ document.addEventListener('mouseup', onUp);
81
+ document.addEventListener('mousemove', onMove);
82
+ }
83
+ }, "\u6B63\u5728\u5BFC\u51FA..."), /*#__PURE__*/React.createElement(_Progress, {
84
+ percent: percent
85
+ })),
86
+ onClose: function onClose() {
87
+ exit = true;
88
+ document.removeEventListener('mouseup', onUp);
89
+ document.removeEventListener('mousemove', onMove);
90
+ }
91
+ });
92
+ };
93
+ loading(0);
94
+ var getResult = function getResult() {
95
+ if (exit) return;
96
+ httpGet('/petrel-poi-center-api/sysPoiExportManage/page', {
97
+ 'page.pn': 1,
98
+ 'page.size': 1,
99
+ 'search.id': apiResult.taskId
100
+ }).then(function (result) {
101
+ var _result$rows = result.rows,
102
+ rows = _result$rows === void 0 ? [] : _result$rows;
103
+ var row = rows === null || rows === void 0 ? void 0 : rows[0];
104
+ if (!row) {
105
+ if (time < errorTryCount) {
106
+ time++;
107
+ sleep(5).then(function () {
108
+ return getResult();
109
+ });
110
+ } else {
111
+ showError('获取导出进度失败,请在消息中心查看导出结果');
112
+ win.postMessage({
113
+ type: 'exportError'
114
+ });
115
+ _notification.close(key);
116
+ }
117
+ } else {
118
+ var status = row.status,
119
+ downloadUrl = row.downloadUrl,
120
+ progress = row.progress;
121
+ //导出中
122
+ if (status < 30) {
123
+ loading(progress);
124
+ sleep(5).then(function () {
125
+ return getResult();
126
+ });
127
+ } else {
128
+ //导出成功
129
+ if (status === 30 && downloadUrl) {
130
+ downloadFile(downloadUrl);
131
+ } else {
132
+ //导出失败
133
+ showError('导出异常,请在消息中心查看失败原因');
134
+ win.postMessage({
135
+ type: 'exportError'
136
+ });
137
+ }
138
+ _notification.close(key);
139
+ }
140
+ }
141
+ }).catch(function () {
142
+ showError('获取导出进度失败,请在消息中心查看导出结果');
143
+ _notification.close(key);
144
+ win.postMessage({
145
+ type: 'exportError'
146
+ });
147
+ });
148
+ };
149
+ sleep(1).then(function () {
150
+ return getResult();
151
+ });
152
+ };
153
+ export default exportProcess;
@@ -314,3 +314,5 @@ export declare const openPageInMain: (option: {
314
314
  export declare const showLoading: (text?: string) => void;
315
315
  export declare const exitLoading: () => void;
316
316
  export declare const handleTheme: () => void;
317
+ export declare const sleep: (secord: number) => Promise<unknown>;
318
+ export declare const downloadFile: (url: string, fileName?: string | undefined) => void;
@@ -889,4 +889,22 @@ export var handleTheme = function handleTheme() {
889
889
  if (theme) {
890
890
  document.body.classList.add('theme-' + theme);
891
891
  }
892
+ };
893
+ export var sleep = function sleep(secord) {
894
+ return new Promise(function (resolve) {
895
+ setTimeout(function () {
896
+ resolve(true);
897
+ }, secord * 1000);
898
+ });
899
+ };
900
+ export var downloadFile = function downloadFile(url, fileName) {
901
+ var a = document.createElement('a');
902
+ a.href = url;
903
+ // a.target = '_blank'; // 新开屏有闪烁
904
+ if (fileName) {
905
+ a.setAttribute('download', fileName);
906
+ }
907
+ document.body.appendChild(a);
908
+ a.click();
909
+ document.body.removeChild(a);
892
910
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ls-pro-common",
3
- "version": "3.0.80",
3
+ "version": "3.0.82",
4
4
  "description": "ls-pro-common",
5
5
  "license": "MIT",
6
6
  "sideEffects": [