@jx3box/jx3box-common-ui 5.7.1 → 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.
@@ -176,12 +176,14 @@
176
176
  background-color: #e6f0fb;
177
177
  // color:@color-link;
178
178
  }
179
- padding: 2px 0;
179
+ padding: 4px 4px;
180
+ .r(3px);
180
181
  }
181
182
  .u-team-logo {
182
- .size(26px);
183
+ .size(24px);
183
184
  .y;
184
- .mr(10px);
185
+ .mr(4px);
186
+ .r(4px);
185
187
  }
186
188
  .u-team-name {
187
189
  .fz(12px);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-common-ui",
3
- "version": "5.7.1",
3
+ "version": "5.7.4",
4
4
  "description": "JX3BOX UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,8 +31,8 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@jx3box/jx3box-comment-ui": "^1.7.0",
34
- "@jx3box/jx3box-common": "^7.1.2",
35
- "@jx3box/jx3box-data": "^1.9.1",
34
+ "@jx3box/jx3box-common": "^7.1.5",
35
+ "@jx3box/jx3box-data": "^1.9.4",
36
36
  "@jx3box/jx3box-editor": "^1.2.7",
37
37
  "axios": "^0.26.1",
38
38
  "dayjs": "^1.11.0",
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
- export { getPostAuthors };
7
+ function uploadImage(formData){
8
+ return $cms().post(`/api/cms/upload/avatar`, formData);
9
+ }
10
+
11
+ export { getPostAuthors, uploadImage };
package/src/App.vue CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  <LeftSidebar :open="true">
10
10
  <LeftSideToggle :mobileOnly="true" />
11
- <Author :author="author" :uid="8" />
11
+ <Author :author="author" :uid="2" />
12
12
  </LeftSidebar>
13
13
 
14
14
  <Main :withoutLeft="false" :withoutRight="false">
@@ -21,7 +21,7 @@
21
21
  <el-radio :label="224">l-224</el-radio>
22
22
  </el-radio-group>
23
23
  <div>
24
- <Avatar :size="avatar_size" url="" :id="8" frame="" />
24
+ <Avatar :id="8" url="" :size="avatar_size" frame="" />
25
25
  </div>
26
26
  </el-tab-pane>
27
27
  <el-tab-pane label="CMS作品" name="post">
@@ -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() {
package/src/Author.vue CHANGED
@@ -16,7 +16,7 @@
16
16
  <div slot="content">
17
17
  <span class="u-tips">经验值:{{ data.experience }}</span>
18
18
  </div>
19
- <span class="u-level" :class="'lv-' + level">Lv.{{ level }}</span>
19
+ <span class="u-level" :class="'lv-' + level" :style={backgroundColor:showLevelColor(level)}>Lv.{{ level }}</span>
20
20
  </el-tooltip>
21
21
  <el-tooltip class="item" effect="dark" :content="vipTypeTitle" placement="top" v-if="isVip">
22
22
  <a class="u-vip" href="/vip/premium?from=sidebar_author" target="_blank">
@@ -83,7 +83,7 @@ const liveStatusMap = ["等待开播", "直播中", "直播结束"];
83
83
  import Avatar from "./author/Avatar.vue";
84
84
  import Authorposts from "./author/Authorposts.vue";
85
85
  import { authorLink, tvLink, getLink, getThumbnail } from "@jx3box/jx3box-common/js/utils";
86
- import { __server, __imgPath } from "@jx3box/jx3box-common/data/jx3box.json";
86
+ import { __server, __imgPath,__userLevelColor } from "@jx3box/jx3box-common/data/jx3box.json";
87
87
  import { getUserInfo, getDouyu, getUserMedals, getUserPublicTeams } from "../service/author";
88
88
  import { user as medal_map } from "@jx3box/jx3box-common/data/medals.json";
89
89
  import User from "@jx3box/jx3box-common/js/user";
@@ -198,6 +198,9 @@ export default {
198
198
  showTeamLogo: function(val) {
199
199
  return getThumbnail(val, 96);
200
200
  },
201
+ showLevelColor:function (level){
202
+ return __userLevelColor[level]
203
+ }
201
204
  },
202
205
  watch: {
203
206
  uid: function() {
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <a class="c-avatar" :href="authorLink(uid)">
3
- <img :src="showAvatar(url)" class="c-avatar-pic" :class="{ isCircle }" />
4
- <i class="c-avatar-frame" v-if="frameName" :class="style">
3
+ <img :src="showAvatar(url)" class="c-avatar-pic"/>
4
+ <i class="c-avatar-frame" v-if="frame">
5
5
  <img :src="frameUrl" />
6
6
  </i>
7
7
  <slot></slot>
@@ -9,9 +9,7 @@
9
9
  </template>
10
10
 
11
11
  <script>
12
- import default_frames from "@jx3box/jx3box-common/data/user_avatar_frame.json";
13
12
  import { __server, __imgPath } from "@jx3box/jx3box-common/data/jx3box.json";
14
- import { getFrames } from "../../service/author";
15
13
  import { showAvatar, authorLink } from "@jx3box/jx3box-common/js/utils";
16
14
  export default {
17
15
  name: "Avatar",
@@ -29,66 +27,17 @@ export default {
29
27
  };
30
28
  },
31
29
  computed: {
32
- frameName: function() {
33
- return this.frame && this.frames[this.frame] ? this.frame : "";
34
- },
35
30
  frameUrl: function() {
36
- if (this.frameName) {
37
- let fileName = this.frames[this.frameName].files[this.style].file;
38
- return __imgPath + `avatar/images/${this.frameName}/${fileName}`;
39
- }
40
- return "";
41
- },
42
- isCircle: function() {
43
- return this.frameName && this.frames[this.frameName].style == "circle";
44
- },
45
- style: function() {
46
- let style = ~~this.size;
47
- for(let [i,v] of this.styles.entries()){
48
- if(style < v.size){
49
- return this.styles[i]['cls']
50
- }
51
- }
52
- return "s";
53
- },
54
- data: function() {
55
- return [this.uid, this.url, this.size, this.frame];
31
+ return __imgPath + `avatar/images/${this.frame}/${this.frame}.svg`;
56
32
  },
57
33
  },
58
34
  methods: {
59
- loadFrames: function() {
60
-
61
- // 无头像框
62
- if(!this.frame) return
63
-
64
- let frames = sessionStorage.getItem("avatarFrames");
65
-
66
- // 本地缓存
67
- if(frames){
68
- try {
69
- frames = JSON.parse(frames);
70
- this.frames = frames;
71
- } catch (e) {
72
- this.frames = default_frames
73
- }
74
-
75
- // 线上数据
76
- }else{
77
- getFrames().then((res) => {
78
- if (res.data) {
79
- this.frames = res.data || {};
80
- sessionStorage.setItem("avatarFrames", JSON.stringify(this.frames));
81
- }
82
- });
83
- }
84
- },
85
35
  showAvatar: function(val) {
86
36
  return showAvatar(val, this.size*3);
87
37
  },
88
38
  authorLink,
89
39
  },
90
40
  mounted : function (){
91
- this.loadFrames()
92
41
  }
93
42
  };
94
43
  </script>
@@ -101,18 +50,19 @@ export default {
101
50
  .c-avatar-pic {
102
51
  .db;
103
52
  .full;
104
- .r(4px);
105
- &.isCircle {
106
- .r(100%);
107
- }
53
+ .r(100%);
108
54
  }
109
55
  .c-avatar-frame {
110
56
  .pa;
57
+ .lt(-10px);
58
+ .size(100%);
59
+ padding: 10px;
60
+ box-sizing: content-box;
111
61
  img {
112
62
  .db;
113
63
  .pa;
114
- .lt(0);
115
64
  .size(100%);
65
+ .lt(0);
116
66
  }
117
67
 
118
68
  &.xs {
@@ -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>