@jx3box/jx3box-ui 2.0.26 → 2.0.28
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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
.c-sidebar-right-msg {
|
|
3
3
|
@aiconh: 22px;
|
|
4
4
|
|
|
5
|
-
border: 1px solid @
|
|
5
|
+
border: 1px solid @v4primary;
|
|
6
6
|
margin: 15px 15px 5px 15px;
|
|
7
7
|
padding: 10px 10px 10px 30px;
|
|
8
8
|
.r(6px);
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
.size(16px);
|
|
16
16
|
svg {
|
|
17
17
|
.size(16px);
|
|
18
|
-
fill: @
|
|
18
|
+
fill: @v4primary;
|
|
19
19
|
}
|
|
20
20
|
.pa;
|
|
21
21
|
.lt(10px, 50%);
|
package/package.json
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
v-model="newComment.content"
|
|
17
17
|
:placeholder="$jx3boxT('jx3boxUi.commentInputForm.placeholder', '参与讨论...')"
|
|
18
18
|
:id="inputId"
|
|
19
|
+
@paste="handlePaste"
|
|
19
20
|
></el-input>
|
|
20
21
|
<div class="c-comment-tools">
|
|
21
22
|
<el-icon class="u-upload-icon" @click="showUploader = !showUploader"><Picture /></el-icon>
|
|
@@ -109,6 +110,7 @@ export default {
|
|
|
109
110
|
attachmentUploadFinish(data) {
|
|
110
111
|
this.$emit("submit", {
|
|
111
112
|
content: this.newComment.content,
|
|
113
|
+
is_secret: this.is_secret ? 1 : 0,
|
|
112
114
|
attachmentList: data,
|
|
113
115
|
});
|
|
114
116
|
this.newComment = {
|
|
@@ -149,6 +151,23 @@ export default {
|
|
|
149
151
|
this.newComment.content = value;
|
|
150
152
|
}
|
|
151
153
|
},
|
|
154
|
+
async handlePaste(event) {
|
|
155
|
+
const clipboardItems = event.clipboardData.items;
|
|
156
|
+
for (let i = 0; i < clipboardItems.length; i++) {
|
|
157
|
+
const item = clipboardItems[i];
|
|
158
|
+
if (item.type.indexOf("image") !== -1) {
|
|
159
|
+
// 阻止默认粘贴图片的名字
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
const blob = item.getAsFile();
|
|
162
|
+
const file = new File([blob], new Date().getTime() + "-" + blob.name, { type: blob.type });
|
|
163
|
+
if (!this.showUploader) this.showUploader = true;
|
|
164
|
+
await this.$nextTick();
|
|
165
|
+
if (this.$refs.uploader) {
|
|
166
|
+
this.$refs.uploader.addFile(file);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
152
171
|
},
|
|
153
172
|
};
|
|
154
173
|
</script>
|
package/src/comment/Upload.vue
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
with-credentials
|
|
14
14
|
:on-exceed="onExceed"
|
|
15
15
|
:on-change="onChange"
|
|
16
|
+
:on-remove="onRemove"
|
|
16
17
|
:on-success="onSuccess"
|
|
17
18
|
:on-error="onError"
|
|
18
19
|
>
|
|
@@ -50,6 +51,7 @@ export default {
|
|
|
50
51
|
dialogVisible: false,
|
|
51
52
|
fileList: [],
|
|
52
53
|
successList: [],
|
|
54
|
+
uploadedMap: {},
|
|
53
55
|
|
|
54
56
|
acceptedExtensions: ["jpg", "jpeg", "png", "gif"],
|
|
55
57
|
maxCount: 5,
|
|
@@ -74,27 +76,49 @@ export default {
|
|
|
74
76
|
});
|
|
75
77
|
},
|
|
76
78
|
onChange(file, fileList) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
79
|
+
this.fileList = fileList;
|
|
80
|
+
if (file.status !== "ready" || !file.raw) return;
|
|
81
|
+
|
|
82
|
+
const ext = (file.name.split(".").pop() || "").toLowerCase();
|
|
83
|
+
if (!this.acceptedExtensions.includes(ext)) {
|
|
84
|
+
this.$notify({
|
|
85
|
+
title: "",
|
|
86
|
+
message: this.$jx3boxT(
|
|
87
|
+
"jx3boxUi.commentUpload.onlyTypes",
|
|
88
|
+
"仅支持 {types} 格式图片!",
|
|
89
|
+
{ types: this.acceptedExtensions.join(" / ").toUpperCase() }
|
|
90
|
+
),
|
|
91
|
+
type: "error",
|
|
92
|
+
duration: 3000,
|
|
93
|
+
position: "bottom-right",
|
|
94
|
+
});
|
|
95
|
+
this.removeFile(file.uid);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (file.size > this.maxSize) {
|
|
100
|
+
this.$notify({
|
|
101
|
+
title: "",
|
|
102
|
+
message: this.$jx3boxT(
|
|
103
|
+
"jx3boxUi.commentUpload.maxSize",
|
|
104
|
+
"单张图片大小不能超过 {size} MB!",
|
|
105
|
+
{
|
|
106
|
+
size: this.maxSize / 1024 / 1024,
|
|
107
|
+
}
|
|
108
|
+
),
|
|
109
|
+
type: "error",
|
|
110
|
+
duration: 3000,
|
|
111
|
+
position: "bottom-right",
|
|
112
|
+
});
|
|
113
|
+
this.removeFile(file.uid);
|
|
114
|
+
return;
|
|
96
115
|
}
|
|
97
116
|
},
|
|
117
|
+
onRemove(file, fileList) {
|
|
118
|
+
this.fileList = fileList;
|
|
119
|
+
if (file?.uid && this.uploadedMap[file.uid]) delete this.uploadedMap[file.uid];
|
|
120
|
+
this.successList = this.fileList.map((f) => this.uploadedMap[f.uid]).filter(Boolean);
|
|
121
|
+
},
|
|
98
122
|
upload() {
|
|
99
123
|
if (this.fileList.length > 0) {
|
|
100
124
|
this.$refs.upload.submit();
|
|
@@ -102,12 +126,19 @@ export default {
|
|
|
102
126
|
this.$emit("onFinish", []);
|
|
103
127
|
}
|
|
104
128
|
},
|
|
105
|
-
onSuccess(response) {
|
|
106
|
-
this.
|
|
129
|
+
onSuccess(response, file, fileList) {
|
|
130
|
+
this.fileList = fileList;
|
|
131
|
+
const url = response?.data?.[0];
|
|
132
|
+
if (url && file?.uid) {
|
|
133
|
+
this.uploadedMap[file.uid] = url;
|
|
134
|
+
file.url = url;
|
|
135
|
+
}
|
|
136
|
+
this.successList = this.fileList.map((f) => this.uploadedMap[f.uid]).filter(Boolean);
|
|
107
137
|
if (this.successList.length == this.fileList.length) {
|
|
108
138
|
this.$emit("onFinish", this.successList || []);
|
|
109
139
|
this.fileList = [];
|
|
110
140
|
this.successList = [];
|
|
141
|
+
this.uploadedMap = {};
|
|
111
142
|
}
|
|
112
143
|
},
|
|
113
144
|
onError() {
|
|
@@ -121,6 +152,16 @@ export default {
|
|
|
121
152
|
this.$emit("onError");
|
|
122
153
|
this.fileList = [];
|
|
123
154
|
},
|
|
155
|
+
addFile(file) {
|
|
156
|
+
if (this.$refs.upload && this.$refs.upload.handleStart) {
|
|
157
|
+
this.$refs.upload.handleStart(file);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
removeFile(uid) {
|
|
161
|
+
this.fileList = this.fileList.filter((item) => item.uid !== uid);
|
|
162
|
+
if (uid && this.uploadedMap[uid]) delete this.uploadedMap[uid];
|
|
163
|
+
this.successList = this.fileList.map((f) => this.uploadedMap[f.uid]).filter(Boolean);
|
|
164
|
+
},
|
|
124
165
|
},
|
|
125
166
|
};
|
|
126
167
|
</script>
|