@lambo-design/shared 1.0.0-beta.237 → 1.0.0-beta.239

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 (182) hide show
  1. package/config/config.js +51 -51
  2. package/config/env.js +4 -4
  3. package/config/index.js +7 -7
  4. package/config/themes/atrovirens/atrovirens.css +575 -575
  5. package/config/themes/atrovirens/atrovirens.less +667 -667
  6. package/config/themes/atrovirens/var.less +674 -674
  7. package/config/themes/blue/blue.css +575 -575
  8. package/config/themes/blue/blue.less +669 -669
  9. package/config/themes/blue/var.less +677 -677
  10. package/config/themes/blue-white/blue-white.css +575 -575
  11. package/config/themes/blue-white/blue-white.less +669 -669
  12. package/config/themes/blue-white/var.less +676 -676
  13. package/config/themes/blue-white-tight/blue-white-tight.css +576 -576
  14. package/config/themes/blue-white-tight/blue-white-tight.less +672 -672
  15. package/config/themes/blue-white-tight/var.less +677 -677
  16. package/config/themes/danqing/danqing.css +576 -575
  17. package/config/themes/danqing/danqing.css.map +1 -1
  18. package/config/themes/danqing/danqing.less +668 -668
  19. package/config/themes/danqing/danqing.wxss +572 -572
  20. package/config/themes/danqing/var.less +679 -679
  21. package/config/themes/deep/deep.css +575 -575
  22. package/config/themes/deep/deep.less +669 -669
  23. package/config/themes/deep/var.less +677 -677
  24. package/config/themes/default/default.css +575 -575
  25. package/config/themes/default/default.less +671 -671
  26. package/config/themes/default/var.less +677 -677
  27. package/config/themes/eap/eap.css +575 -575
  28. package/config/themes/eap/eap.less +671 -671
  29. package/config/themes/eap/var.less +677 -677
  30. package/config/themes/gold/gold.css +575 -575
  31. package/config/themes/gold/gold.less +671 -671
  32. package/config/themes/gold/var.less +677 -677
  33. package/config/themes/index.js +28 -28
  34. package/config/themes/lime/lime.css +575 -575
  35. package/config/themes/lime/lime.less +671 -671
  36. package/config/themes/lime/var.less +678 -678
  37. package/config/themes/orange/orange.css +575 -575
  38. package/config/themes/orange/orange.less +671 -671
  39. package/config/themes/orange/var.less +678 -678
  40. package/config/themes/red/red.css +575 -575
  41. package/config/themes/red/red.less +671 -671
  42. package/config/themes/red/var.less +677 -677
  43. package/config/themes/theme-atrovirens.js +558 -558
  44. package/config/themes/theme-blue.js +558 -558
  45. package/config/themes/theme-bw.js +558 -558
  46. package/config/themes/theme-bwt.js +559 -559
  47. package/config/themes/theme-danqing.js +558 -558
  48. package/config/themes/theme-deep.js +558 -558
  49. package/config/themes/theme-default.js +558 -558
  50. package/config/themes/theme-eap.js +558 -558
  51. package/config/themes/theme-gold.js +558 -558
  52. package/config/themes/theme-lime.js +558 -558
  53. package/config/themes/theme-orange.js +559 -559
  54. package/config/themes/theme-red.js +558 -558
  55. package/config/themes/theme-white.js +557 -557
  56. package/config/themes/white/var.less +675 -675
  57. package/config/themes/white/white.css +575 -575
  58. package/config/themes/white/white.less +668 -668
  59. package/directives/index.js +23 -23
  60. package/directives/module/draggable.js +56 -56
  61. package/directives/module/permission.js +49 -49
  62. package/directives/module/print.js +1 -1
  63. package/directives/module/vue-print-nb/README.md +63 -63
  64. package/directives/module/vue-print-nb/print.js +94 -94
  65. package/directives/module/vue-print-nb/printarea.js +532 -532
  66. package/index.js +10 -10
  67. package/nstyles/common.less +197 -197
  68. package/nstyles/components/404.less +46 -46
  69. package/nstyles/components/button.less +34 -34
  70. package/nstyles/components/date-picker.less +37 -37
  71. package/nstyles/components/drawer.less +20 -20
  72. package/nstyles/components/dropdown.less +18 -18
  73. package/nstyles/components/excel-flow.less +72 -72
  74. package/nstyles/components/form.less +313 -303
  75. package/nstyles/components/index.less +23 -23
  76. package/nstyles/components/layout/collect.less +10 -10
  77. package/nstyles/components/layout/detail-view.less +107 -107
  78. package/nstyles/components/layout/full-screen.less +7 -7
  79. package/nstyles/components/layout/index.less +7 -7
  80. package/nstyles/components/layout/other-menu.less +142 -142
  81. package/nstyles/components/layout/page-view.less +101 -101
  82. package/nstyles/components/layout/sider-trigger.less +41 -41
  83. package/nstyles/components/layout/tags-nav.less +113 -113
  84. package/nstyles/components/modal.less +85 -85
  85. package/nstyles/components/n-button.less +131 -131
  86. package/nstyles/components/n-image-preview.less +131 -131
  87. package/nstyles/components/n-model/index.less +19 -19
  88. package/nstyles/components/n-model/report-index.less +43 -43
  89. package/nstyles/components/n-panel.less +40 -40
  90. package/nstyles/components/n-picker.less +37 -37
  91. package/nstyles/components/n-sign.less +17 -17
  92. package/nstyles/components/n-tooltip.less +10 -10
  93. package/nstyles/components/panel.less +31 -31
  94. package/nstyles/components/select.less +3 -3
  95. package/nstyles/components/sign.less +27 -27
  96. package/nstyles/components/table.less +315 -315
  97. package/nstyles/components/tree.less +158 -158
  98. package/nstyles/components/upload.less +164 -164
  99. package/nstyles/index.less +5 -5
  100. package/nstyles/reset.less +65 -65
  101. package/nstyles/third/ag.less +174 -174
  102. package/nstyles/third/index.less +11 -11
  103. package/nstyles/third/view-design.less +366 -366
  104. package/nstyles/variables/base.less +143 -143
  105. package/nstyles/variables/index.less +4 -4
  106. package/nstyles/variables/theme/default/button.less +7 -7
  107. package/nstyles/variables/theme/default/common.less +57 -57
  108. package/nstyles/variables/theme/default/index.less +7 -7
  109. package/nstyles/variables/theme/default/layout.less +40 -40
  110. package/nstyles/variables/theme/default/table.less +37 -37
  111. package/nstyles/variables/theme/default/tag.less +3 -3
  112. package/nstyles/variables/theme/default/upload.less +3 -3
  113. package/nstyles/variables/theme/index.less +13 -13
  114. package/nstyles/variables/theme/small/button.less +7 -7
  115. package/nstyles/variables/theme/small/common.less +39 -39
  116. package/nstyles/variables/theme/small/index.less +5 -5
  117. package/nstyles/variables/theme/small/layout.less +21 -21
  118. package/nstyles/variables/theme/small/table.less +17 -17
  119. package/nstyles/variables/theme/small/tag.less +3 -3
  120. package/package.json +1 -1
  121. package/plugin/index.js +12 -12
  122. package/plugin/module/date-format.js +30 -30
  123. package/plugin/module/loading.js +26 -26
  124. package/plugin/module/warn-handler.js +11 -11
  125. package/styles/variables.less +21 -21
  126. package/utils/ajax/cacheconf.js +19 -19
  127. package/utils/ajax/content-type.js +30 -30
  128. package/utils/ajax/index.js +12 -12
  129. package/utils/ajax/interceptors.js +97 -97
  130. package/utils/assist.js +147 -147
  131. package/utils/base64.js +126 -126
  132. package/utils/blob.js +47 -47
  133. package/utils/bus.js +3 -3
  134. package/utils/crypto/index.js +48 -48
  135. package/utils/crypto/md5.js +152 -152
  136. package/utils/crypto/sm3.js +235 -235
  137. package/utils/date.js +381 -381
  138. package/utils/dict/built-in-dict.js +20 -20
  139. package/utils/dict/index.js +167 -167
  140. package/utils/dom.js +38 -38
  141. package/utils/event.js +72 -72
  142. package/utils/excel.js +655 -655
  143. package/utils/file.js +19 -19
  144. package/utils/form/validate.js +29 -29
  145. package/utils/half-year.js +68 -68
  146. package/utils/index.js +41 -41
  147. package/utils/json.js +29 -29
  148. package/utils/lodop.js +165 -165
  149. package/utils/menu/before-close.js +17 -17
  150. package/utils/menu/index.js +395 -395
  151. package/utils/mime_type.js +67 -67
  152. package/utils/modelerUtil.js +227 -227
  153. package/utils/n/api.js +22 -22
  154. package/utils/n/date.js +57 -57
  155. package/utils/n/index.js +9 -9
  156. package/utils/n/is-type.js +176 -176
  157. package/utils/n/number.js +144 -144
  158. package/utils/n/permission-cache.js +11 -11
  159. package/utils/n/reuqest/axiosN.js +17 -17
  160. package/utils/n/reuqest/content-type.js +19 -19
  161. package/utils/n/reuqest/interceptors.js +95 -95
  162. package/utils/n/reuqest/url-params.js +12 -12
  163. package/utils/n/storage.js +51 -51
  164. package/utils/n/token.js +51 -51
  165. package/utils/n/user-cache.js +11 -11
  166. package/utils/n/user.js +34 -34
  167. package/utils/n/uuid.js +16 -16
  168. package/utils/n-generator-routers.js +208 -208
  169. package/utils/n-router.js +205 -205
  170. package/utils/n-theme.js +30 -30
  171. package/utils/number.js +180 -180
  172. package/utils/oss.js +57 -57
  173. package/utils/platform.js +1334 -1334
  174. package/utils/quarter.js +58 -58
  175. package/utils/storage.js +198 -198
  176. package/utils/theme.js +138 -138
  177. package/utils/transform.js +179 -0
  178. package/utils/type.js +102 -102
  179. package/utils/util.js +795 -795
  180. package/utils/validator.js +181 -181
  181. package/utils/vxetable/index.js +25 -25
  182. package/utils/zoomScroll.js +9 -9
