@jx3box/jx3box-common-ui 5.5.24 → 5.5.27

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/src/Author.vue CHANGED
@@ -1,56 +1,38 @@
1
1
  <template>
2
2
  <div class="c-author" v-if="data">
3
3
  <div class="u-author">
4
- <Avatar
5
- class="u-avatar"
6
- :uid="uid"
7
- :url="data.user_avatar"
8
- :size="68"
9
- :frame="data.user_avatar_frame"
10
- />
11
- <a class="u-name" :href="authorLink(uid)">
12
- <span>{{ data.display_name }}</span>
4
+ <Avatar class="u-avatar" :uid="uid" :url="data.user_avatar" :size="68" :frame="data.user_avatar_frame" />
5
+ <div class="u-info">
6
+ <a class="u-name" :href="authorLink(uid)">
7
+ <span>{{ data.display_name.slice(0, 12) }}</span>
8
+ <el-tooltip class="item" effect="dark" content="签约作者" placement="top" v-if="isSuperAuthor">
9
+ <a class="u-superauthor" href="/dashboard/#/cooperation" target="_blank">
10
+ <img :src="super_author_icon" alt="superauthor" />
11
+ </a>
12
+ </el-tooltip>
13
13
  </a>
14
- <el-tooltip
15
- class="item"
16
- effect="dark"
17
- content="签约作者"
18
- placement="top"
19
- v-if="isSuperAuthor"
20
- >
21
- <a class="u-superauthor" href="/dashboard/#/cooperation" target="_blank">
22
- <img :src="super_author_icon" alt="superauthor" />
23
- </a>
24
- </el-tooltip>
25
- <el-tooltip
26
- class="item"
27
- effect="dark"
28
- :content="vipTypeTitle"
29
- placement="top"
30
- v-if="isPRO || isVIP"
31
- >
32
- <a class="u-vip" href="/vip/premium?from=sidebar_author" target="_blank">
33
- <i class="i-icon-vip on">{{ vipType }}</i>
34
- </a>
35
- </el-tooltip>
14
+ <div class="u-extend">
15
+ <el-tooltip class="item u-level" effect="dark" placement="top">
16
+ <div slot="content">
17
+ <span class="u-tips">经验值:{{ data.experience }}</span>
18
+ </div>
19
+ <span>Lv.{{ level }}</span>
20
+ </el-tooltip>
21
+ <el-tooltip class="item" effect="dark" :content="vipTypeTitle" placement="top" v-if="isVip">
22
+ <a class="u-vip" href="/vip/premium?from=sidebar_author" target="_blank">
23
+ <i class="i-icon-vip on">{{ vipType }}</i>
24
+ </a>
25
+ </el-tooltip>
26
+ </div>
27
+ </div>
36
28
  </div>
37
29
  <div class="u-bio">{{ data.user_bio }}</div>
38
30
  <div class="u-link" v-if="hasLink">
39
- <a
40
- v-if="data.weibo_name"
41
- class="u-weibo"
42
- :href="weiboLink(data.weibo_id)"
43
- target="_blank"
44
- >
31
+ <a v-if="data.weibo_name" class="u-weibo" :href="weiboLink(data.weibo_id)" target="_blank">
45
32
  <img svg-inline src="../assets/img/author/weibo.svg" />
46
33
  {{ data.weibo_name }}
47
34
  </a>
48
- <a
49
- v-if="data.github_name"
50
- class="u-github"
51
- :href="githubLink(data.github_name)"
52
- target="_blank"
53
- >
35
+ <a v-if="data.github_name" class="u-github" :href="githubLink(data.github_name)" target="_blank">
54
36
  <img svg-inline src="../assets/img/author/github.svg" />
55
37
  {{ data.github_name }}
56
38
  </a>
@@ -87,9 +69,9 @@
87
69
  <i class="el-icon-school"></i>
88
70
  <span>所属团队</span>
89
71
  </div>
90
- <a class="u-team" v-for="(item,i) in teams" :key="i" :href="teamLink(item.team_id)" target="_blank">
72
+ <a class="u-team" v-for="(item, i) in teams" :key="i" :href="teamLink(item.team_id)" target="_blank">
91
73
  <img class="u-team-logo" :src="showTeamLogo(item.team_logo)" />
