eoss-ui 0.6.38 → 0.6.39

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 (261) hide show
  1. package/lib/button-group.js +535 -374
  2. package/lib/button.js +535 -374
  3. package/lib/checkbox-group.js +536 -375
  4. package/lib/config/api.js +31 -19
  5. package/lib/data-table-form.js +547 -386
  6. package/lib/data-table.js +547 -382
  7. package/lib/date-picker.js +535 -374
  8. package/lib/dialog.js +535 -374
  9. package/lib/eoss-ui.common.js +11182 -4328
  10. package/lib/error-page.js +4 -4
  11. package/lib/flow-group.js +553 -377
  12. package/lib/flow-list.js +621 -460
  13. package/lib/flow.js +9822 -2988
  14. package/lib/form.js +540 -379
  15. package/lib/handle-user.js +536 -375
  16. package/lib/handler.js +536 -375
  17. package/lib/icon.js +536 -375
  18. package/lib/index.js +1 -1
  19. package/lib/input-number.js +535 -374
  20. package/lib/input.js +535 -374
  21. package/lib/layout.js +2 -2
  22. package/lib/login.js +550 -389
  23. package/lib/main.js +704 -543
  24. package/lib/nav.js +535 -374
  25. package/lib/notify.js +127 -109
  26. package/lib/page.js +535 -374
  27. package/lib/pagination.js +535 -374
  28. package/lib/player.js +535 -374
  29. package/lib/qr-code.js +548 -387
  30. package/lib/radio-group.js +536 -375
  31. package/lib/retrial-auth.js +538 -377
  32. package/lib/select-ganged.js +536 -375
  33. package/lib/select.js +536 -375
  34. package/lib/selector-panel.js +558 -396
  35. package/lib/selector.js +539 -378
  36. package/lib/sizer.js +541 -380
  37. package/lib/steps.js +535 -374
  38. package/lib/switch.js +535 -374
  39. package/lib/table-form.js +535 -374
  40. package/lib/tabs.js +539 -378
  41. package/lib/theme-chalk/flow.css +1 -1
  42. package/lib/theme-chalk/index.css +1 -1
  43. package/lib/tips.js +536 -375
  44. package/lib/tree-group.js +535 -374
  45. package/lib/tree.js +536 -375
  46. package/lib/upload.js +545 -384
  47. package/lib/utils/util.js +411 -268
  48. package/lib/wujie.js +535 -374
  49. package/lib/wxlogin.js +535 -374
  50. package/package.json +159 -158
  51. package/packages/button/index.js +5 -5
  52. package/packages/button/src/main.vue +418 -418
  53. package/packages/button-group/index.js +5 -5
  54. package/packages/button-group/src/main.vue +298 -298
  55. package/packages/calendar/index.js +5 -5
  56. package/packages/card/index.js +5 -5
  57. package/packages/card/src/main.vue +156 -156
  58. package/packages/cascader/index.js +5 -5
  59. package/packages/cascader/src/main.vue +168 -168
  60. package/packages/checkbox-group/index.js +5 -5
  61. package/packages/checkbox-group/src/main.vue +333 -333
  62. package/packages/clients/index.js +5 -5
  63. package/packages/clients/src/main.vue +144 -144
  64. package/packages/data-table/index.js +5 -5
  65. package/packages/data-table/src/children.vue +39 -39
  66. package/packages/data-table/src/column.vue +983 -983
  67. package/packages/data-table/src/main.vue +1820 -1816
  68. package/packages/data-table/src/sizer.vue +195 -195
  69. package/packages/data-table-form/index.js +5 -5
  70. package/packages/data-table-form/src/checkbox.vue +101 -101
  71. package/packages/data-table-form/src/colgroup.vue +17 -17
  72. package/packages/data-table-form/src/main.vue +181 -181
  73. package/packages/data-table-form/src/radio.vue +65 -65
  74. package/packages/data-table-form/src/table.vue +233 -233
  75. package/packages/data-table-form/src/tbody.vue +336 -336
  76. package/packages/data-table-form/src/thead.vue +68 -68
  77. package/packages/date-picker/index.js +5 -5
  78. package/packages/date-picker/src/main.vue +236 -236
  79. package/packages/dialog/index.js +5 -5
  80. package/packages/enterprise/index.js +5 -5
  81. package/packages/enterprise/src/main.vue +66 -66
  82. package/packages/error-page/index.js +5 -5
  83. package/packages/error-page/src/main.vue +44 -44
  84. package/packages/flow/index.js +5 -5
  85. package/packages/flow/src/component/CommonOpinions.vue +345 -341
  86. package/packages/flow/src/component/CustomPreset.vue +322 -322
  87. package/packages/flow/src/component/FileList.vue +99 -99
  88. package/packages/flow/src/component/Preset.vue +255 -255
  89. package/packages/flow/src/component/SendMsg.vue +229 -229
  90. package/packages/flow/src/component/TimeLimit.vue +190 -190
  91. package/packages/flow/src/component/taskUnionExamine.vue +603 -547
  92. package/packages/flow/src/form.vue +121 -121
  93. package/packages/flow/src/freeStartFlow.vue +2843 -0
  94. package/packages/flow/src/main.vue +2864 -2731
  95. package/packages/flow/src/processForm.vue +1007 -954
  96. package/packages/flow/src/processReject.vue +293 -293
  97. package/packages/flow/src/reset.vue +901 -0
  98. package/packages/flow/src/selectUser.vue +5 -0
  99. package/packages/flow/src/startTaskRead.vue +596 -596
  100. package/packages/flow/src/table.vue +58 -58
  101. package/packages/flow-group/index.js +5 -5
  102. package/packages/flow-group/src/main.vue +688 -684
  103. package/packages/flow-list/index.js +5 -5
  104. package/packages/flow-list/src/main.vue +1172 -1172
  105. package/packages/form/index.js +5 -5
  106. package/packages/form/src/main.vue +3584 -3584
  107. package/packages/form/src/table.vue +1420 -1420
  108. package/packages/handle-user/index.js +5 -5
  109. package/packages/handle-user/src/main.vue +138 -138
  110. package/packages/handler/index.js +5 -5
  111. package/packages/handler/src/main.vue +388 -388
  112. package/packages/icon/index.js +5 -5
  113. package/packages/icon/src/main.vue +101 -101
  114. package/packages/icons/index.js +5 -5
  115. package/packages/icons/src/main.vue +81 -81
  116. package/packages/input/index.js +5 -5
  117. package/packages/input/src/main.vue +356 -356
  118. package/packages/input-number/index.js +5 -5
  119. package/packages/input-number/src/main.vue +106 -106
  120. package/packages/label/index.js +5 -5
  121. package/packages/label/src/main.vue +457 -457
  122. package/packages/layout/index.js +5 -5
  123. package/packages/layout/src/item.vue +152 -152
  124. package/packages/layout/src/main.vue +31 -31
  125. package/packages/login/index.js +5 -5
  126. package/packages/login/src/main.vue +1892 -1894
  127. package/packages/login/src/resetPassword.vue +562 -562
  128. package/packages/main/index.js +5 -5
  129. package/packages/main/src/default/message.vue +249 -249
  130. package/packages/main/src/default/notice.vue +157 -157
  131. package/packages/main/src/default/userinfo.vue +505 -505
  132. package/packages/main/src/public/online.vue +89 -89
  133. package/packages/main/src/public/search.vue +454 -454
  134. package/packages/main/src/public/settings.vue +221 -221
  135. package/packages/main/src/simplicity/apps.vue +388 -388
  136. package/packages/main/src/simplicity/avatar.vue +82 -82
  137. package/packages/main/src/simplicity/handler.vue +221 -221
  138. package/packages/main/src/simplicity/index.vue +1993 -1993
  139. package/packages/main/src/simplicity/lists.vue +84 -84
  140. package/packages/main/src/simplicity/menu-list.vue +128 -128
  141. package/packages/main/src/simplicity/message.vue +259 -259
  142. package/packages/main/src/simplicity/notice.vue +190 -190
  143. package/packages/main/src/simplicity/router-page.vue +45 -45
  144. package/packages/main/src/simplicity/sub-menu.vue +241 -241
  145. package/packages/main/src/simplicity/user.vue +257 -257
  146. package/packages/main/src/simplicity/userinfo.vue +312 -312
  147. package/packages/menu/index.js +5 -5
  148. package/packages/menu/src/main.vue +536 -536
  149. package/packages/nav/index.js +5 -5
  150. package/packages/nav/src/main.vue +402 -402
  151. package/packages/notify/index.js +5 -5
  152. package/packages/notify/src/main.vue +538 -538
  153. package/packages/page/index.js +5 -5
  154. package/packages/page/src/main.vue +167 -167
  155. package/packages/pagination/index.js +5 -5
  156. package/packages/pagination/src/main.vue +96 -96
  157. package/packages/player/index.js +5 -5
  158. package/packages/player/src/main.vue +194 -194
  159. package/packages/qr-code/index.js +5 -5
  160. package/packages/qr-code/src/main.vue +170 -170
  161. package/packages/radio-group/index.js +6 -6
  162. package/packages/radio-group/src/main.vue +319 -319
  163. package/packages/retrial-auth/index.js +5 -5
  164. package/packages/retrial-auth/src/main.vue +280 -280
  165. package/packages/select/index.js +5 -5
  166. package/packages/select/src/main.vue +775 -775
  167. package/packages/select-ganged/index.js +5 -5
  168. package/packages/select-ganged/src/main.vue +724 -724
  169. package/packages/selector/index.js +5 -5
  170. package/packages/selector/src/main.vue +677 -677
  171. package/packages/selector-panel/index.js +5 -5
  172. package/packages/selector-panel/src/main.vue +1028 -1027
  173. package/packages/selector-panel/src/selection.vue +177 -177
  174. package/packages/selector-panel/src/tree.vue +129 -129
  175. package/packages/sizer/index.js +5 -5
  176. package/packages/sizer/src/main.vue +254 -254
  177. package/packages/steps/index.js +5 -5
  178. package/packages/steps/src/main.vue +181 -181
  179. package/packages/switch/index.js +5 -5
  180. package/packages/switch/src/main.vue +154 -154
  181. package/packages/table-form/index.js +5 -5
  182. package/packages/tabs/index.js +5 -5
  183. package/packages/tabs/src/main.vue +788 -788
  184. package/packages/tabs-panel/index.js +5 -5
  185. package/packages/tabs-panel/src/main.vue +29 -29
  186. package/packages/theme-chalk/lib/flow.css +1 -1
  187. package/packages/theme-chalk/lib/index.css +1 -1
  188. package/packages/theme-chalk/src/base.scss +260 -260
  189. package/packages/theme-chalk/src/button-group.scss +175 -175
  190. package/packages/theme-chalk/src/button.scss +24 -24
  191. package/packages/theme-chalk/src/calendar.scss +113 -113
  192. package/packages/theme-chalk/src/card.scss +99 -99
  193. package/packages/theme-chalk/src/checkbox-group.scss +8 -8
  194. package/packages/theme-chalk/src/clients.scss +87 -87
  195. package/packages/theme-chalk/src/data-table-form.scss +67 -67
  196. package/packages/theme-chalk/src/data-table.scss +293 -293
  197. package/packages/theme-chalk/src/date-picker.scss +7 -7
  198. package/packages/theme-chalk/src/dialog.scss +77 -77
  199. package/packages/theme-chalk/src/enterprise.scss +5 -5
  200. package/packages/theme-chalk/src/error-page.scss +18 -18
  201. package/packages/theme-chalk/src/flow-group.scss +110 -110
  202. package/packages/theme-chalk/src/flow-list.scss +36 -36
  203. package/packages/theme-chalk/src/flow.scss +310 -308
  204. package/packages/theme-chalk/src/form.scss +496 -496
  205. package/packages/theme-chalk/src/handle-user.scss +40 -40
  206. package/packages/theme-chalk/src/handler.scss +143 -143
  207. package/packages/theme-chalk/src/icon.scss +1760 -1760
  208. package/packages/theme-chalk/src/icons.scss +99 -99
  209. package/packages/theme-chalk/src/input.scss +9 -9
  210. package/packages/theme-chalk/src/label.scss +24 -24
  211. package/packages/theme-chalk/src/layout.scss +46 -46
  212. package/packages/theme-chalk/src/login.scss +939 -939
  213. package/packages/theme-chalk/src/main.scss +632 -632
  214. package/packages/theme-chalk/src/menu.scss +222 -222
  215. package/packages/theme-chalk/src/mixins/color.scss +117 -117
  216. package/packages/theme-chalk/src/nav.scss +125 -125
  217. package/packages/theme-chalk/src/page.scss +3 -3
  218. package/packages/theme-chalk/src/pagination.scss +29 -29
  219. package/packages/theme-chalk/src/player.scss +9 -9
  220. package/packages/theme-chalk/src/qr-code.scss +17 -17
  221. package/packages/theme-chalk/src/radio-group.scss +9 -9
  222. package/packages/theme-chalk/src/retrial-auth.scss +38 -38
  223. package/packages/theme-chalk/src/select-ganged.scss +8 -8
  224. package/packages/theme-chalk/src/select.scss +8 -8
  225. package/packages/theme-chalk/src/selector-panel.scss +204 -204
  226. package/packages/theme-chalk/src/selector.scss +91 -91
  227. package/packages/theme-chalk/src/simplicity.scss +1262 -1262
  228. package/packages/theme-chalk/src/sizer.scss +36 -36
  229. package/packages/theme-chalk/src/steps.scss +88 -88
  230. package/packages/theme-chalk/src/switch.scss +3 -3
  231. package/packages/theme-chalk/src/table-form.scss +1 -1
  232. package/packages/theme-chalk/src/tabs.scss +87 -87
  233. package/packages/theme-chalk/src/tips.scss +7 -7
  234. package/packages/theme-chalk/src/toolbar.scss +179 -179
  235. package/packages/theme-chalk/src/tree-group.scss +72 -72
  236. package/packages/theme-chalk/src/tree.scss +165 -165
  237. package/packages/theme-chalk/src/upload.scss +167 -167
  238. package/packages/theme-chalk/src/wxlogin.scss +3 -3
  239. package/packages/tips/index.js +5 -5
  240. package/packages/tips/src/main.vue +141 -141
  241. package/packages/toolbar/index.js +5 -5
  242. package/packages/toolbar/src/main.vue +430 -430
  243. package/packages/tree/index.js +5 -5
  244. package/packages/tree-group/index.js +5 -5
  245. package/packages/upload/index.js +5 -5
  246. package/packages/upload/src/main.vue +1334 -1334
  247. package/packages/upload/src/picture.js +15 -15
  248. package/packages/wujie/index.js +5 -5
  249. package/packages/wujie/src/main.vue +145 -145
  250. package/packages/wxlogin/index.js +5 -5
  251. package/packages/wxlogin/src/main.vue +128 -128
  252. package/src/config/api.js +248 -236
  253. package/src/config/image.js +2 -2
  254. package/src/index.js +1 -1
  255. package/src/utils/bus.js +3 -3
  256. package/src/utils/date-util.js +312 -312
  257. package/src/utils/http.js +50 -50
  258. package/src/utils/rules.js +18 -18
  259. package/src/utils/store.js +21 -21
  260. package/src/utils/util.js +398 -258
  261. package/src/utils/webSocket.js +107 -107
