ls-pro-common 3.1.48 → 3.1.50

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 (45) hide show
  1. package/dist/common.js +1 -1
  2. package/dist/common.min.js +1 -1
  3. package/es/components/InputTable.js +26 -19
  4. package/es/http/index.d.ts +34 -28
  5. package/es/http/index.js +153 -153
  6. package/es/utils/cache.d.ts +28 -0
  7. package/es/utils/cache.js +63 -0
  8. package/es/utils/constant.d.ts +12 -0
  9. package/es/utils/constant.js +20 -0
  10. package/es/utils/cookie.d.ts +15 -0
  11. package/es/utils/cookie.js +36 -0
  12. package/es/utils/event.d.ts +16 -0
  13. package/es/utils/event.js +26 -0
  14. package/es/utils/index.d.ts +8 -179
  15. package/es/utils/index.js +12 -423
  16. package/es/utils/print.d.ts +24 -0
  17. package/es/utils/print.js +86 -0
  18. package/es/utils/project.d.ts +33 -0
  19. package/es/utils/project.js +66 -0
  20. package/es/utils/url.d.ts +26 -0
  21. package/es/utils/url.js +113 -0
  22. package/es/utils/user.d.ts +29 -0
  23. package/es/utils/user.js +25 -0
  24. package/lib/components/InputTable.js +26 -19
  25. package/lib/http/index.d.ts +34 -28
  26. package/lib/http/index.js +153 -153
  27. package/lib/utils/cache.d.ts +28 -0
  28. package/lib/utils/cache.js +63 -0
  29. package/lib/utils/constant.d.ts +12 -0
  30. package/lib/utils/constant.js +20 -0
  31. package/lib/utils/cookie.d.ts +15 -0
  32. package/lib/utils/cookie.js +36 -0
  33. package/lib/utils/event.d.ts +16 -0
  34. package/lib/utils/event.js +26 -0
  35. package/lib/utils/index.d.ts +8 -179
  36. package/lib/utils/index.js +12 -423
  37. package/lib/utils/print.d.ts +24 -0
  38. package/lib/utils/print.js +86 -0
  39. package/lib/utils/project.d.ts +33 -0
  40. package/lib/utils/project.js +66 -0
  41. package/lib/utils/url.d.ts +26 -0
  42. package/lib/utils/url.js +113 -0
  43. package/lib/utils/user.d.ts +29 -0
  44. package/lib/utils/user.js +25 -0
  45. package/package.json +1 -1
