@netang/quasar 0.0.53 → 0.0.55
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/_docs/docs/.vuepress/client.js +39 -0
- package/_docs/docs/.vuepress/components/test.vue +23 -0
- package/_docs/docs/.vuepress/config.js +40 -0
- package/_docs/docs/.vuepress/configs/index.js +2 -0
- package/_docs/docs/.vuepress/configs/navbar/index.js +1 -0
- package/_docs/docs/.vuepress/configs/navbar/zh.js +16 -0
- package/_docs/docs/.vuepress/configs/sidebar/index.js +1 -0
- package/_docs/docs/.vuepress/configs/sidebar/zh.js +20 -0
- package/_docs/docs/.vuepress/public/css/index.css +3 -0
- package/_docs/docs/.vuepress/styles/index.scss +3 -0
- package/_docs/docs/components/field-table.md +63 -0
- package/_docs/docs/components/field-tree.md +1 -0
- package/{docs → _docs}/docs/index.md +0 -0
- package/{docs → _docs}/docs/utils/alert.md +0 -0
- package/{docs → _docs}/docs/utils/confirm.md +0 -0
- package/_docs/docs/utils/index.md +1 -0
- package/_docs/package.json +17 -0
- package/components/column-title/index.vue +2 -2
- package/components/data/index.vue +20 -23
- package/components/dialog/index.vue +26 -12
- package/components/dialog-table/index.vue +4 -2
- package/components/dragger/index.vue +3 -2
- package/components/drawer/index.vue +16 -9
- package/components/editor-code/index.vue +12 -5
- package/components/empty/index.vue +16 -1
- package/components/field-date/index.vue +48 -36
- package/components/field-table/index.vue +69 -43
- package/components/field-text/index.vue +6 -2
- package/components/field-tree/index.vue +40 -22
- package/components/input-number/index.vue +5 -4
- package/components/list-menu/index.vue +14 -2
- package/components/power-page/index.vue +10 -0
- package/components/private/components/index.js +7 -2
- package/components/private/components/move-to-tree/index.vue +7 -3
- package/components/private/edit-power-data/index.vue +92 -52
- package/components/private/table-visible-columns-button/index.vue +6 -2
- package/components/render/index.vue +21 -7
- package/components/search/index.vue +30 -2
- package/components/search-item/index.vue +24 -8
- package/components/select/index.vue +5 -2
- package/components/splitter/index.vue +13 -9
- package/components/table/index.vue +32 -5
- package/components/table-pagination/index.vue +0 -1
- package/components/table-splitter/index.vue +22 -3
- package/components/table-summary/index.vue +10 -3
- package/components/thumbnail/index.vue +16 -6
- package/components/toolbar/index.vue +0 -2
- package/components/uploader/index.vue +5 -2
- package/components/uploader-query/index.vue +48 -27
- package/components/value-format/index.vue +19 -12
- package/configs/area3.js +1 -0
- package/docs/404.html +33 -0
- package/docs/assets/404.html-60b35caa.js +1 -0
- package/docs/assets/404.html-d1e63d77.js +1 -0
- package/docs/assets/alert.html-568d4e94.js +1 -0
- package/docs/assets/alert.html-f5dbc3e9.js +1 -0
- package/docs/assets/app-8c3ae4de.js +6 -0
- package/docs/assets/back-to-top-8efcbe56.svg +1 -0
- package/docs/assets/confirm.html-7a1566f6.js +1 -0
- package/docs/assets/confirm.html-96f1b004.js +1 -0
- package/docs/assets/field-table.html-68d610b0.js +1 -0
- package/docs/assets/field-table.html-86cc3511.js +1 -0
- package/docs/assets/field-tree.html-45410c3c.js +1 -0
- package/docs/assets/field-tree.html-c98ac993.js +1 -0
- package/docs/assets/framework-204010b2.js +5 -0
- package/docs/assets/index.html-1695dd7c.js +1 -0
- package/docs/assets/index.html-65a4aa67.js +1 -0
- package/docs/assets/style-ac5a9aa6.css +1 -0
- package/docs/components/field-table.html +33 -0
- package/docs/components/field-tree.html +33 -0
- package/docs/index.html +33 -0
- package/docs/utils/alert.html +33 -0
- package/docs/utils/confirm.html +33 -0
- package/package.json +1 -1
- package/package2.json +30 -0
- package/store/index.js +3 -20
- package/utils/alert.js +3 -1
- package/utils/area.js +27 -14
- package/utils/arr.js +6 -2
- package/utils/auth.js +40 -35
- package/utils/bus.js +1 -1
- package/utils/config.js +42 -15
- package/utils/{confrim.js → confirm.js} +1 -1
- package/utils/copy.js +18 -0
- package/utils/dialog.js +7 -3
- package/utils/dict.js +5 -28
- package/utils/dictOptions.js +24 -0
- package/utils/form.js +6 -2
- package/utils/getData.js +21 -9
- package/utils/getFile.js +11 -5
- package/utils/getImage.js +23 -12
- package/utils/getTime.js +9 -4
- package/utils/index.js +61 -0
- package/utils/loading.js +3 -1
- package/utils/notify.js +1 -1
- package/utils/power.js +164 -118
- package/utils/previewImage.js +4 -2
- package/utils/price.js +12 -3
- package/utils/rule.js +5 -9
- package/utils/ruleValid.js +10 -0
- package/utils/search.js +81 -50
- package/utils/table.js +119 -87
- package/utils/timestamp.js +2 -2
- package/utils/toast.js +1 -1
- package/utils/tree.js +69 -46
- package/utils/uploader/qiniu.js +31 -15
- package/utils/uploader.js +87 -56
- package/utils/useAuth.js +12 -5
- package/utils/useRouter.js +16 -5
- package/utils/useUploader.js +0 -5
- package/docs/docs/.vuepress/config.js +0 -32
- package/docs/docs/components/field-table.md +0 -1
- package/docs/docs/components/field-tree.md +0 -1
- package/docs/package.json +0 -11
- package/utils/http.js +0 -251
package/utils/tree.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import $n_has from 'lodash/has'
|
|
2
|
+
import $n_get from 'lodash/get'
|
|
3
|
+
import $n_isNil from 'lodash/isNil'
|
|
4
|
+
import $n_findIndex from 'lodash/findIndex'
|
|
5
|
+
import $n_cloneDeep from 'lodash/cloneDeep'
|
|
6
|
+
|
|
7
|
+
import $n_router from '@netang/vue-utils/router'
|
|
8
|
+
|
|
9
|
+
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
10
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
11
|
+
import $n_isValidString from '@netang/utils/isValidString'
|
|
12
|
+
import $n_hasId from '@netang/utils/hasId'
|
|
13
|
+
import $n_http from '@netang/utils/http'
|
|
14
|
+
import $n_run from '@netang/utils/run'
|
|
15
|
+
import $n_storage from '@netang/utils/storage'
|
|
16
|
+
|
|
17
|
+
import $n_toast from './toast'
|
|
18
|
+
import $n_confirm from './confirm'
|
|
19
|
+
import $n_dialog from './dialog'
|
|
20
|
+
import $n_alert from './alert'
|
|
21
|
+
|
|
22
|
+
import { isRef, watch, inject, ref } from 'vue'
|
|
2
23
|
|
|
3
24
|
import { NPowerKey } from './symbols'
|
|
4
25
|
|
|
@@ -29,7 +50,7 @@ function getTreeNode(data, nodeId) {
|
|
|
29
50
|
*/
|
|
30
51
|
function getChildren(data, callback) {
|
|
31
52
|
for (const item of data) {
|
|
32
|
-
if ($
|
|
53
|
+
if ($n_run(callback)(item) === false) {
|
|
33
54
|
return false
|
|
34
55
|
}
|
|
35
56
|
// 如果是父节点
|
|
@@ -75,24 +96,24 @@ function create(params) {
|
|
|
75
96
|
}, params)
|
|
76
97
|
|
|
77
98
|
// 获取权限注入
|
|
78
|
-
const $power = $
|
|
99
|
+
const $power = $n_has(params, '$power') ? params.$power : inject(NPowerKey)
|
|
79
100
|
const hasPowr = !! $power
|
|
80
101
|
|
|
81
102
|
// 获取权限路由
|
|
82
|
-
const $route = $
|
|
103
|
+
const $route = $n_isValidString(path) ?
|
|
83
104
|
// 如果为自定义路由
|
|
84
|
-
$
|
|
105
|
+
$n_router.resolve({
|
|
85
106
|
path,
|
|
86
107
|
query,
|
|
87
108
|
})
|
|
88
109
|
// 否则获取当前路由
|
|
89
|
-
: (hasPowr ? $power.getRoute() : $
|
|
110
|
+
: (hasPowr ? $power.getRoute() : $n_router.getRoute())
|
|
90
111
|
|
|
91
112
|
// 权限按钮
|
|
92
113
|
const powerBtns = hasPowr ? $power.powerBtns : ref([])
|
|
93
114
|
|
|
94
115
|
// 是否有展开节点
|
|
95
|
-
const hasExpanded = ! $
|
|
116
|
+
const hasExpanded = ! $n_isNil(expanded) && isRef(expanded)
|
|
96
117
|
|
|
97
118
|
// 如果开启展开节点缓存
|
|
98
119
|
if (hasExpanded && cache) {
|
|
@@ -138,7 +159,7 @@ function create(params) {
|
|
|
138
159
|
function updateNode(data) {
|
|
139
160
|
|
|
140
161
|
// 获取 id
|
|
141
|
-
const id = $
|
|
162
|
+
const id = $n_get(formData.value, 'id')
|
|
142
163
|
|
|
143
164
|
// 更新表单数据
|
|
144
165
|
formData.value = Object.assign({}, formData.value, data)
|
|
@@ -158,7 +179,7 @@ function create(params) {
|
|
|
158
179
|
// 否则为新增节点
|
|
159
180
|
} else if (
|
|
160
181
|
// 如果为新增节点
|
|
161
|
-
$
|
|
182
|
+
$n_get(data, 'id')
|
|
162
183
|
// 没有节点存在
|
|
163
184
|
&& ! nodeItem
|
|
164
185
|
) {
|
|
@@ -185,7 +206,7 @@ function create(params) {
|
|
|
185
206
|
}
|
|
186
207
|
|
|
187
208
|
// 获取节点索引
|
|
188
|
-
const nodeIndex = $
|
|
209
|
+
const nodeIndex = $n_findIndex(parentNodeItem.children, { id })
|
|
189
210
|
if (nodeIndex > -1) {
|
|
190
211
|
parentNodeItem.children.splice(nodeIndex, 1)
|
|
191
212
|
}
|
|
@@ -213,18 +234,18 @@ function create(params) {
|
|
|
213
234
|
|
|
214
235
|
const allPowerBtn = {}
|
|
215
236
|
for (const item of powerBtns.value) {
|
|
216
|
-
if ($
|
|
237
|
+
if ($n_has(maps, $n_get(item, 'name'))) {
|
|
217
238
|
allPowerBtn[maps[item.name]] = item
|
|
218
239
|
}
|
|
219
240
|
}
|
|
220
241
|
|
|
221
242
|
return {
|
|
222
|
-
all: $
|
|
223
|
-
update: $
|
|
224
|
-
move: $
|
|
225
|
-
copy: $
|
|
226
|
-
delete: $
|
|
227
|
-
status: $
|
|
243
|
+
all: $n_isValidObject(allPowerBtn),
|
|
244
|
+
update: $n_has(allPowerBtn, 'update'),
|
|
245
|
+
move: $n_has(allPowerBtn, 'move'),
|
|
246
|
+
copy: $n_has(allPowerBtn, 'copy'),
|
|
247
|
+
delete: $n_has(allPowerBtn, 'delete'),
|
|
248
|
+
status: $n_has(allPowerBtn, 'status'),
|
|
228
249
|
allPowerBtn,
|
|
229
250
|
}
|
|
230
251
|
}
|
|
@@ -234,7 +255,7 @@ function create(params) {
|
|
|
234
255
|
*/
|
|
235
256
|
function confirmMenu(callback) {
|
|
236
257
|
// 确认框
|
|
237
|
-
$
|
|
258
|
+
$n_confirm({
|
|
238
259
|
message: '确认要执行该操作吗?',
|
|
239
260
|
})
|
|
240
261
|
// 点击确认执行
|
|
@@ -272,13 +293,13 @@ function create(params) {
|
|
|
272
293
|
// 移至节点下
|
|
273
294
|
case 'moveDown':
|
|
274
295
|
|
|
275
|
-
if (! $
|
|
296
|
+
if (! $n_get(o.menuStatus, 'value.allPowerBtn.move.url')) {
|
|
276
297
|
console.error('没有找到复制地址')
|
|
277
298
|
return
|
|
278
299
|
}
|
|
279
300
|
|
|
280
301
|
// 创建对话框
|
|
281
|
-
$
|
|
302
|
+
$n_dialog.create({
|
|
282
303
|
// 标题
|
|
283
304
|
title: `移动至节点的${o.type === 'moveUp' ? '上方' : (o.type === 'moveDown' ? '下方' : '内部')}`,
|
|
284
305
|
// 宽度
|
|
@@ -298,8 +319,8 @@ function create(params) {
|
|
|
298
319
|
async onConfirm({ value: moveNodeId }) {
|
|
299
320
|
|
|
300
321
|
// 是否为正确的 id
|
|
301
|
-
if (! $
|
|
302
|
-
$
|
|
322
|
+
if (! $n_hasId(moveNodeId)) {
|
|
323
|
+
$n_toast({
|
|
303
324
|
message: '请选择节点',
|
|
304
325
|
})
|
|
305
326
|
return false
|
|
@@ -307,7 +328,7 @@ function create(params) {
|
|
|
307
328
|
|
|
308
329
|
// 如果节点是自己
|
|
309
330
|
if (moveNodeId === o.node.id) {
|
|
310
|
-
$
|
|
331
|
+
$n_toast({
|
|
311
332
|
message: '不能选择当前节点',
|
|
312
333
|
})
|
|
313
334
|
return false
|
|
@@ -316,14 +337,14 @@ function create(params) {
|
|
|
316
337
|
// 获取需移动至的节点
|
|
317
338
|
const moveNodeItem = getNode(moveNodeId)
|
|
318
339
|
if (! moveNodeItem) {
|
|
319
|
-
$
|
|
340
|
+
$n_alert({
|
|
320
341
|
message: '移动至的节点不存在',
|
|
321
342
|
})
|
|
322
343
|
return false
|
|
323
344
|
}
|
|
324
345
|
|
|
325
346
|
// 克隆当前树列表数据
|
|
326
|
-
const nodesClone = $
|
|
347
|
+
const nodesClone = $n_cloneDeep(nodes.value)
|
|
327
348
|
|
|
328
349
|
// 获取当前节点
|
|
329
350
|
const nodeItem = getNode(o.node.id)
|
|
@@ -358,7 +379,7 @@ function create(params) {
|
|
|
358
379
|
})
|
|
359
380
|
|
|
360
381
|
// 将本节点从原父节点中删除
|
|
361
|
-
const nodeItemIndex = $
|
|
382
|
+
const nodeItemIndex = $n_findIndex(parentNodeItem.children, { id: nodeItem.id })
|
|
362
383
|
parentNodeItem.children.splice(nodeItemIndex, 1)
|
|
363
384
|
|
|
364
385
|
// 将本节点添加至移动至的节点的子节点中
|
|
@@ -383,11 +404,11 @@ function create(params) {
|
|
|
383
404
|
})
|
|
384
405
|
|
|
385
406
|
// 将本节点从原父节点中删除
|
|
386
|
-
const nodeItemIndex = $
|
|
407
|
+
const nodeItemIndex = $n_findIndex(parentNodeItem.children, { id: nodeItem.id })
|
|
387
408
|
parentNodeItem.children.splice(nodeItemIndex, 1)
|
|
388
409
|
|
|
389
410
|
// 获取移动至节点的索引
|
|
390
|
-
const moveNodeItemIndex = $
|
|
411
|
+
const moveNodeItemIndex = $n_findIndex(moveParentNodeItem.children, { id: moveNodeId })
|
|
391
412
|
|
|
392
413
|
for (let i = moveNodeItemIndex + (o.type === 'moveUp' ? 0 : 1); i < moveParentNodeItem.children.length; i++) {
|
|
393
414
|
const item = moveParentNodeItem.children[i]
|
|
@@ -404,7 +425,7 @@ function create(params) {
|
|
|
404
425
|
}
|
|
405
426
|
|
|
406
427
|
// 请求 - 移动
|
|
407
|
-
const { status } = await $
|
|
428
|
+
const { status } = await $n_http({
|
|
408
429
|
url: o.menuStatus.value.allPowerBtn.move.url,
|
|
409
430
|
data: {
|
|
410
431
|
data: moveLists,
|
|
@@ -424,7 +445,7 @@ function create(params) {
|
|
|
424
445
|
// 确认菜单
|
|
425
446
|
confirmMenu(async function() {
|
|
426
447
|
|
|
427
|
-
if (! $
|
|
448
|
+
if (! $n_get(o.menuStatus, 'value.allPowerBtn.copy.url')) {
|
|
428
449
|
console.error('没有找到复制地址')
|
|
429
450
|
return
|
|
430
451
|
}
|
|
@@ -448,7 +469,7 @@ function create(params) {
|
|
|
448
469
|
}
|
|
449
470
|
|
|
450
471
|
// 请求 - 复制
|
|
451
|
-
const { status, data: res } = await $
|
|
472
|
+
const { status, data: res } = await $n_http({
|
|
452
473
|
url: o.menuStatus.value.allPowerBtn.copy.url,
|
|
453
474
|
data: {
|
|
454
475
|
data: copyLists,
|
|
@@ -462,7 +483,7 @@ function create(params) {
|
|
|
462
483
|
if (isLeafNode) {
|
|
463
484
|
|
|
464
485
|
// 如果返回了 id
|
|
465
|
-
if ($
|
|
486
|
+
if ($n_hasId(res)) {
|
|
466
487
|
|
|
467
488
|
// 更新数据
|
|
468
489
|
Object.assign(newAttr, res)
|
|
@@ -487,7 +508,7 @@ function create(params) {
|
|
|
487
508
|
}
|
|
488
509
|
|
|
489
510
|
// 轻提示
|
|
490
|
-
$
|
|
511
|
+
$n_toast({
|
|
491
512
|
type: 'positive',
|
|
492
513
|
message: '复制成功',
|
|
493
514
|
})
|
|
@@ -500,13 +521,13 @@ function create(params) {
|
|
|
500
521
|
// 如果有子节点
|
|
501
522
|
if (o.node.children.length) {
|
|
502
523
|
// 提示框
|
|
503
|
-
$
|
|
524
|
+
$n_alert({
|
|
504
525
|
message: '请先删除该节点下的子节点',
|
|
505
526
|
})
|
|
506
527
|
return
|
|
507
528
|
}
|
|
508
529
|
|
|
509
|
-
if (! $
|
|
530
|
+
if (! $n_get(o.menuStatus, 'value.allPowerBtn.delete.url')) {
|
|
510
531
|
console.error('没有找到删除地址')
|
|
511
532
|
return
|
|
512
533
|
}
|
|
@@ -515,7 +536,7 @@ function create(params) {
|
|
|
515
536
|
confirmMenu(async function() {
|
|
516
537
|
|
|
517
538
|
// 请求 - 删除
|
|
518
|
-
const { status } = await $
|
|
539
|
+
const { status } = await $n_http({
|
|
519
540
|
url: o.menuStatus.value.allPowerBtn.delete.url,
|
|
520
541
|
data: {
|
|
521
542
|
id: o.node.id,
|
|
@@ -529,7 +550,7 @@ function create(params) {
|
|
|
529
550
|
deleteNode(o.node)
|
|
530
551
|
|
|
531
552
|
// 轻提示
|
|
532
|
-
$
|
|
553
|
+
$n_toast({
|
|
533
554
|
type: 'positive',
|
|
534
555
|
message: '删除成功',
|
|
535
556
|
})
|
|
@@ -541,7 +562,7 @@ function create(params) {
|
|
|
541
562
|
// 全部正常
|
|
542
563
|
case 'statusNormal':
|
|
543
564
|
|
|
544
|
-
if (! $
|
|
565
|
+
if (! $n_get(o.menuStatus, 'value.allPowerBtn.status.url')) {
|
|
545
566
|
console.error('没有找到状态地址')
|
|
546
567
|
return
|
|
547
568
|
}
|
|
@@ -566,7 +587,7 @@ function create(params) {
|
|
|
566
587
|
}
|
|
567
588
|
|
|
568
589
|
// 请求 - 全部禁用/正常
|
|
569
|
-
const { status } = await $
|
|
590
|
+
const { status } = await $n_http({
|
|
570
591
|
url: o.menuStatus.value.allPowerBtn.status.url,
|
|
571
592
|
data: {
|
|
572
593
|
// ids
|
|
@@ -590,7 +611,7 @@ function create(params) {
|
|
|
590
611
|
}
|
|
591
612
|
|
|
592
613
|
// 轻提示
|
|
593
|
-
$
|
|
614
|
+
$n_toast({
|
|
594
615
|
type: 'positive',
|
|
595
616
|
message: '恭喜您,操作成功',
|
|
596
617
|
})
|
|
@@ -604,8 +625,8 @@ function create(params) {
|
|
|
604
625
|
*/
|
|
605
626
|
function getExpandedCache(defaultValue = []) {
|
|
606
627
|
// 获取展开节点缓存
|
|
607
|
-
const res = $
|
|
608
|
-
return $
|
|
628
|
+
const res = $n_storage.get('tree_expanded_' + $route.fullPath)
|
|
629
|
+
return $n_isValidArray(res) ? res : defaultValue
|
|
609
630
|
}
|
|
610
631
|
|
|
611
632
|
/**
|
|
@@ -613,7 +634,7 @@ function create(params) {
|
|
|
613
634
|
*/
|
|
614
635
|
function setExpandedCache(expanded) {
|
|
615
636
|
// 设置展开节点缓存(永久缓存)
|
|
616
|
-
$
|
|
637
|
+
$n_storage.set('tree_expanded_' + $route.fullPath, expanded, 0)
|
|
617
638
|
}
|
|
618
639
|
|
|
619
640
|
/**
|
|
@@ -627,13 +648,13 @@ function create(params) {
|
|
|
627
648
|
function getChildren(data) {
|
|
628
649
|
for (const { id, children } of data) {
|
|
629
650
|
ids.push(id)
|
|
630
|
-
if ($
|
|
651
|
+
if ($n_isValidArray(children)) {
|
|
631
652
|
getChildren(children)
|
|
632
653
|
}
|
|
633
654
|
}
|
|
634
655
|
}
|
|
635
656
|
|
|
636
|
-
if ($
|
|
657
|
+
if ($n_isValidArray(nodes.value)) {
|
|
637
658
|
getChildren(nodes.value)
|
|
638
659
|
}
|
|
639
660
|
|
|
@@ -676,7 +697,9 @@ function create(params) {
|
|
|
676
697
|
/**
|
|
677
698
|
* 树业务
|
|
678
699
|
*/
|
|
679
|
-
|
|
700
|
+
const tree = {
|
|
680
701
|
// 创建树实例
|
|
681
702
|
create,
|
|
682
703
|
}
|
|
704
|
+
|
|
705
|
+
export default tree
|
package/utils/uploader/qiniu.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
import $n_has from 'lodash/has'
|
|
2
|
+
import $n_isString from 'lodash/isString'
|
|
3
|
+
import $n_findIndex from 'lodash/findIndex'
|
|
4
|
+
import $n_trim from 'lodash/trim'
|
|
5
|
+
|
|
6
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
7
|
+
import $n_isValidString from '@netang/utils/isValidString'
|
|
8
|
+
import $n_http from '@netang/utils/http'
|
|
9
|
+
|
|
10
|
+
import $n_toast from '../toast'
|
|
11
|
+
|
|
12
|
+
import { configs } from '../config'
|
|
13
|
+
|
|
14
|
+
const {
|
|
15
|
+
// api 文件请求地址
|
|
16
|
+
apiFileUrl,
|
|
17
|
+
} = configs
|
|
18
|
+
|
|
1
19
|
import {
|
|
2
|
-
// 文件请求地址
|
|
3
|
-
REQUEST_URL,
|
|
4
20
|
UPLOAD_STATUS,
|
|
5
21
|
} from '../useUploader'
|
|
6
22
|
|
|
@@ -10,8 +26,8 @@ import {
|
|
|
10
26
|
async function getQiniuToken(bucket = 'public') {
|
|
11
27
|
|
|
12
28
|
// 请求数据
|
|
13
|
-
const { status, data } = await $
|
|
14
|
-
url:
|
|
29
|
+
const { status, data } = await $n_http({
|
|
30
|
+
url: apiFileUrl + 'get_qiniu_token',
|
|
15
31
|
data: {
|
|
16
32
|
bucket,
|
|
17
33
|
},
|
|
@@ -46,7 +62,7 @@ export default async function ({ waitUploadFileLists, uploadFileLists, checkFile
|
|
|
46
62
|
for (const fileItem of waitUploadFileLists) {
|
|
47
63
|
setFileFail(fileItem, '上传失败')
|
|
48
64
|
}
|
|
49
|
-
$
|
|
65
|
+
$n_toast({
|
|
50
66
|
message: '获取上传参数失败',
|
|
51
67
|
})
|
|
52
68
|
return
|
|
@@ -68,7 +84,7 @@ export default async function ({ waitUploadFileLists, uploadFileLists, checkFile
|
|
|
68
84
|
fileItem.status = UPLOAD_STATUS.uploading
|
|
69
85
|
|
|
70
86
|
// 请求上传文件到七牛云
|
|
71
|
-
const { status, data: resUpload } = await $
|
|
87
|
+
const { status, data: resUpload } = await $n_http({
|
|
72
88
|
// 上传地址
|
|
73
89
|
url: 'https://upload.qiniup.com/',
|
|
74
90
|
// 数据
|
|
@@ -92,7 +108,7 @@ export default async function ({ waitUploadFileLists, uploadFileLists, checkFile
|
|
|
92
108
|
onCancel(cancel) {
|
|
93
109
|
// 设置中断上传
|
|
94
110
|
fileItem.abort = function(msg) {
|
|
95
|
-
cancel($
|
|
111
|
+
cancel($n_isValidString(msg) ? msg : '已取消')
|
|
96
112
|
}
|
|
97
113
|
},
|
|
98
114
|
// 监听上传进度
|
|
@@ -116,8 +132,8 @@ export default async function ({ waitUploadFileLists, uploadFileLists, checkFile
|
|
|
116
132
|
}
|
|
117
133
|
|
|
118
134
|
// 请求 - 上传文件至 cdn
|
|
119
|
-
const { status: statusCallback, data: resCallback } = await $
|
|
120
|
-
url:
|
|
135
|
+
const { status: statusCallback, data: resCallback } = await $n_http({
|
|
136
|
+
url: apiFileUrl + 'upload_cdn_callback',
|
|
121
137
|
data: query,
|
|
122
138
|
// 关闭错误提示
|
|
123
139
|
warn: false,
|
|
@@ -140,7 +156,7 @@ export default async function ({ waitUploadFileLists, uploadFileLists, checkFile
|
|
|
140
156
|
function checkQiniuCallback(res, fileItem) {
|
|
141
157
|
|
|
142
158
|
// 如果文件被删除
|
|
143
|
-
if ($
|
|
159
|
+
if ($n_findIndex(uploadFileLists.value, { hash: fileItem.hash }) === -1) {
|
|
144
160
|
// 设置文件上传失败
|
|
145
161
|
setFileFail(fileItem, '上传失败')
|
|
146
162
|
return false
|
|
@@ -215,7 +231,7 @@ export default async function ({ waitUploadFileLists, uploadFileLists, checkFile
|
|
|
215
231
|
d: vduration,
|
|
216
232
|
})
|
|
217
233
|
|
|
218
|
-
if ($
|
|
234
|
+
if ($n_has(rotates, vrotate)) {
|
|
219
235
|
json.o = rotates[vrotate]
|
|
220
236
|
}
|
|
221
237
|
|
|
@@ -263,9 +279,9 @@ export default async function ({ waitUploadFileLists, uploadFileLists, checkFile
|
|
|
263
279
|
// 【8】旋转 270 度(宽高反转)
|
|
264
280
|
'left-bottom': 8,
|
|
265
281
|
}
|
|
266
|
-
if (orientation && $
|
|
267
|
-
const key = $
|
|
268
|
-
if ($
|
|
282
|
+
if (orientation && $n_isString(orientation)) {
|
|
283
|
+
const key = $n_trim(orientation).toLowerCase()
|
|
284
|
+
if ($n_has(orientations, key)) {
|
|
269
285
|
json.o = orientations[key]
|
|
270
286
|
}
|
|
271
287
|
}
|
|
@@ -305,7 +321,7 @@ export default async function ({ waitUploadFileLists, uploadFileLists, checkFile
|
|
|
305
321
|
Object.assign(fileItem, query)
|
|
306
322
|
|
|
307
323
|
return Object.assign({}, query, {
|
|
308
|
-
json: $
|
|
324
|
+
json: $n_isValidObject(json) ? JSON.stringify(json) : ''
|
|
309
325
|
})
|
|
310
326
|
}
|
|
311
327
|
}
|