@jx3box/jx3box-vue3-ui 0.3.6 → 0.3.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/package.json +1 -1
- package/src/App.vue +4 -0
- package/src/editor/Upload.vue +39 -31
- package/src/editor/UploadAlum.vue +6 -5
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
</LeftSidebar>
|
|
22
22
|
|
|
23
23
|
<Main :withoutLeft="false" :withoutRight="false">
|
|
24
|
+
<UploadAlum />
|
|
24
25
|
<PostHeader :post="post"></PostHeader>
|
|
25
26
|
<SimpleThxVue
|
|
26
27
|
postType="bbs"
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
<RightSidebar>
|
|
46
47
|
<PostTopic type="bps" :id="48857"></PostTopic>
|
|
47
48
|
</RightSidebar>
|
|
49
|
+
|
|
48
50
|
<Footer> </Footer>
|
|
49
51
|
<!-- <Bottom></Bottom> -->
|
|
50
52
|
</Main>
|
|
@@ -52,6 +54,7 @@
|
|
|
52
54
|
</template>
|
|
53
55
|
|
|
54
56
|
<script>
|
|
57
|
+
import UploadAlum from "./editor/UploadAlum.vue";
|
|
55
58
|
import Author from "./single/Author.vue";
|
|
56
59
|
import SimpleThxVue from "./single/SimpleThx.vue";
|
|
57
60
|
import Comment from "./single/Comment.vue";
|
|
@@ -68,6 +71,7 @@ export default {
|
|
|
68
71
|
Thx,
|
|
69
72
|
PostHeader,
|
|
70
73
|
PostTopic,
|
|
74
|
+
UploadAlum,
|
|
71
75
|
},
|
|
72
76
|
data() {
|
|
73
77
|
return {
|
package/src/editor/Upload.vue
CHANGED
|
@@ -26,8 +26,9 @@
|
|
|
26
26
|
with-credentials
|
|
27
27
|
:file-list="fileList"
|
|
28
28
|
:on-change="change"
|
|
29
|
-
ref="
|
|
29
|
+
ref="uploadBox"
|
|
30
30
|
:accept="accept"
|
|
31
|
+
:key="timeStamp + fileList.length"
|
|
31
32
|
>
|
|
32
33
|
<template #default>
|
|
33
34
|
<el-icon><Plus /></el-icon>
|
|
@@ -43,7 +44,6 @@
|
|
|
43
44
|
disabled: file.status != 'success',
|
|
44
45
|
}"
|
|
45
46
|
>
|
|
46
|
-
<!-- FIXME: 此处为强制刷新file,优雅的实现方式有待发掘 -->
|
|
47
47
|
<span style="display: none">{{ fileList }}</span>
|
|
48
48
|
<!-- 图片类型 -->
|
|
49
49
|
<img v-if="file.is_img" class="el-upload-list__item-thumbnail u-imgbox" :src="file.url" alt />
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
<!-- 插入按钮 -->
|
|
64
64
|
<template #footer>
|
|
65
65
|
<span class="dialog-footer">
|
|
66
|
-
<el-button @click="
|
|
66
|
+
<el-button @click="closeUpload">取 消</el-button>
|
|
67
67
|
<el-button type="primary" @click="insert">
|
|
68
68
|
{{ buttonTXT }}
|
|
69
69
|
</el-button>
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
|
|
76
76
|
<script>
|
|
77
77
|
import axios from "axios";
|
|
78
|
-
import {
|
|
78
|
+
import { cloneDeep } from "lodash";
|
|
79
|
+
const { __cms } = require("@jx3box/jx3box-common/data/jx3box.json");
|
|
79
80
|
const API_Root = process.env.NODE_ENV === "production" ? __cms : "/";
|
|
80
81
|
const API = API_Root + "api/cms/upload";
|
|
81
|
-
|
|
82
82
|
const imgtypes = ["jpg", "png", "gif", "bmp", "webp", "jpeg", "JPG", "PNG", "GIF", "BMP", "WEBP", "JPEG"];
|
|
83
83
|
|
|
84
84
|
export default {
|
|
@@ -107,19 +107,22 @@ export default {
|
|
|
107
107
|
// 文件大小限制
|
|
108
108
|
sizeLimit: {
|
|
109
109
|
type: Number,
|
|
110
|
-
default: 30
|
|
110
|
+
default: 30,
|
|
111
111
|
},
|
|
112
112
|
},
|
|
113
113
|
data: function () {
|
|
114
114
|
return {
|
|
115
115
|
API: API,
|
|
116
116
|
dialogVisible: false,
|
|
117
|
-
tip:
|
|
117
|
+
tip:
|
|
118
|
+
this.desc ||
|
|
119
|
+
`一次最多同时上传${this.max}个文件(单个文件不超过${this.sizeLimit}M),格式限常见的图片、文档、数据表及压缩包`,
|
|
118
120
|
btn_txt: this.text || "上传附件",
|
|
119
121
|
|
|
120
122
|
fileList: [],
|
|
121
123
|
selectedCount: 0,
|
|
122
124
|
insertList: "",
|
|
125
|
+
timeStamp: null,
|
|
123
126
|
|
|
124
127
|
// accept: allow_types.accept,
|
|
125
128
|
// sizeLimit: allow_types.sizeLimit,
|
|
@@ -128,12 +131,13 @@ export default {
|
|
|
128
131
|
watch: {
|
|
129
132
|
fileList: {
|
|
130
133
|
deep: true,
|
|
131
|
-
handler: function (
|
|
132
|
-
this
|
|
134
|
+
handler: function (newVal) {
|
|
135
|
+
this.timeStamp = new Date().getTime() + Math.random();
|
|
136
|
+
this.$emit("update", newVal);
|
|
133
137
|
},
|
|
134
138
|
},
|
|
135
|
-
insertList: function (
|
|
136
|
-
this.$emit("htmlUpdate",
|
|
139
|
+
insertList: function (newVal) {
|
|
140
|
+
this.$emit("htmlUpdate", newVal);
|
|
137
141
|
},
|
|
138
142
|
},
|
|
139
143
|
computed: {
|
|
@@ -209,46 +213,52 @@ export default {
|
|
|
209
213
|
}
|
|
210
214
|
},
|
|
211
215
|
select: function (file) {
|
|
216
|
+
this.fileList = this.fileList.map((item) => {
|
|
217
|
+
if (item.uid == file.uid) {
|
|
218
|
+
item.selected = !item.selected;
|
|
219
|
+
}
|
|
220
|
+
return item;
|
|
221
|
+
});
|
|
212
222
|
if (file.status == "success") {
|
|
213
|
-
this.$set(file, "selected", !file.selected);
|
|
214
223
|
file.selected ? this.selectedCount++ : this.selectedCount--;
|
|
215
224
|
}
|
|
216
225
|
},
|
|
217
226
|
buildHTML: function () {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
227
|
+
const list = cloneDeep(this.fileList)
|
|
228
|
+
.filter((item) => item.selected && item.status == "success")
|
|
229
|
+
.map((file) => {
|
|
230
|
+
const html = file.is_img
|
|
231
|
+
? ` <img src="${file.url}" />`
|
|
232
|
+
: `<a target="_blank" href="${file.url}">${file.name}</a>`;
|
|
233
|
+
return html;
|
|
234
|
+
});
|
|
224
235
|
this.insertList = list.join(" \n");
|
|
225
236
|
return this.insertList;
|
|
226
237
|
},
|
|
227
238
|
insert: function () {
|
|
228
239
|
// 关闭窗口
|
|
229
|
-
this.
|
|
240
|
+
this.closeUpload();
|
|
230
241
|
|
|
231
242
|
//为空不执行插入
|
|
232
243
|
if (!this.selectedCount) return;
|
|
233
244
|
|
|
234
245
|
// 传递值
|
|
235
246
|
this.$emit("insert", {
|
|
236
|
-
list: this.fileList,
|
|
247
|
+
list: this.fileList.filter((item) => item.selected && item.status == "success"),
|
|
237
248
|
html: this.buildHTML(),
|
|
238
249
|
});
|
|
239
250
|
|
|
240
|
-
|
|
241
|
-
this.
|
|
242
|
-
},
|
|
243
|
-
resetSelectStatus: function () {
|
|
244
|
-
this.fileList.forEach((file, i) => {
|
|
245
|
-
this.$set(this.fileList[i], "selected", false);
|
|
246
|
-
});
|
|
247
|
-
this.selectedCount = 0;
|
|
251
|
+
//移除所有上传图片
|
|
252
|
+
this.clear();
|
|
248
253
|
},
|
|
254
|
+
|
|
249
255
|
clear: function () {
|
|
250
|
-
this.$refs.
|
|
256
|
+
this.$refs.uploadBox.clearFiles();
|
|
251
257
|
this.fileList = [];
|
|
258
|
+
this.selectedCount = 0;
|
|
259
|
+
},
|
|
260
|
+
closeUpload() {
|
|
261
|
+
this.dialogVisible = false;
|
|
252
262
|
},
|
|
253
263
|
removeFile: function (fileList, uid) {
|
|
254
264
|
fileList.forEach((file, i) => {
|
|
@@ -258,8 +268,6 @@ export default {
|
|
|
258
268
|
});
|
|
259
269
|
},
|
|
260
270
|
},
|
|
261
|
-
mounted: function () {},
|
|
262
|
-
components: {},
|
|
263
271
|
};
|
|
264
272
|
</script>
|
|
265
273
|
|
|
@@ -20,18 +20,19 @@
|
|
|
20
20
|
|
|
21
21
|
<script>
|
|
22
22
|
const { getThumbnail } = require("@jx3box/jx3box-common/js/utils.js");
|
|
23
|
-
import Upload from "./Upload.vue";
|
|
23
|
+
import Upload from "./Upload.vue";
|
|
24
24
|
import Sortable from "sortablejs";
|
|
25
25
|
|
|
26
26
|
export default {
|
|
27
27
|
name: "UploadAlum",
|
|
28
|
-
props: ["data"],
|
|
28
|
+
props: ["data"],
|
|
29
29
|
data: function () {
|
|
30
30
|
return {
|
|
31
31
|
imgList: this.data || [],
|
|
32
32
|
dialogImageUrl: "",
|
|
33
33
|
dialogVisible: false,
|
|
34
34
|
timeStamp: new Date().getTime() + Math.random(),
|
|
35
|
+
sortable: null,
|
|
35
36
|
};
|
|
36
37
|
},
|
|
37
38
|
model: {
|
|
@@ -84,8 +85,8 @@ export default {
|
|
|
84
85
|
this.imgList.splice(i, 1);
|
|
85
86
|
},
|
|
86
87
|
sort() {
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
let el = document.getElementById("uploadAlbum");
|
|
89
|
+
this.sortable = Sortable.create(el);
|
|
89
90
|
},
|
|
90
91
|
showThumbnail(val) {
|
|
91
92
|
return getThumbnail(val, 146);
|
|
@@ -122,7 +123,7 @@ export default {
|
|
|
122
123
|
}
|
|
123
124
|
.m-album {
|
|
124
125
|
.flex;
|
|
125
|
-
gap:10px;
|
|
126
|
+
gap: 10px;
|
|
126
127
|
.u-album-item {
|
|
127
128
|
.pr;
|
|
128
129
|
.size(@h);
|