@@ -0,0 +1,63 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+ /**
3
+ * 设置本地缓存
4
+ *
5
+ * @param {String} key 关键字
6
+ * @param {Object} data 值
7
+ * @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
8
+ */
9
+ export var setCache = function setCache(key, data) {
10
+ var session = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
11
+ if (_typeof(data) === 'object') {
12
+ data = JSON.stringify(data);
13
+ }
14
+ if (session) {
15
+ sessionStorage.setItem(key, data);
16
+ } else {
17
+ localStorage.setItem(key, data);
18
+ }
19
+ };
20
+ /**
21
+ * 读取本地缓存
22
+ *
23
+ * @param {String} key 关键字
24
+ * @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
25
+ * @returns 关键字对应的值
26
+ */
27
+ export var getCache = function getCache(key) {
28
+ var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
29
+ var data = session ? sessionStorage.getItem(key) : localStorage.getItem(key);
30
+ if (data && (data.startsWith('{') || data.startsWith('['))) {
31
+ data = JSON.parse(data);
32
+ }
33
+ return data;
34
+ };
35
+ /**
36
+ * 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
37
+ *
38
+ * @param key
39
+ * @returns
40
+ */
41
+ export var getCacheSessionFirst = function getCacheSessionFirst(key) {
42
+ return getCache(key, true) || getCache(key);
43
+ };
44
+ /**
45
+ * @param key 关键字,不传清除所有
46
+ * @param session 是否session storage , 默认 localStorage
47
+ */
48
+ export var clearCache = function clearCache(key) {
49
+ var session = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
50
+ if (key) {
51
+ if (session) {
52
+ sessionStorage.removeItem(key);
53
+ } else {
54
+ localStorage.removeItem(key);
55
+ }
56
+ } else {
57
+ if (session) {
58
+ sessionStorage.clear();
59
+ } else {
60
+ localStorage.clear();
61
+ }
62
+ }
63
+ };
@@ -0,0 +1,12 @@
1
+ /** @name 状态列表 */
2
+ export declare const statusList: {
3
+ value: number;
4
+ text: string;
5
+ label: string;
6
+ }[];
7
+ /** @name 是否列表 */
8
+ export declare const yesnoList: {
9
+ value: number;
10
+ text: string;
11
+ label: string;
12
+ }[];
@@ -0,0 +1,20 @@
1
+ /** @name 状态列表 */
2
+ export var statusList = [{
3
+ value: 1,
4
+ text: '启用',
5
+ label: '1→启用'
6
+ }, {
7
+ value: 0,
8
+ text: '禁用',
9
+ label: '0→禁用'
10
+ }];
11
+ /** @name 是否列表 */
12
+ export var yesnoList = [{
13
+ value: 1,
14
+ text: '是',
15
+ label: '1→是'
16
+ }, {
17
+ value: 0,
18
+ text: '否',
19
+ label: '0→否'
20
+ }];
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 获取Cookie
3
+ *
4
+ * @param {String} name Cookie名
5
+ * @returns
6
+ */
7
+ export declare const getCookie: (name: string) => string | null;
8
+ /**
9
+ * 设置Cookie
10
+ *
11
+ * @param {any} key Cookie名称
12
+ * @param {any} value Cookie 值
13
+ * @param {Number} day 有效天数 默认1天,
14
+ */
15
+ export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * 获取Cookie
3
+ *
4
+ * @param {String} name Cookie名
5
+ * @returns
6
+ */
7
+ export var getCookie = function getCookie(name) {
8
+ var arr;
9
+ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)');
10
+ if (arr = document.cookie.match(reg)) return arr[2];else return null;
11
+ };
12
+ /**
13
+ * 设置Cookie
14
+ *
15
+ * @param {any} key Cookie名称
16
+ * @param {any} value Cookie 值
17
+ * @param {Number} day 有效天数 默认1天,
18
+ */
19
+ export var setCookie = function setCookie(key, value) {
20
+ var day = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
21
+ var sameSite = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
22
+ if (day !== 0) {
23
+ var d = new Date(Date.now() + day * 24 * 60 * 60 * 1000);
24
+ if (sameSite) {
25
+ document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/;sameSite=None;secure=true");
26
+ } else {
27
+ document.cookie = "".concat(key, "=").concat(value, ";expires=").concat(d.toUTCString(), ";path=/");
28
+ }
29
+ } else {
30
+ if (sameSite) {
31
+ document.cookie = key + '=' + value + ';path=/;sameSite=None;secure=true';
32
+ } else {
33
+ document.cookie = key + '=' + value + ';path=/';
34
+ }
35
+ }
36
+ };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 绑定事件
3
+ *
4
+ * @param eventName 事件名
5
+ * @param fn 调用函数
6
+ * @param el 源对象,默认为window
7
+ */
8
+ export declare const on: (eventName: string, fn: Function, el: any | undefined) => void;
9
+ /**
10
+ * 解绑事件
11
+ *
12
+ * @param eventName 事件名
13
+ * @param fn 调用函数
14
+ * @param el 源对象,默认为window
15
+ */
16
+ export declare const off: (eventName: string, fn: Function, el: any | undefined) => void;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 绑定事件
3
+ *
4
+ * @param eventName 事件名
5
+ * @param fn 调用函数
6
+ * @param el 源对象,默认为window
7
+ */
8
+ export var on = function on(eventName, fn, el) {
9
+ if (!el) {
10
+ el = window;
11
+ }
12
+ el.addEventListener(eventName, fn);
13
+ };
14
+ /**
15
+ * 解绑事件
16
+ *
17
+ * @param eventName 事件名
18
+ * @param fn 调用函数
19
+ * @param el 源对象,默认为window
20
+ */
21
+ export var off = function off(eventName, fn, el) {
22
+ if (!el) {
23
+ el = window;
24
+ }
25
+ el.removeEventListener(eventName, fn);
26
+ };
@@ -7,32 +7,14 @@ export * from './promise';
7
7
  export * from './clac';