package/utils/n/number.js CHANGED
@@ -1,144 +1,144 @@
1
- import _ from 'lodash'
2
-
3
- // 数字每三位加逗号
4
- export function toThousands(numStr) {
5
- let result = ''
6
- numStr = (numStr || 0).toString()
7
- while (numStr.length > 3) {
8
- result = ',' + numStr.slice(-3) + result
9
- numStr = numStr.slice(0, numStr.length - 3)
10
- }
11
- if (numStr) {
12
- result = numStr + result
13
- }
14
- return result
15
- }
16
-
17
- /**
18
- * 数字金额转为汉字
19
- */
20
- export function toChies(numStr) {
21
- const len = numStr.length //统计出长度
22
- const chin_list = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'] //所有的数值对应的汉字
23
- const chin_lisp = ['仟', '佰', '拾', '亿', '仟', '佰', '拾', '万', '仟', '佰', '拾'] //进制
24
-
25
- let numbers = []
26
- let hanStr = []
27
- let result = ''
28
-
29
- for (let i = 0; i < len; i++) {
30
- numbers.push(parseInt(numStr[i])) //输入的数据按下标存进去 存进去的只是数字
31
- hanStr[i] = chin_list[numbers[i]] //是根据我们输入的输入的数字,对应着我们的chin_list这个数组
32
- } //123['壹','佰','贰','拾','叁']
33
-
34
- for (let i = len - 1, j = 1; i > 0; i--) {
35
- //i =2 1 //倒序 为了添加进制,方便我们去观看
36
- hanStr.splice(i, 0, chin_lisp[chin_lisp.length - j++]) //j=2
37
- }
38
-
39
- result = hanStr.join('')
40
- if (len >= 1) {
41
- result += '元整'
42
- }
43
- return result
44
- }
45
-
46
- export function numToDX(numStr) {
47
- if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(numStr)) return '数据非法'
48
- let unit = '千百拾亿千百拾万千百拾元角分',
49
- str = ''
50
- numStr += '00'
51
- let p = numStr.indexOf('.')
52
- if (p >= 0) numStr = numStr.substring(0, p) + numStr.substr(p + 1, 2)
53
- unit = unit.substr(unit.length - numStr.length)
54
- for (let i = 0; i < numStr.length; i++)
55
- str += '零壹贰叁肆伍陆柒捌玖'.charAt(parseInt(numStr.charAt(i))) + unit.charAt(i)
56
- return str
57
- .replace(/零(千|百|拾|角)/g, '零')
58
- .replace(/(零)+/g, '零')
59
- .replace(/零(万|亿|元)/g, '$1')
60
- .replace(/(亿)万|壹(拾)/g, '$1$2')
61
- .replace(/^元零?|零分/g, '')
62
- .replace(/元$/g, '元整')
63
- }
64
-
65
- export function formatDecimal(num, decimal = 2) {
66
- num = num.toString()
67
- let index = num.indexOf('.')
68
- if (index !== -1) {
69
- num = num.substring(0, decimal + index + 1)
70
- } else {
71
- num = num.substring(0)
72
- }
73
- return parseFloat(num).toFixed(decimal)
74
- }
75
-
76
- /**
77
- * 保留指定位数的小数,对最后一位进行四舍五入
78
- */
79
- export function round(number, precision = 2) {
80
- if (typeof number === 'number') {
81
- // 指数表示法表示的数字 幂指数为-7以后 +number不转换为数字 只好用正则匹配了
82
- const reg = /([0-9])+e([-0-9]+)/
83
- const result = reg.exec(number + '') || []
84
- if (result.length > 2) {
85
- const num = result[1]
86
- const e = result[2]
87
- return Math.round(parseInt(+num + 'e' + (+e + precision))) / Math.pow(10, precision)
88
- }
89
- return Math.round(parseInt(+number + 'e' + precision)) / Math.pow(10, precision)
90
- }
91
- return number
92
- }
93
-
94
- /**
95
- * 保留指定位数的小数,对最后一位进行四舍五入,并返回字符串
96
- */
97
- export function toFixed(num, precision = 2) {
98
- const number = parseFloat(num + '')
99
- if (!isNaN(number) && (number || number === 0)) {
100
- return round(number, precision).toFixed(precision)
101
- }
102
-
103
- return num
104
- }
105
-
106
- /**
107
- * 数字转中文
108
- */
109
- export const numToChineseNumerals = (num) => {
110
- if (isNaN(num)) {
111
- throw 'numToChineseNumerals: 数据非法'
112
- }
113
- num = Number(num)
114
- return numToChineseNumeralsFormat(num).replace(/^零/, '').replace(/^一十/, '十')
115
- }
116
- const chineseNumeralList = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
117
- const orderOfMagnitudeList = ['', '十', '百', '千']
118
- function numToChineseNumeralsFormat(num) {
119
- if (num === 0) {
120
- return ''
121
- }
122
- const power = Math.floor(Math.log10(num))
123
- const y = Math.floor(power / 8)
124
- const x = Math.floor((power % 8) / 4)
125
- let n1 = Math.floor(num / Math.pow(10, 4 * x + 8 * y))
126
- let n2 = num % Math.pow(10, 4 * x + 8 * y)
127
- let str = _(String(n1).padStart(4, '0'))
128
- .split('')
129
- .map(
130
- (num, index) =>
131
- chineseNumeralList[num] + (num === '0' ? '' : orderOfMagnitudeList[3 - index]),
132
- )
133
- .uniq()
134
- .value()
135
- .join('')
136
- .replace(/零$/, '')
137
- for (let i = 0; i < x; i++) {
138
- str += '万'
139
- }
140
- for (let i = 0; i < y; i++) {
141
- str += '亿'
142
- }
143
- return str + numToChineseNumeralsFormat(n2)
144
- }
1
+ import _ from 'lodash'
2
+
3
+ // 数字每三位加逗号
4
+ export function toThousands(numStr) {
5
+ let result = ''
6
+ numStr = (numStr || 0).toString()
7
+ while (numStr.length > 3) {
8
+ result = ',' + numStr.slice(-3) + result
9
+ numStr = numStr.slice(0, numStr.length - 3)
10
+ }
11
+ if (numStr) {
12
+ result = numStr + result
13
+ }
14
+ return result
15
+ }
16
+
17
+ /**
18
+ * 数字金额转为汉字
19
+ */
20
+ export function toChies(numStr) {
21
+ const len = numStr.length //统计出长度
22
+ const chin_list = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'] //所有的数值对应的汉字
23
+ const chin_lisp = ['仟', '佰', '拾', '亿', '仟', '佰', '拾', '万', '仟', '佰', '拾'] //进制
24
+
25
+ let numbers = []
26
+ let hanStr = []
27
+ let result = ''
28
+
29
+ for (let i = 0; i < len; i++) {
30
+ numbers.push(parseInt(numStr[i])) //输入的数据按下标存进去 存进去的只是数字
31
+ hanStr[i] = chin_list[numbers[i]] //是根据我们输入的输入的数字,对应着我们的chin_list这个数组
32
+ } //123['壹','佰','贰','拾','叁']
33
+
34
+ for (let i = len - 1, j = 1; i > 0; i--) {
35
+ //i =2 1 //倒序 为了添加进制,方便我们去观看
36
+ hanStr.splice(i, 0, chin_lisp[chin_lisp.length - j++]) //j=2
37
+ }
38
+
39
+ result = hanStr.join('')
40
+ if (len >= 1) {
41
+ result += '元整'
42
+ }
43
+ return result
44
+ }
45
+
46
+ export function numToDX(numStr) {
47
+ if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(numStr)) return '数据非法'
48
+ let unit = '千百拾亿千百拾万千百拾元角分',
49
+ str = ''
50
+ numStr += '00'
51
+ let p = numStr.indexOf('.')
52
+ if (p >= 0) numStr = numStr.substring(0, p) + numStr.substr(p + 1, 2)
53
+ unit = unit.substr(unit.length - numStr.length)
54
+ for (let i = 0; i < numStr.length; i++)
55
+ str += '零壹贰叁肆伍陆柒捌玖'.charAt(parseInt(numStr.charAt(i))) + unit.charAt(i)
56
+ return str
57
+ .replace(/零(千|百|拾|角)/g, '零')
58
+ .replace(/(零)+/g, '零')
59
+ .replace(/零(万|亿|元)/g, '$1')
60
+ .replace(/(亿)万|壹(拾)/g, '$1$2')
61
+ .replace(/^元零?|零分/g, '')
62
+ .replace(/元$/g, '元整')
63
+ }
64
+
65
+ export function formatDecimal(num, decimal = 2) {
66
+ num = num.toString()
67
+ let index = num.indexOf('.')
68
+ if (index !== -1) {
69
+ num = num.substring(0, decimal + index + 1)
70
+ } else {
71
+ num = num.substring(0)
72
+ }
73
+ return parseFloat(num).toFixed(decimal)
74
+ }
75
+
76
+ /**
77
+ * 保留指定位数的小数,对最后一位进行四舍五入
78
+ */
79
+ export function round(number, precision = 2) {
80
+ if (typeof number === 'number') {
81
+ // 指数表示法表示的数字 幂指数为-7以后 +number不转换为数字 只好用正则匹配了
82
+ const reg = /([0-9])+e([-0-9]+)/
83
+ const result = reg.exec(number + '') || []
84
+ if (result.length > 2) {
85
+ const num = result[1]
86
+ const e = result[2]
87
+ return Math.round(parseInt(+num + 'e' + (+e + precision))) / Math.pow(10, precision)
88
+ }
89
+ return Math.round(parseInt(+number + 'e' + precision)) / Math.pow(10, precision)
90
+ }
91
+ return number
92
+ }
93
+
94
+ /**
95
+ * 保留指定位数的小数,对最后一位进行四舍五入,并返回字符串
96
+ */
97
+ export function toFixed(num, precision = 2) {
98
+ const number = parseFloat(num + '')
99
+ if (!isNaN(number) && (number || number === 0)) {
100
+ return round(number, precision).toFixed(precision)
101
+ }
102
+
103
+ return num
104
+ }
105
+
106
+ /**
107
+ * 数字转中文
108
+ */
109
+ export const numToChineseNumerals = (num) => {
110
+ if (isNaN(num)) {
111
+ throw 'numToChineseNumerals: 数据非法'
112
+ }
113
+ num = Number(num)
114
+ return numToChineseNumeralsFormat(num).replace(/^零/, '').replace(/^一十/, '十')
115
+ }
116
+ const chineseNumeralList = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']
117
+ const orderOfMagnitudeList = ['', '十', '百', '千']
118
+ function numToChineseNumeralsFormat(num) {
119
+ if (num === 0) {
120
+ return ''
121
+ }
122
+ const power = Math.floor(Math.log10(num))
123
+ const y = Math.floor(power / 8)
124
+ const x = Math.floor((power % 8) / 4)
125
+ let n1 = Math.floor(num / Math.pow(10, 4 * x + 8 * y))
126
+ let n2 = num % Math.pow(10, 4 * x + 8 * y)
127
+ let str = _(String(n1).padStart(4, '0'))
128
+ .split('')
129
+ .map(
130
+ (num, index) =>
131
+ chineseNumeralList[num] + (num === '0' ? '' : orderOfMagnitudeList[3 - index]),
132
+ )
133
+ .uniq()
134
+ .value()
135
+ .join('')
136
+ .replace(/零$/, '')
137
+ for (let i = 0; i < x; i++) {
138
+ str += '万'
139
+ }
140
+ for (let i = 0; i < y; i++) {
141
+ str += '亿'
142
+ }
143
+ return str + numToChineseNumeralsFormat(n2)
144
+ }
@@ -1,11 +1,11 @@
1
- import { getSessionStorage, setSessionStorage, removeSessionStorage } from './storage';
2
- const PERMISSION_KEY = 'ibp-sc-permission';
3
- export function getPermissionCache() {
4
- return getSessionStorage(PERMISSION_KEY);
5
- }
6
- export function setPermissionCache(data) {
7
- setSessionStorage(PERMISSION_KEY, data);
8
- }
9
- export function clearPermissionCache() {
10
- removeSessionStorage(PERMISSION_KEY);
11
- }
1
+ import { getSessionStorage, setSessionStorage, removeSessionStorage } from './storage';
2
+ const PERMISSION_KEY = 'ibp-sc-permission';
3
+ export function getPermissionCache() {
4
+ return getSessionStorage(PERMISSION_KEY);
5
+ }
6
+ export function setPermissionCache(data) {
7
+ setSessionStorage(PERMISSION_KEY, data);
8
+ }
9
+ export function clearPermissionCache() {
10
+ removeSessionStorage(PERMISSION_KEY);
11
+ }
@@ -1,17 +1,17 @@
1
- import axios from 'axios';
2
- import { requestInterceptors, responseInterceptors, inspectorError } from './interceptors';
3
- import { CONTENT_TYPE, setContentType } from './content-type';
4
- export * from './url-params';
5
- export * from './content-type';
6
- export { responseInterceptors };
7
- const instance = axios.create({ timeout: 5 * 60 * 1000 });
8
- instance.interceptors.request.use(requestInterceptors, inspectorError);
9
- instance.interceptors.response.use(responseInterceptors, inspectorError);
10
- instance.formPost = function (url, data, config) {
11
- const headers = (config === null || config === void 0 ? void 0 : config.headers) || {};
12
- setContentType(headers, CONTENT_TYPE.form);
13
- return instance.post(url, data, Object.assign(Object.assign({}, config), { headers }));
14
- };
15
- export { instance as axiosN };
16
-
17
- export default instance;
1
+ import axios from 'axios';
2
+ import { requestInterceptors, responseInterceptors, inspectorError } from './interceptors';
3
+ import { CONTENT_TYPE, setContentType } from './content-type';
4
+ export * from './url-params';
5
+ export * from './content-type';
6
+ export { responseInterceptors };
7
+ const instance = axios.create({ timeout: 5 * 60 * 1000 });
8
+ instance.interceptors.request.use(requestInterceptors, inspectorError);
9
+ instance.interceptors.response.use(responseInterceptors, inspectorError);
10
+ instance.formPost = function (url, data, config) {
11
+ const headers = (config === null || config === void 0 ? void 0 : config.headers) || {};
12
+ setContentType(headers, CONTENT_TYPE.form);
13
+ return instance.post(url, data, Object.assign(Object.assign({}, config), { headers }));
14
+ };
15
+ export { instance as axiosN };
16
+
17
+ export default instance;
@@ -1,19 +1,19 @@
1
- const contentTypeKey = 'Content-Type';
2
- export function getContentType(config) {
3
- let type = (config === null || config === void 0 ? void 0 : config[contentTypeKey]) || (config === null || config === void 0 ? void 0 : config['content-type']) || '';
4
- const suffixIdx = type.indexOf(';');
5
- if (suffixIdx !== -1) {
6
- type = type.substring(0, suffixIdx);
7
- }
8
- return type;
9
- }
10
- export function setContentType(headers, type) {
11
- headers[contentTypeKey] = type;
12
- }
13
- export const CONTENT_TYPE = {
14
- form: 'application/x-www-form-urlencoded',
15
- multiForm: 'multipart/form-data',
16
- body: 'application/json',
17
- os: 'application/octet-stream',
18
- json: 'application/json',
19
- };
1
+ const contentTypeKey = 'Content-Type';
2
+ export function getContentType(config) {
3
+ let type = (config === null || config === void 0 ? void 0 : config[contentTypeKey]) || (config === null || config === void 0 ? void 0 : config['content-type']) || '';
4
+ const suffixIdx = type.indexOf(';');
5
+ if (suffixIdx !== -1) {
6
+ type = type.substring(0, suffixIdx);
7
+ }
8
+ return type;
9
+ }
10
+ export function setContentType(headers, type) {
11
+ headers[contentTypeKey] = type;
12
+ }
13
+ export const CONTENT_TYPE = {
14
+ form: 'application/x-www-form-urlencoded',
15
+ multiForm: 'multipart/form-data',
16
+ body: 'application/json',
17
+ os: 'application/octet-stream',
18
+ json: 'application/json',
19
+ };
@@ -1,95 +1,95 @@
1
- import qs from 'qs';
2
- import { getUrlParams } from './url-params';
3
- import { CONTENT_TYPE, getContentType } from './content-type';
4
- // import cacheRules from './cache-rules'
5
- import { getToken } from '../token';
6
- import { config } from '../../../config/config';
7
- const SUCCESS_CODE = 1;
8
- const NO_SESSION_CODE = 10106;
9
- let timer = null;
10
- function _debounce(callback) {
11
- if (timer) {
12
- clearTimeout(timer);
13
- }
14
- let callNow = !timer;
15
- timer = setTimeout(() => {
16
- timer = null;
17
- }, 1000 * 20);
18
- callNow && callback();
19
- }
20
- // 请求的拦截器,处理Content-Type以及加入token
21
- export function requestInterceptors(config) {
22
- let token = getToken();
23
- if (token) {
24
- config.headers.token = token;
25
- }
26
- // 以下拷自lambo-design
27
- const params = getUrlParams();
28
- // sso_token认证
29
- if (params.hasOwnProperty('sso_token') || sessionStorage.getItem('sso_token')) {
30
- config.params = Object.assign({
31
- sso_token: params.sso_token || sessionStorage.getItem('sso_token'),
32
- sso_id: params.sso_id,
33
- }, config.params);
34
- }
35
- const contentType = getContentType(config.headers);
36
- if (config.method === 'post') {
37
- // form 表单方式提交
38
- if (contentType === CONTENT_TYPE.form) {
39
- config.data = qs.stringify(config.data);
40
- }
41
- }
42
- else if (config.method === 'get') {
43
- // 暂时不要这个逻辑
44
- // for (let rule of cacheRules) {
45
- // if (rule.test(config.url)) {
46
- // return config
47
- // }
48
- // }
49
- // if (config.url.indexOf('?') === -1) {
50
- // config.url = config.url + '?t=' + new Date().getTime()
51
- // } else {
52
- // config.url = config.url + '&t=' + new Date().getTime()
53
- // }
54
- }
55
- return config;
56
- }
57
- export function responseInterceptors(response) {
58
- let data = response.data;
59
- // 下载文件返回格式不是json
60
- const contentType = getContentType(response.headers);
61
- if (contentType !== CONTENT_TYPE.json) {
62
- return data;
63
- }
64
- if (typeof response.data === 'string') {
65
- data = JSON.parse(response.data);
66
- }
67
- const code = data.code;
68
- switch (code) {
69
- case SUCCESS_CODE: {
70
- return data;
71
- }
72
- case NO_SESSION_CODE: {
73
- _debounce(function () {
74
- window.sessionNotValidHandler && window.sessionNotValidHandler();
75
- });
76
- break;
77
- }
78
- default: {
79
- let msg = data.message || data.msg || config.errorMessage;
80
- window.apiErrorHandler && window.apiErrorHandler(msg);
81
- }
82
- }
83
- return Promise.reject(data);
84
- }
85
- export function inspectorError(error) {
86
- var _a;
87
- if ((error === null || error === void 0 ? void 0 : error.code) === 'ECONNABORTED') {
88
- // 超时
89
- window.apiErrorHandler && window.apiErrorHandler('请求超时,请稍后再试');
90
- }
91
- else if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) !== 200) {
92
- window.apiErrorHandler && window.apiErrorHandler('请求出错了');
93
- }
94
- return Promise.reject(error);
95
- }
1
+ import qs from 'qs';
2
+ import { getUrlParams } from './url-params';
3
+ import { CONTENT_TYPE, getContentType } from './content-type';
4
+ // import cacheRules from './cache-rules'
5
+ import { getToken } from '../token';
6
+ import { config } from '../../../config/config';
7
+ const SUCCESS_CODE = 1;
8
+ const NO_SESSION_CODE = 10106;
9
+ let timer = null;
10
+ function _debounce(callback) {
11
+ if (timer) {
12
+ clearTimeout(timer);
13
+ }
14
+ let callNow = !timer;
15
+ timer = setTimeout(() => {
16
+ timer = null;
17
+ }, 1000 * 20);
18
+ callNow && callback();
19
+ }
20
+ // 请求的拦截器,处理Content-Type以及加入token
21
+ export function requestInterceptors(config) {
22
+ let token = getToken();
23
+ if (token) {
24
+ config.headers.token = token;
25
+ }
26
+ // 以下拷自lambo-design
27
+ const params = getUrlParams();
28
+ // sso_token认证
29
+ if (params.hasOwnProperty('sso_token') || sessionStorage.getItem('sso_token')) {
30
+ config.params = Object.assign({
31
+ sso_token: params.sso_token || sessionStorage.getItem('sso_token'),
32
+ sso_id: params.sso_id,
33
+ }, config.params);
34
+ }
35
+ const contentType = getContentType(config.headers);
36
+ if (config.method === 'post') {
37
+ // form 表单方式提交
38
+ if (contentType === CONTENT_TYPE.form) {
39
+ config.data = qs.stringify(config.data);
40
+ }
41
+ }
42
+ else if (config.method === 'get') {
43
+ // 暂时不要这个逻辑
44
+ // for (let rule of cacheRules) {
45
+ // if (rule.test(config.url)) {
46
+ // return config
47
+ // }
48
+ // }
49
+ // if (config.url.indexOf('?') === -1) {
50
+ // config.url = config.url + '?t=' + new Date().getTime()
51
+ // } else {
52
+ // config.url = config.url + '&t=' + new Date().getTime()
53
+ // }
54
+ }
55
+ return config;
56
+ }
57
+ export function responseInterceptors(response) {
58
+ let data = response.data;
59
+ // 下载文件返回格式不是json
60
+ const contentType = getContentType(response.headers);
61
+ if (contentType !== CONTENT_TYPE.json) {
62
+ return data;
63
+ }
64
+ if (typeof response.data === 'string') {
65
+ data = JSON.parse(response.data);
66
+ }
67
+ const code = data.code;
68
+ switch (code) {
69
+ case SUCCESS_CODE: {
70
+ return data;
71
+ }
72
+ case NO_SESSION_CODE: {
73
+ _debounce(function () {
74
+ window.sessionNotValidHandler && window.sessionNotValidHandler();
75
+ });
76
+ break;
77
+ }
78
+ default: {
79
+ let msg = data.message || data.msg || config.errorMessage;
80
+ window.apiErrorHandler && window.apiErrorHandler(msg);
81
+ }
82
+ }
83
+ return Promise.reject(data);
84
+ }
85
+ export function inspectorError(error) {
86
+ var _a;
87
+ if ((error === null || error === void 0 ? void 0 : error.code) === 'ECONNABORTED') {
88
+ // 超时
89
+ window.apiErrorHandler && window.apiErrorHandler('请求超时,请稍后再试');
90
+ }
91
+ else if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) !== 200) {
92
+ window.apiErrorHandler && window.apiErrorHandler('请求出错了');
93
+ }
94
+ return Promise.reject(error);
95
+ }
@@ -1,12 +1,12 @@
1
- export function getUrlParams() {
2
- const url = location.search; //获取url中"?"符后的字串
3
- const theRequest = new Object();
4
- if (url.indexOf('?') != -1) {
5
- const str = url.substr(1);
6
- let strs = str.split('&');
7
- for (let i = 0; i < strs.length; i++) {
8
- theRequest[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1]);
9
- }
10
- }
11
- return theRequest;
12
- }
1
+ export function getUrlParams() {
2
+ const url = location.search; //获取url中"?"符后的字串
3
+ const theRequest = new Object();
4
+ if (url.indexOf('?') != -1) {
5
+ const str = url.substr(1);
6
+ let strs = str.split('&');
7
+ for (let i = 0; i < strs.length; i++) {
8
+ theRequest[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1]);
9
+ }
10
+ }
11
+ return theRequest;
12
+ }