package/src/utils/util.js CHANGED
@@ -26,6 +26,7 @@ const $darkColorCount = 4;
26
26
  const publicKey = 'abcdefghijklmnopqrstuvwxyz12345678';
27
27
  let loginMsg;
28
28
  let initAuth;
29
+ let $_http;
29
30
 
30
31
  const JSONbigToString = JSONbig({ storeAsString: true });
31
32
  import { MessageBox, Loading } from 'eoss-element';
@@ -89,290 +90,293 @@ const ajax = function ({
89
90
  } else {
90
91
  method = method.toLowerCase();
91
92
  }
92
- let baseURL = host === true ? getStorage('host') : host === false ? '' : host;
93
- let http = axios.create({
94
- baseURL: baseURL,
95
- timeout: 99000,
96
- transformResponse: [
97
- function (data) {
98
- try {
99
- return JSONbigToString.parse(data);
100
- } catch (err) {
101
- return data;
93
+ let http = $_http;
94
+ if (!http) {
95
+ let baseURL = host === true ? getStorage('host') : host === false ? '' : host;
96
+ http = axios.create({
97
+ baseURL: baseURL,
98
+ timeout: 99000,
99
+ transformResponse: [
100
+ function (data) {
101
+ try {
102
+ return JSONbigToString.parse(data);
103
+ } catch (err) {
104
+ return data;
105
+ }
102
106
  }
107
+ ]
108
+ });
109
+ // 请求拦截
110
+ http.interceptors.request.use(
111
+ (config) => {
112
+ config.headers.common = getStorage();
113
+ // 根据请求的信息(请求方式,url,请求get/post数据),产生map的key
114
+ // let requestKey = getRequestKey(config);
115
+ // // 判断请求是否重复
116
+ // if (pendingRequest.has(requestKey)) {
117
+ // // 取消上次请求
118
+ // let cancel = pendingRequest.get(requestKey);
119
+ // cancel();
120
+ // // 删除请求信息
121
+ // pendingRequest.delete(requestKey);
122
+ // }
123
+ // // 把请求信息,添加请求到map当中
124
+ // // 生成取消方法
125
+ // config.cancelToken =
126
+ // config.cancelToken ||
127
+ // new axios.CancelToken(cancel => {
128
+ // // 把取消方法添加到map
129
+ // if (!pendingRequest.has(requestKey)) {
130
+ // pendingRequest.set(requestKey, cancel);
131
+ // }
132
+ // });
133
+ return config;
134
+ },
135
+ (err) => {
136
+ return err;
103
137
  }
104
- ]
105
- });
106
- // 请求拦截
107
- http.interceptors.request.use(
108
- (config) => {
109
- config.headers.common = getStorage();
110
- // 根据请求的信息(请求方式,url,请求get/post数据),产生map的key
111
- // let requestKey = getRequestKey(config);
112
- // // 判断请求是否重复
113
- // if (pendingRequest.has(requestKey)) {
114
- // // 取消上次请求
115
- // let cancel = pendingRequest.get(requestKey);
116
- // cancel();
117
- // // 删除请求信息
118
- // pendingRequest.delete(requestKey);
119
- // }
120
- // // 把请求信息,添加请求到map当中
121
- // // 生成取消方法
122
- // config.cancelToken =
123
- // config.cancelToken ||
124
- // new axios.CancelToken(cancel => {
125
- // // 把取消方法添加到map
126
- // if (!pendingRequest.has(requestKey)) {
127
- // pendingRequest.set(requestKey, cancel);
128
- // }
129
- // });
130
- return config;
131
- },
132
- (err) => {
133
- return err;
134
- }
135
- );
136
- // 响应拦截
137
- http.interceptors.response.use(
138
- (response) => {
139
- // delPendingRequest(response.config);
140
- loading && loading.close();
141
- if (
142
- response.headers.authorization &&
143
- response.headers.authorization !== getStorage('token')
144
- ) {
138
+ );
139
+ // 响应拦截
140
+ http.interceptors.response.use(
141
+ (response) => {
142
+ // delPendingRequest(response.config);
143
+ loading && loading.close();
145
144
  if (
146
- localStorage.getItem('storage') === 'localStorage' ||
147
- localStorage.getItem('token') ||
148
- localStorage.getItem('Authorization')
145
+ response.headers.authorization &&
146
+ response.headers.authorization !== getStorage('token')
149
147
  ) {
150
- localStorage.setItem('token', response.headers.authorization);
151
- localStorage.setItem('Authorization', response.headers.authorization);
152
- } else {
153
- sessionStorage.setItem('token', response.headers.authorization);
154
- sessionStorage.setItem(
155
- 'Authorization',
156
- response.headers.authorization
157
- );
148
+ if (
149
+ localStorage.getItem('storage') === 'localStorage' ||
150
+ localStorage.getItem('token') ||
151
+ localStorage.getItem('Authorization')
152
+ ) {
153
+ localStorage.setItem('token', response.headers.authorization);
154
+ localStorage.setItem('Authorization', response.headers.authorization);
155
+ } else {
156
+ sessionStorage.setItem('token', response.headers.authorization);
157
+ sessionStorage.setItem(
158
+ 'Authorization',
159
+ response.headers.authorization
160
+ );
161
+ }
158
162
  }
159
- }
160
- if (
161
- (response.headers.ssId ||
162
- response.headers.Ssid ||
163
- response.headers.ssid) &&
164
- (response.headers.ssId ||
165
- response.headers.SsId ||
166
- response.headers.ssid) !== getStorage('ssId')
167
- ) {
168
163
  if (
169
- localStorage.getItem('storage') === 'localStorage' ||
170
- localStorage.getItem('ssId')
164
+ (response.headers.ssId ||
165
+ response.headers.Ssid ||
166
+ response.headers.ssid) &&
167
+ (response.headers.ssId ||
168
+ response.headers.SsId ||
169
+ response.headers.ssid) !== getStorage('ssId')
171
170
  ) {
172
- localStorage.setItem(
173
- 'ssId',
174
- response.headers.ssId ||
171
+ if (
172
+ localStorage.getItem('storage') === 'localStorage' ||
173
+ localStorage.getItem('ssId')
174
+ ) {
175
+ localStorage.setItem(
176
+ 'ssId',
177
+ response.headers.ssId ||
175
178
  response.headers.SsId ||
176
179
  response.headers.ssid
177
- );
178
- } else {
179
- sessionStorage.setItem(
180
- 'ssId',
181
- response.headers.ssId ||
180
+ );
181
+ } else {
182
+ sessionStorage.setItem(
183
+ 'ssId',
184
+ response.headers.ssId ||
182
185
  response.headers.SsId ||
183
186
  response.headers.ssid
184
- );
185
- }
186
- }
187
- if (response.status === 200) {
188
- if (
189
- response.data.rCode === 64 ||
190
- response.data.rCode === 65 ||
191
- response.data.rCode === 67 ||
192
- response.data.rCode === 69
193
- ) {
194
- removeStorage([
195
- 'Authorization',
196
- 'token',
197
- 'ssId',
198
- 'userId',
199
- 'userName',
200
- 'deviceUnique',
201
- 'menus',
202
- 'useCaseCodes',
203
- 'mainConfig',
204
- 'jump',
205
- 'showLaunch'
206
- ]);
207
- let href = '';
208
- try {
209
- href = win.top.location.href;
210
- } catch (error) {
211
- href = win.location.href;
187
+ );
212
188
  }
189
+ }
190
+ if (response.status === 200) {
213
191
  if (
214
- href.indexOf('#/login') === -1 &&
215
- href.indexOf('/login.html') === -1
192
+ response.data.rCode === 64 ||
193
+ response.data.rCode === 65 ||
194
+ response.data.rCode === 67 ||
195
+ response.data.rCode === 69
216
196
  ) {
217
- let remind = sessionStorage.getItem('remind');
218
- if (!remind) {
219
- clearTimeout(loginMsg);
220
- loginMsg = setTimeout(() => {
221
- sessionStorage.setItem('remind', 1);
222
- MessageBox.confirm(
223
- response.data.rCode === 69
224
- ? '该账号在其他地方已登陆!'
225
- : '登录已过期,请重新登录!',
226
- '提示',
227
- response.data.rCode === 69
228
- ? {
197
+ removeStorage([
198
+ 'Authorization',
199
+ 'token',
200
+ 'ssId',
201
+ 'userId',
202
+ 'userName',
203
+ 'deviceUnique',
204
+ 'menus',
205
+ 'useCaseCodes',
206
+ 'mainConfig',
207
+ 'jump',
208
+ 'showLaunch'
209
+ ]);
210
+ let href = '';
211
+ try {
212
+ href = win.top.location.href;
213
+ } catch (error) {
214
+ href = win.location.href;
215
+ }
216
+ if (
217
+ href.indexOf('#/login') === -1 &&
218
+ href.indexOf('/login.html') === -1
219
+ ) {
220
+ let remind = sessionStorage.getItem('remind');
221
+ if (!remind) {
222
+ clearTimeout(loginMsg);
223
+ loginMsg = setTimeout(() => {
224
+ sessionStorage.setItem('remind', 1);
225
+ MessageBox.confirm(
226
+ response.data.rCode === 69
227
+ ? '该账号在其他地方已登陆!'
228
+ : '登录已过期,请重新登录!',
229
+ '提示',
230
+ response.data.rCode === 69
231
+ ? {
229
232
  confirmButtonText: '确定',
230
233
  closeOnClickModal: false,
231
234
  type: 'warning'
232
235
  }
233
- : {
236
+ : {
234
237
  confirmButtonText: '确定',
235
238
  cancelButtonText: '取消',
236
239
  closeOnClickModal: false,
237
240
  type: 'warning'
238
241
  }
239
- )
240
- .then(() => {
241
- try {
242
- const loginPage =
243
- getStorage('login') || getStorage('loginPage');
244
- if (loginPage) {
245
- let src;
246
- if (!startWith(loginPage, ['http', '/'], true)) {
247
- let pathname = win.top.location.pathname;
248
- if (pathname !== '/') {
249
- pathname = pathname.split('/');
250
- pathname.splice(pathname.length - 1);
251
- pathname = pathname.join('/');
252
- src = pathname + '/' + loginPage.replace('./', '');
242
+ )
243
+ .then(() => {
244
+ try {
245
+ const loginPage =
246
+ getStorage('login') || getStorage('loginPage');
247
+ if (loginPage) {
248
+ let src;
249
+ if (!startWith(loginPage, ['http', '/'], true)) {
250
+ let pathname = win.top.location.pathname;
251
+ if (pathname !== '/') {
252
+ pathname = pathname.split('/');
253
+ pathname.splice(pathname.length - 1);
254
+ pathname = pathname.join('/');
255
+ src = pathname + '/' + loginPage.replace('./', '');
256
+ } else {
257
+ src = pathname + loginPage.replace('./', '');
258
+ }
253
259
  } else {
254
- src = pathname + loginPage.replace('./', '');
260
+ src = loginPage;
255
261
  }
262
+ win.top.location.href = src;
263
+ } else if (
264
+ win.top.location.href.indexOf('main.html') > -1
265
+ ) {
266
+ win.top.location.href = './login.html';
256
267
  } else {
257
- src = loginPage;
258
- }
259
- win.top.location.href = src;
260
- } else if (
261
- win.top.location.href.indexOf('main.html') > -1
262
- ) {
263
- win.top.location.href = './login.html';
264
- } else {
265
- const hash = win.top.location.hash;
266
- if (hash) {
267
- const len = win.top.location.href.indexOf(hash);
268
- win.top.location.href =
269
- win.location.href.slice(0, len) + '#/login';
270
- } else {
271
- win.top.location.href = '/login.html';
268
+ const hash = win.top.location.hash;
269
+ if (hash) {
270
+ const len = win.top.location.href.indexOf(hash);
271
+ win.top.location.href =
272
+ win.location.href.slice(0, len) + '#/login';
273
+ } else {
274
+ win.top.location.href = '/login.html';
275
+ }
272
276
  }
277
+ } catch (error) {
278
+ win.postMessage({ type: 1 }, '*');
273
279
  }
274
- } catch (error) {
275
- win.postMessage({ type: 1 }, '*');
280
+ })
281
+ .catch((e) => {
282
+ sessionStorage.removeItem('remind');
283
+ });
284
+ }, 2000);
285
+ }
286
+ }
287
+ } else if (response.data.rCode === 61) {
288
+ clearTimeout(initAuth);
289
+ initAuth = setTimeout(() => {
290
+ MessageBox({
291
+ title: '请进行二次鉴权',
292
+ closeOnClickModal: false,
293
+ closeOnPressEscape: false,
294
+ showConfirmButton: false,
295
+ dangerouslyUseHTMLString: true,
296
+ scroll: false,
297
+ customClass: 'es-retrial-auth-msg',
298
+ render: (h, msgBox) => {
299
+ return h('es-retrial-auth', {
300
+ ref: 'auth',
301
+ props: {
302
+ reload:
303
+ response.data.results.reload ||
304
+ response.data.results.refresh,
305
+ group: response.data.results.retrialAuthGroupIds,
306
+ type: response.data.results.retrialAuthType,
307
+ msgBox: msgBox
276
308
  }
277
- })
278
- .catch((e) => {
279
- sessionStorage.removeItem('remind');
280
309
  });
281
- }, 2000);
282
- }
310
+ },
311
+ callback: (res, obj) => {
312
+ obj.$children.forEach((item) => {
313
+ item.clearTimeouts && item.clearTimeouts();
314
+ return;
315
+ });
316
+ }
317
+ });
318
+ }, 1000);
283
319
  }
284
- } else if (response.data.rCode === 61) {
285
- clearTimeout(initAuth);
286
- initAuth = setTimeout(() => {
287
- MessageBox({
288
- title: '请进行二次鉴权',
289
- closeOnClickModal: false,
290
- closeOnPressEscape: false,
291
- showConfirmButton: false,
292
- dangerouslyUseHTMLString: true,
293
- scroll: false,
294
- customClass: 'es-retrial-auth-msg',
295
- render: (h, msgBox) => {
296
- return h('es-retrial-auth', {
297
- ref: 'auth',
298
- props: {
299
- reload:
300
- response.data.results.reload ||
301
- response.data.results.refresh,
302
- group: response.data.results.retrialAuthGroupIds,
303
- type: response.data.results.retrialAuthType,
304
- msgBox: msgBox
305
- }
306
- });
307
- },
308
- callback: (res, obj) => {
309
- obj.$children.forEach((item) => {
310
- item.clearTimeouts && item.clearTimeouts();
311
- return;
312
- });
313
- }
314
- });
315
- }, 1000);
320
+ // eslint-disable-next-line no-undef
321
+ return Promise.resolve(JSON.parse(JSON.stringify(response.data)));
316
322
  }
317
- // eslint-disable-next-line no-undef
318
- return Promise.resolve(JSON.parse(JSON.stringify(response.data)));
319
- }
320
- },
321
- (error) => {
322
- loading && loading.close();
323
- // if (!axios.isCancel(error)) {
324
- // delPendingRequest(error.config || {});
325
- // }
326
- if (error && error.response) {
327
- if (error.response.status) {
328
- switch (error.response.status) {
329
- case 400:
330
- error.message = '错误请求';
331
- break;
332
- case 401:
333
- error.message = '未授权,请重新登录';
334
- break;
335
- case 403:
336
- error.message = '服务器错误';
337
- break;
338
- case 404:
339
- error.message = '网络请求不存在';
340
- break;
341
- case 405:
342
- error.message = '请求方法错误';
343
- break;
344
- case 408:
345
- error.message = '请求超时';
346
- break;
347
- case 500:
348
- error.message = '服务器错误';
349
- break;
350
- case 501:
351
- error.message = '网络未实现';
352
- break;
353
- case 502:
354
- error.message = '网络错误';
355
- break;
356
- case 503:
357
- error.message = '服务不可用';
358
- break;
359
- case 504:
360
- error.message = '网络超时';
361
- break;
362
- case 505:
363
- error.message = 'http版本不支持该请求';
364
- break;
365
- default:
366
- error.message = `连接错误${error.response.status}`;
323
+ },
324
+ (error) => {
325
+ loading && loading.close();
326
+ // if (!axios.isCancel(error)) {
327
+ // delPendingRequest(error.config || {});
328
+ // }
329
+ if (error && error.response) {
330
+ if (error.response.status) {
331
+ switch (error.response.status) {
332
+ case 400:
333
+ error.message = '错误请求';
334
+ break;
335
+ case 401:
336
+ error.message = '未授权,请重新登录';
337
+ break;
338
+ case 403:
339
+ error.message = '服务器错误';
340
+ break;
341
+ case 404:
342
+ error.message = '网络请求不存在';
343
+ break;
344
+ case 405:
345
+ error.message = '请求方法错误';
346
+ break;
347
+ case 408:
348
+ error.message = '请求超时';
349
+ break;
350
+ case 500:
351
+ error.message = '服务器错误';
352
+ break;
353
+ case 501:
354
+ error.message = '网络未实现';
355
+ break;
356
+ case 502:
357
+ error.message = '网络错误';
358
+ break;
359
+ case 503:
360
+ error.message = '服务不可用';
361
+ break;
362
+ case 504:
363
+ error.message = '网络超时';
364
+ break;
365
+ case 505:
366
+ error.message = 'http版本不支持该请求';
367
+ break;
368
+ default:
369
+ error.message = `连接错误${error.response.status}`;
370
+ }
371
+ } else {
372
+ error.message = '无法请求,请联系管理员';
367
373
  }
368
- } else {
369
- error.message = '无法请求,请联系管理员';
370
374
  }
375
+ // eslint-disable-next-line no-undef
376
+ return Promise.reject(error);
371
377
  }
372
- // eslint-disable-next-line no-undef
373
- return Promise.reject(error);
374
- }
375
- );
378
+ );
379
+ }
376
380
  let userId = getStorage('userId');
377
381
  if (
378
382
  !Object.prototype.hasOwnProperty.call(data, 'userId') &&
@@ -481,7 +485,142 @@ const ajax = function ({
481
485
  ...configs
482
486
  });
483
487
  };
488
+ /**
489
+ * ajaxStream
490
+ * @desc:ajax流式请求
491
+ * @author huangbo
492
+ * @date 2022年5月7日
493
+ * @param {Object} [controller] - controller
494
+ * @param {String} [method] - 请求类型
495
+ * @param {String} [url] - 请求地址
496
+ * @param {String} [host] - host
497
+ * @param {Object} [data] - 请求参数
498
+ * @param {Object} [params] - 请求参数
499
+ **/
500
+ const ajaxStream = function ({ controller, method = 'post', host, url, data, params, progress, success, fail, final, ...configs }) {
501
+ try {
502
+ // 如果有正在进行的请求,取消它
503
+ if (controller) {
504
+ controller.abort();
505
+ }
506
+ controller = new AbortController();
507
+ const baseURL = host || getStorage('baseHost') || '';
508
+ let userId = getStorage('userId');
509
+ if (
510
+ data && !Object.prototype.hasOwnProperty.call(data, 'userId') &&
511
+ userId
512
+ ) {
513
+ data.userId = userId;
514
+ }
515
+ if (
516
+ params && !Object.prototype.hasOwnProperty.call(params, 'userId') &&
517
+ userId
518
+ ) {
519
+ params.userId = getStorage('userId');
520
+ }
521
+ let info = {
522
+
523
+ };
524
+ let partialData = '';
525
+ let lastProcessedIndex = 0;
526
+ let done = false;
527
+ ajax({
528
+ timeout: 990000,
529
+ format: false,
530
+ method,
531
+ url: baseURL + url,
532
+ signal: controller.signal,
533
+ responseType: 'text',
534
+ data,
535
+ params,
536
+ ...configs,
537
+ onDownloadProgress: progressEvent => {
538
+ // 获取从上次处理后新增的数据
539
+ const currentResponse = (progressEvent.event || progressEvent).currentTarget.responseText;
540
+ const chunk = currentResponse.slice(lastProcessedIndex);
541
+
542
+ // 更新偏移量
543
+ lastProcessedIndex = currentResponse.length;
544
+
545
+ // 假设数据是以 'data:' 开头的 SSE 格式
546
+ partialData += chunk;
547
+ const lines = partialData.split('\n');
548
+ let remainingData = ''; // 用于保存未完整处理的部分数据
549
+ lines.forEach(line => {
550
+ if (line.startsWith('data:')) {
551
+ const data = line.replace('data:', '').trim();
552
+ if (data) {
553
+ try {
554
+ // 假设数据是 JSON 格式
555
+ const parsedData = JSON.parse(data);
556
+ info.time = parsedData.time;
557
+ info.conversationId = parsedData.conversationId;
558
+
559
+ // 使用正则表达式匹配 <think> 标签
560
+ const thinkRegex = /<think>([\s\S]*?)<\/think>([\s\S]*)?/;
561
+ const match = parsedData.message.match(thinkRegex);
562
+ if (match) {
563
+ const thinkContent = match[1] ? match[1].trim() : ''; // <think> 标签内的数据
564
+ const content = match[2] ? match[2].trim() : ''; // <think> 标签后的数据
565
+ // 更新 AI 消息内容
566
+ info.thinkContent += thinkContent;
567
+ info.content += content;
568
+ } else {
569
+ // 如果没有 <think> 标签,直接将消息内容赋值到 content
570
+ info.content += parsedData.message;
571
+ }
572
+ done = parsedData.done;
573
+ } catch (parseError) {
574
+ console.error('解析数据出错:', parseError);
575
+ }
576
+ // Promise.resolve({message: info, controller});
577
+ }
578
+ } else {
579
+ // 保存未处理完的部分数据
580
+ remainingData += line + '\n';
581
+ }
582
+ });
484
583
 
584
+ // 将未完整处理的数据保留到 partialData 中
585
+ partialData = remainingData;
586
+ progress && progress({ message: info, controller, done });
587
+ }
588
+ }).then(() => {
589
+ // 处理请求完成后的信息
590
+ const originalText = info.content;
591
+ const regex = /<think>([\s\S]*?)<\/think>([\s\S]*)/;
592
+ const match = originalText.match(regex);
593
+ if (match) {
594
+ info.thinkContent = match ? match[1].trim() : '';
595
+ info.content = match ? match[2].trim() : '';
596
+ }
597
+ success && success({ message: info, controller });
598
+ })
599
+ .catch(() => {
600
+ // 处理请求完成后的信息
601
+ const originalText = info.content || '';
602
+ const regex = /<think>([\s\S]*?)<\/think>([\s\S]*)/;
603
+ const match = originalText.match(regex);
604
+ if (match) {
605
+ info.thinkContent = match ? match[1].trim() : '';
606
+ info.content = match ? match[2].trim() : '';
607
+ }
608
+ fail && fail({ status: 1, message: info, controller });
609
+ });
610
+ } catch (error) {
611
+ console.error('聊天请求出错:', error);
612
+ let errorMessage = '抱歉,发生了一个错误,请稍后再试。';
613
+ if (error.code === 'ERR_NETWORK') {
614
+ errorMessage = '网络连接错误,请检查服务器是否正在运行或网络连接是否正常。';
615
+ } else if (error.response) {
616
+ errorMessage = `服务器错误 (${error.response.status}): ${error.response.data || '未知错误'
617
+ }`;
618
+ }
619
+ fail && fail({ status: 0, message: { role: 'assistant', content: errorMessage }, controller });
620
+ } finally {
621
+ final && final({ status: -1, message: null, controller });
622
+ }
623
+ };
485
624
  /**
486
625
  * arrUnique
487
626
  * @desc:数组元素对象去重
@@ -552,7 +691,7 @@ const browser = function () {
552
691
  * @author huangbo
553
692
  * @date 2022年5月7日
554
693
  **/
555
- const busEmit = function (vm = this, {method, args}) {
694
+ const busEmit = function (vm = this, { method, args }) {
556
695
  const bus = win.$wujie ? win.$wujie.bus : vm.bus || vm.$root.Bus;
557
696
  bus && bus.$emit(method, args);
558
697
  window.postMessage({ method, query: args }, '*');
@@ -1430,7 +1569,7 @@ const getMainConfig = function (callback) {
1430
1569
  callback(res.results);
1431
1570
  }
1432
1571
  })
1433
- .catch(() => {});
1572
+ .catch(() => { });
1434
1573
  };
1435
1574
 
1436
1575
  /**
@@ -2219,7 +2358,7 @@ const isLogined = function ({
2219
2358
  removeStorage();
2220
2359
  }
2221
2360
  })
2222
- .catch(() => {});
2361
+ .catch(() => { });
2223
2362
  return;
2224
2363
  }
2225
2364
  let pathname = '';
@@ -2252,7 +2391,7 @@ const isLogined = function ({
2252
2391
  Object.prototype.hasOwnProperty.call(to.query, 'serverId') &&
2253
2392
  Object.prototype.hasOwnProperty.call(to.query, 'authType')
2254
2393
  ) {
2255
- let loadingInstance = Loading.service({text: '页面加载中', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.65)'});
2394
+ let loadingInstance = Loading.service({ text: '页面加载中', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.65)' });
2256
2395
  ajax({
2257
2396
  method: 'post',
2258
2397
  url: authCenter,
@@ -2372,7 +2511,7 @@ const isLogined = function ({
2372
2511
  })
2373
2512
  .catch((e) => {
2374
2513
  loadingInstance.close();
2375
- });
2514
+ });
2376
2515
  } else if (
2377
2516
  token ||
2378
2517
  to.path === '/' ||
@@ -3244,10 +3383,10 @@ const watermark = function (option) {
3244
3383
  };
3245
3384
  let options = option
3246
3385
  ? extend(
3247
- true,
3248
- config,
3249
- typeof option === 'string' ? { html: option } : option
3250
- )
3386
+ true,
3387
+ config,
3388
+ typeof option === 'string' ? { html: option } : option
3389
+ )
3251
3390
  : config;
3252
3391
  let wrap = document.getElementById('watermark');
3253
3392
  if (!wrap) {
@@ -3327,6 +3466,7 @@ const watermark = function (option) {
3327
3466
 
3328
3467
  export default {
3329
3468
  ajax,
3469
+ ajaxStream,
3330
3470
  arrUnique,
3331
3471
  average,
3332
3472
  browser,