8
8
  export { getBrowserId } from 'ls-pro-tools';
9
9
  export * from './pasteUpload';
10
- /**
11
- * 获取 url 参数
12
- *
13
- * @param name
14
- * @param url
15
- * @returns
16
- */
17
- export declare const getUrlQuery: (name: string, url?: string) => string;
18
- export declare const getResourceProps: (name: string) => any;
19
- /**
20
- * 设置url传参
21
- *
22
- * @param {any} url
23
- * @param {any} keyvals
24
- * @returns
25
- */
26
- export declare const setUrlQuery: (url: string, keyvals?: Record<string, any>) => string;
27
- /**
28
- * 给 url 添加网关
29
- *
30
- * @param url 原url,以 / 打头
31
- * @param gatewayKey 设置gateway关键字 默认为 'gateway'
32
- * @param defaultGateway 默认网关 ''
33
- * @returns
34
- */
35
- export declare const toGatewayUrl: (url: string, gatewayKey?: string, defaultGateway?: string) => string;
10
+ export * from './cache';
11
+ export * from './constant';
12
+ export * from './cookie';
13
+ export * from './event';
14
+ export * from './url';
15
+ export * from './print';
16
+ export * from './user';
17
+ export * from './project';
36
18
  /**
37
19
  * 设置文档title
38
20
  *
@@ -40,55 +22,12 @@ export declare const toGatewayUrl: (url: string, gatewayKey?: string, defaultGat
40
22
  * @returns
41
23
  */
42
24
  export declare const setTitle: (title: string) => void;
43
- /**
44
- * 获取Cookie
45
- *
46
- * @param {String} name Cookie名
47
- * @returns
48
- */
49
- export declare const getCookie: (name: string) => string | null;
50
- /**
51
- * 设置Cookie
52
- *
53
- * @param {any} key Cookie名称
54
- * @param {any} value Cookie 值
55
- * @param {Number} day 有效天数 默认1天,
56
- */
57
- export declare const setCookie: (key: string, value: string | number, day?: number, sameSite?: boolean) => void;
58
25
  /**
59
26
  * 判断是否登录
60
27
  *
61
28
  * @returns
62
29
  */
63
30
  export declare const isLogin: () => boolean;
64
- /**
65
- * 设置本地缓存
66
- *
67
- * @param {String} key 关键字
68
- * @param {Object} data 值
69
- * @param {Boolean} session 保存到 sessionStorage 还是 localStorage,默认 localStorage
70
- */
71
- export declare const setCache: (key: string, data: any, session?: boolean) => void;
72
- /**
73
- * 读取本地缓存
74
- *
75
- * @param {String} key 关键字
76
- * @param {boolean} session 从 sessionStorage 取数还是从 localStorage 中取数 默认从 localStorage
77
- * @returns 关键字对应的值
78
- */
79
- export declare const getCache: any;
80
- /**
81
- * 读取本地缓存,优先从sessionStorage 取,取不到时再从 localStorage取
82
- *
83
- * @param key
84
- * @returns
85
- */
86
- export declare const getCacheSessionFirst: (key: string) => any;
87
- /**
88
- * @param key 关键字,不传清除所有
89
- * @param session 是否session storage , 默认 localStorage
90
- */
91
- export declare const clearCache: (key?: string | undefined, session?: boolean) => void;
92
31
  /**
93
32
  * 日期组选择转换
94
33
  *
@@ -99,94 +38,6 @@ export declare const clearCache: (key?: string | undefined, session?: boolean) =
99
38
  * @returns
100
39
  */
101
40
  export declare const rangeToSearch: (values: any, startField: string, endField: string, endSuffix?: string, startSuffex?: string) => any;
