@jx3box/jx3box-common-ui 8.9.30 → 9.0.0

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.9.30",
3
+ "version": "9.0.0",
4
4
  "description": "JX3BOX UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,7 +31,7 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@jx3box/jx3box-comment-ui": "^1.9.9",
34
- "@jx3box/jx3box-common": "^8.4.2",
34
+ "@jx3box/jx3box-common": "^8.4.7",
35
35
  "@jx3box/jx3box-data": "^3.6.9",
36
36
  "@jx3box/jx3box-editor": "^2.2.16",
37
37
  "@jx3box/reporter": "^0.0.4",
package/src/App.vue CHANGED
@@ -265,7 +265,7 @@ export default {
265
265
  },
266
266
  data: function () {
267
267
  return {
268
- tab: "widget",
268
+ tab: "post",
269
269
 
270
270
  post: {},
271
271
  post_id: "79820",
@@ -0,0 +1,157 @@
1
+ <template>
2
+ <div class="w-rss" @click="onRssClick">
3
+ <el-tooltip effect="dark" :content="tooltipContent" placement="top-start">
4
+ <div>
5
+ <img v-if="subscribed" class="u-icon" svg-inline :src="rmSrc" />
6
+ <img v-else class="u-icon" svg-inline :src="addSrc" />
7
+ <span class="u-count" v-if="!hiddenNum && total > 0">{{ total }}</span>
8
+ </div>
9
+ </el-tooltip>
10
+ </div>
11
+ </template>
12
+
13
+ <script>
14
+ import User from "@jx3box/jx3box-common/js/user";
15
+ import { __cdn } from "@jx3box/jx3box-common/data/jx3box.json";
16
+ import {
17
+ getCommunityRss,
18
+ getWikiRss,
19
+ getPostRss,
20
+ subscribeCommunity,
21
+ subscribePost,
22
+ subscribeWiki,
23
+ unsubscribeWiki,
24
+ unsubscribeCommunity,
25
+ unsubscribePost,
26
+ } from "@jx3box/jx3box-common/js/rss";
27
+ import { omit } from "lodash";
28
+ import { __postType, __wikiType } from "@jx3box/jx3box-common/data/jx3box.json";
29
+
30
+ export default {
31
+ name: "Rss",
32
+ props: {
33
+ type: {
34
+ type: String,
35
+ default: "", // community, cj, bps,
36
+ },
37
+ id: {
38
+ type: [String, Number],
39
+ default: "",
40
+ },
41
+ hiddenNum: {
42
+ type: Boolean,
43
+ default: false,
44
+ },
45
+ },
46
+ data() {
47
+ return {
48
+ subscribed: false,
49
+ total: 0,
50
+ };
51
+ },
52
+ computed: {
53
+ tooltipContent() {
54
+ return this.subscribed ? "已订阅" : "加入订阅";
55
+ },
56
+ addSrc() {
57
+ return __cdn + "design/vector/icon/rss.svg";
58
+ },
59
+ rmSrc() {
60
+ return __cdn + "design/vector/icon/unrss.svg";
61
+ },
62
+ category({ type }) {
63
+ if (type.includes("community")) return "community";
64
+ if (__postType[type]) return "posts";
65
+ if (__wikiType[type]) return "wiki";
66
+ return "";
67
+ },
68
+ getRssFn({ category }) {
69
+ if (category === "community") return getCommunityRss;
70
+ if (category === "posts") return getPostRss;
71
+ if (category === "wiki") return getWikiRss;
72
+ return null;
73
+ },
74
+ subscribeFn({ category }) {
75
+ if (category === "community") return subscribeCommunity;
76
+ if (category === "posts") return subscribePost;
77
+ if (category === "wiki") return subscribeWiki;
78
+ return null;
79
+ },
80
+ unsubscribeFn({ category }) {
81
+ if (category === "community") return unsubscribeCommunity;
82
+ if (category === "posts") return unsubscribePost;
83
+ if (category === "wiki") return unsubscribeWiki;
84
+ return null;
85
+ },
86
+ params() {
87
+ return {
88
+ type: this.type,
89
+ id: this.id,
90
+ }
91
+ },
92
+ isLogin() {
93
+ return User.isLogin();
94
+ },
95
+ },
96
+ watch: {
97
+ params: {
98
+ deep: true,
99
+ immediate: true,
100
+ handler(val) {
101
+ if (this.isLogin && val?.id) {
102
+ this.checkSubscribed();
103
+ }
104
+ }
105
+ }
106
+ },
107
+ methods: {
108
+ onRssClick() {
109
+ if (!this.isLogin) {
110
+ User.toLogin();
111
+ return;
112
+ }
113
+ if (this.subscribed) {
114
+ this.unsubscribe();
115
+ } else {
116
+ this.subscribe();
117
+ }
118
+ },
119
+ checkSubscribed() {
120
+ this.getRssFn && this.getRssFn(this.params).then((res) => {
121
+ this.subscribed = res.data.data.subscribed;
122
+ this.total = res.data.data.total;
123
+ });
124
+ },
125
+ subscribe() {
126
+ this.subscribeFn && this.subscribeFn(this.params).then((res) => {
127
+ this.subscribed = true;
128
+ this.total++;
129
+ });
130
+ },
131
+ unsubscribe() {
132
+ this.unsubscribeFn && this.unsubscribeFn(this.params).then((res) => {
133
+ this.subscribed = false;
134
+ this.total--;
135
+ });
136
+ },
137
+ },
138
+ };
139
+ </script>
140
+
141
+ <style lang="less">
142
+ .w-rss {
143
+ .pointer;
144
+ .dbi;
145
+ .u-icon {
146
+ .size(26px);
147
+ .y;
148
+ .pr;
149
+ }
150
+ .u-count {
151
+ color: #888;
152
+ .ml(10px);
153
+ top: 4px;
154
+ .pr;
155
+ }
156
+ }
157
+ </style>
@@ -38,6 +38,7 @@
38
38
  />
39
39
  <Like :postId="postId" :postType="postType"></Like>
40
40
  <fav :postId="postId" :postType="postType" :postTitle="postTitle"></fav>
41
+ <Rss v-if="showRss" :type="postType" :id="postId"></Rss>
41
42
  <boxcoin-user
42
43
  v-if="userBoxcoinEnable && boxcoin_enable && allowGift"
43
44
  :postId="postId"
@@ -51,8 +52,8 @@
51
52
  :category="category"
52
53
  @updateRecord="updateRecord"
53
54
  />
54
- <Share :postId="postId" :postType="postType" :client="client" />
55
55
  <watch-later :category="postType" :title="postTitle"></watch-later>
56
+ <Share :postId="postId" :postType="postType" :client="client" />
56
57
  </div>
57
58
  <div class="w-thx-records">
58
59
  <boxcoin-records
@@ -81,6 +82,7 @@ import BoxcoinRecords from "../interact/boxcoin_records.vue";
81
82
  import BoxcoinAdmin from "../interact/boxcoin_admin.vue";
82
83
  import BoxcoinUser from "../interact/boxcoin_user.vue";
83
84
  import WatchLater from "../interact/watchLater.vue";
85
+ import Rss from "../interact/Rss.vue";
84
86
 
85
87
  import User from "@jx3box/jx3box-common/js/user";
86
88
  import { getPostBoxcoinConfig, getBoxcoinStatus } from "../../service/thx";
@@ -134,6 +136,10 @@ export default {
134
136
  category: {
135
137
  default: undefined,
136
138
  },
139
+ showRss: {
140
+ type: Boolean,
141
+ default: false,
142
+ },
137
143
  },
138
144
  components: {
139
145
  Like,
@@ -144,6 +150,7 @@ export default {
144
150
  "boxcoin-admin": BoxcoinAdmin,
145
151
  "boxcoin-user": BoxcoinUser,
146
152
  WatchLater,
153
+ Rss,
147
154
  },
148
155
  data: function () {
149
156
  return {
@@ -47,6 +47,7 @@
47
47
  :userBoxcoinEnable="true"
48
48
  :authors="authors"
49
49
  :client="post_client"
50
+ showRss
50
51
  />
51
52
 
52
53
  <!-- 评论 -->