@jx3box/jx3box-editor 1.3.8 → 1.4.1
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/assets/css/tinymce/a.less +5 -5
- package/package.json +1 -1
- package/src/BoxResource.vue +10 -7
- package/src/Upload.vue +167 -167
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.e-jx3-author{
|
|
12
|
-
padding: 2px 5px;
|
|
13
|
-
border-radius: 3px;
|
|
14
|
-
border: 1px solid #8250df;
|
|
12
|
+
// padding: 2px 5px;
|
|
13
|
+
// border-radius: 3px;
|
|
14
|
+
// border: 1px solid #8250df;
|
|
15
15
|
color:#8250df;
|
|
16
16
|
|
|
17
17
|
&:hover{
|
|
18
|
-
box-shadow:
|
|
19
|
-
background-color: #fafbfc;
|
|
18
|
+
box-shadow: 0 1px 0 #8250df;
|
|
19
|
+
// background-color: #fafbfc;
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
package/package.json
CHANGED
package/src/BoxResource.vue
CHANGED
|
@@ -86,12 +86,11 @@
|
|
|
86
86
|
</template>
|
|
87
87
|
|
|
88
88
|
<script>
|
|
89
|
-
import {
|
|
89
|
+
import { loadStat, } from "../service/database";
|
|
90
90
|
import { loadAuthors, loadEmotions } from "../service/cms";
|
|
91
91
|
import { getUserInfo } from "../service/author";
|
|
92
92
|
import { __iconPath, __Root, __OriginRoot, __imgPath } from "@jx3box/jx3box-common/data/jx3box.json";
|
|
93
|
-
import
|
|
94
|
-
import { iconLink, getLink, showAvatar } from "@jx3box/jx3box-common/js/utils";
|
|
93
|
+
import { getLink, showAvatar } from "@jx3box/jx3box-common/js/utils";
|
|
95
94
|
import User from "@jx3box/jx3box-common/js/user";
|
|
96
95
|
export default {
|
|
97
96
|
name: "Resource",
|
|
@@ -271,10 +270,14 @@ export default {
|
|
|
271
270
|
insert: function() {
|
|
272
271
|
if (this.type === 'authors') {
|
|
273
272
|
if (this.userStatus == 0 && this.canInsertAuthor) {
|
|
274
|
-
this.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
273
|
+
if (this.selectedAuthor.ID) {
|
|
274
|
+
this.setAuthors();
|
|
275
|
+
this.$emit("insert", this.html);
|
|
276
|
+
this.dialogVisible = false;
|
|
277
|
+
this.selectedAuthor = {};
|
|
278
|
+
} else {
|
|
279
|
+
this.$message.warning("请选择一个用户");
|
|
280
|
+
}
|
|
278
281
|
} else {
|
|
279
282
|
this.$alert('您的等级不足或无权限(Lv2以上可用)', '消息');
|
|
280
283
|
}
|
package/src/Upload.vue
CHANGED
|
@@ -53,187 +53,187 @@
|
|
|
53
53
|
</template>
|
|
54
54
|
|
|
55
55
|
<script>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
onlyImage: {
|
|
71
|
-
type: Boolean,
|
|
72
|
-
},
|
|
73
|
-
desc: {
|
|
74
|
-
type: String,
|
|
75
|
-
},
|
|
76
|
-
accept: {
|
|
77
|
-
type: String,
|
|
78
|
-
},
|
|
79
|
-
enable: {
|
|
80
|
-
type: Boolean,
|
|
81
|
-
default: true,
|
|
82
|
-
},
|
|
56
|
+
import axios from "axios";
|
|
57
|
+
import { __cms } from "@jx3box/jx3box-common/data/jx3box.json";
|
|
58
|
+
const API_Root = process.env.NODE_ENV === "production" ? __cms : "/";
|
|
59
|
+
const API = API_Root + "api/cms/upload";
|
|
60
|
+
|
|
61
|
+
import allow_types from "@jx3box/jx3box-common/data/conf";
|
|
62
|
+
const imgtypes = ["jpg", "png", "gif", "bmp", "webp", "jpeg"];
|
|
63
|
+
|
|
64
|
+
export default {
|
|
65
|
+
name: "Upload",
|
|
66
|
+
props: {
|
|
67
|
+
text: {
|
|
68
|
+
type: String,
|
|
83
69
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
API: API,
|
|
87
|
-
dialogVisible: false,
|
|
88
|
-
tip: this.desc || "一次最多同时上传10个文件(不超过5M),格式限常见的图片、文档、数据表及压缩包",
|
|
89
|
-
btn_txt: this.text || "上传附件",
|
|
90
|
-
|
|
91
|
-
fileList: [],
|
|
92
|
-
selectedCount: 0,
|
|
93
|
-
insertList: "",
|
|
94
|
-
|
|
95
|
-
// accept: allow_types.accept,
|
|
96
|
-
// sizeLimit: allow_types.sizeLimit,
|
|
97
|
-
};
|
|
70
|
+
onlyImage: {
|
|
71
|
+
type: Boolean,
|
|
98
72
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
deep: true,
|
|
102
|
-
handler: function(newval) {
|
|
103
|
-
this.$emit("update", newval);
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
insertList: function(newval) {
|
|
107
|
-
this.$emit("htmlUpdate", newval);
|
|
108
|
-
},
|
|
73
|
+
desc: {
|
|
74
|
+
type: String,
|
|
109
75
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
76
|
+
accept: {
|
|
77
|
+
type: String,
|
|
78
|
+
},
|
|
79
|
+
enable: {
|
|
80
|
+
type: Boolean,
|
|
81
|
+
default: true,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
data: function () {
|
|
85
|
+
return {
|
|
86
|
+
API: API,
|
|
87
|
+
dialogVisible: false,
|
|
88
|
+
tip: this.desc || "一次最多同时上传10个文件(不超过5M),格式限常见的图片、文档、数据表及压缩包",
|
|
89
|
+
btn_txt: this.text || "上传附件",
|
|
90
|
+
|
|
91
|
+
fileList: [],
|
|
92
|
+
selectedCount: 0,
|
|
93
|
+
insertList: "",
|
|
94
|
+
|
|
95
|
+
// accept: allow_types.accept,
|
|
96
|
+
// sizeLimit: allow_types.sizeLimit,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
watch: {
|
|
100
|
+
fileList: {
|
|
101
|
+
deep: true,
|
|
102
|
+
handler: function (newval) {
|
|
103
|
+
this.$emit("update", newval);
|
|
113
104
|
},
|
|
114
105
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
106
|
+
insertList: function (newval) {
|
|
107
|
+
this.$emit("htmlUpdate", newval);
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
computed: {
|
|
111
|
+
buttonTXT: function () {
|
|
112
|
+
return this.selectedCount ? "插 入" : "确 定";
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
methods: {
|
|
116
|
+
change: function (file, fileList) {
|
|
117
|
+
if (file.status != "success") {
|
|
118
|
+
// 判断大小
|
|
119
|
+
// if (file.size > this.sizeLimit) {
|
|
120
|
+
// this.$message.error("文件超出大小限制");
|
|
121
|
+
// this.removeFile(fileList, file.uid);
|
|
122
|
+
// return;
|
|
123
|
+
// }
|
|
124
|
+
|
|
125
|
+
// 分析文件类型
|
|
126
|
+
let ext = file.name.split(".").pop();
|
|
127
|
+
let is_img = imgtypes.includes(ext);
|
|
128
|
+
|
|
129
|
+
if (this.onlyImage && !is_img) return;
|
|
130
|
+
|
|
131
|
+
// 构建数据
|
|
132
|
+
let fdata = new FormData();
|
|
133
|
+
fdata.append("file", file.raw);
|
|
134
|
+
|
|
135
|
+
// 异步上传
|
|
136
|
+
axios
|
|
137
|
+
.post(API, fdata, {
|
|
138
|
+
headers: {
|
|
139
|
+
"Content-Type": "multipart/form-data",
|
|
140
|
+
},
|
|
141
|
+
withCredentials: true,
|
|
142
|
+
auth: {
|
|
143
|
+
username: (localStorage && localStorage.getItem("token")) || "",
|
|
144
|
+
password: "cms common request",
|
|
145
|
+
},
|
|
146
|
+
})
|
|
147
|
+
.then((res) => {
|
|
148
|
+
if (res.data.code) {
|
|
156
149
|
this.$message({
|
|
157
|
-
message:
|
|
158
|
-
type: "
|
|
150
|
+
message: res.data.msg,
|
|
151
|
+
type: "error",
|
|
159
152
|
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
file.selected = true;
|
|
167
|
-
|
|
168
|
-
// 修改状态加入仓库
|
|
169
|
-
file.status = "success";
|
|
170
|
-
this.fileList.push(file);
|
|
171
|
-
this.selectedCount++;
|
|
172
|
-
})
|
|
173
|
-
.catch((err) => {
|
|
174
|
-
if (err.response.data.code) {
|
|
175
|
-
this.$message.error(`[${err.response.data.code}] ${err.response.data.message}`);
|
|
176
|
-
} else {
|
|
177
|
-
this.$message.error("请求异常");
|
|
178
|
-
}
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// 提醒
|
|
156
|
+
this.$message({
|
|
157
|
+
message: "上传成功",
|
|
158
|
+
type: "success",
|
|
179
159
|
});
|
|
160
|
+
|
|
161
|
+
// 修改path
|
|
162
|
+
file.url = res.data.data && res.data.data[0];
|
|
163
|
+
|
|
164
|
+
// 额外赋值
|
|
165
|
+
file.is_img = is_img;
|
|
166
|
+
file.selected = true;
|
|
167
|
+
|
|
168
|
+
// 修改状态加入仓库
|
|
169
|
+
file.status = "success";
|
|
170
|
+
this.fileList.push(file);
|
|
171
|
+
this.selectedCount++;
|
|
172
|
+
})
|
|
173
|
+
.catch((err) => {
|
|
174
|
+
if (err.response.data.code) {
|
|
175
|
+
this.$message.error(`[${err.response.data.code}] ${err.response.data.message}`);
|
|
176
|
+
} else {
|
|
177
|
+
this.$message.error("请求异常");
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
select: function (file) {
|
|
183
|
+
if (file.status == "success") {
|
|
184
|
+
this.$set(file, "selected", !file.selected);
|
|
185
|
+
file.selected ? this.selectedCount++ : this.selectedCount--;
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
buildHTML: function () {
|
|
189
|
+
let list = [];
|
|
190
|
+
this.fileList.forEach((file) => {
|
|
191
|
+
if (file.selected) {
|
|
192
|
+
file.is_img ? list.push(`<img src="${file.url}" />`) : list.push(`<a target="_blank" href="${file.url}">${file.name}</a>`);
|
|
180
193
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
buildHTML: function() {
|
|
189
|
-
let list = [];
|
|
190
|
-
this.fileList.forEach((file) => {
|
|
191
|
-
if (file.selected) {
|
|
192
|
-
file.is_img ? list.push(`<img src="${file.url}" />`) : list.push(`<a target="_blank" href="${file.url}">${file.name}</a>`);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
this.insertList = list.join(" \n");
|
|
196
|
-
return this.insertList;
|
|
197
|
-
},
|
|
198
|
-
insert: function() {
|
|
199
|
-
// 关闭窗口
|
|
200
|
-
this.dialogVisible = false;
|
|
194
|
+
});
|
|
195
|
+
this.insertList = list.join(" \n");
|
|
196
|
+
return this.insertList;
|
|
197
|
+
},
|
|
198
|
+
insert: function () {
|
|
199
|
+
// 关闭窗口
|
|
200
|
+
this.dialogVisible = false;
|
|
201
201
|
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
//为空不执行插入
|
|
203
|
+
if (!this.selectedCount) return;
|
|
204
204
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
// 传递值
|
|
206
|
+
this.$emit("insert", {
|
|
207
|
+
list: this.fileList,
|
|
208
|
+
html: this.buildHTML(),
|
|
209
|
+
});
|
|
210
210
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
},
|
|
211
|
+
//移除所有选择状态
|
|
212
|
+
this.resetSelectStatus();
|
|
213
|
+
},
|
|
214
|
+
resetSelectStatus: function () {
|
|
215
|
+
this.fileList.forEach((file, i) => {
|
|
216
|
+
this.$set(this.fileList[i], "selected", false);
|
|
217
|
+
});
|
|
218
|
+
this.selectedCount = 0;
|
|
219
|
+
},
|
|
220
|
+
clear: function () {
|
|
221
|
+
this.$refs.uploadbox.clearFiles();
|
|
222
|
+
this.fileList = [];
|
|
223
|
+
},
|
|
224
|
+
removeFile: function (fileList, uid) {
|
|
225
|
+
fileList.forEach((file, i) => {
|
|
226
|
+
if (file.uid == uid) {
|
|
227
|
+
fileList.splice(i, 1);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
231
230
|
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
}
|
|
231
|
+
},
|
|
232
|
+
mounted: function () {},
|
|
233
|
+
components: {},
|
|
234
|
+
};
|
|
235
235
|
</script>
|
|
236
236
|
|
|
237
237
|
<style lang="less">
|
|
238
|
-
|
|
238
|
+
@import "../assets/css/upload.less";
|
|
239
239
|
</style>
|