102
- /** @name 状态列表 */
103
- export declare const statusList: {
104
- value: number;
105
- text: string;
106
- label: string;
107
- }[];
108
- /** @name 是否列表 */
109
- export declare const yesnoList: {
110
- value: number;
111
- text: string;
112
- label: string;
113
- }[];
114
- /**
115
- * 绑定事件
116
- *
117
- * @param eventName 事件名
118
- * @param fn 调用函数
119
- * @param el 源对象,默认为window
120
- */
121
- export declare const on: (eventName: string, fn: Function, el: any | undefined) => void;
122
- /**
123
- * 解绑事件
124
- *
125
- * @param eventName 事件名
126
- * @param fn 调用函数
127
- * @param el 源对象,默认为window
128
- */
129
- export declare const off: (eventName: string, fn: Function, el: any | undefined) => void;
130
- /**
131
- * 打印预览
132
- *
133
- * @param templateNo 打印模板编码
134
- * @param reqUrl 业务请求api
135
- * @param bodyParam Post传参数
136
- * @param param Get传参数
137
- * @param method 请求方式,默认post
138
- * @param isNewPrintCenter 是否是新的打印中心,默认false
139
- * @returns
140
- */
141
- export declare const printView: (templateNo: string, reqUrl: string, bodyParam?: any, param?: any, method?: 'POST' | 'GET', isNewPrintCenter?: boolean) => any;
142
- /**
143
- * 直接打印,通过打印组件进行打印。
144
- *
145
- * @param taskName 打印任务名
146
- * @param templateNo 打印模板
147
- * @param reqUrl 业务请求api
148
- * @param bodyParam Post传参数
149
- * @param param Get传参数
150
- * @param method 请求方式,默认post
151
- * @returns
152
- */
153
- export declare const printAsync: (taskName: string, templateNo: string, reqUrl: string, bodyParam?: any, param?: any, method?: 'POST' | 'GET', isNewPrintCenter?: boolean) => Promise<any>;
154
- export declare const isDev: boolean;
155
- export declare type UserType = {
156
- id?: string;
157
- userId?: string;
158
- userName?: string;
159
- loginName?: string;
160
- companyId?: string;
161
- companyCode?: string;
162
- companyName?: string;
163
- email?: string;
164
- employeeAttr?: string;
165
- expireTime?: string;
166
- icon?: string;
167
- idCard?: string;
168
- ifAdmin?: number | string;
169
- orgId?: string;
170
- orgParentIds?: string;
171
- phoneNumber?: string;
172
- remarks?: string;
173
- };
174
- /** @name 用户信息 */
175
- export declare const getUserInfo: () => UserType | null;
176
- /** @name 用户名 */
177
- export declare const getUserName: () => string | undefined;
178
- /** @name 登录名 */
179
- export declare const getLoginName: () => string | undefined;
180
- /** @name 公司Id */
181
- export declare const getCompanyId: () => string | undefined;
182
- /**
183
- * 判断是否是微前端子应用
184
- *
185
- * @returns String | undefined
186
- */
187
- export declare const isQiankunSubApp: () => any;
188
- /** @name 微前端原生路径 */
189
- export declare const appPath: (path?: string) => any;
190
41
  /**
191
42
  * 深度复制对象
192
43
  *
@@ -194,21 +45,6 @@ export declare const appPath: (path?: string) => any;
194
45
  * @returns
195
46
  */
196
47
  export declare const deepClone: (obj: any) => any;
197
- /**
198
- * 在主工程中打开模块
199
- *
200
- * @param option {path:模块路由,需要加工程编码, resourceId: 资源Id,两者传一个即可,data:参数,moduleName:模块名称}
201
- */
202
- export declare const openPageInMain: (option: {
203
- [key: string]: any;
204
- path?: string | undefined;
205
- resourceId?: string | undefined;
206
- data?: any;
207
- ifRefreshTarget?: boolean | undefined;
208
- moduleName?: string | undefined;
209
- }) => void;
210
- /** 处理主题 */
211
- export declare const handleTheme: () => void;
212
48
  /**
213
49
  * 睡眠
214
50
  *
@@ -231,10 +67,3 @@ export declare const urlDownloadDomain: (url: string) => string;
231
67
  * @param isBlank 是否新开窗口下载,默认新开窗口,不影响原页面展示
232
68
  */
233
69
  export declare const downloadFile: (url: string, fileName?: string | undefined, isBlank?: boolean) => void;
234
- /**
235
- * 微前端主工程注入子工程时,子工程调用此方法设置资源Id,权限等参数
236
- *
237
- * @param props
238
- */
239
- export declare const setCurrentResCode: (props: any) => void;
240
- export declare const isDingtalk: boolean;