@jx3box/jx3box-common-ui 6.0.6 → 6.0.7

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.
@@ -20,6 +20,10 @@
20
20
  }
21
21
  }
22
22
 
23
+ .u-pagination-box {
24
+ margin-top: 12px;
25
+ }
26
+
23
27
  .m-comments-panel {
24
28
  font-size: 14px;
25
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-common-ui",
3
- "version": "6.0.6",
3
+ "version": "6.0.7",
4
4
  "description": "JX3BOX UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,9 +31,9 @@
31
31
  ],
32
32
  "dependencies": {
33
33
  "@jx3box/jx3box-comment-ui": "^1.7.0",
34
- "@jx3box/jx3box-common": "^7.3.6",
35
- "@jx3box/jx3box-data": "^1.10.2",
36
- "@jx3box/jx3box-editor": "^1.4.3",
34
+ "@jx3box/jx3box-common": "^7.3.11",
35
+ "@jx3box/jx3box-data": "^1.10.6",
36
+ "@jx3box/jx3box-editor": "^1.4.4",
37
37
  "axios": "^0.26.1",
38
38
  "dayjs": "^1.11.0",
39
39
  "element-ui": "^2.13.2",
@@ -36,7 +36,7 @@
36
36
  <!-- 展开、收起 -->
37
37
  <el-button
38
38
  type="default"
39
- v-if="comment.reply_form.show"
39
+ v-if="comment.reply_form && comment.reply_form.show"
40
40
  class="u-reply"
41
41
  @click="
42
42
  comment.reply_form.show = !comment.reply_form.show
@@ -64,7 +64,7 @@
64
64
  ></span>
65
65
  </div>
66
66
  <!-- 评论回复表单 -->
67
- <div class="m-reply-form" v-if="comment.reply_form.show">
67
+ <div class="m-reply-form" v-if="comment.reply_form && comment.reply_form.show">
68
68
  <textarea
69
69
  class="u-reply-content"
70
70
  v-model="comment.reply_form.content"
@@ -5,7 +5,7 @@
5
5
  <span>百科评论</span>
6
6
  </template>
7
7
  <template slot="body">
8
- <div class="m-comments-panel">
8
+ <div class="m-comments-panel" v-loading="loading">
9
9
  <div class="u-empty" v-if="!comments || !comments.length">
10
10
  <span v-if="comments === null">🎉 数据加载中...</span>
11
11
  <span v-if="comments === false">⚠️ 数据加载异常</span>
@@ -13,6 +13,14 @@
13
13
  </div>
14
14
  <!-- 递归评论组件 -->
15
15
  <Comment :comments="comments" :source-id="sourceId" />
16
+ <el-pagination
17
+ class="u-pagination-box"
18
+ background :current-page="page"
19
+ :total="total"
20
+ :page-size="pageSize"
21
+ layout="prev, pager, next, total"
22
+ @current-change="handleCurrentChange"
23
+ ></el-pagination>
16
24
  <!-- 回复表单 -->
17
25
  <div id="m-reply-form" class="m-reply-form">
18
26
  <h4 class="u-title">
@@ -57,6 +65,10 @@ export default {
57
65
  content: "",
58
66
  user_nickname: User.getInfo().name,
59
67
  },
68
+ page: 1,
69
+ pageSize: 10,
70
+ total: 0,
71
+ loading: false,
60
72
  };
61
73
  },
62
74
  computed: {
@@ -68,7 +80,8 @@ export default {
68
80
  get_comments() {
69
81
  if (!this.type || !this.sourceId) return;
70
82
  // WikiComment.list(this.type, this.sourceId, this.client)
71
- wikiComment.list({ type: this.type, id: this.sourceId }, { client: this.client })
83
+ this.loading = true;
84
+ wikiComment.list({ type: this.type, id: this.sourceId }, { client: this.client, page: this.page })
72
85
  .then(
73
86
  (res) => {
74
87
  res = res.data;
@@ -81,11 +94,16 @@ export default {
81
94
  user_nickname: User.getInfo().name,
82
95
  };
83
96
  }
97
+ this.page = res.data.current_page;
98
+ this.total = res.data.total
84
99
  this.comments = filter(comments, 0);
100
+ // this.comments = comments;
101
+ this.loading = false;
85
102
  }
86
103
  },
87
104
  () => {
88
105
  this.comments = false;
106
+ this.loading = false;
89
107
  }
90
108
  );
91
109
 
@@ -95,11 +113,21 @@ export default {
95
113
  let c = comments[index];
96
114
  if (!c) continue;
97
115
  if (c.parent_id === parent) {
98
- // 置空当前元素
99
- comments[index] = null;
100
- // 递归执行
101
- let children = filter(comments, c.id);
102
- c.children = children ? children : [];
116
+ // 递归
117
+ let children = filter(c.children, c.id);
118
+ c.children = children.map((item) => {
119
+ item.parent = {
120
+ user_id: c.user_id,
121
+ user_nickname: c.user_nickname,
122
+ id: c.id,
123
+ }
124
+ item.reply_form = {
125
+ show: false,
126
+ content: "",
127
+ user_nickname: User.getInfo().name,
128
+ }
129
+ return item
130
+ });
103
131
  outputs.push(c);
104
132
  }
105
133
  }
@@ -152,6 +180,10 @@ export default {
152
180
  form.show = false;
153
181
  });
154
182
  },
183
+ handleCurrentChange(page) {
184
+ this.page = page;
185
+ this.get_comments();
186
+ }
155
187
  },
156
188
  components: {
157
189
  WikiPanel,