kouxiangtang 0.0.78 → 0.0.79
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 +48 -4
- package/dist/{AttachmentUploader-Dk3pI8xI.js → AttachmentUploader-CNRraZtx.js} +58 -48
- package/dist/AttachmentUploader-CNRraZtx.js.map +1 -0
- package/dist/{ImageUploader-Sl6CARAH.js → ImageUploader-Bjfhrzw7.js} +2 -2
- package/dist/{ImageUploader-Sl6CARAH.js.map → ImageUploader-Bjfhrzw7.js.map} +1 -1
- package/dist/ImagesUploader-DETYCvHu.js +132 -0
- package/dist/ImagesUploader-DETYCvHu.js.map +1 -0
- package/dist/{RichTextEditor-BN-Grymy.js → RichTextEditor-CnEVXr9n.js} +2 -2
- package/dist/{RichTextEditor-BN-Grymy.js.map → RichTextEditor-CnEVXr9n.js.map} +1 -1
- package/dist/{config-CEbzlR4L.js → config-2_Cr-n4i.js} +2 -2
- package/dist/{config-CEbzlR4L.js.map → config-2_Cr-n4i.js.map} +1 -1
- package/dist/{config-Dfv9X_oH.js → config-2s11rv4U.js} +3 -3
- package/dist/{config-Dfv9X_oH.js.map → config-2s11rv4U.js.map} +1 -1
- package/dist/{config-kSnMLu_i.js → config-B3rFCdb1.js} +2 -2
- package/dist/{config-kSnMLu_i.js.map → config-B3rFCdb1.js.map} +1 -1
- package/dist/{config-BDUo3FW4.js → config-B4U-qONS.js} +2 -2
- package/dist/{config-BDUo3FW4.js.map → config-B4U-qONS.js.map} +1 -1
- package/dist/{config-BIoYHFta.js → config-B91vghof.js} +3 -3
- package/dist/{config-BIoYHFta.js.map → config-B91vghof.js.map} +1 -1
- package/dist/{config-urM6mrhD.js → config-BMGrKMpE.js} +2 -2
- package/dist/{config-urM6mrhD.js.map → config-BMGrKMpE.js.map} +1 -1
- package/dist/{config-B7sfuPS-.js → config-BSN-cBcX.js} +2 -2
- package/dist/{config-B7sfuPS-.js.map → config-BSN-cBcX.js.map} +1 -1
- package/dist/{config-BPF5NKbv.js → config-BV-dO9EP.js} +2 -2
- package/dist/{config-BPF5NKbv.js.map → config-BV-dO9EP.js.map} +1 -1
- package/dist/{config-DFY-g88P.js → config-CNGnJM6F.js} +2 -2
- package/dist/{config-DFY-g88P.js.map → config-CNGnJM6F.js.map} +1 -1
- package/dist/{config-DIgyOzyY.js → config-CYpYjgUQ.js} +2 -2
- package/dist/{config-DIgyOzyY.js.map → config-CYpYjgUQ.js.map} +1 -1
- package/dist/{config-DWQ07KGg.js → config-Cb_n8bE4.js} +2 -2
- package/dist/{config-DWQ07KGg.js.map → config-Cb_n8bE4.js.map} +1 -1
- package/dist/{config-Cs24dvIw.js → config-Cmc43iHq.js} +2 -2
- package/dist/{config-Cs24dvIw.js.map → config-Cmc43iHq.js.map} +1 -1
- package/dist/{config-Gr_n4RJU.js → config-CxKo7dEe.js} +3 -3
- package/dist/{config-Gr_n4RJU.js.map → config-CxKo7dEe.js.map} +1 -1
- package/dist/{config-nxWFYd4H.js → config-DGVtv5rW.js} +2 -2
- package/dist/{config-nxWFYd4H.js.map → config-DGVtv5rW.js.map} +1 -1
- package/dist/{config-D6JmkLzW.js → config-DIc7DMXS.js} +2 -2
- package/dist/{config-D6JmkLzW.js.map → config-DIc7DMXS.js.map} +1 -1
- package/dist/{config-CWEv8XKO.js → config-DgHf3vtF.js} +2 -2
- package/dist/{config-CWEv8XKO.js.map → config-DgHf3vtF.js.map} +1 -1
- package/dist/{config-7NNTCgWz.js → config-Dl3vDC54.js} +2 -2
- package/dist/{config-7NNTCgWz.js.map → config-Dl3vDC54.js.map} +1 -1
- package/dist/{config-3CmGvWbJ.js → config-OKHueQCv.js} +2 -2
- package/dist/{config-3CmGvWbJ.js.map → config-OKHueQCv.js.map} +1 -1
- package/dist/{config-BMegUoCu.js → config-nIyua4ul.js} +2 -2
- package/dist/{config-BMegUoCu.js.map → config-nIyua4ul.js.map} +1 -1
- package/dist/{index-DWaIPnvt.js → index-CL6D4EuF.js} +104 -101
- package/dist/index-CL6D4EuF.js.map +1 -0
- package/dist/kouxiangtang.js +1 -1
- package/dist/kouxiangtang.umd.cjs +5 -5
- package/dist/kouxiangtang.umd.cjs.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/AttachmentUploader-Dk3pI8xI.js.map +0 -1
- package/dist/ImagesUploader-CD6qu0oD.js +0 -123
- package/dist/ImagesUploader-CD6qu0oD.js.map +0 -1
- package/dist/index-DWaIPnvt.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,7 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
## kouxiangtang
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
### 介绍
|
|
4
|
+
`kouxiangtang` 通用的管理后台前端框架,此框架带有明确的后台数据管理目的。
|
|
4
5
|
|
|
5
|
-
## Recommended IDE Setup
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### 定义一个领域模型(`domain`)
|
|
8
|
+
本组件库为热血星球系列小程序使用,可能会随着业务非向下兼容改动,其他公司或下载使用请谨慎。
|
|
9
|
+
|
|
10
|
+
### 每个领域模型都有列表页
|
|
11
|
+
<img src="https://bloodcare-1251596343.cos.ap-shanghai.myqcloud.com/assets/qrcode/ui-lib-qrcode.jpg" width="240" height="240" style="margin: 20px auto;">
|
|
12
|
+
|
|
13
|
+
### 每个领域模型都有详情页
|
|
14
|
+
通过 `npm` 命令行安装
|
|
15
|
+
```
|
|
16
|
+
npm install bulade-ui -S
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 每个领域模型根据 `API` 接口情况提供标准的增删改查的操作
|
|
20
|
+
在微信小程序开发者工具组,点击“工具”菜单中的“构建 npm”,将其构建到 `miniprogram_npm` 目录下
|
|
21
|
+
|
|
22
|
+
### 列表页提供可配置的数据过滤方式
|
|
23
|
+
``` JSON
|
|
24
|
+
"usingComponents": {
|
|
25
|
+
"bld-button": "bulade-ui/button"
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
``` HTML
|
|
29
|
+
<bld-button iclass="button" type="success" size="lg" >按钮</bld-button>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 提供针对列表页数据集的批量操作(`PageAction`)
|
|
33
|
+
```
|
|
34
|
+
# 安装项目依赖
|
|
35
|
+
npm install
|
|
36
|
+
|
|
37
|
+
# 执行组件编译
|
|
38
|
+
npm run dev
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 提供针对单条数据的操作(`RowAction`)
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
npm run watch
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 提供针对数据关联的显示
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
npm run watch
|
|
51
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { computed as F, ref as y, openBlock as p, createElementBlock as
|
|
1
|
+
import { computed as F, ref as y, openBlock as p, createElementBlock as k, Fragment as E, createVNode as r, unref as n, normalizeClass as M, withModifiers as R, withCtx as i, createBlock as f, createTextVNode as j, createElementVNode as U, renderList as L, toDisplayString as O, createCommentVNode as S } from "vue";
|
|
2
2
|
import { ElUpload as q, ElIcon as v, ElButton as W, ElDialog as G, ElForm as H, ElFormItem as J, ElInput as K, ElMessage as u, ElLoading as w } from "element-plus";
|
|
3
|
-
import { _ as Q, j as X, p as Y, d as Z, k as ee, h as te, m as ae } from "./index-
|
|
3
|
+
import { _ as Q, j as X, p as Y, d as Z, k as ee, h as te, m as ae } from "./index-CL6D4EuF.js";
|
|
4
4
|
import "./el-progress-l0sNRNKZ.js";
|
|
5
5
|
const se = ["src"], ne = { class: "file-type" }, le = {
|
|
6
6
|
__name: "AttachmentUploader",
|
|
@@ -26,8 +26,8 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
28
|
emits: ["on-success", "on-remove", "on-change"],
|
|
29
|
-
setup(
|
|
30
|
-
const m = C,
|
|
29
|
+
setup(b, { emit: C }) {
|
|
30
|
+
const m = C, s = b, g = F(() => s.pics.map((e) => {
|
|
31
31
|
const t = e.url.substring(e.url.lastIndexOf(".") + 1);
|
|
32
32
|
if (typeof e.name !== void 0)
|
|
33
33
|
return e.fileType = t, e;
|
|
@@ -41,7 +41,7 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
41
41
|
}
|
|
42
42
|
return { ...e, name: e.id, fileType: t };
|
|
43
43
|
})), _ = y(""), h = y(!1);
|
|
44
|
-
y(
|
|
44
|
+
y(s);
|
|
45
45
|
const x = X().fileUploadUrl;
|
|
46
46
|
`${localStorage.getItem("token")}`;
|
|
47
47
|
const V = (e) => {
|
|
@@ -50,14 +50,14 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
50
50
|
return e.type.startsWith("image/") ? (t.onload = async (o) => {
|
|
51
51
|
const d = new Image();
|
|
52
52
|
d.src = o.target.result, d.onload = () => {
|
|
53
|
-
const c = document.createElement("canvas"),
|
|
54
|
-
c.width = d.width, c.height = d.height,
|
|
55
|
-
(
|
|
56
|
-
const
|
|
53
|
+
const c = document.createElement("canvas"), $ = c.getContext("2d");
|
|
54
|
+
c.width = d.width, c.height = d.height, $.drawImage(d, 0, 0, c.width, c.height), c.toBlob(
|
|
55
|
+
(z) => {
|
|
56
|
+
const A = new File([z], e.name, {
|
|
57
57
|
type: e.type,
|
|
58
58
|
lastModified: Date.now()
|
|
59
59
|
});
|
|
60
|
-
a(
|
|
60
|
+
a(A);
|
|
61
61
|
},
|
|
62
62
|
e.type,
|
|
63
63
|
0.5
|
|
@@ -65,30 +65,40 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
65
65
|
};
|
|
66
66
|
}, !1) : (a(e), !1);
|
|
67
67
|
});
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
}, I = (e) => {
|
|
69
|
+
var t, a;
|
|
70
|
+
if (e.status === "success")
|
|
71
|
+
if (s.props.deleteParams) {
|
|
72
|
+
const l = (t = s.props.deleteParams) != null && t.data ? (a = s.props.deleteParams) == null ? void 0 : a.data : {};
|
|
73
|
+
te.remove(
|
|
74
|
+
`${s.props.deleteParams.url}/${e.id}/attachment`,
|
|
75
|
+
l,
|
|
76
|
+
l
|
|
77
|
+
).then(() => {
|
|
78
|
+
m("on-remove", e);
|
|
79
|
+
});
|
|
80
|
+
} else
|
|
81
|
+
m("on-remove", e);
|
|
72
82
|
}, T = () => {
|
|
73
83
|
u({
|
|
74
|
-
message: `最多只能上传 ${
|
|
84
|
+
message: `最多只能上传 ${s.props.limit} 个文件!`,
|
|
75
85
|
type: "warning"
|
|
76
86
|
});
|
|
77
|
-
},
|
|
87
|
+
}, P = (e) => {
|
|
78
88
|
_.value = e.url, h.value = !0;
|
|
79
|
-
},
|
|
89
|
+
}, B = (e) => {
|
|
80
90
|
const t = e.name.substring(0, e.name.lastIndexOf("."));
|
|
81
91
|
if (!/^[\u4e00-\u9fa5\w-_]+$/.test(t))
|
|
82
92
|
return u({
|
|
83
93
|
message: "请勿输入特殊字符!",
|
|
84
94
|
type: "warning"
|
|
85
95
|
}), !1;
|
|
86
|
-
V(e).then((l) => l.size / 1024 / 1024 < 5 ? (
|
|
96
|
+
V(e).then((l) => l.size / 1024 / 1024 < 5 ? (N(l), !1) : (u({
|
|
87
97
|
message: "上传大小不能超过 5MB!",
|
|
88
98
|
type: "warning"
|
|
89
99
|
}), !1));
|
|
90
100
|
};
|
|
91
|
-
function
|
|
101
|
+
function D(e, t) {
|
|
92
102
|
if (!e.name) {
|
|
93
103
|
u({
|
|
94
104
|
message: "附件名称不能为空!",
|
|
@@ -98,7 +108,7 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
98
108
|
}
|
|
99
109
|
m("on-change", e);
|
|
100
110
|
}
|
|
101
|
-
function
|
|
111
|
+
function N(e) {
|
|
102
112
|
return w.service({ text: "上传中,请稍后", background: "rgba(0,0,0,0.3)" }), new Promise((t, a) => {
|
|
103
113
|
const l = new FormData();
|
|
104
114
|
l.append("file", e), ae.post(x, l, {}).then((o) => (w.service().close(), u({
|
|
@@ -112,37 +122,37 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
112
122
|
});
|
|
113
123
|
});
|
|
114
124
|
}
|
|
115
|
-
return (e, t) => (p(),
|
|
116
|
-
r(
|
|
125
|
+
return (e, t) => (p(), k(E, null, [
|
|
126
|
+
r(n(q), {
|
|
117
127
|
"file-list": g.value,
|
|
118
|
-
action:
|
|
119
|
-
limit:
|
|
120
|
-
accept:
|
|
121
|
-
"list-type":
|
|
122
|
-
"on-remove":
|
|
123
|
-
"before-upload":
|
|
128
|
+
action: n(x),
|
|
129
|
+
limit: s.props.limit,
|
|
130
|
+
accept: s.props.accept,
|
|
131
|
+
"list-type": s.props.listType,
|
|
132
|
+
"on-remove": I,
|
|
133
|
+
"before-upload": B,
|
|
124
134
|
"on-exceed": T,
|
|
125
|
-
"on-preview":
|
|
135
|
+
"on-preview": P,
|
|
126
136
|
multiple: !0,
|
|
127
137
|
"http-request": () => !1,
|
|
128
|
-
"show-file-list":
|
|
138
|
+
"show-file-list": s.props.listType !== "text",
|
|
129
139
|
class: M([
|
|
130
140
|
"upload-main",
|
|
131
|
-
{ "disable-upload": g.value.length >=
|
|
141
|
+
{ "disable-upload": g.value.length >= s.props.limit }
|
|
132
142
|
]),
|
|
133
143
|
onClick: t[0] || (t[0] = R(() => {
|
|
134
144
|
}, ["prevent"]))
|
|
135
145
|
}, {
|
|
136
146
|
default: i(() => [
|
|
137
|
-
|
|
147
|
+
s.props.listType !== "text" ? (p(), f(n(v), {
|
|
138
148
|
key: 0,
|
|
139
149
|
disabled: !0
|
|
140
150
|
}, {
|
|
141
151
|
default: i(() => [
|
|
142
|
-
r(
|
|
152
|
+
r(n(Y))
|
|
143
153
|
]),
|
|
144
154
|
_: 1
|
|
145
|
-
})) : (p(), f(
|
|
155
|
+
})) : (p(), f(n(W), {
|
|
146
156
|
key: 1,
|
|
147
157
|
class: "upload-button",
|
|
148
158
|
type: "primary"
|
|
@@ -155,12 +165,12 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
155
165
|
]),
|
|
156
166
|
_: 1
|
|
157
167
|
}, 8, ["file-list", "action", "limit", "accept", "list-type", "show-file-list", "class"]),
|
|
158
|
-
r(
|
|
168
|
+
r(n(G), {
|
|
159
169
|
modelValue: h.value,
|
|
160
170
|
"onUpdate:modelValue": t[1] || (t[1] = (a) => h.value = a)
|
|
161
171
|
}, {
|
|
162
172
|
default: i(() => [
|
|
163
|
-
|
|
173
|
+
U("img", {
|
|
164
174
|
"w-full": "",
|
|
165
175
|
src: _.value,
|
|
166
176
|
alt: "Preview Image"
|
|
@@ -168,35 +178,35 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
168
178
|
]),
|
|
169
179
|
_: 1
|
|
170
180
|
}, 8, ["modelValue"]),
|
|
171
|
-
|
|
181
|
+
s.props.listType == "text" ? (p(), f(n(H), { key: 0 }, {
|
|
172
182
|
default: i(() => [
|
|
173
|
-
(p(!0),
|
|
183
|
+
(p(!0), k(E, null, L(g.value, (a, l) => (p(), f(n(J), {
|
|
174
184
|
key: l,
|
|
175
185
|
class: "file-list"
|
|
176
186
|
}, {
|
|
177
187
|
default: i(() => [
|
|
178
|
-
r(
|
|
188
|
+
r(n(v), {
|
|
179
189
|
color: "#73767a",
|
|
180
190
|
size: 14
|
|
181
191
|
}, {
|
|
182
192
|
default: i(() => [
|
|
183
|
-
r(
|
|
193
|
+
r(n(Z))
|
|
184
194
|
]),
|
|
185
195
|
_: 1
|
|
186
196
|
}),
|
|
187
|
-
r(
|
|
197
|
+
r(n(K), {
|
|
188
198
|
modelValue: a.name,
|
|
189
199
|
"onUpdate:modelValue": (o) => a.name = o,
|
|
190
|
-
onChange: (o) =>
|
|
200
|
+
onChange: (o) => D(a)
|
|
191
201
|
}, null, 8, ["modelValue", "onUpdate:modelValue", "onChange"]),
|
|
192
|
-
|
|
193
|
-
r(
|
|
202
|
+
U("span", ne, "." + O(a.fileType), 1),
|
|
203
|
+
r(n(v), {
|
|
194
204
|
color: "#73767a",
|
|
195
205
|
size: 12,
|
|
196
|
-
onClick: (o) =>
|
|
206
|
+
onClick: (o) => I(a)
|
|
197
207
|
}, {
|
|
198
208
|
default: i(() => [
|
|
199
|
-
r(
|
|
209
|
+
r(n(ee))
|
|
200
210
|
]),
|
|
201
211
|
_: 2
|
|
202
212
|
}, 1032, ["onClick"])
|
|
@@ -208,8 +218,8 @@ const se = ["src"], ne = { class: "file-type" }, le = {
|
|
|
208
218
|
})) : S("", !0)
|
|
209
219
|
], 64));
|
|
210
220
|
}
|
|
211
|
-
}, pe = /* @__PURE__ */ Q(le, [["__scopeId", "data-v-
|
|
221
|
+
}, pe = /* @__PURE__ */ Q(le, [["__scopeId", "data-v-4c31cc76"]]);
|
|
212
222
|
export {
|
|
213
223
|
pe as default
|
|
214
224
|
};
|
|
215
|
-
//# sourceMappingURL=AttachmentUploader-
|
|
225
|
+
//# sourceMappingURL=AttachmentUploader-CNRraZtx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AttachmentUploader-CNRraZtx.js","sources":["../src/framework/field/attachment/AttachmentUploader.vue"],"sourcesContent":["<script setup>\nimport {\n ElUpload,\n ElIcon,\n ElDialog,\n ElForm,\n ElFormItem,\n ElButton,\n ElInput,\n} from \"element-plus\";\nimport axios from \"axios\";\nimport http from \"../../utils/http\";\nimport { getConfig } from \"../../config-loader\";\nimport { ref, computed } from \"vue\";\nimport { ElLoading, ElMessage } from \"element-plus\";\nimport { Plus, Document, Close } from \"@element-plus/icons-vue\";\n\nconst emit = defineEmits([\"on-success\", \"on-remove\", \"on-change\"]);\nconst props = defineProps({\n pics: {\n type: Array,\n default() {\n return [];\n },\n },\n limit: { type: Number },\n props: {\n type: Object,\n default() {\n return {\n listType: \"picture-card\", //'text' | 'picture' | 'picture-card'\n limit: 5, //最多上传几个文件\n accept: \"image/*\",\n };\n },\n },\n});\n\nconst files = computed(() => {\n return props.pics.map((item) => {\n const fileType = item.url.substring(item.url.lastIndexOf(\".\") + 1);\n if (typeof item.name !== undefined) {\n item.fileType = fileType;\n return item;\n }\n\n if (item.url) {\n const parts = item.url.split(\"/\");\n const namedItem = {\n ...item,\n name: parts[parts.length - 1],\n fileType: fileType,\n };\n return namedItem;\n }\n\n return { ...item, name: item.id, fileType: fileType };\n });\n});\nconst dialogImageUrl = ref(\"\");\nconst dialogVisible = ref(false);\nconst imageUrl = ref(props);\nconst uploadUrl = getConfig().fileUploadUrl;\nconst header = {\n Authorization: `Bearer ${localStorage.getItem(\"token\")}`,\n};\nconst compressImg = (file) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n\n return new Promise(function (resolve, reject) {\n if (!file.type.startsWith(\"image/\")) {\n resolve(file);\n return false;\n }\n reader.onload = async (e) => {\n const img = new Image();\n img.src = e.target.result;\n img.onload = () => {\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n canvas.width = img.width;\n canvas.height = img.height;\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height);\n canvas.toBlob(\n (blob) => {\n const newFile = new File([blob], file.name, {\n type: file.type,\n lastModified: Date.now(),\n });\n resolve(newFile);\n },\n file.type,\n 0.5,\n );\n };\n };\n return false;\n });\n};\nconst handleRemoveSuccess = (uploadFile) => {\n if (uploadFile.status === \"success\") {\n if (props.props.deleteParams) {\n const paramsData = props.props.deleteParams?.data\n ? props.props.deleteParams?.data\n : {};\n http\n .remove(\n `${props.props.deleteParams.url}/${uploadFile.id}/attachment`,\n paramsData,\n paramsData,\n )\n .then(() => {\n emit(\"on-remove\", uploadFile);\n });\n } else {\n emit(\"on-remove\", uploadFile);\n }\n }\n};\nconst handleExceed = () => {\n ElMessage({\n message: `最多只能上传 ${props.props.limit} 个文件!`,\n type: \"warning\",\n });\n};\nconst handlePictureCardPreview = (uploadFile) => {\n dialogImageUrl.value = uploadFile.url;\n dialogVisible.value = true;\n};\nconst handleBeforeUpload = (file) => {\n const fileName = file.name.substring(0, file.name.lastIndexOf(\".\"));\n const regex = /^[\\u4e00-\\u9fa5\\w-_]+$/;\n if (!regex.test(fileName)) {\n ElMessage({\n message: \"请勿输入特殊字符!\",\n type: \"warning\",\n });\n return false;\n }\n compressImg(file).then((newFile) => {\n if (newFile.size / 1024 / 1024 < 5) {\n uploadRequest(newFile);\n return false;\n } else {\n ElMessage({\n message: \"上传大小不能超过 5MB!\",\n type: \"warning\",\n });\n return false;\n }\n });\n};\n\nfunction handleFileNameChange(file, index) {\n if (!file.name) {\n ElMessage({\n message: \"附件名称不能为空!\",\n type: \"warning\",\n });\n return;\n }\n emit(\"on-change\", file);\n}\n\nfunction uploadRequest(file) {\n ElLoading.service({ text: \"上传中,请稍后\", background: \"rgba(0,0,0,0.3)\" });\n return new Promise((resolve, reject) => {\n const formData = new FormData();\n formData.append(\"file\", file);\n axios\n .post(uploadUrl, formData, {})\n .then((res) => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传成功\",\n type: \"success\",\n });\n emit(\"on-success\", res.data.data);\n resolve(res.data);\n return false;\n })\n .catch(() => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传失败\",\n type: \"warning\",\n });\n reject(\"Upload failed\");\n });\n });\n}\n</script>\n\n<template>\n <!-- 删除请求头加权限后请添加到组建中 :headers=\"header\"-->\n <el-upload\n :file-list=\"files\"\n :action=\"uploadUrl\"\n :limit=\"props.props.limit\"\n :accept=\"props.props.accept\"\n :list-type=\"props.props.listType\"\n :on-remove=\"handleRemoveSuccess\"\n :before-upload=\"handleBeforeUpload\"\n :on-exceed=\"handleExceed\"\n :on-preview=\"handlePictureCardPreview\"\n :multiple=\"true\"\n :http-request=\"\n () => {\n return false;\n }\n \"\n :show-file-list=\"props.props.listType !== 'text'\"\n :class=\"[\n 'upload-main',\n { 'disable-upload': files.length >= props.props.limit },\n ]\"\n @click.prevent\n >\n <template v-if=\"props.props.listType !== 'text'\">\n <el-icon :disabled=\"true\">\n <Plus />\n </el-icon>\n </template>\n <template v-else>\n <el-button class=\"upload-button\" type=\"primary\"> 上传附件 </el-button>\n </template>\n </el-upload>\n <el-dialog v-model=\"dialogVisible\">\n <img w-full :src=\"dialogImageUrl\" alt=\"Preview Image\" />\n </el-dialog>\n <el-form v-if=\"props.props.listType == 'text'\">\n <el-form-item v-for=\"(file, index) in files\" :key=\"index\" class=\"file-list\">\n <el-icon color=\"#73767a\" :size=\"14\">\n <Document />\n </el-icon>\n <el-input\n v-model=\"file.name\"\n @change=\"handleFileNameChange(file, index)\"\n />\n <span class=\"file-type\">.{{ file.fileType }}</span>\n <el-icon color=\"#73767a\" :size=\"12\" @click=\"handleRemoveSuccess(file)\">\n <Close />\n </el-icon>\n </el-form-item>\n </el-form>\n</template>\n<style scoped lang=\"scss\">\n:deep(.el-upload-list) {\n .el-upload-list__item-actions span {\n margin-left: 20px;\n }\n}\n\n.disable-upload {\n :deep(.el-upload--picture-card) {\n display: none !important;\n }\n\n :deep(.el-upload--text) {\n display: none !important;\n }\n\n :deep(.el-upload--picture) {\n display: none !important;\n }\n}\n.upload-main {\n flex-basis: 100%;\n}\n.file-list {\n display: flex;\n align-items: center;\n margin-top: 10px;\n .file-type {\n height: 22px;\n line-height: 22px;\n margin-right: 5px;\n background: #eeeeee;\n border-radius: 4px;\n font-size: 12px;\n padding: 0 4px;\n }\n :deep(.el-form-item__content) {\n display: contents;\n }\n :deep(.el-input__wrapper) {\n margin: 0 5px;\n }\n :deep(.el-input__inner) {\n height: 20px;\n line-height: 20px;\n }\n}\n</style>\n"],"names":["emit","__emit","props","__props","files","computed","item","fileType","parts","dialogImageUrl","ref","dialogVisible","uploadUrl","getConfig","compressImg","file","reader","resolve","reject","e","img","canvas","ctx","blob","newFile","handleRemoveSuccess","uploadFile","paramsData","_a","_b","http","handleExceed","ElMessage","handlePictureCardPreview","handleBeforeUpload","fileName","uploadRequest","handleFileNameChange","index","ElLoading","formData","axios","res"],"mappings":"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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { openBlock as t, createBlock as o, unref as e, withCtx as s, renderSlot as I, createElementVNode as v, createVNode as l, withModifiers as E, createCommentVNode as b } from "vue";
|
|
2
2
|
import { ElUpload as x, ElImage as B, ElIcon as n, ElMessage as i, ElLoading as d } from "element-plus";
|
|
3
|
-
import { _ as M, j as C, l as S, p as L, n as N, m as V } from "./index-
|
|
3
|
+
import { _ as M, j as C, l as S, p as L, n as N, m as V } from "./index-CL6D4EuF.js";
|
|
4
4
|
import "./el-progress-l0sNRNKZ.js";
|
|
5
5
|
const q = { class: "image-slot" }, z = {
|
|
6
6
|
__name: "ImageUploader",
|
|
@@ -94,4 +94,4 @@ const q = { class: "image-slot" }, z = {
|
|
|
94
94
|
export {
|
|
95
95
|
F as default
|
|
96
96
|
};
|
|
97
|
-
//# sourceMappingURL=ImageUploader-
|
|
97
|
+
//# sourceMappingURL=ImageUploader-Bjfhrzw7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUploader-
|
|
1
|
+
{"version":3,"file":"ImageUploader-Bjfhrzw7.js","sources":["../src/framework/field/image/ImageUploader.vue"],"sourcesContent":["<script setup>\nimport { ElUpload, ElImage, ElIcon } from \"element-plus\";\nimport axios from \"axios\";\nimport { getConfig } from \"../../config-loader\";\nimport { ElLoading, ElMessage } from \"element-plus\";\nimport { Plus, Delete, Loading } from \"@element-plus/icons-vue\";\n\nconst emit = defineEmits([\"on-success\"]);\nconst props = defineProps({\n imageUrl: { type: String },\n});\nconst uploadUrl = getConfig().imageUploadUrl;\nconst header = {\n Authorization: `Bearer ${localStorage.getItem(\"token\")}`,\n};\nconst handleBeforeUpload = (uploadFile) => {\n const isLt2M = uploadFile.size / 1024 / 1024 < 5;\n if (!isLt2M) {\n ElMessage({\n message: \"上传大小不能超过 5MB!\",\n type: \"warning\",\n });\n return false;\n }\n};\nconst handleSuccess = (response) => {\n emit(\"on-success\", response.data.imageUrl);\n};\n\nfunction deleteImageUrl() {\n emit(\"on-success\", \"\");\n}\n\nfunction uploadRequest(file) {\n ElLoading.service({ text: \"上传中,请稍后\", background: \"rgba(0,0,0,0.3)\" });\n return new Promise((resolve, reject) => {\n const formData = new FormData();\n formData.append(\"image\", file.file);\n axios\n .post(uploadUrl, formData, {})\n .then((res) => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传成功\",\n type: \"success\",\n });\n resolve(res.data);\n })\n .catch(() => {\n ElLoading.service().close();\n ElMessage({\n message: \"上传失败\",\n type: \"warning\",\n });\n reject(\"Upload failed\");\n });\n });\n}\n</script>\n\n<template>\n <!-- 删除请求头加权限后请添加到组建中 :headers=\"header\"-->\n <el-upload\n class=\"image-uploader\"\n :action=\"uploadUrl\"\n name=\"image\"\n :show-file-list=\"false\"\n :on-success=\"handleSuccess\"\n :before-upload=\"handleBeforeUpload\"\n :http-request=\"uploadRequest\"\n >\n <slot />\n <el-image\n v-if=\"props.imageUrl\"\n class=\"image\"\n :src=\"props.imageUrl\"\n fit=\"scale-down\"\n >\n <template #placeholder>\n <div class=\"image-slot\">\n <el-icon class=\"placeholder-icon\">\n <Loading />\n </el-icon>\n </div>\n </template>\n </el-image>\n <el-icon v-else class=\"uploader-icon\">\n <Plus />\n </el-icon>\n <el-icon\n v-if=\"props.imageUrl\"\n class=\"delete-icon\"\n @click.stop.prevent=\"deleteImageUrl\"\n >\n <Delete />\n </el-icon>\n </el-upload>\n</template>\n\n<style scoped lang=\"scss\">\n.image-uploader {\n :deep(.el-upload) {\n border: 1px dashed var(--el-border-color);\n border-radius: 6px;\n cursor: pointer;\n position: relative;\n overflow: hidden;\n transition: var(--el-transition-duration-fast);\n\n &:hover {\n border-color: var(--el-color-primary);\n }\n }\n\n .image {\n width: 146px;\n height: 146px;\n\n .placeholder-icon {\n width: 146px;\n height: 146px;\n font-size: 30px;\n color: #a7a7a7;\n }\n }\n\n .uploader-icon {\n font-size: 28px;\n color: #8c939d;\n width: 146px;\n height: 146px;\n text-align: center;\n }\n\n .delete-icon {\n font-size: 20px;\n color: #b7b4b4;\n position: absolute;\n top: 10px;\n right: 10px;\n }\n}\n</style>\n"],"names":["emit","__emit","props","__props","uploadUrl","getConfig","handleBeforeUpload","uploadFile","ElMessage","handleSuccess","response","deleteImageUrl","uploadRequest","file","ElLoading","resolve","reject","formData","axios","res"],"mappings":";;;;;;;;;;;AAOA,UAAMA,IAAOC,GACPC,IAAQC,GAGRC,IAAYC,EAAW,EAAC;AACf,IACY,gBAAa,QAAQ,OAAO;AAEvD,UAAMC,IAAqB,CAACC,MAAe;AAEzC,UAAI,EADWA,EAAW,OAAO,OAAO,OAAO;AAE7C,eAAAC,EAAU;AAAA,UACR,SAAS;AAAA,UACT,MAAM;AAAA,QACZ,CAAK,GACM;AAAA,IAEX,GACMC,IAAgB,CAACC,MAAa;AAClC,MAAAV,EAAK,cAAcU,EAAS,KAAK,QAAQ;AAAA,IAC3C;AAEA,aAASC,IAAiB;AACxB,MAAAX,EAAK,cAAc,EAAE;AAAA,IACvB;AAEA,aAASY,EAAcC,GAAM;AAC3B,aAAAC,EAAU,QAAQ,EAAE,MAAM,WAAW,YAAY,kBAAiB,CAAE,GAC7D,IAAI,QAAQ,CAACC,GAASC,MAAW;AACtC,cAAMC,IAAW,IAAI;AACrB,QAAAA,EAAS,OAAO,SAASJ,EAAK,IAAI,GAClCK,EACG,KAAKd,GAAWa,GAAU,EAAE,EAC5B,KAAK,CAACE,MAAQ;AACb,UAAAL,EAAU,UAAU,SACpBN,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDO,EAAQI,EAAI,IAAI;AAAA,QACxB,CAAO,EACA,MAAM,MAAM;AACX,UAAAL,EAAU,UAAU,SACpBN,EAAU;AAAA,YACR,SAAS;AAAA,YACT,MAAM;AAAA,UAChB,CAAS,GACDQ,EAAO,eAAe;AAAA,QAC9B,CAAO;AAAA,MACP,CAAG;AAAA,IACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { ref as c, computed as I, openBlock as i, createElementBlock as k, createVNode as u, unref as o, normalizeClass as E, withModifiers as T, withCtx as r, createBlock as f, createTextVNode as V, createElementVNode as P } from "vue";
|
|
2
|
+
import { ElUpload as U, ElIcon as B, ElButton as z, ElDialog as D, ElMessage as g } from "element-plus";
|
|
3
|
+
import { _ as N, p as C, h as M } from "./index-CL6D4EuF.js";
|
|
4
|
+
import "./el-progress-l0sNRNKZ.js";
|
|
5
|
+
const $ = ["src"], q = {
|
|
6
|
+
__name: "ImagesUploader",
|
|
7
|
+
props: {
|
|
8
|
+
images: {
|
|
9
|
+
type: Array,
|
|
10
|
+
default() {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
limit: { type: Number },
|
|
15
|
+
props: {
|
|
16
|
+
type: Object,
|
|
17
|
+
default() {
|
|
18
|
+
return {
|
|
19
|
+
listType: "picture-card",
|
|
20
|
+
limit: 5,
|
|
21
|
+
accept: "image/*"
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
emits: ["on-remove", "on-upload"],
|
|
27
|
+
setup(v, { emit: y }) {
|
|
28
|
+
const s = y, m = c(""), n = c(!1), l = v, d = I(() => l.images.map((e) => {
|
|
29
|
+
if (!(e != null && e.url))
|
|
30
|
+
return { ...e, name: "unknown", fileType: "unknown" };
|
|
31
|
+
const t = e.url.substring(e.url.lastIndexOf(".") + 1), a = e.url.split("/");
|
|
32
|
+
return {
|
|
33
|
+
...e,
|
|
34
|
+
name: a[a.length - 1],
|
|
35
|
+
fileType: t
|
|
36
|
+
};
|
|
37
|
+
}));
|
|
38
|
+
function _(e) {
|
|
39
|
+
var t, a;
|
|
40
|
+
if (l.props.deleteParams) {
|
|
41
|
+
const p = (t = l.props.deleteParams) != null && t.data ? (a = l.props.deleteParams) == null ? void 0 : a.data : {};
|
|
42
|
+
M.remove(
|
|
43
|
+
`${l.props.deleteParams.url}/${e.id}/attachment`,
|
|
44
|
+
p,
|
|
45
|
+
p
|
|
46
|
+
).then(() => {
|
|
47
|
+
s("on-remove", e);
|
|
48
|
+
});
|
|
49
|
+
} else
|
|
50
|
+
s("on-remove", e);
|
|
51
|
+
}
|
|
52
|
+
function w() {
|
|
53
|
+
g({
|
|
54
|
+
message: `最多只能上传 ${l.props.limit} 个文件!`,
|
|
55
|
+
type: "warning"
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function b(e) {
|
|
59
|
+
m.value = e.url, n.value = !0;
|
|
60
|
+
}
|
|
61
|
+
function h(e) {
|
|
62
|
+
return e.size > 5242880 ? (g({
|
|
63
|
+
message: "上传大小不能超过 5MB!",
|
|
64
|
+
type: "warning"
|
|
65
|
+
}), !1) : !0;
|
|
66
|
+
}
|
|
67
|
+
function x(e) {
|
|
68
|
+
const t = new FormData();
|
|
69
|
+
t.append("file", e.file), s("on-upload", t);
|
|
70
|
+
}
|
|
71
|
+
return (e, t) => (i(), k("div", null, [
|
|
72
|
+
u(o(U), {
|
|
73
|
+
"file-list": d.value,
|
|
74
|
+
limit: l.props.limit,
|
|
75
|
+
accept: l.props.accept,
|
|
76
|
+
"list-type": l.props.listType,
|
|
77
|
+
"on-remove": _,
|
|
78
|
+
"on-exceed": w,
|
|
79
|
+
"on-preview": b,
|
|
80
|
+
multiple: !0,
|
|
81
|
+
"before-upload": h,
|
|
82
|
+
"http-request": x,
|
|
83
|
+
"show-file-list": l.props.listType !== "text",
|
|
84
|
+
class: E([
|
|
85
|
+
"upload-main",
|
|
86
|
+
{ "disable-upload": d.value.length >= l.props.limit }
|
|
87
|
+
]),
|
|
88
|
+
onClick: t[0] || (t[0] = T(() => {
|
|
89
|
+
}, ["prevent"]))
|
|
90
|
+
}, {
|
|
91
|
+
default: r(() => [
|
|
92
|
+
l.props.listType !== "text" ? (i(), f(o(B), {
|
|
93
|
+
key: 0,
|
|
94
|
+
disabled: !0
|
|
95
|
+
}, {
|
|
96
|
+
default: r(() => [
|
|
97
|
+
u(o(C))
|
|
98
|
+
]),
|
|
99
|
+
_: 1
|
|
100
|
+
})) : (i(), f(o(z), {
|
|
101
|
+
key: 1,
|
|
102
|
+
class: "upload-button",
|
|
103
|
+
type: "primary"
|
|
104
|
+
}, {
|
|
105
|
+
default: r(() => [
|
|
106
|
+
V(" 上传附件 ")
|
|
107
|
+
]),
|
|
108
|
+
_: 1
|
|
109
|
+
}))
|
|
110
|
+
]),
|
|
111
|
+
_: 1
|
|
112
|
+
}, 8, ["file-list", "limit", "accept", "list-type", "show-file-list", "class"]),
|
|
113
|
+
u(o(D), {
|
|
114
|
+
modelValue: n.value,
|
|
115
|
+
"onUpdate:modelValue": t[1] || (t[1] = (a) => n.value = a)
|
|
116
|
+
}, {
|
|
117
|
+
default: r(() => [
|
|
118
|
+
P("img", {
|
|
119
|
+
"w-full": "",
|
|
120
|
+
src: m.value,
|
|
121
|
+
alt: "Preview Image"
|
|
122
|
+
}, null, 8, $)
|
|
123
|
+
]),
|
|
124
|
+
_: 1
|
|
125
|
+
}, 8, ["modelValue"])
|
|
126
|
+
]));
|
|
127
|
+
}
|
|
128
|
+
}, A = /* @__PURE__ */ N(q, [["__scopeId", "data-v-b723b633"]]);
|
|
129
|
+
export {
|
|
130
|
+
A as default
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=ImagesUploader-DETYCvHu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImagesUploader-DETYCvHu.js","sources":["../src/framework/field/images/ImagesUploader.vue"],"sourcesContent":["<script setup>\nimport { ElUpload, ElDialog, ElIcon, ElButton } from \"element-plus\";\nimport { computed, ref } from \"vue\";\nimport { ElMessage } from \"element-plus\";\nimport { Plus } from \"@element-plus/icons-vue\";\nimport http from \"../../utils/http\";\n\nconst emit = defineEmits([\"on-remove\", \"on-upload\"]);\nconst dialogImageUrl = ref(\"\");\nconst dialogVisible = ref(false);\nconst props = defineProps({\n images: {\n type: Array,\n default() {\n return [];\n },\n },\n limit: { type: Number },\n props: {\n type: Object,\n default() {\n return {\n listType: \"picture-card\",\n limit: 5,\n accept: \"image/*\",\n };\n },\n },\n});\n\nconst files = computed(() => {\n return props.images.map((item) => {\n if (!item?.url) {\n return { ...item, name: \"unknown\", fileType: \"unknown\" };\n }\n\n const fileType = item.url.substring(item.url.lastIndexOf(\".\") + 1);\n const parts = item.url.split(\"/\");\n const namedItem = {\n ...item,\n name: parts[parts.length - 1],\n fileType,\n };\n return namedItem;\n });\n});\n\nfunction onRemove(uploadFile) {\n if (props.props.deleteParams) {\n const paramsData = props.props.deleteParams?.data\n ? props.props.deleteParams?.data\n : {};\n http\n .remove(\n `${props.props.deleteParams.url}/${uploadFile.id}/attachment`,\n paramsData,\n paramsData,\n )\n .then(() => {\n emit(\"on-remove\", uploadFile);\n });\n } else {\n emit(\"on-remove\", uploadFile);\n }\n}\n\nfunction onExceed() {\n ElMessage({\n message: `最多只能上传 ${props.props.limit} 个文件!`,\n type: \"warning\",\n });\n}\n\nfunction onPreview(uploadFile) {\n dialogImageUrl.value = uploadFile.url;\n dialogVisible.value = true;\n}\n\nfunction beforeUpload(uploadFile) {\n const limitSize = 1024 * 1024 * 5;\n if (uploadFile.size > limitSize) {\n ElMessage({\n message: \"上传大小不能超过 5MB!\",\n type: \"warning\",\n });\n return false;\n }\n\n return true;\n}\n\nfunction httpRequest(uploadFile) {\n const formData = new FormData();\n formData.append(\"file\", uploadFile.file);\n emit(\"on-upload\", formData);\n}\n</script>\n\n<template>\n <div>\n <el-upload\n :file-list=\"files\"\n :limit=\"props.props.limit\"\n :accept=\"props.props.accept\"\n :list-type=\"props.props.listType\"\n :on-remove=\"onRemove\"\n :on-exceed=\"onExceed\"\n :on-preview=\"onPreview\"\n :multiple=\"true\"\n :before-upload=\"beforeUpload\"\n :http-request=\"httpRequest\"\n :show-file-list=\"props.props.listType !== 'text'\"\n :class=\"[\n 'upload-main',\n { 'disable-upload': files.length >= props.props.limit },\n ]\"\n @click.prevent\n >\n <template v-if=\"props.props.listType !== 'text'\">\n <el-icon :disabled=\"true\">\n <Plus />\n </el-icon>\n </template>\n <template v-else>\n <el-button class=\"upload-button\" type=\"primary\"> 上传附件 </el-button>\n </template>\n </el-upload>\n <el-dialog v-model=\"dialogVisible\">\n <img w-full :src=\"dialogImageUrl\" alt=\"Preview Image\" />\n </el-dialog>\n </div>\n</template>\n<style scoped lang=\"scss\">\n:deep(.el-upload-list) {\n .el-upload-list__item-actions span {\n margin-left: 20px;\n }\n}\n\n.disable-upload {\n :deep(.el-upload--picture-card) {\n display: none !important;\n }\n\n :deep(.el-upload--text) {\n display: none !important;\n }\n\n :deep(.el-upload--picture) {\n display: none !important;\n }\n}\n.upload-main {\n flex-basis: 100%;\n}\n.file-list {\n display: flex;\n align-items: center;\n margin-top: 10px;\n .file-type {\n height: 22px;\n line-height: 22px;\n margin-right: 5px;\n background: #eeeeee;\n border-radius: 4px;\n font-size: 12px;\n padding: 0 4px;\n }\n :deep(.el-form-item__content) {\n display: contents;\n }\n :deep(.el-input__wrapper) {\n margin: 0 5px;\n }\n :deep(.el-input__inner) {\n height: 20px;\n line-height: 20px;\n }\n}\n</style>\n"],"names":["emit","__emit","dialogImageUrl","ref","dialogVisible","props","__props","files","computed","item","fileType","parts","onRemove","uploadFile","paramsData","_a","_b","http","onExceed","ElMessage","onPreview","beforeUpload","httpRequest","formData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,UAAMA,IAAOC,GACPC,IAAiBC,EAAI,EAAE,GACvBC,IAAgBD,EAAI,EAAK,GACzBE,IAAQC,GAoBRC,IAAQC,EAAS,MACdH,EAAM,OAAO,IAAI,CAACI,MAAS;AAChC,UAAI,EAACA,KAAA,QAAAA,EAAM;AACT,eAAO,EAAE,GAAGA,GAAM,MAAM,WAAW,UAAU;AAG/C,YAAMC,IAAWD,EAAK,IAAI,UAAUA,EAAK,IAAI,YAAY,GAAG,IAAI,CAAC,GAC3DE,IAAQF,EAAK,IAAI,MAAM,GAAG;AAMhC,aALkB;AAAA,QAChB,GAAGA;AAAA,QACH,MAAME,EAAMA,EAAM,SAAS,CAAC;AAAA,QAC5B,UAAAD;AAAA,MACN;AAAA,IAEA,CAAG,CACF;AAED,aAASE,EAASC,GAAY;;AAC5B,UAAIR,EAAM,MAAM,cAAc;AAC5B,cAAMS,KAAaC,IAAAV,EAAM,MAAM,iBAAZ,QAAAU,EAA0B,QACzCC,IAAAX,EAAM,MAAM,iBAAZ,gBAAAW,EAA0B,OAC1B;AACJ,QAAAC,EACG;AAAA,UACC,GAAGZ,EAAM,MAAM,aAAa,GAAG,IAAIQ,EAAW,EAAE;AAAA,UAChDC;AAAA,UACAA;AAAA,QACD,EACA,KAAK,MAAM;AACV,UAAAd,EAAK,aAAaa,CAAU;AAAA,QACpC,CAAO;AAAA,MACP;AACI,QAAAb,EAAK,aAAaa,CAAU;AAAA,IAEhC;AAEA,aAASK,IAAW;AAClB,MAAAC,EAAU;AAAA,QACR,SAAS,UAAUd,EAAM,MAAM,KAAK;AAAA,QACpC,MAAM;AAAA,MACV,CAAG;AAAA,IACH;AAEA,aAASe,EAAUP,GAAY;AAC7B,MAAAX,EAAe,QAAQW,EAAW,KAClCT,EAAc,QAAQ;AAAA,IACxB;AAEA,aAASiB,EAAaR,GAAY;AAEhC,aAAIA,EAAW,OAAO,WACpBM,EAAU;AAAA,QACR,SAAS;AAAA,QACT,MAAM;AAAA,MACZ,CAAK,GACM,MAGF;AAAA,IACT;AAEA,aAASG,EAAYT,GAAY;AAC/B,YAAMU,IAAW,IAAI;AACrB,MAAAA,EAAS,OAAO,QAAQV,EAAW,IAAI,GACvCb,EAAK,aAAauB,CAAQ;AAAA,IAC5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as rr, onMounted as ir, onBeforeUnmount as ar, ref as $n, watch as Pn, nextTick as Gn, h as or, computed as sr, openBlock as ur, createBlock as lr, unref as fr } from "vue";
|
|
2
2
|
import * as rt from "quill";
|
|
3
3
|
import Rn from "quill";
|
|
4
|
-
import { o as W, r as cr, m as hr, j as dr } from "./index-
|
|
4
|
+
import { o as W, r as cr, m as hr, j as dr } from "./index-CL6D4EuF.js";
|
|
5
5
|
import { ElMessage as Ln } from "element-plus";
|
|
6
6
|
var ue = -1, re = 1, Z = 0;
|
|
7
7
|
function at(r, a, n, u) {
|
|
@@ -1811,4 +1811,4 @@ const Wn = {
|
|
|
1811
1811
|
export {
|
|
1812
1812
|
Rr as default
|
|
1813
1813
|
};
|
|
1814
|
-
//# sourceMappingURL=RichTextEditor-
|
|
1814
|
+
//# sourceMappingURL=RichTextEditor-CnEVXr9n.js.map
|