ui-process-h5 0.1.33 → 1.0.5
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/README.md +0 -18
- package/package.json +16 -64
- package/scripts/postinstall.mjs +14 -0
- package/scripts/switch-cli.mjs +4 -0
- package/scripts/utils.mjs +60 -0
- package/v2/style.css +1 -0
- package/v2/ui-process-h5.js +13448 -0
- package/v2/ui-process-h5.umd.cjs +67 -0
- package/v2.7/style.css +1 -0
- package/v2.7/ui-process-h5.js +12825 -0
- package/v2.7/ui-process-h5.umd.cjs +67 -0
- package/v3/style.css +1 -0
- package/v3/ui-process-h5.js +10316 -0
- package/v3/ui-process-h5.umd.cjs +55 -0
- package/packages/components/process/index.js +0 -8
- package/packages/components/process/src/button.vue +0 -55
- package/packages/components/process/src/index.vue +0 -447
- package/packages/components/process/src/popup.vue +0 -128
- package/packages/components/process/src/tab.vue +0 -467
- package/packages/components/utils/request/api.ts +0 -11
- package/packages/components/utils/request/cache.d.ts +0 -52
- package/packages/components/utils/request/cache.js +0 -99
- package/packages/components/utils/request/request.ts +0 -62
- package/packages/index.js +0 -4
|
@@ -1,467 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="tops-tab">
|
|
3
|
-
<div class="tops-tab-header">
|
|
4
|
-
<template v-for="(item, i) of isTapList">
|
|
5
|
-
<div
|
|
6
|
-
class="tops-tab-header-items"
|
|
7
|
-
:class="[item.key === active ? 'active' : '']"
|
|
8
|
-
@click="handleActive(item.key, i)"
|
|
9
|
-
ref="label"
|
|
10
|
-
>
|
|
11
|
-
{{ item.label }}
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
<div class="bottom-line" v-if="isTapList.length"></div>
|
|
15
|
-
</div>
|
|
16
|
-
<div class="tops-tab-body">
|
|
17
|
-
<div
|
|
18
|
-
v-for="item in isTapList"
|
|
19
|
-
:key="item.key"
|
|
20
|
-
v-show="active === item.key"
|
|
21
|
-
style="height: calc(100% - 45px);"
|
|
22
|
-
>
|
|
23
|
-
<!-- :taskNode="getTaskNode()" -->
|
|
24
|
-
<slot
|
|
25
|
-
v-if="item.key === 'a' && item.type === 'default'"
|
|
26
|
-
name="default"
|
|
27
|
-
></slot>
|
|
28
|
-
<slot
|
|
29
|
-
v-if="item.key === 'b' && item.type === 'default'"
|
|
30
|
-
:name="item.slot"
|
|
31
|
-
>
|
|
32
|
-
<iframe
|
|
33
|
-
v-if="trackUrl"
|
|
34
|
-
:src="trackUrl"
|
|
35
|
-
style="width: 100%; min-height: 500px; border: none;"
|
|
36
|
-
scrolling="no"
|
|
37
|
-
frameborder="0"
|
|
38
|
-
></iframe>
|
|
39
|
-
<div v-else class="textnone">
|
|
40
|
-
暂无流程图
|
|
41
|
-
</div>
|
|
42
|
-
</slot>
|
|
43
|
-
<slot
|
|
44
|
-
v-if="item.key === 'c' && item.type === 'default'"
|
|
45
|
-
:name="item.slot"
|
|
46
|
-
>
|
|
47
|
-
<div
|
|
48
|
-
v-if="taskCommentList?.length > 0"
|
|
49
|
-
v-for="(item, index) in taskCommentList"
|
|
50
|
-
:key="item.id"
|
|
51
|
-
class="seal-list__item"
|
|
52
|
-
>
|
|
53
|
-
<!-- <div v-for="item in list" :key="item.id" class="seal-list__item"> -->
|
|
54
|
-
<div>
|
|
55
|
-
<div class="seal-list__item--option">
|
|
56
|
-
<span>节点名称</span>
|
|
57
|
-
<span>{{ item.activityName }}</span>
|
|
58
|
-
</div>
|
|
59
|
-
<div class="seal-list__item--option">
|
|
60
|
-
<span>审批人</span>
|
|
61
|
-
<span>{{ item.createUserName }}</span>
|
|
62
|
-
</div>
|
|
63
|
-
<div class="seal-list__item--option">
|
|
64
|
-
<span>审批操作</span>
|
|
65
|
-
<span>{{ item.actionName }}</span>
|
|
66
|
-
</div>
|
|
67
|
-
<div class="seal-list__item--option">
|
|
68
|
-
<span>审批意见</span>
|
|
69
|
-
<span v-html="item.msg"></span>
|
|
70
|
-
</div>
|
|
71
|
-
<div class="seal-list__item--option">
|
|
72
|
-
<span>审批时间</span>
|
|
73
|
-
<span>{{ item.createDate }}</span>
|
|
74
|
-
</div>
|
|
75
|
-
<div
|
|
76
|
-
v-if="
|
|
77
|
-
item.metaAnnexList &&
|
|
78
|
-
item.metaAnnexList.length
|
|
79
|
-
"
|
|
80
|
-
class="seal-list__item--attch"
|
|
81
|
-
>
|
|
82
|
-
<!-- @click="linkUrl(item.metaAnnexList, index)" -->
|
|
83
|
-
<span>查看附件</span>
|
|
84
|
-
</div>
|
|
85
|
-
</div>
|
|
86
|
-
</div>
|
|
87
|
-
<div v-else class="textnone">暂无数据</div>
|
|
88
|
-
</slot>
|
|
89
|
-
<slot v-if="item.type == 'slot'" :name="item.slot"></slot>
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
</template>
|
|
94
|
-
|
|
95
|
-
<script >
|
|
96
|
-
import { defineComponent, ref, watch, onMounted, computed } from "vue-demi";
|
|
97
|
-
// import { getProcessStatus } from "../../utils/request/api";
|
|
98
|
-
|
|
99
|
-
export default defineComponent({
|
|
100
|
-
name: "TopTab",
|
|
101
|
-
props: {
|
|
102
|
-
/**
|
|
103
|
-
* 根据参数插入自定义tab
|
|
104
|
-
* label:选项卡title
|
|
105
|
-
* key:选项卡ID 请勿重复defaultTabList内已拥有的默认key
|
|
106
|
-
* type:插槽类型 "slot" "default"
|
|
107
|
-
* sort:排序参数,无参数默认插入末尾
|
|
108
|
-
* slot:插槽name
|
|
109
|
-
*/
|
|
110
|
-
tapList: {
|
|
111
|
-
type: Array,
|
|
112
|
-
default: () => [],
|
|
113
|
-
},
|
|
114
|
-
// 自定义tab (传入后 默认tab,tapList,失效)
|
|
115
|
-
selfTapList: {
|
|
116
|
-
type: Array,
|
|
117
|
-
default: () => [],
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
setup(props) {
|
|
121
|
-
// 流程图
|
|
122
|
-
const trackUrl = ref(
|
|
123
|
-
"http://59.53.91.231:8088/portal/r/w?sid=6f714ec1-7570-4525-ac51-b092402d8295&cmd=CLIENT_BPM_FORM_TRACK_OPEN&processInstId=1f6e7196-e1ea-428e-b295-aa23a54a2402&supportCanvas=true&formInfo="
|
|
124
|
-
);
|
|
125
|
-
|
|
126
|
-
// 审批信息
|
|
127
|
-
const taskCommentList = ref([
|
|
128
|
-
{
|
|
129
|
-
actionName: "提交",
|
|
130
|
-
activityName: "部门负责人",
|
|
131
|
-
createDate: "2023-04-20 14:47:35",
|
|
132
|
-
createUser: "18ccbf63229f0c79f39940ae284c111e",
|
|
133
|
-
createUserName: "朱鸿飞",
|
|
134
|
-
customUniqueId: "",
|
|
135
|
-
departmentName: "测试部",
|
|
136
|
-
id: "88df38c8-9756-4b4a-a9b0-dcb0ec1b57d5",
|
|
137
|
-
metaAnnexList: null,
|
|
138
|
-
msg: "同意",
|
|
139
|
-
positionName: "测试部119147",
|
|
140
|
-
processInstId: "1f6e7196-e1ea-428e-b295-aa23a54a2402",
|
|
141
|
-
taskInstId: "38bbef1c-efbb-456d-bd79-08ed9d96b4b3",
|
|
142
|
-
},
|
|
143
|
-
]);
|
|
144
|
-
|
|
145
|
-
// 选中
|
|
146
|
-
const active = ref("");
|
|
147
|
-
|
|
148
|
-
// tab 渲染
|
|
149
|
-
const defaultTabList = ref([
|
|
150
|
-
{
|
|
151
|
-
label: "基本信息",
|
|
152
|
-
key: "a",
|
|
153
|
-
type: "default",
|
|
154
|
-
slot: "default",
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
label: "流程图",
|
|
158
|
-
key: "b",
|
|
159
|
-
type: "default",
|
|
160
|
-
slot: "tab2",
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
label: "审批记录",
|
|
164
|
-
key: "c",
|
|
165
|
-
type: "default",
|
|
166
|
-
slot: "tab3",
|
|
167
|
-
},
|
|
168
|
-
]);
|
|
169
|
-
|
|
170
|
-
const isTapList = ref([
|
|
171
|
-
{
|
|
172
|
-
label: "基本信息",
|
|
173
|
-
key: "a",
|
|
174
|
-
type: "default",
|
|
175
|
-
slot: "default",
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
label: "流程图",
|
|
179
|
-
key: "b",
|
|
180
|
-
type: "default",
|
|
181
|
-
slot: "tab2",
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
label: "审批记录",
|
|
185
|
-
key: "c",
|
|
186
|
-
type: "default",
|
|
187
|
-
slot: "tab3",
|
|
188
|
-
},
|
|
189
|
-
]);
|
|
190
|
-
|
|
191
|
-
const label = ref();
|
|
192
|
-
|
|
193
|
-
// taskNode taskObj
|
|
194
|
-
|
|
195
|
-
/* method */
|
|
196
|
-
// 选中方法
|
|
197
|
-
const handleActive = (e, i) => {
|
|
198
|
-
if (e === active.value) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
active.value = e;
|
|
203
|
-
tabAnimation(i);
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
const tabAnimation = (i) => {
|
|
207
|
-
if (label.value.length) {
|
|
208
|
-
let doc = (
|
|
209
|
-
document.getElementsByClassName("bottom-line")[0]
|
|
210
|
-
);
|
|
211
|
-
let left;
|
|
212
|
-
if (doc.offsetWidth < label.value[i].offsetWidth - 10) {
|
|
213
|
-
let num =
|
|
214
|
-
(label.value[i].offsetWidth - doc.offsetWidth - 10) / 2;
|
|
215
|
-
left = `${label.value[i].offsetLeft + num}px`;
|
|
216
|
-
} else if (doc.offsetWidth > label.value[i].offsetWidth - 10) {
|
|
217
|
-
let num =
|
|
218
|
-
(doc.offsetWidth - label.value[i].offsetWidth + 10) / 2;
|
|
219
|
-
left = `${label.value[i].offsetLeft - num}px`;
|
|
220
|
-
} else {
|
|
221
|
-
left = `${label.value[i].offsetLeft}px`;
|
|
222
|
-
}
|
|
223
|
-
doc.style.transition = ".3s";
|
|
224
|
-
doc.style.transform = `translateX(${left})`;
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
/* watch */
|
|
229
|
-
watch(
|
|
230
|
-
() => props.selfTapList,
|
|
231
|
-
(val, preVal) => {
|
|
232
|
-
if (val.length) {
|
|
233
|
-
isTapList.value = [].concat(val);
|
|
234
|
-
active.value = isTapList.value[0].key;
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
//如果加了这个参数,值为true的话,就消除了惰性,watch会在创建后立即执行一次
|
|
239
|
-
//那么首次执行,val为默认值,preVal为undefined
|
|
240
|
-
immediate: true,
|
|
241
|
-
//这个参数代表监听对象时,可以监听深度嵌套的对象属性
|
|
242
|
-
deep: true,
|
|
243
|
-
}
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
watch(
|
|
247
|
-
() => props.tapList,
|
|
248
|
-
(val, preVal) => {
|
|
249
|
-
if (!props.selfTapList.length) {
|
|
250
|
-
isTapList.value = [].concat(defaultTabList.value);
|
|
251
|
-
if (val.length > 0) {
|
|
252
|
-
/* return [] */
|
|
253
|
-
val.forEach((v, i) => {
|
|
254
|
-
if (v.sort && v.sort > 1) {
|
|
255
|
-
isTapList.value.splice(v.sort - 1, 0, v);
|
|
256
|
-
} else if (v.sort == 1) {
|
|
257
|
-
isTapList.value.unshift(v);
|
|
258
|
-
} else {
|
|
259
|
-
isTapList.value.push(v);
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
active.value = isTapList.value[0].key;
|
|
264
|
-
}
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
//如果加了这个参数,值为true的话,就消除了惰性,watch会在创建后立即执行一次
|
|
268
|
-
//那么首次执行,val为默认值,preVal为undefined
|
|
269
|
-
immediate: true,
|
|
270
|
-
//这个参数代表监听对象时,可以监听深度嵌套的对象属性
|
|
271
|
-
deep: true,
|
|
272
|
-
}
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
/* mounted */
|
|
276
|
-
onMounted(() => {
|
|
277
|
-
// 渲染后初始化为第一个位置
|
|
278
|
-
tabAnimation(0);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
return {
|
|
282
|
-
isTapList,
|
|
283
|
-
active,
|
|
284
|
-
handleActive,
|
|
285
|
-
label,
|
|
286
|
-
taskCommentList,
|
|
287
|
-
trackUrl,
|
|
288
|
-
};
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
</script>
|
|
292
|
-
|
|
293
|
-
<style scoped>
|
|
294
|
-
.tops-tab {
|
|
295
|
-
height: 100%;
|
|
296
|
-
}
|
|
297
|
-
.tops-tab-header {
|
|
298
|
-
display: flex;
|
|
299
|
-
width: 100%;
|
|
300
|
-
height: 45px;
|
|
301
|
-
font-size: 14px;
|
|
302
|
-
color: #333;
|
|
303
|
-
padding: 10px 17px;
|
|
304
|
-
font-weight: 500;
|
|
305
|
-
box-sizing: border-box;
|
|
306
|
-
overflow-x: auto;
|
|
307
|
-
white-space: nowrap;
|
|
308
|
-
flex-wrap: nowrap;
|
|
309
|
-
flex-shrink: 0;
|
|
310
|
-
-ms-overflow-style: none;
|
|
311
|
-
position: relative;
|
|
312
|
-
background-color: #fff;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
.tops-tab-header::after {
|
|
316
|
-
content: "";
|
|
317
|
-
position: absolute;
|
|
318
|
-
width: 100%;
|
|
319
|
-
height: 1px;
|
|
320
|
-
background-color: #f2f2f2;
|
|
321
|
-
left: 0;
|
|
322
|
-
bottom: 0;
|
|
323
|
-
z-index: 10;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
.tops-tab-header::-webkit-scrollbar {
|
|
327
|
-
display: none;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
.tops-tab-header-items {
|
|
331
|
-
white-space: nowrap;
|
|
332
|
-
padding-right: 10px;
|
|
333
|
-
box-sizing: border-box;
|
|
334
|
-
display: inline-block;
|
|
335
|
-
height: 100%;
|
|
336
|
-
text-align: center;
|
|
337
|
-
margin-right: 32px;
|
|
338
|
-
font-weight: 400;
|
|
339
|
-
font-size: 15px;
|
|
340
|
-
text-align: left;
|
|
341
|
-
color: #333;
|
|
342
|
-
display: flex;
|
|
343
|
-
align-items: center;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
.tops-tab-header-items:last-child {
|
|
347
|
-
padding-right: 0;
|
|
348
|
-
margin-right: 0;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
.tops-tab-header .active {
|
|
352
|
-
position: relative;
|
|
353
|
-
color: #1389ff;
|
|
354
|
-
font-family: "PingFang SC Bold";
|
|
355
|
-
font-weight: 700;
|
|
356
|
-
font-size: 15px;
|
|
357
|
-
text-align: left;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
.tops-tab-header .bottom-line {
|
|
361
|
-
width: 30px;
|
|
362
|
-
height: 3px;
|
|
363
|
-
border-radius: 1.5px;
|
|
364
|
-
background-color: #1389ff;
|
|
365
|
-
position: absolute;
|
|
366
|
-
bottom: 1px;
|
|
367
|
-
left: 0;
|
|
368
|
-
z-index: 12;
|
|
369
|
-
}
|
|
370
|
-
.tops-tab-body {
|
|
371
|
-
height: 100%;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
.seal-list__item {
|
|
375
|
-
padding: 6px 10px;
|
|
376
|
-
margin: 10px;
|
|
377
|
-
margin-bottom: 0px;
|
|
378
|
-
padding-bottom: 0px;
|
|
379
|
-
background-color: #ffffff;
|
|
380
|
-
border-radius: 10px;
|
|
381
|
-
box-sizing: border-box;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
.seal-list__item:last-child {
|
|
385
|
-
margin-bottom: 70px;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
.seal-list__item .seal-list__item--header {
|
|
389
|
-
margin-bottom: 6px;
|
|
390
|
-
display: flex;
|
|
391
|
-
align-items: center;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
.seal-list__item .seal-list__item--header span:first-of-type {
|
|
395
|
-
font-size: 15px;
|
|
396
|
-
margin-right: 6px;
|
|
397
|
-
font-weight: bold;
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
.seal-list__item .seal-list__item--option {
|
|
401
|
-
display: flex;
|
|
402
|
-
justify-content: space-between;
|
|
403
|
-
align-items: center;
|
|
404
|
-
font-size: 14px;
|
|
405
|
-
padding: 10px 0;
|
|
406
|
-
color: #333;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
.seal-list__item .seal-list__item--option {
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
.seal-list__item .seal-list__item--option span:last-child {
|
|
413
|
-
max-width: 144px;
|
|
414
|
-
overflow: hidden;
|
|
415
|
-
white-space: nowrap;
|
|
416
|
-
text-overflow: ellipsis;
|
|
417
|
-
color: #888;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
.seal-list__item .seal-list__item--option :last-child {
|
|
421
|
-
/* padding-bottom: 14px; */
|
|
422
|
-
}
|
|
423
|
-
.seal-list__item .seal-list__item--attch {
|
|
424
|
-
font-size: 14px;
|
|
425
|
-
padding: 10px 0;
|
|
426
|
-
color: #333;
|
|
427
|
-
text-align: right;
|
|
428
|
-
color: #1389ff;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
.seal-list__item .seal-list__item--actions {
|
|
432
|
-
margin-top: 12px;
|
|
433
|
-
position: relative;
|
|
434
|
-
display: flex;
|
|
435
|
-
justify-content: space-around;
|
|
436
|
-
align-items: center;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
.seal-list__item .seal-list__item--actions ::before {
|
|
440
|
-
content: "";
|
|
441
|
-
top: 0;
|
|
442
|
-
width: 100%;
|
|
443
|
-
transform: scaleY(0.5);
|
|
444
|
-
transform-origin: top;
|
|
445
|
-
border-top: 1px #e8e8e8 solid;
|
|
446
|
-
position: absolute;
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
.seal-list__item .seal-list__item--actions .van-button {
|
|
450
|
-
width: 50%;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
.seal-list__item .seal-list__item--actions .van-button ::after {
|
|
454
|
-
content: "";
|
|
455
|
-
height: 60%;
|
|
456
|
-
border-left: 1px #e8e8e8 solid;
|
|
457
|
-
position: absolute;
|
|
458
|
-
left: 100%;
|
|
459
|
-
top: 50%;
|
|
460
|
-
transform: translate(-50%, -50%) scaleX(0.5);
|
|
461
|
-
transform-origin: left;
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
.seal-list__item .seal-list__item--actions .van-button:last-child ::after {
|
|
465
|
-
content: none;
|
|
466
|
-
}
|
|
467
|
-
</style>
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
export const ACCESS_TOKEN :string
|
|
3
|
-
export const SUBJECTID :string
|
|
4
|
-
export const TASK_JSON :string
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 设置cookie
|
|
8
|
-
* @param key
|
|
9
|
-
* @param value
|
|
10
|
-
* @param options
|
|
11
|
-
* @returns {*}
|
|
12
|
-
*/
|
|
13
|
-
export function saveCookie(key: string, value: string, options: any): void
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 获取cookie
|
|
17
|
-
* @param key cookie的key
|
|
18
|
-
* @param defaultValue
|
|
19
|
-
* @returns {*}
|
|
20
|
-
*/
|
|
21
|
-
export function loadCookie(key: string, defaultValue: string): string
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 删除cookie
|
|
26
|
-
* @param key
|
|
27
|
-
* @returns {string}
|
|
28
|
-
*/
|
|
29
|
-
export function removeCookie (key: string): string
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 设置本地存储
|
|
34
|
-
* @param key
|
|
35
|
-
* @param value
|
|
36
|
-
* @returns {*}
|
|
37
|
-
*/
|
|
38
|
-
export function saveStorage (key: string, value: string) : string
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* 获取本地存储
|
|
42
|
-
* @param key
|
|
43
|
-
* @param defaultValue
|
|
44
|
-
* @returns {*}
|
|
45
|
-
*/
|
|
46
|
-
export function loadStorage (key: string, defaultValue: string) : string
|
|
47
|
-
/**
|
|
48
|
-
* 删除本地存储
|
|
49
|
-
* @param key
|
|
50
|
-
* @returns {string}
|
|
51
|
-
*/
|
|
52
|
-
export function removeStorage (key: string) : string
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import Cookies from 'js-cookie'
|
|
2
|
-
import storage from 'good-storage'
|
|
3
|
-
|
|
4
|
-
export const ACCESS_TOKEN = 'Access_Token'// accessToken String
|
|
5
|
-
export const SUBJECTID = 'SUBJECTID'// accessToken String
|
|
6
|
-
export const TASK_JSON = "TASK_JSON"
|
|
7
|
-
/**
|
|
8
|
-
* 设置cookie
|
|
9
|
-
* @param key
|
|
10
|
-
* @param value
|
|
11
|
-
* @param options
|
|
12
|
-
* @returns {*}
|
|
13
|
-
*/
|
|
14
|
-
export function saveCookie(key, value, options) {
|
|
15
|
-
Cookies.set(key, value, options)
|
|
16
|
-
return value
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 获取cookie
|
|
21
|
-
* @param key
|
|
22
|
-
* @param defaultValue
|
|
23
|
-
* @returns {*}
|
|
24
|
-
*/
|
|
25
|
-
export function loadCookie(key, defaultValue) {
|
|
26
|
-
return Cookies.get(key) || defaultValue
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 删除cookie
|
|
31
|
-
* @param key
|
|
32
|
-
* @returns {string}
|
|
33
|
-
*/
|
|
34
|
-
export function removeCookie(key) {
|
|
35
|
-
Cookies.remove(key)
|
|
36
|
-
return ''
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* 设置本地存储
|
|
41
|
-
* @param key
|
|
42
|
-
* @param value
|
|
43
|
-
* @returns {*}
|
|
44
|
-
*/
|
|
45
|
-
export function saveStorage(key, value) {
|
|
46
|
-
storage.set(key, value)
|
|
47
|
-
return value
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 获取本地存储
|
|
52
|
-
* @param key
|
|
53
|
-
* @param defaultValue
|
|
54
|
-
* @returns {*}
|
|
55
|
-
*/
|
|
56
|
-
export function loadStorage(key, defaultValue) {
|
|
57
|
-
return storage.get(key, defaultValue)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 删除本地存储
|
|
62
|
-
* @param key
|
|
63
|
-
* @returns {string}
|
|
64
|
-
*/
|
|
65
|
-
export function removeStorage(key) {
|
|
66
|
-
storage.remove(key)
|
|
67
|
-
return ''
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 保存会话存储
|
|
72
|
-
* @param key
|
|
73
|
-
* @param value
|
|
74
|
-
* @returns {*}
|
|
75
|
-
*/
|
|
76
|
-
export function saveSessionStorage(key, value) {
|
|
77
|
-
storage.session.set(key, value)
|
|
78
|
-
return value
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* 获取会话存储
|
|
83
|
-
* @param key
|
|
84
|
-
* @param defaultValue
|
|
85
|
-
* @returns {*}
|
|
86
|
-
*/
|
|
87
|
-
export function loadSessionStorage(key, defaultValue) {
|
|
88
|
-
return storage.session.get(key, defaultValue)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* 删除会话存储
|
|
93
|
-
* @param key
|
|
94
|
-
* @returns {string}
|
|
95
|
-
*/
|
|
96
|
-
export function removeSessionStorage(key) {
|
|
97
|
-
storage.session.remove(key)
|
|
98
|
-
return ''
|
|
99
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import axios, {
|
|
2
|
-
AxiosRequestConfig,
|
|
3
|
-
AxiosResponse,
|
|
4
|
-
AxiosError,
|
|
5
|
-
InternalAxiosRequestConfig,
|
|
6
|
-
} from "axios";
|
|
7
|
-
import { ACCESS_TOKEN, loadStorage } from "./cache";
|
|
8
|
-
|
|
9
|
-
const host = process.env.VUE_APP_BASE_URL;
|
|
10
|
-
const base = process.env.VUE_APP_BASE_API;
|
|
11
|
-
// const host = "http://59.53.91.231:2106";
|
|
12
|
-
|
|
13
|
-
axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";
|
|
14
|
-
|
|
15
|
-
const opts = {
|
|
16
|
-
baseURL: `${host}${base}`,
|
|
17
|
-
timeout: 999999999,
|
|
18
|
-
errorTip: true,
|
|
19
|
-
transformResponse: [
|
|
20
|
-
function (data: any, headers: any) {
|
|
21
|
-
if (typeof data === "string") {
|
|
22
|
-
try {
|
|
23
|
-
data = JSON.parse(data);
|
|
24
|
-
} catch (e) {}
|
|
25
|
-
}
|
|
26
|
-
return data;
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const service = axios.create(opts);
|
|
32
|
-
|
|
33
|
-
service.interceptors.request.use((config)=> {
|
|
34
|
-
const isToken = (config.headers || {}).isToken === false;
|
|
35
|
-
if (loadStorage("token", "") && !isToken) {
|
|
36
|
-
config.headers["Authorization"] = "Bearer " + loadStorage("token", ""); // 让每个请求携带自定义token 请根据实际情况自行修改 15c572f2-1fff-4ef2-94dc-728fc8d6fe14
|
|
37
|
-
}
|
|
38
|
-
/* config.headers["Authorization"] =
|
|
39
|
-
"Bearer " + "15c572f2-1fff-4ef2-94dc-728fc8d6fe14"; */
|
|
40
|
-
return config;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
service.interceptors.response.use((response) => {
|
|
44
|
-
if (Object.prototype.toString.call(response.data) === "[object Blob]") {
|
|
45
|
-
return response;
|
|
46
|
-
}
|
|
47
|
-
const { data, config } = response;
|
|
48
|
-
const { code, success } = data;
|
|
49
|
-
const message = response.data.msg;
|
|
50
|
-
// 增加失败判断
|
|
51
|
-
data.fail = code !== 200 && success !== true;
|
|
52
|
-
if (code === 401) {
|
|
53
|
-
console.log("登录状态已过期");
|
|
54
|
-
return data;
|
|
55
|
-
} else if (code !== 200) {
|
|
56
|
-
console.log("错误");
|
|
57
|
-
return data;
|
|
58
|
-
}
|
|
59
|
-
return data;
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
export default service;
|
package/packages/index.js
DELETED