@jx3box/jx3box-common-ui 5.7.3 → 5.7.4
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/service/cms.js +5 -1
- package/src/App.vue +9 -0
- package/src/upload/upload_banner.vue +138 -0
package/package.json
CHANGED
package/service/cms.js
CHANGED
|
@@ -4,4 +4,8 @@ function getPostAuthors(post_id) {
|
|
|
4
4
|
return $cms({mute:true}).get(`/api/cms/post/${post_id}/authors`);
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function uploadImage(formData){
|
|
8
|
+
return $cms().post(`/api/cms/upload/avatar`, formData);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { getPostAuthors, uploadImage };
|
package/src/App.vue
CHANGED
|
@@ -62,6 +62,9 @@
|
|
|
62
62
|
<tagBy :data="['PVE', 'PVX']" :type="tag" />
|
|
63
63
|
<clientBy type="" />
|
|
64
64
|
<zlpBy />
|
|
65
|
+
|
|
66
|
+
<hr />
|
|
67
|
+
<uploadImage v-model="upload" info="非必选。首页海报尺寸1100*300(推荐2200*600支持高分屏),最大20M。"></uploadImage>
|
|
65
68
|
</el-tab-pane>
|
|
66
69
|
<el-tab-pane label="百科组件" name="wiki"
|
|
67
70
|
><WikiPanel :wiki-post="wikiPost">
|
|
@@ -142,6 +145,8 @@ import tagBy from "./filters/tagBy.vue";
|
|
|
142
145
|
import clientBy from "./filters/clientBy.vue";
|
|
143
146
|
import zlpBy from "./filters/zlpBy.vue";
|
|
144
147
|
|
|
148
|
+
import uploadImage from './upload/upload_banner.vue'
|
|
149
|
+
|
|
145
150
|
import WikiPanel from "./wiki/WikiPanel.vue";
|
|
146
151
|
import WikiRevisions from "./wiki/WikiRevisions.vue";
|
|
147
152
|
import WikiComments from "./wiki/WikiComments.vue";
|
|
@@ -193,6 +198,8 @@ export default {
|
|
|
193
198
|
clientBy,
|
|
194
199
|
zlpBy,
|
|
195
200
|
|
|
201
|
+
uploadImage,
|
|
202
|
+
|
|
196
203
|
WikiPanel,
|
|
197
204
|
WikiRevisions,
|
|
198
205
|
WikiComments,
|
|
@@ -212,6 +219,8 @@ export default {
|
|
|
212
219
|
visible: false,
|
|
213
220
|
|
|
214
221
|
avatar_size : 60,
|
|
222
|
+
|
|
223
|
+
upload: '',
|
|
215
224
|
};
|
|
216
225
|
},
|
|
217
226
|
created: function() {
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="c-upload-banner">
|
|
3
|
+
<el-alert class="u-tip" :title="info" type="info" show-icon></el-alert>
|
|
4
|
+
<div v-if="data" class="u-upload" :style="uploadStyle">
|
|
5
|
+
<img :src="preview" />
|
|
6
|
+
<i class="u-upload-mask"></i>
|
|
7
|
+
<i class="u-upload-delete el-icon-delete" title="移除" @click="remove"></i>
|
|
8
|
+
</div>
|
|
9
|
+
<div v-else class="u-upload el-upload el-upload--picture-card" @click="select">
|
|
10
|
+
<i class="el-icon-plus"></i>
|
|
11
|
+
</div>
|
|
12
|
+
<input class="u-upload-input" type="file" @change="upload" ref="uploadInput" accept=".jpg, .jpeg, .png, .gif, .bmp" />
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
import { getThumbnail } from "@jx3box/jx3box-common/js/utils";
|
|
18
|
+
import { uploadImage } from '../../service/cms.js';
|
|
19
|
+
export default {
|
|
20
|
+
name: 'upload-banner',
|
|
21
|
+
props: {
|
|
22
|
+
content: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: '',
|
|
25
|
+
},
|
|
26
|
+
info: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: '用于展示tips',
|
|
29
|
+
},
|
|
30
|
+
size: {
|
|
31
|
+
type: [Array, Number],
|
|
32
|
+
default: 148,
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
data() {
|
|
36
|
+
return {
|
|
37
|
+
data: this.content || '',
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
model: {
|
|
41
|
+
prop: 'content',
|
|
42
|
+
event: 'input',
|
|
43
|
+
},
|
|
44
|
+
watch: {
|
|
45
|
+
content(val) {
|
|
46
|
+
this.data = val;
|
|
47
|
+
},
|
|
48
|
+
data(val) {
|
|
49
|
+
this.$emit('input', val);
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
computed: {
|
|
53
|
+
fileInput: function () {
|
|
54
|
+
return this.$refs.uploadInput;
|
|
55
|
+
},
|
|
56
|
+
preview() {
|
|
57
|
+
let size = Array.isArray(this.size) ? this.size : [this.size, this.size];
|
|
58
|
+
return getThumbnail(this.data, size, true);
|
|
59
|
+
},
|
|
60
|
+
uploadStyle() {
|
|
61
|
+
let size = Array.isArray(this.size) ? this.size : [this.size, this.size];
|
|
62
|
+
return {
|
|
63
|
+
width: size[0] + 'px',
|
|
64
|
+
height: size[1] + 'px',
|
|
65
|
+
};
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
select() {
|
|
70
|
+
this.fileInput.dispatchEvent(new MouseEvent('click', {
|
|
71
|
+
bubbles: true,
|
|
72
|
+
cancelable: true,
|
|
73
|
+
view: window,
|
|
74
|
+
}));
|
|
75
|
+
},
|
|
76
|
+
upload() {
|
|
77
|
+
const file = this.fileInput.files[0];
|
|
78
|
+
if (!file) return;
|
|
79
|
+
const formData = new FormData();
|
|
80
|
+
formData.append('avatar', file);
|
|
81
|
+
uploadImage(formData).then(res => {
|
|
82
|
+
this.data = res.data.data[0];
|
|
83
|
+
this.$message({
|
|
84
|
+
message: "上传成功",
|
|
85
|
+
type: "success",
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
remove() {
|
|
90
|
+
this.data = '';
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<style lang="less">
|
|
97
|
+
.c-upload-banner {
|
|
98
|
+
.u-tip{
|
|
99
|
+
padding:5px 15px;
|
|
100
|
+
}
|
|
101
|
+
.u-upload {
|
|
102
|
+
.pr;
|
|
103
|
+
.size(148px);
|
|
104
|
+
.mt(10px);
|
|
105
|
+
img {
|
|
106
|
+
.size(100%);
|
|
107
|
+
.y(bottom);
|
|
108
|
+
}
|
|
109
|
+
.u-upload-mask {
|
|
110
|
+
.none;
|
|
111
|
+
.pa;
|
|
112
|
+
.lt(0);
|
|
113
|
+
.size(100%);
|
|
114
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
115
|
+
}
|
|
116
|
+
.u-upload-delete {
|
|
117
|
+
.pa;
|
|
118
|
+
.lt(50%);
|
|
119
|
+
.size(24px);
|
|
120
|
+
.fz(24px);
|
|
121
|
+
padding: 40px;
|
|
122
|
+
transform: translate(-50%, -50%);
|
|
123
|
+
color: #fff;
|
|
124
|
+
.pointer;
|
|
125
|
+
.none;
|
|
126
|
+
}
|
|
127
|
+
&:hover {
|
|
128
|
+
.u-upload-mask,
|
|
129
|
+
.u-upload-delete {
|
|
130
|
+
.db;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
.u-upload-input {
|
|
135
|
+
.none;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
</style>
|