92
- <span class="u-team-name">{{item.team_name}}@{{item.team_server}}</span>
74
+ <span class="u-team-name">{{ item.team_name }}@{{ item.team_server }}</span>
93
75
  </a>
94
76
  </div>
95
77
  <Authorposts :uid="uid" />
@@ -100,27 +82,16 @@
100
82
  const liveStatusMap = ["等待开播", "直播中", "直播结束"];
101
83
  import Avatar from "./author/Avatar.vue";
102
84
  import Authorposts from "./author/Authorposts.vue";
103
- import {
104
- authorLink,
105
- tvLink,
106
- getLink,
107
- getThumbnail,
108
- } from "@jx3box/jx3box-common/js/utils";
85
+ import { authorLink, tvLink, getLink, getThumbnail } from "@jx3box/jx3box-common/js/utils";
109
86
  import { __server, __imgPath } from "@jx3box/jx3box-common/data/jx3box.json";
110
- import {
111
- getUserInfo,
112
- getDouyu,
113
- getUserMedals,
114
- getUserPublicTeams,
115
- getSuperAuthor,
116
- getIdentity,
117
- } from "../service/author";
87
+ import { getUserInfo, getDouyu, getUserMedals, getUserPublicTeams } from "../service/author";
118
88
  import { user as medal_map } from "@jx3box/jx3box-common/data/medals.json";
119
89
  import User from "@jx3box/jx3box-common/js/user";
