@jx3box/jx3box-editor 0.9.4 → 0.9.9
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/markdown.less +27 -7
- package/assets/css/tinymce.less +16 -15
- package/docs/markdown.md +16 -0
- package/package.json +3 -3
- package/src/Markdown.vue +78 -29
- package/src/Resource.vue +7 -2
- package/src/Tinymce.vue +10 -2
- package/src/Upload.vue +38 -51
- package/src/components/article/render_markdown.vue +0 -0
- package/src/components/article/render_tinymce.vue +0 -0
package/assets/css/markdown.less
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
|
-
.c-
|
|
1
|
+
.c-editor-header {
|
|
2
|
+
.mb(10px);
|
|
3
|
+
.clearfix;
|
|
4
|
+
|
|
5
|
+
.c-upload,
|
|
6
|
+
.c-resource {
|
|
7
|
+
.fl;
|
|
8
|
+
}
|
|
9
|
+
.c-upload {
|
|
10
|
+
.mr(5px);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.c-markdown{
|
|
15
|
+
.h(780px);
|
|
16
|
+
.v-note-wrapper{
|
|
17
|
+
.h(780px);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.c-markdown-toolbar-item {
|
|
2
22
|
.mr(5px);
|
|
3
23
|
.pointer;
|
|
4
24
|
padding: 2px 5px 3px 5px;
|
|
5
25
|
|
|
6
|
-
&:hover{
|
|
26
|
+
&:hover {
|
|
7
27
|
background: #e9e9eb;
|
|
8
28
|
.r(4px);
|
|
9
29
|
}
|
|
10
30
|
}
|
|
11
|
-
.c-markdown-store-item{
|
|
31
|
+
.c-markdown-store-item {
|
|
12
32
|
.none;
|
|
13
33
|
}
|
|
14
34
|
|
|
15
|
-
.c-markdown{
|
|
16
|
-
.markdown-body .hljs{
|
|
17
|
-
background-color
|
|
35
|
+
.c-markdown {
|
|
36
|
+
.markdown-body .hljs {
|
|
37
|
+
background-color: #f6f8fa;
|
|
18
38
|
}
|
|
19
|
-
}
|
|
39
|
+
}
|
package/assets/css/tinymce.less
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
.c-editor-
|
|
2
|
-
|
|
3
|
-
.
|
|
4
|
-
.mb(10px);
|
|
5
|
-
.clearfix;
|
|
1
|
+
.c-editor-header{
|
|
2
|
+
.mb(10px);
|
|
3
|
+
.clearfix;
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
.c-upload{
|
|
11
|
-
.mr(5px);
|
|
12
|
-
}
|
|
5
|
+
.c-upload,.c-resource{
|
|
6
|
+
.fl;
|
|
13
7
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
max-height: 168px;
|
|
17
|
-
overflow: auto;
|
|
8
|
+
.c-upload{
|
|
9
|
+
.mr(5px);
|
|
18
10
|
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.c-editor-emotion{
|
|
14
|
+
max-height: 168px;
|
|
15
|
+
overflow: auto;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.c-editor-tinymce {
|
|
19
|
+
|
|
19
20
|
|
|
20
21
|
.u-tutorial {
|
|
21
22
|
padding:0 10px;
|
package/docs/markdown.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
## Markdown
|
|
2
|
+
|
|
3
|
+
这组件真是垃圾,有时间我一定自己重写一个。。。
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## main.js引入
|
|
7
|
+
```javascript
|
|
8
|
+
import mavonEditor from "@jx3box/markdown";
|
|
9
|
+
import "@jx3box/markdown/dist/css/index.css";
|
|
10
|
+
Vue.use(mavonEditor)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 封装模块引入
|
|
14
|
+
```javascript
|
|
15
|
+
import Markdown from '@jx3box/jx3box-editor/src/Markdown.vue'
|
|
16
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jx3box/jx3box-editor",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.9",
|
|
4
4
|
"description": "JX3BOX Article & Editor",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"build": "vue-cli-service build",
|
|
10
10
|
"lint": "vue-cli-service lint",
|
|
11
11
|
"inspect": "vue inspect > output.js",
|
|
12
|
-
"update": "npm --registry https://registry.npmjs.org install @jx3box/jx3box-common@latest @jx3box/jx3box-macro@latest @jx3box/jx3box-talent@latest @jx3box/jx3box-emotion@latest @jx3box/jx3box-data@latest",
|
|
12
|
+
"update": "npm --registry https://registry.npmjs.org install @jx3box/jx3box-common@latest @jx3box/jx3box-macro@latest @jx3box/jx3box-talent@latest @jx3box/jx3box-emotion@latest @jx3box/jx3box-data@latest @jx3box/markdown@latest",
|
|
13
13
|
"article": "vue-cli-service build --target lib --name jx3box_article src/Article.vue --mode production",
|
|
14
14
|
"tinymce": "vue-cli-service build --target lib --name tinymce src/Tinymce.vue && cp public/tinymce.html dist/tinymce.html"
|
|
15
15
|
},
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@jx3box/jx3box-emotion": "^1.0.10",
|
|
37
37
|
"@jx3box/jx3box-macro": "^1.0.1",
|
|
38
38
|
"@jx3box/jx3box-talent": "^1.1.2",
|
|
39
|
-
"@jx3box/markdown": "0.0.
|
|
39
|
+
"@jx3box/markdown": "0.0.8",
|
|
40
40
|
"@tinymce/tinymce-vue": "^3.2.2",
|
|
41
41
|
"axios": "^0.19.2",
|
|
42
42
|
"core-js": "^3.6.5",
|
package/src/Markdown.vue
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="c-markdown">
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
|
|
2
|
+
<div class="c-editor-markdown">
|
|
3
|
+
|
|
4
|
+
<slot name="prepend"></slot>
|
|
5
|
+
|
|
6
|
+
<div class="c-editor-header">
|
|
7
|
+
<Upload v-if="attachmentEnable" @insert="insertAttachments" :enable="true" />
|
|
8
|
+
<Resource v-if="resourceEnable" @insert="insertResource" :enable="false" />
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<slot></slot>
|
|
12
|
+
|
|
13
|
+
<mavon-editor class="c-markdown" ref="md" v-model="data" :editable="editable" :navigation="false" @change="updateData" :subfield="false" :readOnly="readOnly">
|
|
6
14
|
<template slot="left-toolbar-after">
|
|
7
15
|
<span class="c-markdown-toolbar-image c-markdown-toolbar-item" title="上传图片" @click="selectImages"><i class="el-icon-picture-outline-round"></i></span>
|
|
8
16
|
<span class="c-markdown-toolbar-file c-markdown-toolbar-item" title="上传附件" @click="selectFiles"><i class="el-icon-paperclip"></i></span>
|
|
9
17
|
</template>
|
|
10
18
|
</mavon-editor>
|
|
19
|
+
<input class="c-markdown-store-item" id="c-markdown-store-images" type="file" @change="uploadImages" ref="markdownImages" multiple :accept="allow_image_types" />
|
|
20
|
+
<input class="c-markdown-store-item" id="c-markdown-store-files" type="file" @change="uploadFiles" ref="markdownFiles" multiple />
|
|
21
|
+
|
|
22
|
+
<slot name="append"></slot>
|
|
11
23
|
</div>
|
|
12
24
|
</template>
|
|
13
25
|
|
|
14
26
|
<script>
|
|
27
|
+
import Upload from "./Upload";
|
|
28
|
+
import Resource from "./Resource";
|
|
15
29
|
import { uploadFile } from "../service/cms";
|
|
16
30
|
export default {
|
|
17
31
|
name: "Markdown",
|
|
@@ -23,8 +37,23 @@ export default {
|
|
|
23
37
|
type: Boolean,
|
|
24
38
|
default: true,
|
|
25
39
|
},
|
|
40
|
+
attachmentEnable: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true,
|
|
43
|
+
},
|
|
44
|
+
resourceEnable: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: true,
|
|
47
|
+
},
|
|
48
|
+
readOnly : {
|
|
49
|
+
type : Boolean,
|
|
50
|
+
default : false,
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
components: {
|
|
54
|
+
Upload,
|
|
55
|
+
Resource,
|
|
26
56
|
},
|
|
27
|
-
components: {},
|
|
28
57
|
data: function() {
|
|
29
58
|
return {
|
|
30
59
|
data: this.content,
|
|
@@ -52,24 +81,13 @@ export default {
|
|
|
52
81
|
},
|
|
53
82
|
},
|
|
54
83
|
computed: {
|
|
55
|
-
// 将fileList类数组转为标准数组
|
|
56
|
-
// images_list: function() {
|
|
57
|
-
// let images = Array.from(this.images);
|
|
58
|
-
// let _images = [];
|
|
59
|
-
// for (let item of images) {
|
|
60
|
-
// if (this.allow_image_types.includes(item.type)) {
|
|
61
|
-
// _images.push(item);
|
|
62
|
-
// }
|
|
63
|
-
// }
|
|
64
|
-
// return _images;
|
|
65
|
-
// },
|
|
66
84
|
files_list: function() {
|
|
67
85
|
let files = Array.from(this.files);
|
|
68
86
|
return files;
|
|
69
87
|
},
|
|
70
|
-
$md
|
|
71
|
-
return this.$refs.md
|
|
72
|
-
}
|
|
88
|
+
$md: function() {
|
|
89
|
+
return this.$refs.md;
|
|
90
|
+
},
|
|
73
91
|
},
|
|
74
92
|
methods: {
|
|
75
93
|
// 点击上传按钮
|
|
@@ -108,12 +126,12 @@ export default {
|
|
|
108
126
|
this.resolved_files.push({
|
|
109
127
|
url: url,
|
|
110
128
|
filename: list[i]["name"],
|
|
111
|
-
type
|
|
112
|
-
ext
|
|
129
|
+
type: list[i]["type"],
|
|
130
|
+
ext: list[i]["name"].split(".").pop(),
|
|
113
131
|
});
|
|
114
132
|
}
|
|
115
133
|
});
|
|
116
|
-
this.insertFiles()
|
|
134
|
+
this.insertFiles();
|
|
117
135
|
})
|
|
118
136
|
.finally(() => {
|
|
119
137
|
// 上传完成后清空input
|
|
@@ -123,17 +141,17 @@ export default {
|
|
|
123
141
|
});
|
|
124
142
|
},
|
|
125
143
|
// 插入正文
|
|
126
|
-
insertFiles
|
|
127
|
-
for(let item of this.resolved_files){
|
|
144
|
+
insertFiles: function() {
|
|
145
|
+
for (let item of this.resolved_files) {
|
|
128
146
|
// 插入图片
|
|
129
|
-
if(this.image_ext.includes(item.ext)){
|
|
147
|
+
if (this.image_ext.includes(item.ext)) {
|
|
130
148
|
this.$md.insertText(this.$md.getTextareaDom(), {
|
|
131
149
|
prefix: ``,
|
|
132
150
|
subfix: "",
|
|
133
151
|
str: "",
|
|
134
152
|
});
|
|
135
|
-
|
|
136
|
-
}else{
|
|
153
|
+
// 插入文字链接
|
|
154
|
+
} else {
|
|
137
155
|
this.$md.insertText(this.$md.getTextareaDom(), {
|
|
138
156
|
prefix: `[${item.filename}](${item.url})`,
|
|
139
157
|
subfix: "",
|
|
@@ -141,8 +159,39 @@ export default {
|
|
|
141
159
|
});
|
|
142
160
|
}
|
|
143
161
|
}
|
|
144
|
-
}
|
|
145
|
-
|
|
162
|
+
},
|
|
163
|
+
// 更新触发
|
|
164
|
+
updateData: function(data, render) {
|
|
165
|
+
this.$emit("updateData", {
|
|
166
|
+
data,
|
|
167
|
+
render,
|
|
168
|
+
});
|
|
169
|
+
},
|
|
170
|
+
// 插入附件
|
|
171
|
+
insertAttachments: function(data) {
|
|
172
|
+
let list = data?.list || []
|
|
173
|
+
for(let item of list){
|
|
174
|
+
// 插入图片
|
|
175
|
+
if (item.is_img) {
|
|
176
|
+
this.$md.insertText(this.$md.getTextareaDom(), {
|
|
177
|
+
prefix: ``,
|
|
178
|
+
subfix: "",
|
|
179
|
+
str: "",
|
|
180
|
+
});
|
|
181
|
+
// 插入文字链接
|
|
182
|
+
} else {
|
|
183
|
+
this.$md.insertText(this.$md.getTextareaDom(), {
|
|
184
|
+
prefix: `[${item.name}](${item.url})`,
|
|
185
|
+
subfix: "",
|
|
186
|
+
str: "",
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
insertResource: function(data) {
|
|
192
|
+
// TODO:
|
|
193
|
+
// tinyMCE.editors["tinymce"].insertContent(data);
|
|
194
|
+
},
|
|
146
195
|
},
|
|
147
196
|
filters: {},
|
|
148
197
|
created: function() {},
|
package/src/Resource.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="c-resource">
|
|
3
3
|
<!-- 上传触发按钮 -->
|
|
4
|
-
<el-button class="u-switch" type="primary" @click="dialogVisible = true">
|
|
4
|
+
<el-button class="u-switch" type="primary" @click="dialogVisible = true" :disabled="!enable">
|
|
5
5
|
<img class="u-icon" svg-inline src="../assets/img/jx3.svg" />剑三资源
|
|
6
6
|
</el-button>
|
|
7
7
|
|
|
@@ -268,7 +268,12 @@ import User from "@jx3box/jx3box-common/js/user";
|
|
|
268
268
|
import { iconLink } from "@jx3box/jx3box-common/js/utils";
|
|
269
269
|
export default {
|
|
270
270
|
name: "Resource",
|
|
271
|
-
props:
|
|
271
|
+
props: {
|
|
272
|
+
enable : {
|
|
273
|
+
type: Boolean,
|
|
274
|
+
default : true,
|
|
275
|
+
}
|
|
276
|
+
},
|
|
272
277
|
data: function () {
|
|
273
278
|
return {
|
|
274
279
|
dialogVisible: false,
|
package/src/Tinymce.vue
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="c-editor-tinymce">
|
|
3
|
+
|
|
4
|
+
<slot name="prepend"></slot>
|
|
5
|
+
|
|
3
6
|
<div class="c-editor-header">
|
|
4
7
|
<Upload v-if="attachmentEnable" @insert="insertAttachments" />
|
|
5
8
|
<Resource v-if="resourceEnable" @insert="insertResource" />
|
|
6
|
-
<slot></slot>
|
|
7
9
|
</div>
|
|
8
10
|
<Emotion class="c-editor-emotion" @selected="emotionSelected"></Emotion>
|
|
11
|
+
|
|
12
|
+
<slot></slot>
|
|
13
|
+
|
|
9
14
|
<editor
|
|
10
15
|
id="tinymce"
|
|
11
16
|
v-model="data"
|
|
@@ -22,6 +27,8 @@
|
|
|
22
27
|
>[编辑器使用指南]</a
|
|
23
28
|
>
|
|
24
29
|
</el-alert>
|
|
30
|
+
|
|
31
|
+
<slot name="append"></slot>
|
|
25
32
|
</div>
|
|
26
33
|
</template>
|
|
27
34
|
|
|
@@ -157,6 +164,7 @@ export default {
|
|
|
157
164
|
// },
|
|
158
165
|
// ],
|
|
159
166
|
},
|
|
167
|
+
mode : 'tinymce'
|
|
160
168
|
};
|
|
161
169
|
},
|
|
162
170
|
model: {
|
|
@@ -188,7 +196,7 @@ export default {
|
|
|
188
196
|
const pathKey = key.slice(1);
|
|
189
197
|
const IMAGE = `<img class="t-emotion" src="${__ossRoot}image/emotion/${pathKey}.gif" alt="${key}" />`
|
|
190
198
|
tinyMCE.editors["tinymce"].insertContent(IMAGE)
|
|
191
|
-
}
|
|
199
|
+
},
|
|
192
200
|
},
|
|
193
201
|
mounted: function() {},
|
|
194
202
|
components: {
|
package/src/Upload.vue
CHANGED
|
@@ -1,35 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="c-upload">
|
|
3
3
|
<!-- 上传触发按钮 -->
|
|
4
|
-
<el-button type="primary" @click="dialogVisible = true" icon="el-icon-upload">{{btn_txt}}</el-button>
|
|
4
|
+
<el-button type="primary" @click="dialogVisible = true" icon="el-icon-upload" :disabled="!enable">{{ btn_txt }}</el-button>
|
|
5
5
|
|
|
6
6
|
<!-- 弹出界面 -->
|
|
7
7
|
<el-dialog class="c-large-dialog" title="上传" :visible.sync="dialogVisible">
|
|
8
8
|
<!-- 清空按钮 -->
|
|
9
|
-
<el-button
|
|
10
|
-
class="u-upload-clear"
|
|
11
|
-
plain
|
|
12
|
-
icon="el-icon-delete"
|
|
13
|
-
size="mini"
|
|
14
|
-
@click="clear"
|
|
15
|
-
>清空</el-button>
|
|
9
|
+
<el-button class="u-upload-clear" plain icon="el-icon-delete" size="mini" @click="clear">清空</el-button>
|
|
16
10
|
|
|
17
11
|
<!-- 限制提示 -->
|
|
18
12
|
<el-alert class="u-upload-tip" :title="tip" type="info" show-icon :closable="false"></el-alert>
|
|
19
13
|
|
|
20
14
|
<!-- 文件区 -->
|
|
21
|
-
<el-upload
|
|
22
|
-
:action="API"
|
|
23
|
-
list-type="picture-card"
|
|
24
|
-
:auto-upload="false"
|
|
25
|
-
:limit="10"
|
|
26
|
-
multiple
|
|
27
|
-
with-credentials
|
|
28
|
-
:file-list="fileList"
|
|
29
|
-
:on-change="change"
|
|
30
|
-
ref="uploadbox"
|
|
31
|
-
:accept="accept"
|
|
32
|
-
>
|
|
15
|
+
<el-upload :action="API" list-type="picture-card" :auto-upload="false" :limit="10" multiple with-credentials :file-list="fileList" :on-change="change" ref="uploadbox" :accept="accept">
|
|
33
16
|
<!-- :accept="accept" -->
|
|
34
17
|
<i slot="default" class="el-icon-plus"></i>
|
|
35
18
|
|
|
@@ -45,12 +28,7 @@
|
|
|
45
28
|
}"
|
|
46
29
|
>
|
|
47
30
|
<!-- 图片类型 -->
|
|
48
|
-
<img
|
|
49
|
-
v-if="file.is_img"
|
|
50
|
-
class="el-upload-list__item-thumbnail u-imgbox"
|
|
51
|
-
:src="file.url"
|
|
52
|
-
alt
|
|
53
|
-
/>
|
|
31
|
+
<img v-if="file.is_img" class="el-upload-list__item-thumbnail u-imgbox" :src="file.url" alt />
|
|
54
32
|
<!-- 其他类型 -->
|
|
55
33
|
<div v-else class="u-filebox">
|
|
56
34
|
<img class="u-fileplaceholder" svg-inline src="../assets/img/file.svg" />
|
|
@@ -67,9 +45,7 @@
|
|
|
67
45
|
<span slot="footer" class="dialog-footer">
|
|
68
46
|
<el-button @click="dialogVisible = false">取 消</el-button>
|
|
69
47
|
<el-button type="primary" @click="insert">
|
|
70
|
-
{{
|
|
71
|
-
buttonTXT
|
|
72
|
-
}}
|
|
48
|
+
{{ buttonTXT }}
|
|
73
49
|
</el-button>
|
|
74
50
|
</span>
|
|
75
51
|
</el-dialog>
|
|
@@ -87,8 +63,25 @@ const imgtypes = ["jpg", "png", "gif", "bmp", "webp"];
|
|
|
87
63
|
|
|
88
64
|
export default {
|
|
89
65
|
name: "Upload",
|
|
90
|
-
props:
|
|
91
|
-
|
|
66
|
+
props: {
|
|
67
|
+
text: {
|
|
68
|
+
type: String,
|
|
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
|
+
}
|
|
83
|
+
},
|
|
84
|
+
data: function() {
|
|
92
85
|
return {
|
|
93
86
|
API: API,
|
|
94
87
|
dialogVisible: false,
|
|
@@ -106,21 +99,21 @@ export default {
|
|
|
106
99
|
watch: {
|
|
107
100
|
fileList: {
|
|
108
101
|
deep: true,
|
|
109
|
-
handler: function
|
|
102
|
+
handler: function(newval) {
|
|
110
103
|
this.$emit("update", newval);
|
|
111
104
|
},
|
|
112
105
|
},
|
|
113
|
-
insertList: function
|
|
106
|
+
insertList: function(newval) {
|
|
114
107
|
this.$emit("htmlUpdate", newval);
|
|
115
108
|
},
|
|
116
109
|
},
|
|
117
110
|
computed: {
|
|
118
|
-
buttonTXT: function
|
|
111
|
+
buttonTXT: function() {
|
|
119
112
|
return this.selectedCount ? "插 入" : "确 定";
|
|
120
113
|
},
|
|
121
114
|
},
|
|
122
115
|
methods: {
|
|
123
|
-
change: function
|
|
116
|
+
change: function(file, fileList) {
|
|
124
117
|
if (file.status != "success") {
|
|
125
118
|
// 判断大小
|
|
126
119
|
// if (file.size > this.sizeLimit) {
|
|
@@ -133,7 +126,7 @@ export default {
|
|
|
133
126
|
let ext = file.name.split(".").pop();
|
|
134
127
|
let is_img = imgtypes.includes(ext);
|
|
135
128
|
|
|
136
|
-
if(this.onlyImage && !is_img) return
|
|
129
|
+
if (this.onlyImage && !is_img) return;
|
|
137
130
|
|
|
138
131
|
// 构建数据
|
|
139
132
|
let fdata = new FormData();
|
|
@@ -166,36 +159,30 @@ export default {
|
|
|
166
159
|
})
|
|
167
160
|
.catch((err) => {
|
|
168
161
|
if (err.response.data.code) {
|
|
169
|
-
this.$message.error(
|
|
170
|
-
`[${err.response.data.code}] ${err.response.data.message}`
|
|
171
|
-
);
|
|
162
|
+
this.$message.error(`[${err.response.data.code}] ${err.response.data.message}`);
|
|
172
163
|
} else {
|
|
173
164
|
this.$message.error("请求异常");
|
|
174
165
|
}
|
|
175
166
|
});
|
|
176
167
|
}
|
|
177
168
|
},
|
|
178
|
-
select: function
|
|
169
|
+
select: function(file) {
|
|
179
170
|
if (file.status == "success") {
|
|
180
171
|
this.$set(file, "selected", !file.selected);
|
|
181
172
|
file.selected ? this.selectedCount++ : this.selectedCount--;
|
|
182
173
|
}
|
|
183
174
|
},
|
|
184
|
-
buildHTML: function
|
|
175
|
+
buildHTML: function() {
|
|
185
176
|
let list = [];
|
|
186
177
|
this.fileList.forEach((file) => {
|
|
187
178
|
if (file.selected) {
|
|
188
|
-
file.is_img
|
|
189
|
-
? list.push(`<img src="${file.url}" />`)
|
|
190
|
-
: list.push(
|
|
191
|
-
`<a target="_blank" href="${file.url}">${file.name}</a>`
|
|
192
|
-
);
|
|
179
|
+
file.is_img ? list.push(`<img src="${file.url}" />`) : list.push(`<a target="_blank" href="${file.url}">${file.name}</a>`);
|
|
193
180
|
}
|
|
194
181
|
});
|
|
195
182
|
this.insertList = list.join(" \n");
|
|
196
183
|
return this.insertList;
|
|
197
184
|
},
|
|
198
|
-
insert: function
|
|
185
|
+
insert: function() {
|
|
199
186
|
// 关闭窗口
|
|
200
187
|
this.dialogVisible = false;
|
|
201
188
|
|
|
@@ -211,17 +198,17 @@ export default {
|
|
|
211
198
|
//移除所有选择状态
|
|
212
199
|
this.resetSelectStatus();
|
|
213
200
|
},
|
|
214
|
-
resetSelectStatus: function
|
|
201
|
+
resetSelectStatus: function() {
|
|
215
202
|
this.fileList.forEach((file, i) => {
|
|
216
203
|
this.$set(this.fileList[i], "selected", false);
|
|
217
204
|
});
|
|
218
205
|
this.selectedCount = 0;
|
|
219
206
|
},
|
|
220
|
-
clear: function
|
|
207
|
+
clear: function() {
|
|
221
208
|
this.$refs.uploadbox.clearFiles();
|
|
222
209
|
this.fileList = [];
|
|
223
210
|
},
|
|
224
|
-
removeFile: function
|
|
211
|
+
removeFile: function(fileList, uid) {
|
|
225
212
|
fileList.forEach((file, i) => {
|
|
226
213
|
if (file.uid == uid) {
|
|
227
214
|
fileList.splice(i, 1);
|
|
@@ -229,7 +216,7 @@ export default {
|
|
|
229
216
|
});
|
|
230
217
|
},
|
|
231
218
|
},
|
|
232
|
-
mounted: function
|
|
219
|
+
mounted: function() {},
|
|
233
220
|
components: {},
|
|
234
221
|
};
|
|
235
222
|
</script>
|
|
File without changes
|
|
File without changes
|