@jx3box/jx3box-ui 2.3.17 → 2.3.19

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-ui",
3
- "version": "2.3.17",
3
+ "version": "2.3.19",
4
4
  "description": "JX3BOX Vue3 UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,8 +34,8 @@
34
34
  "@element-plus/icons-vue": "^2.3.2",
35
35
  "@jx3box/jx3box-common": "^9.2.9",
36
36
  "@jx3box/jx3box-data": "^3.9.6",
37
- "@jx3box/jx3box-editor": "^3.2.9",
38
- "@jx3box/jx3box-emotion": "^1.3.1",
37
+ "@jx3box/jx3box-editor": "^3.2.11",
38
+ "@jx3box/jx3box-emotion": "^1.3.2",
39
39
  "@jx3box/jx3box-macro": "^1.0.4",
40
40
  "@jx3box/jx3box-talent": "^1.3.14",
41
41
  "@tinymce/tinymce-vue": "^5.1.1",
package/service/author.js CHANGED
@@ -34,9 +34,10 @@ async function getDouyu(ids) {
34
34
  return res.data.data;
35
35
  }
36
36
 
37
+ // 兼容备用:公共作者组件已改用 /user/skin 聚合数据
37
38
  async function getUserMedals(uid, params) {
38
39
  return $next({ mute: true })
39
- .get("/api/next2/user/" + uid + "/medals", {params})
40
+ .get("/api/next2/user/" + uid + "/medals", { params })
40
41
  .then((res) => {
41
42
  return res.data.data;
42
43
  });
package/service/cms.js CHANGED
@@ -170,6 +170,7 @@ function refreshAuth() {
170
170
  return $cms().post(`/api/cms/user/account/token/refresh`);
171
171
  }
172
172
 
173
+ // 兼容备用:公共作者组件已改用 /user/skin 聚合数据
173
174
  function getUserHonor(uid) {
174
175
  return $cms({ mute: true }).get(`/api/cms/user/honor/${uid}/using`);
175
176
  }
@@ -1,76 +1,47 @@
1
1
  <template>
2
- <a class="c-author-honor" :style="{ backgroundImage: `url(${imgUrl()})` }" v-if="honor" :href="url" target="_blank">
3
- <span :style="{ color: honor.color }">{{ honor.honor }}</span>
2
+ <a
3
+ class="c-author-honor"
4
+ :style="{ backgroundImage: `url(${imgUrl()})` }"
5
+ v-if="displayHonor"
6
+ :href="url"
7
+ target="_blank"
8
+ >
9
+ <span :style="{ color: displayHonor.color }">{{ displayHonor.honor }}</span>
4
10
  </a>
5
11
  </template>
6
12
  <script>
7
13
  import JX3BOX from "@jx3box/jx3box-common/data/jx3box.json";
8
- import { getUserHonor } from "../../service/cms";
9
14
  import { inRange } from "lodash";
10
15
 
11
16
  const { __cdn, __Root } = JX3BOX;
12
- const HONOR_IMG_KEY = "honor_img";
13
17
  export default {
14
18
  props: {
15
- uid: {
16
- type: [Number, String],
17
- default: 0,
18
- },
19
- },
20
- data: function () {
21
- return {
22
- honor: "",
23
- };
24
- },
25
- watch: {
26
- uid: {
27
- immediate: true,
28
- handler: function (val) {
29
- val && this.getHonor();
30
- },
19
+ honor: {
20
+ type: Object,
21
+ default: null,
31
22
  },
32
23
  },
33
24
  computed: {
34
- isJdt() {
35
- return this.honor?.val?.toLowerCase()?.includes("jdt");
25
+ displayHonor() {
26
+ return this.formatHonor(this.honor);
36
27
  },
37
28
  url() {
38
- return this.honor?.honor_info?.url ? __Root + this.honor?.honor_info?.url : "";
29
+ return this.displayHonor?.honor_info?.url ? __Root + this.displayHonor.honor_info.url : "";
39
30
  },
40
31
  },
41
32
  methods: {
42
33
  imgUrl: function () {
43
- let item = this.honor?.honor_info;
34
+ let item = this.displayHonor?.honor_info;
44
35
  if (!item) return;
45
- return __cdn + `design/decoration/honor/${item.img}/${item.img}.${item.img_ext}`;
46
- },
47
- getHonor() {
48
- let user_id = this.uid;
49
- if (!user_id) return;
50
- let honor_local = sessionStorage.getItem(HONOR_IMG_KEY + user_id) || "";
51
- //解析本地缓存
52
- if (honor_local == "no") return;
53
- try {
54
- this.honor = JSON.parse(honor_local);
55
- } catch (err) {
56
- getUserHonor(user_id).then((res) => {
57
- this.honor = res.data.data;
58
- if (!this.honor) {
59
- //空 则为无主题,不再加载接口,界面设No
60
- sessionStorage.setItem(HONOR_IMG_KEY + user_id, "no");
61
- return;
62
- }
63
- this.getHonorStyle(this.honor);
64
- });
65
- }
36
+ return __cdn + `design/decoration/honor/${item.img}/${item.img}.${item.img_ext || "png"}`;
66
37
  },
67
- //有称号后,获取样式配置
68
- getHonorStyle(honor) {
69
- const data = honor;
38
+ formatHonor(honor) {
39
+ if (!honor?.honor_info) return null;
40
+ const data = { ...honor };
70
41
  let honorConfig = honor?.honor_info;
71
42
  let only = honorConfig.only;
72
- let prefix = honorConfig.prefix;
73
- let regPrefix = honorConfig.prefix.match(/\{([^{}]+?)\}/g);
43
+ let prefix = honorConfig.prefix || "";
44
+ let regPrefix = prefix.match(/\{([^{}]+?)\}/g);
74
45
  let ranking = honorConfig.ranking || [];
75
46
  let honorStr = honorConfig.year || "";
76
47
 
@@ -103,14 +74,13 @@ export default {
103
74
  }
104
75
  }
105
76
  }
106
- data.honor = honorStr + honorConfig.suffix;
77
+ data.honor = honorStr + (honorConfig.suffix || "");
107
78
  data.color = honorConfig.color;
108
79
  data.img = honorConfig.img;
109
80
  data.img_ext = honorConfig.img_ext;
110
81
  data.isHave = true;
111
82
  data.isImgIndex = ranking?.length > 0;
112
- sessionStorage.setItem(HONOR_IMG_KEY + this.uid, JSON.stringify(data));
113
- this.honor = data;
83
+ return data;
114
84
  },
115
85
  },
116
86
  };
@@ -63,7 +63,7 @@
63
63
  </div>
64
64
  </div>
65
65
  </div>
66
- <Honor :uid="uid"></Honor>
66
+ <Honor :honor="honor"></Honor>
67
67
  <div class="u-bio">{{ data.user_bio }}</div>
68
68
  </div>
69
69
  </template>
@@ -91,6 +91,10 @@ export default {
91
91
  type: [Number, String],
92
92
  default: 0,
93
93
  },
94
+ honor: {
95
+ type: Object,
96
+ default: null,
97
+ },
94
98
  },
95
99
  components: {
96
100
  Avatar,
@@ -24,7 +24,6 @@
24
24
  <script>
25
25
  import * as utilModule from "@jx3box/jx3box-common/js/utils";
26
26
  const { getMedalLink } = utilModule;
27
- import { getUserMedals } from "../../service/author";
28
27
  import JX3BOX from "@jx3box/jx3box-common/data/jx3box.json";
29
28
  import i18nMixin from "../../i18n/mixin";
30
29
  const { __cdn, __Root } = JX3BOX;
@@ -32,32 +31,19 @@ const { __cdn, __Root } = JX3BOX;
32
31
  export default {
33
32
  name: "AuthorMedals",
34
33
  mixins: [i18nMixin],
35
- props: ["uid"],
36
- components: {},
37
- data: function () {
38
- return {
39
- medals: [],
40
- };
34
+ props: {
35
+ medals: {
36
+ type: Array,
37
+ default: () => [],
38
+ },
41
39
  },
40
+ components: {},
42
41
  computed: {
43
42
  ready: function () {
44
- return this.uid && this.medals && this.medals.length;
45
- },
46
- },
47
- watch: {
48
- uid: {
49
- immediate: true,
50
- handler: function (val) {
51
- val && this.loadMedals();
52
- },
43
+ return this.medals && this.medals.length;
53
44
  },
54
45
  },
55
46
  methods: {
56
- loadMedals: function () {
57
- getUserMedals(this.uid, {is_wear: 1}).then((data) => {
58
- this.medals = data || [];
59
- });
60
- },
61
47
  showIcon(medal) {
62
48
  return __cdn + "design/medals/user/" + medal + ".webp";
63
49
  },
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="c-author" :style="decorationStyles">
3
- <AuthorInfo :uid="uid" :anonymous="anonymous" @ready="installModules" />
3
+ <AuthorInfo :uid="uid" :anonymous="anonymous" :honor="activeHonor" @ready="installModules" />
4
4
  <template v-if="data">
5
5
  <div class="u-interact">
6
6
  <!-- <AuthorFollow style="margin-right: 8px;" :uid="uid" /> -->
@@ -13,7 +13,7 @@
13
13
  </div>
14
14
  <!-- <AuthorLink class="u-block u-links" :uid="uid" :data="data" /> -->
15
15
  <AuthorRole class="u-block u-roles" :data="data" />
16
- <AuthorMedals class="u-block u-trophy" :uid="uid" />
16
+ <AuthorMedals class="u-block u-trophy" :medals="activeMedals" />
17
17
  <!-- <AuthorTeams class="u-block u-teams" :uid="uid" /> -->
18
18
  <!-- <AuthorFans class="u-block u-fans" :uid="uid" /> -->
19
19
  <slot></slot>
@@ -73,6 +73,8 @@ export default {
73
73
  data: "",
74
74
  sidebarSkin: "",
75
75
  sidebarSkinPosition: "",
76
+ activeHonor: null,
77
+ activeMedals: [],
76
78
  };
77
79
  },
78
80
  computed: {
@@ -89,6 +91,8 @@ export default {
89
91
  uid() {
90
92
  this.sidebarSkin = "";
91
93
  this.sidebarSkinPosition = "";
94
+ this.activeHonor = null;
95
+ this.activeMedals = [];
92
96
  this.loadSidebarSkin();
93
97
  },
94
98
  },
@@ -146,6 +150,8 @@ export default {
146
150
 
147
151
  getUserSkin(this.uid).then((res) => {
148
152
  const records = res.data.data || [];
153
+ this.activeHonor = records.find((item) => item?.type === "honor")?.honor || null;
154
+ this.activeMedals = records.find((item) => item?.type === "medals")?.medals || [];
149
155
  const record = records.find((item) => this.resolveSkinDetail(item));
150
156
  if (record && this.setSidebarSkin(record)) {
151
157
  return;
@@ -5,6 +5,8 @@ const root = path.resolve(__dirname, "..");
5
5
  const service = fs.readFileSync(path.join(root, "service/cms.js"), "utf8");
6
6
  const author = fs.readFileSync(path.join(root, "src/single/Author.vue"), "utf8");
7
7
  const authorInfo = fs.readFileSync(path.join(root, "src/author/AuthorInfo.vue"), "utf8");
8
+ const authorHonor = fs.readFileSync(path.join(root, "src/author/AuthorHonor.vue"), "utf8");
9
+ const authorMedals = fs.readFileSync(path.join(root, "src/author/AuthorMedals.vue"), "utf8");
8
10
  const authorStyle = fs.readFileSync(path.join(root, "assets/css/single/author.less"), "utf8");
9
11
 
10
12
  function assert(condition, message) {
@@ -23,6 +25,22 @@ assert(author.includes('item.subtype === "pc_sidebar"'), "Author should consume
23
25
 
24
26
  assert(author.includes("record.skins"), "Author should resolve active skin resources from skins[]");
25
27
 
28
+ assert(author.includes('item?.type === "honor"'), "Author should read active honor from the user skin response");
29
+
30
+ assert(author.includes('item?.type === "medals"'), "Author should read active medals from the user skin response");
31
+
32
+ assert(author.includes(':medals="activeMedals"'), "Author should pass active medals to AuthorMedals");
33
+
34
+ assert(!authorMedals.includes("getUserMedals"), "AuthorMedals should not request medals independently");
35
+
36
+ assert(!authorMedals.includes("getUserMedals"), "AuthorMedals should not request the legacy medal endpoint");
37
+
38
+ assert(authorInfo.includes(':honor="honor"'), "AuthorInfo should pass the active honor to AuthorHonor");
39
+
40
+ assert(!authorHonor.includes("sessionStorage"), "AuthorHonor should not use session storage");
41
+
42
+ assert(!authorHonor.includes("getUserHonor"), "AuthorHonor should not request the legacy active honor endpoint");
43
+
26
44
  assert(author.includes("backgroundPosition: this.sidebarSkinPosition"), "Author should apply skin position");
27
45
 
28
46
  assert(author.includes('rt: "right top"'), "Author should map rt to right top");