90
+ import { __userLevel } from "@jx3box/jx3box-common/data/jx3box.json";
120
91
  export default {
121
92
  name: "Author",
122
93
  props: ["uid"],
123
- data: function () {
94
+ data: function() {
124
95
  return {
125
96
  data: "",
126
97
  tv: "",
@@ -133,50 +104,52 @@ export default {
133
104
  // team_server : "蝶恋花"
134
105
  // }
135
106
  ],
136
- isSuperAuthor: false,
137
- isPRO: false,
138
107
  isVIP: false,
139
108
  };
140
109
  },
141
110
  computed: {
142
- tv_type: function () {
111
+ tv_type: function() {
143
112
  return this.data && this.data.tv_type;
144
113
  },
145
- tv_id: function () {
114
+ tv_id: function() {
146
115
  return (this.data && this.data.tv_id) || 0;
147
116
  },
148
- tv_img: function () {
117
+ tv_img: function() {
149
118
  return __imgPath + "image/tv/" + this.tv_type + ".png";
150
119
  },
151
- tv_link: function () {
120
+ tv_link: function() {
152
121
  return tvLink(this.tv_type, this.tv_id) || "";
153
122
  },
154
- tv_status: function () {
123
+ tv_status: function() {
155
124
  return (this.tv && this.tv.show_status == 1) || false;
156
125
  },
157
- super_author_icon: function () {
126
+ super_author_icon: function() {
158
127
  return __imgPath + "image/user/" + "superauthor.svg";
159
128
  },
160
- hasLink: function () {
161
- return (
162
- this.data.weibo_name ||
163
- this.data.github_name ||
164
- this.data.tuilan_id ||
165
- this.data.tv_id
166
- );
129
+ hasLink: function() {
130
+ return this.data.weibo_name || this.data.github_name || this.data.tuilan_id || this.data.tv_id;
167
131
  },
168
- hasTrophy: function () {
132
+ hasTrophy: function() {
169
133
  return this.medals.length;
170
134
  },
171
- vipType: function () {
172
- return this.isPRO ? "PRO" : "PRE";
135
+ vipType: function() {
136
+ return this.data?.is_pro ? "PRO" : "PRE";
137
+ },
138
+ vipTypeTitle: function() {
139
+ return this.data?.is_pro ? "专业版会员" : "高级版会员";
140
+ },
141
+ isVip: function() {
142
+ return this.data?.is_pro || this.data?.is_pre;
143
+ },
144
+ isSuperAuthor: function() {
145
+ return this.data?.sign;
173
146
  },
174
- vipTypeTitle: function () {
175
- return this.isPRO ? "专业版会员" : "高级版会员";
147
+ level: function() {
148
+ return User.getLevel(this.data?.experience);
176
149
  },
177
150
  },
178
151
  methods: {
179
- loadData: function () {
152
+ loadData: function() {
180
153
  return getUserInfo(this.uid)
181
154
  .then((data) => {
182
155
  this.data = data;
@@ -184,11 +157,9 @@ export default {
184
157
  .then(() => {
185
158
  this.loadMedals();
186
159
  this.loadTeams();
187
- this.checkSuperAuthor();
188
- this.loadIdentity();
189
160
  });
190
161
  },
191
- loadTV: function () {
162
+ loadTV: function() {
192
163
  if (this.tv_type == "douyu") {
193
164
  if (!this.tv_id || isNaN(this.tv_id)) return;
194
165
  getDouyu(this.tv_id).then((data) => {
@@ -196,59 +167,44 @@ export default {
196
167
  });
197
168
  }
198
169
  },
199
- loadMedals: function () {
170
+ loadMedals: function() {
200
171
  getUserMedals(this.uid).then((data) => {
201
172
  this.medals = data;
202
173
  });
203
174
  },
204
- loadTeams: function () {
175
+ loadTeams: function() {
205
176
  getUserPublicTeams(this.uid).then((data) => {
206
177
  this.teams = data && data.slice(0, 5);
207
178
  });
208
179
  },
209
- async checkVIP() {
210
- this.isPRO = await User.isPRO();
211
- this.isVIP = await User.isVIP();
212
- },
213
- checkSuperAuthor: function () {
214
- getSuperAuthor(this.uid).then((res) => {
215
- this.isSuperAuthor = res.data.data;
216
- });
217
- },
218
- loadIdentity: function () {
219
- getIdentity(this.uid).then((res) => {
220
- this.isPRO = res.data.data.isPRO;
221
- this.isVIP = res.data.data.isPRE;
222
- });
223
- },
224
180
 
225
181
  // filters
226
- showMedalIcon: function (val) {
182
+ showMedalIcon: function(val) {
227
183
  return __imgPath + "image/medals/user/" + val + ".gif";
228
184
  },
229
- showMedalDesc : function (item){
230
- return item.medal_desc || medal_map[item.medal]
185
+ showMedalDesc: function(item) {
186
+ return item.medal_desc || medal_map[item.medal];
231
187
  },
232
188
  authorLink,
233
- weiboLink: function (val) {
189
+ weiboLink: function(val) {
234
190
  return "https://weibo.com/" + val;
235
191
  },
236
- githubLink: function (val) {
192
+ githubLink: function(val) {
237
193
  return "https://github.com/" + val;
238
194
  },
239
- teamLink: function (team_id) {
195
+ teamLink: function(team_id) {
240
196
  return getLink("org", team_id);
241
197
  },
242
- showTeamLogo: function (val) {
198
+ showTeamLogo: function(val) {
243
199
  return getThumbnail(val, 32);
244
200
  },
245
201
  },
246
202
  watch: {
247
- uid: function () {
203
+ uid: function() {
248
204
  this.loadData();
249
205
  },
250
206
  },
251
- mounted: function () {
207
+ mounted: function() {
252
208
  this.uid && this.loadData();
253
209
  },
254
210
  components: {
@@ -1,19 +1,18 @@
1
1
  <template>
2
- <div class="c-authorposts">
2
+ <div class="c-authorposts" v-if="uid">
3
3
  <div class="u-label">
4
4
  <i class="el-icon-notebook-2"></i>
5
5
  <span>作者最新作品</span>
6
- <a :href="id | authorLink" class="u-more" target="_blank">全部 &raquo;</a>
6
+ <a :href="uid | authorLink" class="u-more" target="_blank">全部 &raquo;</a>
7
7
  </div>
8
-
8
+
9
9
  <ul v-if="data && data.length">
10
10
  <li v-for="(item, i) in data" :key="i">
11
- <a
12
- class="u-item"
13
- :href="url(item.ID, item.post_type)"
14
- target="_blank"
15
- >
16
- <span><i class="u-icon el-icon-reading"></i> {{ item.post_title || item.post_type + '/无标题' }}</span>
11
+ <a class="u-item" :href="url(item.ID, item.post_type)" target="_blank">
12
+ <span
13
+ ><i class="u-icon el-icon-reading"></i>
14
+ {{ item.post_title || item.post_type + "/无标题" }}</span
15
+ >
17
16
  </a>
18
17
  </li>
19
18
  </ul>
@@ -22,42 +21,40 @@
22
21
 
23
22
  <script>
24
23
  import { getUserPosts } from "../../service/author";
25
- import {authorLink,getLink} from '@jx3box/jx3box-common/js/utils'
24
+ import { authorLink, getLink } from "@jx3box/jx3box-common/js/utils";
26
25
  export default {
27
26
  name: "Authorposts",
28
27
  props: ["uid"],
29
28
  data: function() {
30
29
  return {
31
30
  data: [],
32
- id : this.uid || 0,
33
31
  };
34
32
  },
35
- computed : {
36
- },
37
- watch : {
38
- uid : function (newid){
39
- this.id = newid
40
- this.init()
41
- }
33
+ computed: {},
34
+ watch: {
35
+ uid: {
36
+ immediate: true,
37
+ handler: function(user_id) {
38
+ if (user_id) this.init();
39
+ },
40
+ },
42
41
  },
43
42
  methods: {
44
43
  url: function(pid, type) {
45
- return getLink(type,pid)
44
+ return getLink(type, pid);
45
+ },
46
+ init: function() {
47
+ getUserPosts(this.uid)
48
+ .then((data) => {
49
+ this.data = data.slice(0, 5);
50
+ })
51
+ .catch((err) => {
52
+ console.log(err);
53
+ });
46
54
  },
47
- init : function (){
48
- if (!this.id) return;
49
- getUserPosts(this.id).then((data) => {
50
- this.data = data.slice(0, 5);
51
- }).catch((err) => {
52
- console.log(err)
53
- })
54
- }
55
- },
56
- filters : {
57
- authorLink
58
55
  },
59
- mounted: function() {
60
- this.init()
56
+ filters: {
57
+ authorLink,
61
58
  },
62
59
  };
63
60
  </script>
@@ -119,7 +119,10 @@ import {
119
119
  } from "@jx3box/jx3box-common/data/jx3box.json";
120
120
  import panel from "../../assets/data/panel.json";
121
121
  import { getMsg, getMenu } from "../../service/header";
122
- import { getSuperAuthor } from "../../service/author";
122
+ import { getMyInfo, userSignIn } from "../../service/author";
123
+ import dayjs from 'dayjs';
124
+ import isToday from 'dayjs/plugin/isToday';
125
+ dayjs.extend(isToday);
123
126
  export default {
124
127
  props: [],
125
128
  data: function () {
@@ -201,6 +204,12 @@ export default {
201
204
  return __imgPath + "image/user/" + "superauthor.svg";
202
205
  },
203
206
  },
207
+ watch: {
208
+ fold(val) {
209
+ if (!val) {
210
+ }
211
+ }
212
+ },
204
213
  methods: {
205
214
  // 消息
206
215
  checkMSG: function () {
@@ -242,6 +251,31 @@ export default {
242
251
  });
243
252
  });
244
253
  },
254
+ // 签到
255
+ signIn: function (){
256
+ try {
257
+ let user_last_login = localStorage.getItem('user_last_login');
258
+ user_last_login = user_last_login && JSON.parse(user_last_login) || ''
259
+
260
+ if (user_last_login && dayjs(user_last_login).isToday()) {
261
+ console.log('已签到')
262
+ } else {
263
+ userSignIn().then(res => {
264
+ this.$message({
265
+ type: 'success',
266
+ message: '签到成功',
267
+ customClass: 'c-header-signin'
268
+ })
269
+ localStorage.setItem('user_last_login', JSON.stringify(dayjs()))
270
+ }).catch(err => {
271
+ localStorage.setItem('user_last_login', JSON.stringify(dayjs()))
272
+ console.log(dayjs.tz.guess())
273
+ }).finally(() => {})
274
+ }
275
+ } catch(e) {
276
+ console.log(e)
277
+ }
278
+ },
245
279
 
246
280
  // 资产
247
281
  loadAsset: function () {
@@ -249,10 +283,10 @@ export default {
249
283
  this.asset = data;
250
284
  });
251
285
  },
252
- checkSuperAuthor: function () {
253
- getSuperAuthor(this.user?.uid).then((res) => {
254
- this.isSuperAuthor = res.data.data;
255
- });
286
+ loadMyInfo: function () {
287
+ getMyInfo().then(res => {
288
+ this.isSuperAuthor = !!res.sign
289
+ })
256
290
  },
257
291
 
258
292
  // 初始化
@@ -262,7 +296,8 @@ export default {
262
296
  this.checkMSG();
263
297
  this.loadPanel();
264
298
  this.loadAsset();
265
- this.checkSuperAuthor();
299
+ this.loadMyInfo()
300
+ this.signIn()
266
301
  }
267
302
  },
268
303
 
@@ -284,4 +319,4 @@ export default {
284
319
  },
285
320
  components: {},
286
321
  };
287
- </script>
322
+ </script>
@@ -1,9 +1,7 @@
1
1
  <template>
2
2
  <el-button class="w-fav" size="mini" type="primary" @click="doFav">
3
- <i v-if="!favorited" class="el-icon-star-off"></i>
4
- <i v-else class="el-icon-star-on"></i>
5
- <span v-if="!favorited">收藏</span>
6
- <span v-else>取消收藏</span>
3
+ <i :class="favorite ? 'el-icon-star-on' : 'el-icon-star-off'"></i>
4
+ <span>{{ favorite ? "取消收藏" : "收藏" }}</span>
7
5
  </el-button>
8
6
  </template>
9
7
 
@@ -12,63 +10,41 @@ import User from "@jx3box/jx3box-common/js/user";
12
10
  import { hasFav, addFav, delFav } from "../../service/fav";
13
11
  export default {
14
12
  name: "Fav",
15
- props: ["postType", "postId"],
16
- data: function() {
13
+ props: ["postType", "postId", "postTitle"],
14
+ data: function () {
17
15
  return {
18
16
  login: User.isLogin(),
19
- favorited: false,
17
+ favorite: false,
20
18
  };
21
19
  },
22
20
  methods: {
23
- doFav: function() {
21
+ doFav: function () {
24
22
  if (this.login) {
25
- this.favorited ? this.delFav() : this.addFav();
23
+ this.favorite ? this.delFav() : this.addFav();
26
24
  } else {
27
25
  User.toLogin();
28
26
  }
29
27
  },
30
- hasFav: function() {
31
- hasFav(this.postType, this.postId).then(
32
- (data) => {
33
- data = data.data;
34
- this.favorited = data.code === 200 && data.data.favorited > 0;
35
- },
36
- (err) => {
37
- this.fail(err);
38
- }
39
- );
28
+ hasFav: function () {
29
+ hasFav(this.postType, this.postId).then((res) => {
30
+ this.favorite = res.id || false;
31
+ });
40
32
  },
41
- addFav: function() {
42
- addFav(this.postType, this.postId).then(
43
- (data) => {
44
- if (data.data.code === 200) {
45
- this.favorited = true;
46
- } else this.fail(data.data.message);
47
- },
48
- (err) => {
49
- this.fail(err);
50
- }
51
- );
33
+ addFav: function () {
34
+ addFav(this.postType, this.postId, this.postTitle).then((res) => {
35
+ this.favorite = res.id;
36
+ });
52
37
  },
53
- delFav: function() {
54
- delFav(this.postType, this.postId).then(
55
- (data) => {
56
- if (data.data.code === 200) {
57
- this.favorited = false;
58
- } else this.fail(data.data.message);
59
- },
60
- (err) => {
61
- this.fail(err);
62
- }
63
- );
38
+ delFav: function () {
39
+ delFav(this.favorite).then(() => {
40
+ this.favorite = false;
41
+ });
64
42
  },
65
- fail: function(err) {
43
+ fail: function (err) {
66
44
  if (err.response && err.response.data && err.response.data.code) {
67
- this.$message.error(
68
- `[${err.response.data.code}] ${err.response.data.msg}`
69
- );
45
+ this.$message.error(`[${err.response.data.code}] ${err.response.data.msg}`);
70
46
  } else {
71
- this.$message.error(typeof err === 'string' ? err : "网络请求异常");
47
+ this.$message.error(typeof err === "string" ? err : "网络请求异常");
72
48
  }
73
49
  console.log(err);
74
50
  },
@@ -78,8 +54,8 @@ export default {
78
54
  immediate: true,
79
55
  handler() {
80
56
  if (this.login && this.postType && this.postId) this.hasFav();
81
- }
82
- }
57
+ },
58
+ },
83
59
  },
84
60
  };
85
61
  </script>