eoss-ui 0.6.38 → 0.6.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/button-group.js +572 -374
- package/lib/button.js +572 -374
- package/lib/checkbox-group.js +573 -375
- package/lib/config/api.js +31 -19
- package/lib/data-table-form.js +584 -386
- package/lib/data-table.js +597 -392
- package/lib/date-picker.js +572 -374
- package/lib/dialog.js +572 -374
- package/lib/eoss-ui.common.js +10749 -3855
- package/lib/error-page.js +4 -4
- package/lib/flow-group.js +590 -377
- package/lib/flow-list.js +577 -379
- package/lib/flow.js +9723 -2852
- package/lib/form.js +577 -379
- package/lib/handle-user.js +573 -375
- package/lib/handler.js +573 -375
- package/lib/icon.js +573 -375
- package/lib/index.js +1 -1
- package/lib/input-number.js +572 -374
- package/lib/input.js +572 -374
- package/lib/layout.js +2 -2
- package/lib/login.js +587 -389
- package/lib/main.js +609 -411
- package/lib/nav.js +572 -374
- package/lib/notify.js +127 -109
- package/lib/page.js +572 -374
- package/lib/pagination.js +572 -374
- package/lib/player.js +572 -374
- package/lib/qr-code.js +572 -374
- package/lib/radio-group.js +573 -375
- package/lib/retrial-auth.js +575 -377
- package/lib/select-ganged.js +573 -375
- package/lib/select.js +573 -375
- package/lib/selector-panel.js +595 -396
- package/lib/selector.js +576 -378
- package/lib/sizer.js +578 -380
- package/lib/steps.js +572 -374
- package/lib/switch.js +572 -374
- package/lib/table-form.js +572 -374
- package/lib/tabs.js +576 -378
- package/lib/theme-chalk/flow.css +1 -1
- package/lib/theme-chalk/index.css +1 -1
- package/lib/tips.js +573 -375
- package/lib/tree-group.js +572 -374
- package/lib/tree.js +573 -375
- package/lib/upload.js +582 -384
- package/lib/utils/util.js +448 -268
- package/lib/wujie.js +572 -374
- package/lib/wxlogin.js +572 -374
- package/package.json +2 -1
- package/packages/.DS_Store +0 -0
- package/packages/data-table/.DS_Store +0 -0
- package/packages/data-table/src/column.vue +9 -3
- package/packages/data-table/src/main.vue +5 -1
- package/packages/data-table-form/.DS_Store +0 -0
- package/packages/data-table-form/src/table.vue +6 -6
- package/packages/error-page/.DS_Store +0 -0
- package/packages/error-page/src/main.vue +2 -2
- package/packages/flow/.DS_Store +0 -0
- package/packages/flow/src/component/CommonOpinions.vue +5 -1
- package/packages/flow/src/component/taskUnionExamine.vue +83 -27
- package/packages/flow/src/freeStartFlow.vue +2843 -0
- package/packages/flow/src/main.vue +769 -636
- package/packages/flow/src/processForm.vue +62 -9
- package/packages/flow/src/reset.vue +901 -0
- package/packages/flow/src/selectUser.vue +5 -0
- package/packages/flow-group/src/main.vue +4 -0
- package/packages/form/.DS_Store +0 -0
- package/packages/form/src/main.vue +3 -3
- package/packages/login/.DS_Store +0 -0
- package/packages/login/src/main.vue +4 -6
- package/packages/main/.DS_Store +0 -0
- package/packages/main/src/.DS_Store +0 -0
- package/packages/selector/.DS_Store +0 -0
- package/packages/selector/src/main.vue +1 -1
- package/packages/selector-panel/.DS_Store +0 -0
- package/packages/selector-panel/src/main.vue +3 -2
- package/packages/sizer/.DS_Store +0 -0
- package/packages/sizer/src/main.vue +5 -5
- package/packages/tabs/.DS_Store +0 -0
- package/packages/tabs/src/main.vue +2 -2
- package/packages/theme-chalk/lib/flow.css +1 -1
- package/packages/theme-chalk/lib/index.css +1 -1
- package/packages/theme-chalk/src/.DS_Store +0 -0
- package/packages/theme-chalk/src/flow.scss +2 -0
- package/packages/upload/.DS_Store +0 -0
- package/src/.DS_Store +0 -0
- package/src/config/api.js +31 -19
- package/src/index.js +157 -157
- package/src/utils/util.js +433 -258
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
|
|
93
|
-
|
|
94
|
-
baseURL:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
localStorage.getItem('Authorization')
|
|
145
|
+
response.headers.authorization &&
|
|
146
|
+
response.headers.authorization !== getStorage('token')
|
|
149
147
|
) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
'
|
|
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
|
-
|
|
170
|
-
|
|
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
|
-
|
|
173
|
-
'
|
|
174
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
215
|
-
|
|
192
|
+
response.data.rCode === 64 ||
|
|
193
|
+
response.data.rCode === 65 ||
|
|
194
|
+
response.data.rCode === 67 ||
|
|
195
|
+
response.data.rCode === 69
|
|
216
196
|
) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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 =
|
|
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
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
}
|
|
275
|
-
|
|
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
|
-
|
|
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
|
-
|
|
285
|
-
|
|
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
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
);
|
|
378
|
+
);
|
|
379
|
+
}
|
|
376
380
|
let userId = getStorage('userId');
|
|
377
381
|
if (
|
|
378
382
|
!Object.prototype.hasOwnProperty.call(data, 'userId') &&
|
|
@@ -481,7 +485,177 @@ 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
|
+
time: 0,
|
|
523
|
+
conversationId: '',
|
|
524
|
+
content: '',
|
|
525
|
+
thinkContent: '',
|
|
526
|
+
primeval: '',
|
|
527
|
+
chunk: ''
|
|
528
|
+
};
|
|
529
|
+
let partialData = '';
|
|
530
|
+
let lastProcessedIndex = 0;
|
|
531
|
+
let done = false;
|
|
532
|
+
let finishThink = false;
|
|
533
|
+
ajax({
|
|
534
|
+
timeout: 990000,
|
|
535
|
+
format: false,
|
|
536
|
+
method,
|
|
537
|
+
url: baseURL + url,
|
|
538
|
+
signal: controller.signal,
|
|
539
|
+
responseType: 'text',
|
|
540
|
+
data,
|
|
541
|
+
params,
|
|
542
|
+
...configs,
|
|
543
|
+
onDownloadProgress: progressEvent => {
|
|
544
|
+
// 获取从上次处理后新增的数据
|
|
545
|
+
const currentResponse = (progressEvent.event || progressEvent).currentTarget.responseText;
|
|
546
|
+
const chunk = currentResponse.slice(lastProcessedIndex);
|
|
547
|
+
if (chunk === 'data:') {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
// 更新偏移量
|
|
552
|
+
lastProcessedIndex = currentResponse.length;
|
|
553
|
+
|
|
554
|
+
// 假设数据是以 'data:' 开头的 SSE 格式
|
|
555
|
+
partialData += chunk;
|
|
556
|
+
const lines = partialData.split('\n');
|
|
557
|
+
let remainingData = ''; // 用于保存未完整处理的部分数据
|
|
558
|
+
let primeval = '';
|
|
559
|
+
let chunks = '';
|
|
560
|
+
lines.forEach(line => {
|
|
561
|
+
if (line === '') {
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
if (line.startsWith('data:')) {
|
|
565
|
+
const data = line.replace('data:', '').trim();
|
|
566
|
+
if (data) {
|
|
567
|
+
try {
|
|
568
|
+
// 假设数据是 JSON 格式
|
|
569
|
+
const parsedData = JSON.parse(data);
|
|
570
|
+
info.time = parsedData.time;
|
|
571
|
+
info.conversationId = parsedData.conversationId;
|
|
572
|
+
const thinkRegex = /<think>([\s\S]*?)<\/think>([\s\S]*)?/;
|
|
573
|
+
const match = parsedData.message.match(thinkRegex);
|
|
574
|
+
if (match) {
|
|
575
|
+
const thinkContent = match[1] ? match[1].trim() : ''; // <think> 标签内的数据
|
|
576
|
+
const content = match[2] ? match[2].trim() : ''; // <think> 标签后的数据
|
|
577
|
+
// 更新 AI 消息内容
|
|
578
|
+
info.thinkContent += thinkContent;
|
|
579
|
+
info.content += content;
|
|
580
|
+
} else {
|
|
581
|
+
const startRegex = /<think>([\s\S]*)/;
|
|
582
|
+
const endRegex = /([\s\S]*?)<\/think>([\s\S]*)?/;
|
|
583
|
+
const start = parsedData.message.match(startRegex);
|
|
584
|
+
const end = parsedData.message.match(endRegex);
|
|
585
|
+
if (start) {
|
|
586
|
+
const thinkContent = start[1] ? start[1].trim() : ''; // <think> 标签内的数据
|
|
587
|
+
info.thinkContent += thinkContent;
|
|
588
|
+
} else {
|
|
589
|
+
if (end) {
|
|
590
|
+
finishThink = true;
|
|
591
|
+
const thinkContent = end[1] ? end[1].trim() : ''; // <think> 标签后的数据
|
|
592
|
+
const content = end[2] ? end[2].trim() : '';
|
|
593
|
+
// 更新 AI 消息内容
|
|
594
|
+
info.thinkContent += thinkContent;
|
|
595
|
+
info.content += content;
|
|
596
|
+
chunks += content;
|
|
597
|
+
} else if (finishThink) {
|
|
598
|
+
info.content += parsedData.message;
|
|
599
|
+
chunks += parsedData.message;
|
|
600
|
+
} else {
|
|
601
|
+
info.thinkContent += parsedData.message;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
primeval += parsedData.message;
|
|
606
|
+
done = parsedData.done;
|
|
607
|
+
} catch (parseError) {
|
|
608
|
+
console.error('解析数据出错:', parseError);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
} else {
|
|
612
|
+
// 保存未处理完的部分数据
|
|
613
|
+
remainingData += line + '\n';
|
|
614
|
+
}
|
|
615
|
+
});
|
|
616
|
+
info.primeval = primeval;
|
|
617
|
+
info.chunk = chunks;
|
|
484
618
|
|
|
619
|
+
// 将未完整处理的数据保留到 partialData 中
|
|
620
|
+
partialData = remainingData;
|
|
621
|
+
progress && progress({ message: info, controller, done });
|
|
622
|
+
}
|
|
623
|
+
}).then(() => {
|
|
624
|
+
// 处理请求完成后的信息
|
|
625
|
+
const originalText = info.content;
|
|
626
|
+
const regex = /<think>([\s\S]*?)<\/think>([\s\S]*)/;
|
|
627
|
+
const match = originalText.match(regex);
|
|
628
|
+
if (match) {
|
|
629
|
+
info.thinkContent = match ? match[1].trim() : '';
|
|
630
|
+
info.content = match ? match[2].trim() : '';
|
|
631
|
+
}
|
|
632
|
+
success && success({ message: info, controller });
|
|
633
|
+
})
|
|
634
|
+
.catch(() => {
|
|
635
|
+
// 处理请求完成后的信息
|
|
636
|
+
const originalText = info.content || '';
|
|
637
|
+
const regex = /<think>([\s\S]*?)<\/think>([\s\S]*)/;
|
|
638
|
+
const match = originalText.match(regex);
|
|
639
|
+
if (match) {
|
|
640
|
+
info.thinkContent = match ? match[1].trim() : '';
|
|
641
|
+
info.content = match ? match[2].trim() : '';
|
|
642
|
+
}
|
|
643
|
+
fail && fail({ status: 1, message: info, controller });
|
|
644
|
+
});
|
|
645
|
+
} catch (error) {
|
|
646
|
+
console.error('聊天请求出错:', error);
|
|
647
|
+
let errorMessage = '抱歉,发生了一个错误,请稍后再试。';
|
|
648
|
+
if (error.code === 'ERR_NETWORK') {
|
|
649
|
+
errorMessage = '网络连接错误,请检查服务器是否正在运行或网络连接是否正常。';
|
|
650
|
+
} else if (error.response) {
|
|
651
|
+
errorMessage = `服务器错误 (${error.response.status}): ${error.response.data || '未知错误'
|
|
652
|
+
}`;
|
|
653
|
+
}
|
|
654
|
+
fail && fail({ status: 0, message: { role: 'assistant', content: errorMessage }, controller });
|
|
655
|
+
} finally {
|
|
656
|
+
final && final({ status: -1, message: null, controller });
|
|
657
|
+
}
|
|
658
|
+
};
|
|
485
659
|
/**
|
|
486
660
|
* arrUnique
|
|
487
661
|
* @desc:数组元素对象去重
|
|
@@ -552,7 +726,7 @@ const browser = function () {
|
|
|
552
726
|
* @author huangbo
|
|
553
727
|
* @date 2022年5月7日
|
|
554
728
|
**/
|
|
555
|
-
const busEmit = function (vm = this, {method, args}) {
|
|
729
|
+
const busEmit = function (vm = this, { method, args }) {
|
|
556
730
|
const bus = win.$wujie ? win.$wujie.bus : vm.bus || vm.$root.Bus;
|
|
557
731
|
bus && bus.$emit(method, args);
|
|
558
732
|
window.postMessage({ method, query: args }, '*');
|
|
@@ -1430,7 +1604,7 @@ const getMainConfig = function (callback) {
|
|
|
1430
1604
|
callback(res.results);
|
|
1431
1605
|
}
|
|
1432
1606
|
})
|
|
1433
|
-
.catch(() => {});
|
|
1607
|
+
.catch(() => { });
|
|
1434
1608
|
};
|
|
1435
1609
|
|
|
1436
1610
|
/**
|
|
@@ -2219,7 +2393,7 @@ const isLogined = function ({
|
|
|
2219
2393
|
removeStorage();
|
|
2220
2394
|
}
|
|
2221
2395
|
})
|
|
2222
|
-
.catch(() => {});
|
|
2396
|
+
.catch(() => { });
|
|
2223
2397
|
return;
|
|
2224
2398
|
}
|
|
2225
2399
|
let pathname = '';
|
|
@@ -2252,7 +2426,7 @@ const isLogined = function ({
|
|
|
2252
2426
|
Object.prototype.hasOwnProperty.call(to.query, 'serverId') &&
|
|
2253
2427
|
Object.prototype.hasOwnProperty.call(to.query, 'authType')
|
|
2254
2428
|
) {
|
|
2255
|
-
let loadingInstance = Loading.service({text: '页面加载中', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.65)'});
|
|
2429
|
+
let loadingInstance = Loading.service({ text: '页面加载中', spinner: 'el-icon-loading', background: 'rgba(0, 0, 0, 0.65)' });
|
|
2256
2430
|
ajax({
|
|
2257
2431
|
method: 'post',
|
|
2258
2432
|
url: authCenter,
|
|
@@ -2372,7 +2546,7 @@ const isLogined = function ({
|
|
|
2372
2546
|
})
|
|
2373
2547
|
.catch((e) => {
|
|
2374
2548
|
loadingInstance.close();
|
|
2375
|
-
});
|
|
2549
|
+
});
|
|
2376
2550
|
} else if (
|
|
2377
2551
|
token ||
|
|
2378
2552
|
to.path === '/' ||
|
|
@@ -3244,10 +3418,10 @@ const watermark = function (option) {
|
|
|
3244
3418
|
};
|
|
3245
3419
|
let options = option
|
|
3246
3420
|
? extend(
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3421
|
+
true,
|
|
3422
|
+
config,
|
|
3423
|
+
typeof option === 'string' ? { html: option } : option
|
|
3424
|
+
)
|
|
3251
3425
|
: config;
|
|
3252
3426
|
let wrap = document.getElementById('watermark');
|
|
3253
3427
|
if (!wrap) {
|
|
@@ -3327,6 +3501,7 @@ const watermark = function (option) {
|
|
|
3327
3501
|
|
|
3328
3502
|
export default {
|
|
3329
3503
|
ajax,
|
|
3504
|
+
ajaxStream,
|
|
3330
3505
|
arrUnique,
|
|
3331
3506
|
average,
|
|
3332
3507
|
browser,
|