@cmstops/pro-compo 3.9.1-rc.5 → 3.9.1-rc.7
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 +103 -76
- package/es/baseFilter/component.js +71 -14
- package/es/hooks/useUpload.d.ts +50 -2
- package/es/hooks/useUpload.js +43 -4
- package/es/selectResourceModal/components/List/ListLocal/index.js +8 -3
- package/es/selectResourceModal/components/List/ListNormal/Filter.js +8 -2
- package/lib/baseFilter/component.js +69 -12
- package/lib/hooks/useUpload.js +43 -3
- package/lib/selectResourceModal/components/List/ListLocal/index.js +6 -1
- package/lib/selectResourceModal/components/List/ListNormal/Filter.js +8 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,107 +1,134 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 智媒管家业务组件库
|
|
2
2
|
|
|
3
|
-
[
|
|
3
|
+
> 快速上手:[传送门](/docs/get-start.md)
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 模块介绍
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
业务组件库基于 Vue3 + Storybook 搭建,结合 ArcoDesgin,包含智媒管家平台核心业务相关组件
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
# 添加组件
|
|
11
|
-
npm run add:component -- YourComponentName
|
|
9
|
+
## 版本规范
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
npm run dev
|
|
11
|
+
关于版本,这里需要提一下
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
按理论来讲业务组件的版本和产品的版本不应该有强关联(即产品的版本是 3.0,业务组件可以是 1.0)
|
|
14
|
+
但是因为产品的买家(即甲方爸爸)使用的产品可能是 3.1、3.2、3.3...,并且会有强定制的情况
|
|
18
15
|
|
|
19
|
-
|
|
20
|
-
npm run prepublishOnly && arco preview
|
|
16
|
+
所以这里我们需要有一个约定,以便研发人员更好的溯源 & 协作 & 维护~
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
当前约定如下:
|
|
19
|
+
|
|
20
|
+
| 分支类型 | 分支名称 | 描述 | 使用位置 | 版本号规则 |
|
|
21
|
+
| ------------ | ---------------------------- | -------------------------------- | ------------- | ---------------------------- |
|
|
22
|
+
| **主分支** | main | 研发自测完毕并 _可以上线_ 的需求 | 预发布环境 | x.x.x-**rc**.y |
|
|
23
|
+
| **版本分支** | release/xxx | 经过完整测试的需求 | 线上/项目环境 | x.x.x-**stable**.y |
|
|
24
|
+
| **定制分支** | release/xxx-{{project.name}} | 经过测试的 _定制_ 需求 | 项目环境 | x.x.x-**{{project.name}}**.y |
|
|
25
|
+
| **开发分支** | develop | 研发自测完毕的需求 | 测试环境 | x.x.x-**alpha**.y |
|
|
26
|
+
|
|
27
|
+
> 所谓 "可以上线",有两种情况:
|
|
28
|
+
>
|
|
29
|
+
> 1. 是指当前产品发布计划中是否有该功能,如果有,则可以合并至 main,否则不可以
|
|
30
|
+
> 2. 该功能是所有版本通用的功能,无论产品版本是多少,都可以合并至 main
|
|
31
|
+
|
|
32
|
+
### 版本发布示例
|
|
25
33
|
|
|
34
|
+
假设当前产品版本是 3.2.0
|
|
35
|
+
此时:
|
|
26
36
|
|
|
27
|
-
|
|
37
|
+
- 主分支 main 版本号为 3.2.0-rc.0
|
|
38
|
+
- 版本分支 release/v3.2.0 版本号为 3.2.0-stable.0
|
|
39
|
+
- 开发分支 develop 版本号为 3.2.0-alpha.0
|
|
28
40
|
|
|
29
|
-
|
|
41
|
+
#### 示例 1:当前版本 bug 修复 A 功能和 B 功能
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
1. 第一步:基于 release/v3.2.0 版本切出:hotfix/v3.2.0-A,hotfix/v3.2.0-B
|
|
44
|
+
2. 第二步:bug-A 修复后,将 hotfix/v3.2.0-A 合并至 develop 自测并发布 3.2.0-alpha.**1**
|
|
45
|
+
3. 第三步:bug-B 修复后,将 hotfix/v3.2.0-B 合并至 develop 自测并发布 3.2.0-alpha.**2**
|
|
46
|
+
4. 第四步:自测完毕后,将 hotfix/v3.2.0-A & hotfix/v3.2.0-B 合并至 main 并发布 3.2.0-rc.**1** 交付测试
|
|
47
|
+
5. 第五步:测试完毕后,将 hotfix/v3.2.0-A & hotfix/v3.2.0-B 合并至 release/v3.2.0 并发布 3.2.0-stable.**1** 交付线上
|
|
33
48
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* @title 组件名
|
|
37
|
-
* @memberOf 组件类型,例如:数据输入
|
|
38
|
-
* @description 描述你的组件。
|
|
39
|
-
*/
|
|
49
|
+
> 注意:第二步第三步可以分开 publish,也可以都合并到 develop 之后再 publish,因为两个 bug 不一定是同一个人修复,所以会有个先后顺序
|
|
50
|
+
> 但是尽量 rc 和 stable 尽量统一发布,减少版本号的迭代,方便维护和问题追溯
|
|
40
51
|
|
|
41
|
-
|
|
42
|
-
* @title 基本用法
|
|
43
|
-
* @description 描述你的例子
|
|
44
|
-
*/
|
|
45
|
-
import Basic from './basic.vue';
|
|
52
|
+
功能分支走向图:
|
|
46
53
|
|
|
47
|
-
|
|
54
|
+
```mermaid
|
|
55
|
+
graph TD
|
|
56
|
+
A[release/v3.2.0] --> B[hotfix/v3.2.0-A]
|
|
57
|
+
A --> C[hotfix/v3.2.0-B]
|
|
58
|
+
B --> D[develop 3.2.0-alpha.1]
|
|
59
|
+
C --> E[develop 3.2.0-alpha.2]
|
|
60
|
+
D --> F[main 3.2.0-rc.1]
|
|
61
|
+
E --> F
|
|
62
|
+
F --> G[release/v3.2.0 3.2.0-stable.1]
|
|
48
63
|
```
|
|
49
64
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*/
|
|
68
|
-
buttonProps: {
|
|
69
|
-
// 如果使用PropType,请使用对象的形式定义
|
|
70
|
-
type: Object as PropType<Record<string, any>>,
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
// ❌ 没有书写注释的属性会被忽略
|
|
75
|
-
props: {
|
|
76
|
-
disabled: Boolean,
|
|
77
|
-
},
|
|
65
|
+
#### 示例 2:历史版本 release/v3.0.0 bug 修复 C 功能
|
|
66
|
+
|
|
67
|
+
1. 第一步:基于 release/v3.0.0 版本分支切出:hotfix/v3.0.0-C
|
|
68
|
+
2. 第二步:bug-C 修复后,将 hotfix/v3.0.0-C 合并至 develop 自测,并发布 3.2.0-alpha.**3**
|
|
69
|
+
3. 第三步:自测完毕后,将 hotfix/v3.0.0-C 合并至 main 并发布 3.2.0-rc.**2** 交付测试
|
|
70
|
+
4. 第四步:测试完毕后,将 hotfix/v3.0.0-C 合并至 release/v3.0.0、release/v3.0.0、release/v3.1.0、release/v3.2.0;并发布:3.0.0-stable.x、3.1.0-stable.y、3.2.0-stable.**2**
|
|
71
|
+
|
|
72
|
+
功能分支走向图:
|
|
73
|
+
|
|
74
|
+
```mermaid
|
|
75
|
+
graph TD
|
|
76
|
+
A[release/v3.0.0] --> B[hotfix/v3.0.0-C]
|
|
77
|
+
B --> C[develop 3.2.0-alpha.3]
|
|
78
|
+
C --> D[main 3.2.0-rc.2]
|
|
79
|
+
D --> E[release/v3.0.0 3.0.0-stable.x]
|
|
80
|
+
D --> F[release/v3.1.0 3.1.0-stable.y]
|
|
81
|
+
D --> G[release/v3.2.0 3.2.0-stable.2]
|
|
78
82
|
```
|
|
79
83
|
|
|
80
|
-
|
|
84
|
+
> 注意:如果是低版本的问题,尽可能的在出问题的版本处理,然后逐层向上合并(如果新版本已经修复并且代码改动较多,有冲突时,解决冲突并保留新版本原逻辑即可)
|
|
85
|
+
> **如果按照社区常见的版本迭代规则,bug 的解决应该是在最新版本,旧版本的代码是不会改动的。**
|
|
86
|
+
> **但是实际我们自己的业务场景必须低版本也要能解决,为了尽量不去重复写代码,只能去手动的维护一下该操作。**
|
|
81
87
|
|
|
82
|
-
|
|
88
|
+
#### 示例 3:新版本 release/v3.3.0 功能 D 开发
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
---
|
|
90
|
+
1. 第一步:基于 release/v3.2.0 版本切出:feature/v3.3.0-D
|
|
91
|
+
2. 第二步:Feat-D 开发完毕后,将 feature/v3.3.0-D 合并至 develop 自测,并发布 3.3.0-alpha.**0**
|
|
92
|
+
3. 第三步:自测完毕后,将 feature/v3.3.0-D 合并至 main,并发布 3.3.0-rc.**0**
|
|
93
|
+
4. 第四步:测试完毕后,基于 release/v3.2.0 切出 release/v3.3.0,将 feature/v3.3.0-D 合并至 release/v3.3.0
|
|
89
94
|
|
|
90
|
-
|
|
95
|
+
功能分支走向图:
|
|
91
96
|
|
|
92
|
-
|
|
97
|
+
```mermaid
|
|
98
|
+
graph TD
|
|
99
|
+
A[release/v3.2.0] --> B[feature/v3.3.0-D]
|
|
100
|
+
B --> C[develop 3.3.0-alpha.0]
|
|
101
|
+
C --> D[main 3.3.0-rc.0]
|
|
102
|
+
A --> E[release/v3.3.0]
|
|
103
|
+
D --> E
|
|
104
|
+
```
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
#### 示例 4:通用功能 E 开发
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
1. 第一步:基于最早版本 release/v3.0.0 切出:feature/v3.0.0-E
|
|
109
|
+
2. 第二步:Feat-E 开发完毕后,将 feature/v3.0.0-E 合并至 develop 自测,并发布 3.3.0-alpha.**1**
|
|
110
|
+
3. 第三步:自测完毕后,将 feature/v3.0.0-E 合并至 main,并发布 3.3.0-rc.**1**
|
|
111
|
+
4. 第四步:测试完毕后,将 feature/v3.0.0-E 合并至 release/v3.0.0、releaes/v3.1.0、release/v3.2.0、release/v3.3.0
|
|
97
112
|
|
|
98
|
-
|
|
113
|
+
> 业务组件库这个项目和其他模块的不同之处在于,如果这里说是新功能
|
|
114
|
+
> 一般是指又抽离出了一个产品的核心业务,而这个核心业务与产品的 **版本** 关联性不强,所有版本均可使用的这种功能
|
|
99
115
|
|
|
100
|
-
|
|
116
|
+
功能分支走向图:
|
|
101
117
|
|
|
102
|
-
|
|
118
|
+
```mermaid
|
|
119
|
+
graph TD
|
|
120
|
+
A[release/v3.0.0] --> B[feature/v3.0.0-E]
|
|
121
|
+
B --> C[develop 3.3.0-alpha.1]
|
|
122
|
+
C --> D[main 3.3.0-rc.1]
|
|
123
|
+
D --> E[release/v3.0.0]
|
|
124
|
+
D --> F[release/v3.1.0]
|
|
125
|
+
D --> G[release/v3.2.0]
|
|
126
|
+
D --> H[release/v3.3.0]
|
|
103
127
|
```
|
|
104
128
|
|
|
105
|
-
|
|
129
|
+
#### 示例 5:3.1.0 版本 _G_ 项目定制 功能 F 开发
|
|
130
|
+
|
|
131
|
+
1. 第一步:基于 release/v3.1.0 切出:feature/v3.1.0-G-F
|
|
132
|
+
2. 第二步:Feat-F 开发完毕后,基于 release/v3.1.0 切出 release/v3.1.0-G,将 feature/v3.1.0-G-F 合并至 release/v3.1.0-G,并发布 3.1.0-G.**0**
|
|
106
133
|
|
|
107
|
-
|
|
134
|
+
> 注意:如果有项目有定制,后续的任何通用更新不会覆盖该版本,所以在定制之前需和产品 **再三确认**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent, ref, computed, watch, nextTick, toRaw, openBlock, createElementBlock, Fragment, createElementVNode, withModifiers, createVNode, withCtx, renderList, createBlock, unref, normalizeStyle, createCommentVNode
|
|
2
|
-
import {
|
|
1
|
+
import { defineComponent, ref, computed, watch, nextTick, toRaw, openBlock, createElementBlock, Fragment, createElementVNode, withModifiers, createVNode, withCtx, renderList, createBlock, renderSlot, unref, createTextVNode, toDisplayString, normalizeStyle, createCommentVNode } from "vue";
|
|
2
|
+
import { InputGroup, Select, Option, Input, InputSearch, RangePicker, RadioGroup, Radio } from "@arco-design/web-vue";
|
|
3
3
|
import _sfc_main$2 from "./components/filterItem.js";
|
|
4
4
|
import _sfc_main$1 from "./components/FilterGroup.js";
|
|
5
5
|
const _sfc_main = defineComponent({
|
|
@@ -37,9 +37,11 @@ const _sfc_main = defineComponent({
|
|
|
37
37
|
});
|
|
38
38
|
return _columns;
|
|
39
39
|
});
|
|
40
|
-
const getOptions = (
|
|
41
|
-
return item
|
|
42
|
-
|
|
40
|
+
const getOptions = computed(() => {
|
|
41
|
+
return (item) => {
|
|
42
|
+
return item.options ? item.options : [];
|
|
43
|
+
};
|
|
44
|
+
});
|
|
43
45
|
const hasValue = computed(() => {
|
|
44
46
|
return (key) => {
|
|
45
47
|
var _a, _b;
|
|
@@ -76,7 +78,10 @@ const _sfc_main = defineComponent({
|
|
|
76
78
|
_form[column.range] = rangeTemp[column.range];
|
|
77
79
|
} else if (column.component === "select") {
|
|
78
80
|
_form[column.key] = column.defaultValue || null;
|
|
79
|
-
} else {
|
|
81
|
+
} else if (column.component === "input-group") {
|
|
82
|
+
_form[column.selectKey] = column.selectDefaultValue || "";
|
|
83
|
+
_form[column.inputKey] = column.inputDefaultValue || "";
|
|
84
|
+
} else if (column.component) {
|
|
80
85
|
_form[column.key] = column.defaultValue || "";
|
|
81
86
|
}
|
|
82
87
|
});
|
|
@@ -178,17 +183,48 @@ const _sfc_main = defineComponent({
|
|
|
178
183
|
active: hasValue.value(item.key)
|
|
179
184
|
}, {
|
|
180
185
|
default: withCtx(() => [
|
|
181
|
-
item.component === "input" ? (openBlock(), createBlock(unref(
|
|
182
|
-
|
|
186
|
+
item.slot ? renderSlot(_ctx.$slots, item.slot, { key: 0 }) : item.component === "input-group" ? (openBlock(), createBlock(unref(InputGroup), { key: 1 }, {
|
|
187
|
+
default: withCtx(() => [
|
|
188
|
+
createVNode(unref(Select), {
|
|
189
|
+
modelValue: form.value[item.selectKey],
|
|
190
|
+
"onUpdate:modelValue": ($event) => form.value[item.selectKey] = $event,
|
|
191
|
+
"default-active-first-option": "",
|
|
192
|
+
style: { "width": "100px" }
|
|
193
|
+
}, {
|
|
194
|
+
default: withCtx(() => [
|
|
195
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(item.selectOptions, (option, idx) => {
|
|
196
|
+
return openBlock(), createBlock(unref(Option), {
|
|
197
|
+
key: idx,
|
|
198
|
+
value: option.value
|
|
199
|
+
}, {
|
|
200
|
+
default: withCtx(() => [
|
|
201
|
+
createTextVNode(toDisplayString(option.label), 1)
|
|
202
|
+
]),
|
|
203
|
+
_: 2
|
|
204
|
+
}, 1032, ["value"]);
|
|
205
|
+
}), 128))
|
|
206
|
+
]),
|
|
207
|
+
_: 2
|
|
208
|
+
}, 1032, ["modelValue", "onUpdate:modelValue"]),
|
|
209
|
+
createVNode(unref(Input), {
|
|
210
|
+
modelValue: form.value[item.inputKey],
|
|
211
|
+
"onUpdate:modelValue": ($event) => form.value[item.inputKey] = $event,
|
|
212
|
+
placeholder: item.placeholder ? item.placeholder : `\u8BF7\u8F93\u5165${item.inputLabel}`,
|
|
213
|
+
style: { "width": "180px" }
|
|
214
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])
|
|
215
|
+
]),
|
|
216
|
+
_: 2
|
|
217
|
+
}, 1024)) : item.component === "input" ? (openBlock(), createBlock(unref(InputSearch), {
|
|
218
|
+
key: 2,
|
|
183
219
|
modelValue: form.value[item.key],
|
|
184
220
|
"onUpdate:modelValue": ($event) => form.value[item.key] = $event,
|
|
185
221
|
style: normalizeStyle({ width: styleWidth(columnsMap.value[item.key]) }),
|
|
186
222
|
"allow-clear": "",
|
|
187
223
|
size: "medium",
|
|
188
|
-
placeholder: `\u8BF7\u8F93\u5165${item.label}`
|
|
224
|
+
placeholder: item.placeholder ? item.placeholder : `\u8BF7\u8F93\u5165${item.label}`
|
|
189
225
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "style", "placeholder"])) : createCommentVNode("v-if", true),
|
|
190
226
|
item.component === "select" ? (openBlock(), createBlock(unref(Select), {
|
|
191
|
-
key:
|
|
227
|
+
key: 3,
|
|
192
228
|
modelValue: form.value[item.key],
|
|
193
229
|
"onUpdate:modelValue": ($event) => form.value[item.key] = $event,
|
|
194
230
|
"popup-container": "#base-filter-popup-container",
|
|
@@ -196,13 +232,13 @@ const _sfc_main = defineComponent({
|
|
|
196
232
|
"allow-search": item.allowSearch,
|
|
197
233
|
"default-active-first-option": false,
|
|
198
234
|
style: normalizeStyle({ width: styleWidth(columnsMap.value[item.key]) }),
|
|
199
|
-
placeholder: `\u8BF7\u9009\u62E9${item.label}`,
|
|
235
|
+
placeholder: item.placeholder ? item.placeholder : `\u8BF7\u9009\u62E9${item.label}`,
|
|
200
236
|
onSearch: ($event) => handleSelectSearch($event, item),
|
|
201
237
|
onPopupVisibleChange: ($event) => handleSelectPopupChange($event, item),
|
|
202
238
|
onChange: ($event) => handleSelectChange($event, item)
|
|
203
239
|
}, {
|
|
204
240
|
default: withCtx(() => [
|
|
205
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(getOptions(item), (opt) => {
|
|
241
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(getOptions.value(item), (opt) => {
|
|
206
242
|
return openBlock(), createBlock(unref(Option), {
|
|
207
243
|
key: opt.value,
|
|
208
244
|
label: opt.label,
|
|
@@ -213,7 +249,7 @@ const _sfc_main = defineComponent({
|
|
|
213
249
|
_: 2
|
|
214
250
|
}, 1032, ["modelValue", "onUpdate:modelValue", "allow-search", "style", "placeholder", "onSearch", "onPopupVisibleChange", "onChange"])) : createCommentVNode("v-if", true),
|
|
215
251
|
item.component === "range-picker" ? (openBlock(), createBlock(unref(RangePicker), {
|
|
216
|
-
key:
|
|
252
|
+
key: 4,
|
|
217
253
|
modelValue: form.value[item.key].range,
|
|
218
254
|
"onUpdate:modelValue": ($event) => form.value[item.key].range = $event,
|
|
219
255
|
style: normalizeStyle({ width: styleWidth(form.value[item.key]) }),
|
|
@@ -224,7 +260,28 @@ const _sfc_main = defineComponent({
|
|
|
224
260
|
"popup-container": "#base-filter-popup-container",
|
|
225
261
|
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
226
262
|
}, ["stop"]))
|
|
227
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "style"])) : createCommentVNode("v-if", true)
|
|
263
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "style"])) : createCommentVNode("v-if", true),
|
|
264
|
+
item.component === "radio" ? (openBlock(), createBlock(unref(RadioGroup), {
|
|
265
|
+
key: 5,
|
|
266
|
+
modelValue: form.value[item.key],
|
|
267
|
+
"onUpdate:modelValue": ($event) => form.value[item.key] = $event,
|
|
268
|
+
type: "button"
|
|
269
|
+
}, {
|
|
270
|
+
default: withCtx(() => [
|
|
271
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(item.options || [], (option, idx) => {
|
|
272
|
+
return openBlock(), createBlock(unref(Radio), {
|
|
273
|
+
key: idx,
|
|
274
|
+
value: option.value
|
|
275
|
+
}, {
|
|
276
|
+
default: withCtx(() => [
|
|
277
|
+
createTextVNode(toDisplayString(option.label), 1)
|
|
278
|
+
]),
|
|
279
|
+
_: 2
|
|
280
|
+
}, 1032, ["value"]);
|
|
281
|
+
}), 128))
|
|
282
|
+
]),
|
|
283
|
+
_: 2
|
|
284
|
+
}, 1032, ["modelValue", "onUpdate:modelValue"])) : createCommentVNode("v-if", true)
|
|
228
285
|
]),
|
|
229
286
|
_: 2
|
|
230
287
|
}, 1032, ["active"]);
|
package/es/hooks/useUpload.d.ts
CHANGED
|
@@ -7,24 +7,72 @@ export declare type TypeAddMediaParam = {
|
|
|
7
7
|
directory_id: number;
|
|
8
8
|
size: number;
|
|
9
9
|
};
|
|
10
|
+
declare type WaterMark = {
|
|
11
|
+
id: string;
|
|
12
|
+
position: string;
|
|
13
|
+
url: string;
|
|
14
|
+
title: string;
|
|
15
|
+
};
|
|
16
|
+
declare type UploadTemplate = {
|
|
17
|
+
watermark?: {
|
|
18
|
+
default?: WaterMark;
|
|
19
|
+
images: WaterMark[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
10
22
|
export declare function getSize(value: number): string;
|
|
11
23
|
export declare function addMedia(BASE_API: string, params: TypeAddMediaParam): Promise<import("axios").AxiosResponse<any, any>>;
|
|
12
24
|
export declare function getMediaDetails(BASE_API: string, repoId: number, id: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
13
25
|
export declare function reTranscodeMedia(BASE_API: string, media_id: number): Promise<import("axios").AxiosResponse<any, any>>;
|
|
14
26
|
declare type UploadOptions = {
|
|
15
|
-
noAddMedia
|
|
27
|
+
noAddMedia?: boolean;
|
|
28
|
+
};
|
|
29
|
+
declare type UploadFileOptions = {
|
|
30
|
+
template?: UploadTemplate;
|
|
16
31
|
};
|
|
17
32
|
export default function useUpload(options?: UploadOptions): {
|
|
18
33
|
list: import("vue").Ref<any[], any[]>;
|
|
19
|
-
uploadFile: (BASE_API: string, file: any, dir: number | undefined, repoId: number, callback?: CallbackFunc | undefined) => void;
|
|
34
|
+
uploadFile: (BASE_API: string, file: any, dir: number | undefined, repoId: number, callback?: CallbackFunc | undefined, upOptions?: UploadFileOptions | undefined) => void;
|
|
20
35
|
reTranscode: (BASE_API: string, file: any) => Promise<boolean>;
|
|
21
36
|
transcodingFile: (BASE_API: string, file: any, repoId: number) => void;
|
|
22
37
|
recordTaskStatusChange: (file: any, progress: number, isTrans?: boolean | undefined) => void;
|
|
23
38
|
removeRecord: (file: any) => void;
|
|
24
39
|
};
|
|
40
|
+
export declare function getWatermarkTemplate(BASE_API: string): Promise<import("axios").AxiosResponse<any, any>>;
|
|
25
41
|
export declare function useUploadConfig(): {
|
|
26
42
|
config: import("vue").Ref<any, any>;
|
|
43
|
+
template: import("vue").Ref<{
|
|
44
|
+
watermark?: {
|
|
45
|
+
default?: {
|
|
46
|
+
id: string;
|
|
47
|
+
position: string;
|
|
48
|
+
url: string;
|
|
49
|
+
title: string;
|
|
50
|
+
} | undefined;
|
|
51
|
+
images: {
|
|
52
|
+
id: string;
|
|
53
|
+
position: string;
|
|
54
|
+
url: string;
|
|
55
|
+
title: string;
|
|
56
|
+
}[];
|
|
57
|
+
} | undefined;
|
|
58
|
+
}, UploadTemplate | {
|
|
59
|
+
watermark?: {
|
|
60
|
+
default?: {
|
|
61
|
+
id: string;
|
|
62
|
+
position: string;
|
|
63
|
+
url: string;
|
|
64
|
+
title: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
images: {
|
|
67
|
+
id: string;
|
|
68
|
+
position: string;
|
|
69
|
+
url: string;
|
|
70
|
+
title: string;
|
|
71
|
+
}[];
|
|
72
|
+
} | undefined;
|
|
73
|
+
}>;
|
|
27
74
|
checkFileSizeOutLimit: (file: File, callback: (msg: string) => void) => boolean;
|
|
28
75
|
initUploadConfig: (BASE_API: string, domainId: number) => Promise<void>;
|
|
76
|
+
initTemplate: (BASE_API: string) => Promise<void>;
|
|
29
77
|
};
|
|
30
78
|
export {};
|
package/es/hooks/useUpload.js
CHANGED
|
@@ -73,7 +73,7 @@ function useUpload(options) {
|
|
|
73
73
|
list.value = originList;
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
|
-
const uploadFile = (BASE_API, file, dir = 0, repoId, callback) => {
|
|
76
|
+
const uploadFile = (BASE_API, file, dir = 0, repoId, callback, upOptions) => {
|
|
77
77
|
const newFile = {
|
|
78
78
|
id: file.id || generateUUID(),
|
|
79
79
|
sig_id: file.sig_id || generateUUID(),
|
|
@@ -93,18 +93,24 @@ function useUpload(options) {
|
|
|
93
93
|
};
|
|
94
94
|
const uploading = upload.start(progress);
|
|
95
95
|
uploading.then(async (url) => {
|
|
96
|
+
var _a;
|
|
96
97
|
if (options == null ? void 0 : options.noAddMedia) {
|
|
97
98
|
recordTaskStatusChange({ ...newFile, status: 0, url }, 1);
|
|
98
99
|
callback && callback({ ...newFile, url }, "success");
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
102
|
+
const params = {};
|
|
103
|
+
if ((_a = upOptions == null ? void 0 : upOptions.template) == null ? void 0 : _a.watermark) {
|
|
104
|
+
params.watermark = upOptions.template.watermark.default;
|
|
105
|
+
}
|
|
101
106
|
const { code, message } = await addMedia(BASE_API, {
|
|
102
107
|
url,
|
|
103
108
|
size: newFile.size,
|
|
104
109
|
directory_id: dir,
|
|
105
110
|
repository_id: repoId,
|
|
106
111
|
catalog: newFile.type,
|
|
107
|
-
alias: newFile.name
|
|
112
|
+
alias: newFile.name,
|
|
113
|
+
...params
|
|
108
114
|
});
|
|
109
115
|
if (code !== 0) {
|
|
110
116
|
console.log("\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525} \u4E0A\u4F20\u5931\u8D25\uFF1A", newFile.name, code, message);
|
|
@@ -194,9 +200,16 @@ function getConfiguration(BASE_API, params) {
|
|
|
194
200
|
params
|
|
195
201
|
});
|
|
196
202
|
}
|
|
203
|
+
function getWatermarkTemplate(BASE_API) {
|
|
204
|
+
return request(BASE_API, {
|
|
205
|
+
url: `/poplar/v2/material/image/watermark`,
|
|
206
|
+
method: "get"
|
|
207
|
+
});
|
|
208
|
+
}
|
|
197
209
|
function useUploadConfig() {
|
|
198
210
|
const { get, set, remove } = useLocalstorage("LOCAL_UPLOAD_CONFIG");
|
|
199
211
|
const config = ref(get() || {});
|
|
212
|
+
const template = ref({});
|
|
200
213
|
async function initUploadConfig(BASE_API, domainId) {
|
|
201
214
|
if (config.value.size_config_enabled != null)
|
|
202
215
|
return;
|
|
@@ -245,11 +258,37 @@ function useUploadConfig() {
|
|
|
245
258
|
);
|
|
246
259
|
return false;
|
|
247
260
|
}
|
|
261
|
+
async function initTemplate(BASE_API) {
|
|
262
|
+
try {
|
|
263
|
+
const { code, message } = await getWatermarkTemplate(BASE_API);
|
|
264
|
+
if (code !== 0)
|
|
265
|
+
return;
|
|
266
|
+
if (message) {
|
|
267
|
+
let defaultWaterMark;
|
|
268
|
+
if (Array.isArray(message.images)) {
|
|
269
|
+
message.images.forEach((item) => {
|
|
270
|
+
if (message.default === item.id)
|
|
271
|
+
defaultWaterMark = item;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
template.value = {
|
|
275
|
+
watermark: {
|
|
276
|
+
default: defaultWaterMark,
|
|
277
|
+
images: message.images
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
} catch (e) {
|
|
282
|
+
console.error(e);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
248
285
|
window.addEventListener("beforeunload", remove, false);
|
|
249
286
|
return {
|
|
250
287
|
config,
|
|
288
|
+
template,
|
|
251
289
|
checkFileSizeOutLimit,
|
|
252
|
-
initUploadConfig
|
|
290
|
+
initUploadConfig,
|
|
291
|
+
initTemplate
|
|
253
292
|
};
|
|
254
293
|
}
|
|
255
|
-
export { addMedia, useUpload as default, getMediaDetails, getSize, reTranscodeMedia, useUploadConfig };
|
|
294
|
+
export { addMedia, useUpload as default, getMediaDetails, getSize, getWatermarkTemplate, reTranscodeMedia, useUploadConfig };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent, inject, computed, openBlock, createBlock, withCtx, renderSlot, createElementVNode, createVNode, unref, createElementBlock, toDisplayString, createCommentVNode, Fragment, renderList } from "vue";
|
|
1
|
+
import { defineComponent, inject, computed, onMounted, openBlock, createBlock, withCtx, renderSlot, createElementVNode, createVNode, unref, createElementBlock, toDisplayString, createCommentVNode, Fragment, renderList } from "vue";
|
|
2
2
|
import _sfc_main$2 from "./Upload.js";
|
|
3
|
-
import useUpload from "../../../../hooks/useUpload.js";
|
|
3
|
+
import useUpload, { useUploadConfig } from "../../../../hooks/useUpload.js";
|
|
4
4
|
import _sfc_main$1 from "../ListWraper.js";
|
|
5
5
|
const _hoisted_1 = { class: "list-upload" };
|
|
6
6
|
const _hoisted_2 = { class: "list-content" };
|
|
@@ -22,6 +22,7 @@ const _sfc_main = defineComponent({
|
|
|
22
22
|
var _a;
|
|
23
23
|
return (_a = userInfo == null ? void 0 : userInfo.value) == null ? void 0 : _a.repository_id;
|
|
24
24
|
});
|
|
25
|
+
const { template, initTemplate } = useUploadConfig();
|
|
25
26
|
const { list, uploadFile, reTranscode, transcodingFile, removeRecord } = useUpload();
|
|
26
27
|
function handleChange(file) {
|
|
27
28
|
if (!baseAPI || !repoId.value)
|
|
@@ -31,7 +32,8 @@ const _sfc_main = defineComponent({
|
|
|
31
32
|
file.file,
|
|
32
33
|
0,
|
|
33
34
|
repoId.value,
|
|
34
|
-
(media) => transcodingFile(baseAPI, media, repoId.value)
|
|
35
|
+
(media) => transcodingFile(baseAPI, media, repoId.value),
|
|
36
|
+
{ template: template.value }
|
|
35
37
|
);
|
|
36
38
|
}
|
|
37
39
|
async function handleOptions(e) {
|
|
@@ -54,6 +56,9 @@ const _sfc_main = defineComponent({
|
|
|
54
56
|
removeRecord(e.item);
|
|
55
57
|
}
|
|
56
58
|
}
|
|
59
|
+
onMounted(() => {
|
|
60
|
+
initTemplate(baseAPI);
|
|
61
|
+
});
|
|
57
62
|
return (_ctx, _cache) => {
|
|
58
63
|
return openBlock(), createBlock(_sfc_main$1, null, {
|
|
59
64
|
"footer-extra": withCtx(() => [
|
|
@@ -294,8 +294,14 @@ const _sfc_main = defineComponent({
|
|
|
294
294
|
key: "id"
|
|
295
295
|
},
|
|
296
296
|
"allow-clear": "",
|
|
297
|
-
"allow-search": ""
|
|
298
|
-
|
|
297
|
+
"allow-search": "",
|
|
298
|
+
"filter-tree-node": (searchValue, nodeData) => {
|
|
299
|
+
console.log(nodeData);
|
|
300
|
+
if (!nodeData.alias)
|
|
301
|
+
return false;
|
|
302
|
+
return nodeData.alias.toLowerCase().indexOf(searchValue.toLowerCase()) > -1;
|
|
303
|
+
}
|
|
304
|
+
}, null, 8, ["modelValue", "data", "filter-tree-node"])
|
|
299
305
|
]),
|
|
300
306
|
createCommentVNode(" \u7D20\u6750\u7C7B\u578B "),
|
|
301
307
|
createElementVNode("div", _hoisted_7, [
|
|
@@ -38,9 +38,11 @@ const _sfc_main = vue.defineComponent({
|
|
|
38
38
|
});
|
|
39
39
|
return _columns;
|
|
40
40
|
});
|
|
41
|
-
const getOptions = (
|
|
42
|
-
return item
|
|
43
|
-
|
|
41
|
+
const getOptions = vue.computed(() => {
|
|
42
|
+
return (item) => {
|
|
43
|
+
return item.options ? item.options : [];
|
|
44
|
+
};
|
|
45
|
+
});
|
|
44
46
|
const hasValue = vue.computed(() => {
|
|
45
47
|
return (key) => {
|
|
46
48
|
var _a, _b;
|
|
@@ -77,7 +79,10 @@ const _sfc_main = vue.defineComponent({
|
|
|
77
79
|
_form[column.range] = rangeTemp[column.range];
|
|
78
80
|
} else if (column.component === "select") {
|
|
79
81
|
_form[column.key] = column.defaultValue || null;
|
|
80
|
-
} else {
|
|
82
|
+
} else if (column.component === "input-group") {
|
|
83
|
+
_form[column.selectKey] = column.selectDefaultValue || "";
|
|
84
|
+
_form[column.inputKey] = column.inputDefaultValue || "";
|
|
85
|
+
} else if (column.component) {
|
|
81
86
|
_form[column.key] = column.defaultValue || "";
|
|
82
87
|
}
|
|
83
88
|
});
|
|
@@ -179,17 +184,48 @@ const _sfc_main = vue.defineComponent({
|
|
|
179
184
|
active: hasValue.value(item.key)
|
|
180
185
|
}, {
|
|
181
186
|
default: vue.withCtx(() => [
|
|
182
|
-
item.component === "input" ? (vue.openBlock(), vue.createBlock(vue.unref(webVue.
|
|
183
|
-
|
|
187
|
+
item.slot ? vue.renderSlot(_ctx.$slots, item.slot, { key: 0 }) : item.component === "input-group" ? (vue.openBlock(), vue.createBlock(vue.unref(webVue.InputGroup), { key: 1 }, {
|
|
188
|
+
default: vue.withCtx(() => [
|
|
189
|
+
vue.createVNode(vue.unref(webVue.Select), {
|
|
190
|
+
modelValue: form.value[item.selectKey],
|
|
191
|
+
"onUpdate:modelValue": ($event) => form.value[item.selectKey] = $event,
|
|
192
|
+
"default-active-first-option": "",
|
|
193
|
+
style: { "width": "100px" }
|
|
194
|
+
}, {
|
|
195
|
+
default: vue.withCtx(() => [
|
|
196
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(item.selectOptions, (option, idx) => {
|
|
197
|
+
return vue.openBlock(), vue.createBlock(vue.unref(webVue.Option), {
|
|
198
|
+
key: idx,
|
|
199
|
+
value: option.value
|
|
200
|
+
}, {
|
|
201
|
+
default: vue.withCtx(() => [
|
|
202
|
+
vue.createTextVNode(vue.toDisplayString(option.label), 1)
|
|
203
|
+
]),
|
|
204
|
+
_: 2
|
|
205
|
+
}, 1032, ["value"]);
|
|
206
|
+
}), 128))
|
|
207
|
+
]),
|
|
208
|
+
_: 2
|
|
209
|
+
}, 1032, ["modelValue", "onUpdate:modelValue"]),
|
|
210
|
+
vue.createVNode(vue.unref(webVue.Input), {
|
|
211
|
+
modelValue: form.value[item.inputKey],
|
|
212
|
+
"onUpdate:modelValue": ($event) => form.value[item.inputKey] = $event,
|
|
213
|
+
placeholder: item.placeholder ? item.placeholder : `\u8BF7\u8F93\u5165${item.inputLabel}`,
|
|
214
|
+
style: { "width": "180px" }
|
|
215
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "placeholder"])
|
|
216
|
+
]),
|
|
217
|
+
_: 2
|
|
218
|
+
}, 1024)) : item.component === "input" ? (vue.openBlock(), vue.createBlock(vue.unref(webVue.InputSearch), {
|
|
219
|
+
key: 2,
|
|
184
220
|
modelValue: form.value[item.key],
|
|
185
221
|
"onUpdate:modelValue": ($event) => form.value[item.key] = $event,
|
|
186
222
|
style: vue.normalizeStyle({ width: styleWidth(columnsMap.value[item.key]) }),
|
|
187
223
|
"allow-clear": "",
|
|
188
224
|
size: "medium",
|
|
189
|
-
placeholder: `\u8BF7\u8F93\u5165${item.label}`
|
|
225
|
+
placeholder: item.placeholder ? item.placeholder : `\u8BF7\u8F93\u5165${item.label}`
|
|
190
226
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "style", "placeholder"])) : vue.createCommentVNode("v-if", true),
|
|
191
227
|
item.component === "select" ? (vue.openBlock(), vue.createBlock(vue.unref(webVue.Select), {
|
|
192
|
-
key:
|
|
228
|
+
key: 3,
|
|
193
229
|
modelValue: form.value[item.key],
|
|
194
230
|
"onUpdate:modelValue": ($event) => form.value[item.key] = $event,
|
|
195
231
|
"popup-container": "#base-filter-popup-container",
|
|
@@ -197,13 +233,13 @@ const _sfc_main = vue.defineComponent({
|
|
|
197
233
|
"allow-search": item.allowSearch,
|
|
198
234
|
"default-active-first-option": false,
|
|
199
235
|
style: vue.normalizeStyle({ width: styleWidth(columnsMap.value[item.key]) }),
|
|
200
|
-
placeholder: `\u8BF7\u9009\u62E9${item.label}`,
|
|
236
|
+
placeholder: item.placeholder ? item.placeholder : `\u8BF7\u9009\u62E9${item.label}`,
|
|
201
237
|
onSearch: ($event) => handleSelectSearch($event, item),
|
|
202
238
|
onPopupVisibleChange: ($event) => handleSelectPopupChange($event, item),
|
|
203
239
|
onChange: ($event) => handleSelectChange($event, item)
|
|
204
240
|
}, {
|
|
205
241
|
default: vue.withCtx(() => [
|
|
206
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(getOptions(item), (opt) => {
|
|
242
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(getOptions.value(item), (opt) => {
|
|
207
243
|
return vue.openBlock(), vue.createBlock(vue.unref(webVue.Option), {
|
|
208
244
|
key: opt.value,
|
|
209
245
|
label: opt.label,
|
|
@@ -214,7 +250,7 @@ const _sfc_main = vue.defineComponent({
|
|
|
214
250
|
_: 2
|
|
215
251
|
}, 1032, ["modelValue", "onUpdate:modelValue", "allow-search", "style", "placeholder", "onSearch", "onPopupVisibleChange", "onChange"])) : vue.createCommentVNode("v-if", true),
|
|
216
252
|
item.component === "range-picker" ? (vue.openBlock(), vue.createBlock(vue.unref(webVue.RangePicker), {
|
|
217
|
-
key:
|
|
253
|
+
key: 4,
|
|
218
254
|
modelValue: form.value[item.key].range,
|
|
219
255
|
"onUpdate:modelValue": ($event) => form.value[item.key].range = $event,
|
|
220
256
|
style: vue.normalizeStyle({ width: styleWidth(form.value[item.key]) }),
|
|
@@ -225,7 +261,28 @@ const _sfc_main = vue.defineComponent({
|
|
|
225
261
|
"popup-container": "#base-filter-popup-container",
|
|
226
262
|
onClick: _cache[1] || (_cache[1] = vue.withModifiers(() => {
|
|
227
263
|
}, ["stop"]))
|
|
228
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "style"])) : vue.createCommentVNode("v-if", true)
|
|
264
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "style"])) : vue.createCommentVNode("v-if", true),
|
|
265
|
+
item.component === "radio" ? (vue.openBlock(), vue.createBlock(vue.unref(webVue.RadioGroup), {
|
|
266
|
+
key: 5,
|
|
267
|
+
modelValue: form.value[item.key],
|
|
268
|
+
"onUpdate:modelValue": ($event) => form.value[item.key] = $event,
|
|
269
|
+
type: "button"
|
|
270
|
+
}, {
|
|
271
|
+
default: vue.withCtx(() => [
|
|
272
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(item.options || [], (option, idx) => {
|
|
273
|
+
return vue.openBlock(), vue.createBlock(vue.unref(webVue.Radio), {
|
|
274
|
+
key: idx,
|
|
275
|
+
value: option.value
|
|
276
|
+
}, {
|
|
277
|
+
default: vue.withCtx(() => [
|
|
278
|
+
vue.createTextVNode(vue.toDisplayString(option.label), 1)
|
|
279
|
+
]),
|
|
280
|
+
_: 2
|
|
281
|
+
}, 1032, ["value"]);
|
|
282
|
+
}), 128))
|
|
283
|
+
]),
|
|
284
|
+
_: 2
|
|
285
|
+
}, 1032, ["modelValue", "onUpdate:modelValue"])) : vue.createCommentVNode("v-if", true)
|
|
229
286
|
]),
|
|
230
287
|
_: 2
|
|
231
288
|
}, 1032, ["active"]);
|
package/lib/hooks/useUpload.js
CHANGED
|
@@ -75,7 +75,7 @@ function useUpload(options) {
|
|
|
75
75
|
list.value = originList;
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
const uploadFile = (BASE_API, file, dir = 0, repoId, callback) => {
|
|
78
|
+
const uploadFile = (BASE_API, file, dir = 0, repoId, callback, upOptions) => {
|
|
79
79
|
const newFile = {
|
|
80
80
|
id: file.id || index.generateUUID(),
|
|
81
81
|
sig_id: file.sig_id || index.generateUUID(),
|
|
@@ -95,18 +95,24 @@ function useUpload(options) {
|
|
|
95
95
|
};
|
|
96
96
|
const uploading = upload.start(progress);
|
|
97
97
|
uploading.then(async (url) => {
|
|
98
|
+
var _a;
|
|
98
99
|
if (options == null ? void 0 : options.noAddMedia) {
|
|
99
100
|
recordTaskStatusChange({ ...newFile, status: 0, url }, 1);
|
|
100
101
|
callback && callback({ ...newFile, url }, "success");
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
104
|
+
const params = {};
|
|
105
|
+
if ((_a = upOptions == null ? void 0 : upOptions.template) == null ? void 0 : _a.watermark) {
|
|
106
|
+
params.watermark = upOptions.template.watermark.default;
|
|
107
|
+
}
|
|
103
108
|
const { code, message } = await addMedia(BASE_API, {
|
|
104
109
|
url,
|
|
105
110
|
size: newFile.size,
|
|
106
111
|
directory_id: dir,
|
|
107
112
|
repository_id: repoId,
|
|
108
113
|
catalog: newFile.type,
|
|
109
|
-
alias: newFile.name
|
|
114
|
+
alias: newFile.name,
|
|
115
|
+
...params
|
|
110
116
|
});
|
|
111
117
|
if (code !== 0) {
|
|
112
118
|
console.log("\u{1F525}\u{1F525}\u{1F525}\u{1F525}\u{1F525} \u4E0A\u4F20\u5931\u8D25\uFF1A", newFile.name, code, message);
|
|
@@ -196,9 +202,16 @@ function getConfiguration(BASE_API, params) {
|
|
|
196
202
|
params
|
|
197
203
|
});
|
|
198
204
|
}
|
|
205
|
+
function getWatermarkTemplate(BASE_API) {
|
|
206
|
+
return request(BASE_API, {
|
|
207
|
+
url: `/poplar/v2/material/image/watermark`,
|
|
208
|
+
method: "get"
|
|
209
|
+
});
|
|
210
|
+
}
|
|
199
211
|
function useUploadConfig() {
|
|
200
212
|
const { get, set, remove } = useLocalStorage["default"]("LOCAL_UPLOAD_CONFIG");
|
|
201
213
|
const config = vue.ref(get() || {});
|
|
214
|
+
const template = vue.ref({});
|
|
202
215
|
async function initUploadConfig(BASE_API, domainId) {
|
|
203
216
|
if (config.value.size_config_enabled != null)
|
|
204
217
|
return;
|
|
@@ -247,16 +260,43 @@ function useUploadConfig() {
|
|
|
247
260
|
);
|
|
248
261
|
return false;
|
|
249
262
|
}
|
|
263
|
+
async function initTemplate(BASE_API) {
|
|
264
|
+
try {
|
|
265
|
+
const { code, message } = await getWatermarkTemplate(BASE_API);
|
|
266
|
+
if (code !== 0)
|
|
267
|
+
return;
|
|
268
|
+
if (message) {
|
|
269
|
+
let defaultWaterMark;
|
|
270
|
+
if (Array.isArray(message.images)) {
|
|
271
|
+
message.images.forEach((item) => {
|
|
272
|
+
if (message.default === item.id)
|
|
273
|
+
defaultWaterMark = item;
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
template.value = {
|
|
277
|
+
watermark: {
|
|
278
|
+
default: defaultWaterMark,
|
|
279
|
+
images: message.images
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
} catch (e) {
|
|
284
|
+
console.error(e);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
250
287
|
window.addEventListener("beforeunload", remove, false);
|
|
251
288
|
return {
|
|
252
289
|
config,
|
|
290
|
+
template,
|
|
253
291
|
checkFileSizeOutLimit,
|
|
254
|
-
initUploadConfig
|
|
292
|
+
initUploadConfig,
|
|
293
|
+
initTemplate
|
|
255
294
|
};
|
|
256
295
|
}
|
|
257
296
|
exports.addMedia = addMedia;
|
|
258
297
|
exports["default"] = useUpload;
|
|
259
298
|
exports.getMediaDetails = getMediaDetails;
|
|
260
299
|
exports.getSize = getSize;
|
|
300
|
+
exports.getWatermarkTemplate = getWatermarkTemplate;
|
|
261
301
|
exports.reTranscodeMedia = reTranscodeMedia;
|
|
262
302
|
exports.useUploadConfig = useUploadConfig;
|
|
@@ -23,6 +23,7 @@ const _sfc_main = vue.defineComponent({
|
|
|
23
23
|
var _a;
|
|
24
24
|
return (_a = userInfo == null ? void 0 : userInfo.value) == null ? void 0 : _a.repository_id;
|
|
25
25
|
});
|
|
26
|
+
const { template, initTemplate } = useUpload.useUploadConfig();
|
|
26
27
|
const { list, uploadFile, reTranscode, transcodingFile, removeRecord } = useUpload["default"]();
|
|
27
28
|
function handleChange(file) {
|
|
28
29
|
if (!baseAPI || !repoId.value)
|
|
@@ -32,7 +33,8 @@ const _sfc_main = vue.defineComponent({
|
|
|
32
33
|
file.file,
|
|
33
34
|
0,
|
|
34
35
|
repoId.value,
|
|
35
|
-
(media) => transcodingFile(baseAPI, media, repoId.value)
|
|
36
|
+
(media) => transcodingFile(baseAPI, media, repoId.value),
|
|
37
|
+
{ template: template.value }
|
|
36
38
|
);
|
|
37
39
|
}
|
|
38
40
|
async function handleOptions(e) {
|
|
@@ -55,6 +57,9 @@ const _sfc_main = vue.defineComponent({
|
|
|
55
57
|
removeRecord(e.item);
|
|
56
58
|
}
|
|
57
59
|
}
|
|
60
|
+
vue.onMounted(() => {
|
|
61
|
+
initTemplate(baseAPI);
|
|
62
|
+
});
|
|
58
63
|
return (_ctx, _cache) => {
|
|
59
64
|
return vue.openBlock(), vue.createBlock(ListWraper, null, {
|
|
60
65
|
"footer-extra": vue.withCtx(() => [
|
|
@@ -295,8 +295,14 @@ const _sfc_main = vue.defineComponent({
|
|
|
295
295
|
key: "id"
|
|
296
296
|
},
|
|
297
297
|
"allow-clear": "",
|
|
298
|
-
"allow-search": ""
|
|
299
|
-
|
|
298
|
+
"allow-search": "",
|
|
299
|
+
"filter-tree-node": (searchValue, nodeData) => {
|
|
300
|
+
console.log(nodeData);
|
|
301
|
+
if (!nodeData.alias)
|
|
302
|
+
return false;
|
|
303
|
+
return nodeData.alias.toLowerCase().indexOf(searchValue.toLowerCase()) > -1;
|
|
304
|
+
}
|
|
305
|
+
}, null, 8, ["modelValue", "data", "filter-tree-node"])
|
|
300
306
|
]),
|
|
301
307
|
vue.createCommentVNode(" \u7D20\u6750\u7C7B\u578B "),
|
|
302
308
|
vue.createElementVNode("div", _hoisted_7, [
|