@jx3box/jx3box-common-ui 6.0.6 → 6.0.9

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.9",
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.5",
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,16 @@
13
13
  </div>
14
14
  <!-- 递归评论组件 -->
15
15
  <Comment :comments="comments" :source-id="sourceId" />
16
+ <el-pagination
17
+ class="u-pagination-box"
18
+ background
19
+ hide-on-single-page
20
+ :current-page="page"
21
+ :total="total"
22
+ :page-size="pageSize"
23
+ layout="prev, pager, next, total"
24
+ @current-change="handleCurrentChange"
25
+ ></el-pagination>
16
26
  <!-- 回复表单 -->
17
27
  <div id="m-reply-form" class="m-reply-form">
18
28
  <h4 class="u-title">
@@ -57,6 +67,10 @@ export default {
57
67
  content: "",
58
68
  user_nickname: User.getInfo().name,
59
69
  },
70
+ page: 1,
71
+ pageSize: 10,
72
+ total: 0,
73
+ loading: false,
60
74
  };
61
75
  },
62
76
  computed: {
@@ -68,7 +82,8 @@ export default {
68
82
  get_comments() {
69
83
  if (!this.type || !this.sourceId) return;
70
84
  // WikiComment.list(this.type, this.sourceId, this.client)
71
- wikiComment.list({ type: this.type, id: this.sourceId }, { client: this.client })
85
+ this.loading = true;
86
+ wikiComment.list({ type: this.type, id: this.sourceId }, { client: this.client, page: this.page })
72
87
  .then(
73
88
  (res) => {
74
89
  res = res.data;
@@ -81,11 +96,16 @@ export default {
81
96
  user_nickname: User.getInfo().name,
82
97
  };
83
98
  }
99
+ this.page = res.data.current_page;
100
+ this.total = res.data.total
84
101
  this.comments = filter(comments, 0);
102
+ // this.comments = comments;
103
+ this.loading = false;
85
104
  }
86
105
  },
87
106
  () => {
88
107
  this.comments = false;
108
+ this.loading = false;
89
109
  }
90
110
  );
91
111
 
@@ -95,11 +115,21 @@ export default {
95
115
  let c = comments[index];
96
116
  if (!c) continue;
97
117
  if (c.parent_id === parent) {
98
- // 置空当前元素
99
- comments[index] = null;
100
- // 递归执行
101
- let children = filter(comments, c.id);
102
- c.children = children ? children : [];
118
+ // 递归
119
+ let children = filter(c.children, c.id);
120
+ c.children = children.map((item) => {
121
+ item.parent = {
122
+ user_id: c.user_id,
123
+ user_nickname: c.user_nickname,
124
+ id: c.id,
125
+ }
126
+ item.reply_form = {
127
+ show: false,
128
+ content: "",
129
+ user_nickname: User.getInfo().name,
130
+ }
131
+ return item
132
+ });
103
133
  outputs.push(c);
104
134
  }
105
135
  }
@@ -152,6 +182,10 @@ export default {
152
182
  form.show = false;
153
183
  });
154
184
  },
185
+ handleCurrentChange(page) {
186
+ this.page = page;
187
+ this.get_comments();
188
+ }
155
189
  },
156
190
  components: {
157
191
  WikiPanel,