@jx3box/jx3box-common-ui 8.2.3 → 8.2.5

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-common-ui",
3
- "version": "8.2.3",
3
+ "version": "8.2.5",
4
4
  "description": "JX3BOX UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -33,7 +33,7 @@
33
33
  "@jx3box/jx3box-comment-ui": "^1.8.7",
34
34
  "@jx3box/jx3box-common": "^8.2.4",
35
35
  "@jx3box/jx3box-data": "^3.5.6",
36
- "@jx3box/jx3box-editor": "^2.1.6",
36
+ "@jx3box/jx3box-editor": "^2.1.7",
37
37
  "@jx3box/reporter": "^0.0.4",
38
38
  "axios": "^0.26.1",
39
39
  "dayjs": "^1.11.0",
package/service/cms.js CHANGED
@@ -18,6 +18,10 @@ function getDecorationJson() {
18
18
  let url = __imgPath + "decoration/index.json";
19
19
  return axios.get(url);
20
20
  }
21
+ function getHonorJson() {
22
+ let url = __imgPath + "decoration/honor.json";
23
+ return axios.get(url);
24
+ }
21
25
  // 通用上传
22
26
  function upload(formData) {
23
27
  return $cms().post(`/api/cms/upload`, formData);
@@ -73,5 +77,5 @@ function setUserMeta(key,data) {
73
77
  return $cms().post(`/api/cms/user/my/meta?key=${key}`, data);
74
78
  }
75
79
 
76
- export { getPostAuthors, uploadImage, upload, getDecoration, getDecorationJson, checkTeamMember,
80
+ export { getPostAuthors, uploadImage, upload, getDecoration, getDecorationJson, getHonorJson, checkTeamMember,
77
81
  getSliders, getCollection, getTopicBucket, getConfig, getUserMeta, setUserMeta };
package/src/App.vue CHANGED
@@ -15,9 +15,9 @@
15
15
  bread info
16
16
  </Breadcrumb>
17
17
 
18
- <LeftSidebar :open="true" :uid="1005">
18
+ <LeftSidebar :open="true" :uid="8">
19
19
  <LeftSideToggle :mobileOnly="true" />
20
- <Author :author="author" :uid="1005" />
20
+ <Author :author="author" :uid="8" />
21
21
  </LeftSidebar>
22
22
 
23
23
  <Main :withoutLeft="false" :withoutRight="false">
@@ -1,11 +1,13 @@
1
1
  <template>
2
2
  <div class="c-author-honor" :style="{ backgroundImage: `url(${imgUrl()})` }" v-if="honor">
3
- <span v-if="!isJdt" :style="{ color: honor.color }">{{ honorName }}</span>
3
+ <span v-if="!isJdt" :style="{ color: honor.color }">{{ honor.honor }}</span>
4
4
  </div>
5
5
  </template>
6
6
  <script>
7
7
  import { __imgPath } from "@jx3box/jx3box-common/data/jx3box.json";
8
+ import { getHonorJson } from "../../service/cms";
8
9
  import { getUserHonors } from "../../service/author";
10
+ import { inRange } from "lodash";
9
11
  const HONOR_IMG_KEY = "honor_img";
10
12
  export default {
11
13
  props: ["uid"],
@@ -24,16 +26,16 @@ export default {
24
26
  },
25
27
  computed: {
26
28
  isJdt() {
27
- return this.honor?.val?.toLowerCase()?.includes('jdt')
29
+ return this.honor?.val?.toLowerCase()?.includes("jdt");
28
30
  },
29
- honorName({ honor }) {
30
- return `${honor.year}${honor.prefix}${honor.suffix}`
31
- }
32
31
  },
33
32
  methods: {
34
33
  imgUrl: function () {
35
34
  let item = this.honor;
36
35
  if (!item) return;
36
+ if (item.isImgIndex) {
37
+ return __imgPath + `decoration/honor/${item.img}/${item.img}_${item.imgIndex}.${item.img_ext}`;
38
+ }
37
39
  return __imgPath + `decoration/honor/${item.img}/${item.img}.${item.img_ext}`;
38
40
  },
39
41
  getHonor() {
@@ -46,7 +48,7 @@ export default {
46
48
  this.honor = JSON.parse(honor_local);
47
49
  } catch (err) {
48
50
  getUserHonors(user_id).then((data) => {
49
- let res = data?.filter(item => item.using);
51
+ let res = data?.filter((item) => item.using);
50
52
  if (res.length == 0) {
51
53
  //空 则为无主题,不再加载接口,界面设No
52
54
  sessionStorage.setItem(HONOR_IMG_KEY + user_id, "no");
@@ -58,10 +60,56 @@ export default {
58
60
  }
59
61
  },
60
62
  //有称号后,获取样式配置
61
- getHonorStyle(data) {
62
- data = data.honor;
63
- sessionStorage.setItem(HONOR_IMG_KEY + this.uid, JSON.stringify(data));
64
- this.honor = data;
63
+ getHonorStyle(honor) {
64
+ const data = honor?.honor || {};
65
+ getHonorJson().then((res) => {
66
+ let honorList = res.data;
67
+ let honorConfig = honorList[data.img];
68
+ let only = honorConfig.only;
69
+ let prefix = honorConfig.prefix;
70
+ let regPrefix = honorConfig.prefix.match(/\{([^{}]+?)\}/g);
71
+ let ranking = honorConfig.ranking;
72
+ let honorStr = honorConfig.year || "";
73
+ if (!only) {
74
+ if (regPrefix) {
75
+ honorStr = honorStr + (data[regPrefix[0].slice(1, -1)] || "");
76
+ } else {
77
+ honorStr = honorStr + prefix;
78
+ }
79
+ } else {
80
+ honorStr = prefix;
81
+ }
82
+ if (ranking.length > 0) {
83
+ data.imgIndex = 0;
84
+ for (let i = 0; i < ranking.length; i++) {
85
+ if (
86
+ honor.ranking !== undefined &&
87
+ inRange(Number(honor.ranking), ranking[i][0], ranking[i][1])
88
+ ) {
89
+ data.imgIndex = i;
90
+ let str = ranking[i][2];
91
+ let regStr = str.match(/\{([^{}]+?)\}/g);
92
+ if (regStr) {
93
+ honorStr =
94
+ honorStr +
95
+ str.replace(/\{([^{}]+?)\}/g, function (match, p1) {
96
+ return data[p1] || "";
97
+ });
98
+ } else {
99
+ honorStr = honorStr + str;
100
+ }
101
+ break;
102
+ }
103
+ }
104
+ }
105
+ data.honor = honorStr + honorConfig.suffix;
106
+ data.color = honorConfig.color;
107
+ data.ext = honorConfig.ext;
108
+ data.isHave = true;
109
+ data.isImgIndex = ranking.length > 0;
110
+ sessionStorage.setItem(HONOR_IMG_KEY + this.uid, JSON.stringify(data));
111
+ this.honor = data;
112
+ });
65
113
  },
66
114
  },
67
115
  };