@jx3box/jx3box-ui 2.0.27 → 2.0.29

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.0.27",
3
+ "version": "2.0.29",
4
4
  "description": "JX3BOX Vue3 UI",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,10 +9,18 @@
9
9
  >
10
10
  <el-form :model="form" ref="form" :label-position="isPhone ? 'top' : 'left'" label-width="80px">
11
11
  <el-form-item :label="$jx3boxT('jx3boxUi.designTask.formTitle', '标题')">
12
- <el-input v-model="form.title" :placeholder="$jx3boxT('jx3boxUi.designTask.titlePlaceholder', '请输入标题')"></el-input>
12
+ <el-input
13
+ v-model="form.title"
14
+ :placeholder="$jx3boxT('jx3boxUi.designTask.titlePlaceholder', '请输入标题')"
15
+ ></el-input>
13
16
  </el-form-item>
14
17
  <el-form-item :label="$jx3boxT('jx3boxUi.designTask.formType', '类型')">
15
- <el-select v-model="form.type" :placeholder="$jx3boxT('jx3boxUi.designTask.typePlaceholder', '请选择类型')" style="width: 100%" filterable>
18
+ <el-select
19
+ v-model="form.type"
20
+ :placeholder="$jx3boxT('jx3boxUi.designTask.typePlaceholder', '请选择类型')"
21
+ style="width: 100%"
22
+ filterable
23
+ >
16
24
  <el-option v-for="item in config" :key="item.id" :label="item.label" :value="item.name"></el-option>
17
25
  </el-select>
18
26
  </el-form-item>
@@ -24,7 +32,10 @@
24
32
  </el-radio-group>
25
33
  </el-form-item>
26
34
  <el-form-item :label="$jx3boxT('jx3boxUi.designTask.formRemark', '备注')">
27
- <el-input v-model="form.remark" :placeholder="$jx3boxT('jx3boxUi.designTask.remarkPlaceholder', '请输入备注')"></el-input>
35
+ <el-input
36
+ v-model="form.remark"
37
+ :placeholder="$jx3boxT('jx3boxUi.designTask.remarkPlaceholder', '请输入备注')"
38
+ ></el-input>
28
39
  </el-form-item>
29
40
  <el-form-item :label="$jx3boxT('jx3boxUi.designTask.formStar', '星级')" class="m-star-line">
30
41
  <el-rate v-model="form.star" :colors="colors"></el-rate>
@@ -34,18 +45,30 @@
34
45
  <el-divider content-position="left">{{ $jx3boxT("jx3boxUi.designTask.recent", "近期推送") }}</el-divider>
35
46
  <template v-if="logs && logs.length">
36
47
  <el-table :data="logs" border size="small" max-height="300px">
37
- <el-table-column :label="$jx3boxT('jx3boxUi.designTask.pushAt', '推送时间')" prop="push_at" align="center">
48
+ <el-table-column
49
+ :label="$jx3boxT('jx3boxUi.designTask.pushAt', '推送时间')"
50
+ prop="push_at"
51
+ align="center"
52
+ >
38
53
  <template #default="{ row }">
39
54
  {{ formatTime(row.push_at) }}
40
55
  </template>
41
56
  </el-table-column>
42
- <el-table-column :label="$jx3boxT('jx3boxUi.designTask.pusher', '推送人')" prop="pusher.display_name" align="center"></el-table-column>
57
+ <el-table-column
58
+ :label="$jx3boxT('jx3boxUi.designTask.pusher', '推送人')"
59
+ prop="pusher.display_name"
60
+ align="center"
61
+ ></el-table-column>
43
62
  <el-table-column :label="$jx3boxT('jx3boxUi.designTask.star', '星级')" prop="star" align="center">
44
63
  <template #default="{ row }">
45
64
  <el-rate v-model="row.star" disabled :colors="colors"></el-rate>
46
65
  </template>
47
66
  </el-table-column>
48
- <el-table-column :label="$jx3boxT('jx3boxUi.designTask.remark', '备注')" prop="remark" align="center"></el-table-column>
67
+ <el-table-column
68
+ :label="$jx3boxT('jx3boxUi.designTask.remark', '备注')"
69
+ prop="remark"
70
+ align="center"
71
+ ></el-table-column>
49
72
  </el-table>
50
73
  </template>
51
74
  <el-alert
@@ -184,11 +207,6 @@ export default {
184
207
  .el-form-item {
185
208
  margin-bottom: 12px;
186
209
  }
187
- .m-star-line {
188
- .el-form-item__content {
189
- top: 10px;
190
- }
191
- }
192
210
  .u-time {
193
211
  color: #c0c4cc;
194
212
  }
@@ -213,11 +213,6 @@ export default {
213
213
  .el-form-item {
214
214
  margin-bottom: 12px;
215
215
  }
216
- .m-star-line {
217
- .el-form-item__content {
218
- top: 10px;
219
- }
220
- }
221
216
  .u-time {
222
217
  color: #c0c4cc;
223
218
  }
@@ -1,10 +1,6 @@
1
1
  <template>
2
2
  <div class="u-cmt">
3
- <div
4
- class="u-text"
5
- v-if="content != ''"
6
- v-html="renderContent"
7
- ></div>
3
+ <div class="u-text" v-if="content != ''" v-html="renderContent"></div>
8
4
  <div class="u-attachements" v-if="attachments.length">
9
5
  <el-image
10
6
  v-for="url in attachments"
@@ -16,47 +12,22 @@
16
12
  </div>
17
13
  <div class="u-toolbar u-toolbar--primary">
18
14
  <div class="u-toolbar-left">
19
- <el-button
20
- v-if="!currentUserHadLike"
21
- link
22
- size="small"
23
- @click="doLike(true)"
24
- ><img
25
- class="u-up" svg-inline
26
- src="../../assets/img/comment/heart_1.svg"
27
- alt=""
28
- />{{ $jx3boxT("jx3boxUi.commentContent.like", "点赞") }}<span class="u-like-count">{{ likesFormat(hasLikeCount) }}</span></el-button
15
+ <el-button v-if="!currentUserHadLike" link size="small" @click="doLike(true)"
16
+ ><img class="u-up" svg-inline src="../../assets/img/comment/heart_1.svg" alt="" />{{
17
+ $jx3boxT("jx3boxUi.commentContent.like", "点赞")
18
+ }}<span class="u-like-count">{{ likesFormat(hasLikeCount) }}</span></el-button
29
19
  >
30
- <el-button
31
- link
32
- size="small"
33
- v-if="currentUserHadLike"
34
- @click="doLike(false)"
35
- ><img
36
- class="u-up" svg-inline
37
- src="../../assets/img/comment/heart_2.svg"
38
- alt=""
39
- />{{ $jx3boxT("jx3boxUi.commentContent.liked", "已赞") }}<span class="u-like-count">{{
40
- likesFormat(hasLikeCount)
41
- }}</span></el-button
42
- >
43
- <el-button
44
- link
45
- size="small"
46
- icon="ChatRound"
47
- @click="showForm = !showForm"
48
- type="primary"
49
- >{{ $jx3boxT("jx3boxUi.commentContent.reply", "回复") }}</el-button
50
- >
51
- <el-button
52
- v-if="canDelete"
53
- link
54
- icon="Delete"
55
- size="small"
56
- @click="deleteComment()"
57
- type="danger"
58
- >{{ $jx3boxT("jx3boxUi.commentContent.delete", "删除") }}</el-button
20
+ <el-button link size="small" v-if="currentUserHadLike" @click="doLike(false)"
21
+ ><img class="u-up" svg-inline src="../../assets/img/comment/heart_2.svg" alt="" />{{
22
+ $jx3boxT("jx3boxUi.commentContent.liked", "已赞")
23
+ }}<span class="u-like-count">{{ likesFormat(hasLikeCount) }}</span></el-button
59
24
  >
25
+ <el-button link size="small" icon="ChatRound" @click="showForm = !showForm" type="primary">{{
26
+ $jx3boxT("jx3boxUi.commentContent.reply", "回复")
27
+ }}</el-button>
28
+ <el-button v-if="canDelete" link icon="Delete" size="small" @click="deleteComment()" type="danger">{{
29
+ $jx3boxT("jx3boxUi.commentContent.delete", "删除")
30
+ }}</el-button>
60
31
  <el-button
61
32
  link
62
33
  size="small"
@@ -112,13 +83,7 @@
112
83
  </time>
113
84
  </div>
114
85
  <div class="u-toolbar-right">
115
- <el-button
116
- class="u-admin u-filter"
117
- v-if="canAddWhite"
118
- link
119
- size="small"
120
- @click="setWhiteComment(true)"
121
- >
86
+ <el-button class="u-admin u-filter" v-if="canAddWhite" link size="small" @click="setWhiteComment(true)">
122
87
  <img
123
88
  class="u-icon-filter"
124
89
  src="../../assets/img/editor/view.svg"
@@ -140,12 +105,7 @@
140
105
  >
141
106
  </div>
142
107
  </div>
143
- <el-form
144
- v-if="showForm"
145
- ref="form"
146
- :model="newComment"
147
- class="c-comment-subbox"
148
- >
108
+ <el-form v-if="showForm" ref="form" :model="newComment" class="c-comment-subbox">
149
109
  <el-form-item>
150
110
  <el-input
151
111
  type="textarea"
@@ -157,12 +117,7 @@
157
117
  <el-form-item class="c-comment-tool-box">
158
118
  <div class="c-comment-tools">
159
119
  <el-icon class="u-upload-icon" @click="showUploader = !showUploader"><Picture /></el-icon>
160
- <Emotion
161
- class="c-comment-emotion"
162
- @selected="handleEmotionSelected"
163
- type="pop"
164
- :max="6"
165
- ></Emotion>
120
+ <Emotion class="c-comment-emotion" @selected="handleEmotionSelected" type="pop" :max="6"></Emotion>
166
121
  </div>
167
122
  <Uploader
168
123
  v-if="showUploader"
@@ -172,16 +127,12 @@
172
127
  />
173
128
  </el-form-item>
174
129
  <el-form-item>
175
- <el-button
176
- size="small"
177
- type="primary"
178
- @click="submit()"
179
- :disabled="disableSubmitBtn"
180
- >{{ $jx3boxT("jx3boxUi.commentContent.submit", "提交") }}</el-button
181
- >
182
- <el-button size="small" link @click="showForm = false" type="primary"
183
- >{{ $jx3boxT("jx3boxUi.commentContent.collapse", "收起") }}</el-button
184
- >
130
+ <el-button size="small" type="primary" @click="submit()" :disabled="disableSubmitBtn">{{
131
+ $jx3boxT("jx3boxUi.commentContent.submit", "提交")
132
+ }}</el-button>
133
+ <el-button size="small" link @click="showForm = false" type="primary">{{
134
+ $jx3boxT("jx3boxUi.commentContent.collapse", "收起")
135
+ }}</el-button>
185
136
  </el-form-item>
186
137
  </el-form>
187
138
  </div>
@@ -306,9 +257,7 @@ export default {
306
257
  return;
307
258
  }
308
259
  this.currentUserHadLike = setLike;
309
- this.hasLikeCount = setLike
310
- ? this.hasLikeCount + 1
311
- : this.hasLikeCount - 1;
260
+ this.hasLikeCount = setLike ? this.hasLikeCount + 1 : this.hasLikeCount - 1;
312
261
  this.$emit("setLikeComment", setLike);
313
262
  },
314
263
  topComment(setTop) {
@@ -411,10 +360,7 @@ export default {
411
360
  await this.$nextTick();
412
361
 
413
362
  myField.focus();
414
- myField.setSelectionRange(
415
- endPos + value.length,
416
- endPos + value.length
417
- );
363
+ myField.setSelectionRange(endPos + value.length, endPos + value.length);
418
364
  } else {
419
365
  this.newComment.content = value;
420
366
  }
@@ -432,27 +378,25 @@ export default {
432
378
  <style lang="less">
433
379
  /* src/comment/CommentContent.vue */
434
380
  .c-comment-cmt {
435
-
436
381
  //--el-color-primary:@primary;
437
382
 
438
383
  flex-grow: 1;
439
384
  position: relative;
440
385
  .u-toolbar {
441
386
  font-size: 12px;
442
- margin-top:5px;
443
- color:@v4tip;
387
+ margin-top: 5px;
388
+ color: @v4tip;
444
389
  .el-button.is-link {
445
- color:@v4tip;
390
+ color: @v4tip;
446
391
  font-weight: normal;
447
- &:hover{
448
- color:@pink;
392
+ &:hover {
393
+ color: @pink;
449
394
  }
450
395
  }
451
396
  // .el-button.is-link.u-admin{
452
397
  // color:orange;
453
398
  // }
454
399
 
455
-
456
400
  .el-button + .el-button {
457
401
  margin-left: 20px;
458
402
  }
@@ -490,6 +434,7 @@ export default {
490
434
  line-height: 1.715;
491
435
  img {
492
436
  vertical-align: -3px;
437
+ display: inline-block;
493
438
  }
494
439
  white-space: pre-line;
495
440
  }
@@ -16,6 +16,7 @@
16
16
  v-model="newComment.content"
17
17
  :placeholder="$jx3boxT('jx3boxUi.commentInputForm.placeholder', '参与讨论...')"
18
18
  :id="inputId"
19
+ @paste="handlePaste"
19
20
  ></el-input>
20
21
  <div class="c-comment-tools">
21
22
  <el-icon class="u-upload-icon" @click="showUploader = !showUploader"><Picture /></el-icon>
@@ -109,6 +110,7 @@ export default {
109
110
  attachmentUploadFinish(data) {
110
111
  this.$emit("submit", {
111
112
  content: this.newComment.content,
113
+ is_secret: this.is_secret ? 1 : 0,
112
114
  attachmentList: data,
113
115
  });
114
116
  this.newComment = {
@@ -149,6 +151,23 @@ export default {
149
151
  this.newComment.content = value;
150
152
  }
151
153
  },
154
+ async handlePaste(event) {
155
+ const clipboardItems = event.clipboardData.items;
156
+ for (let i = 0; i < clipboardItems.length; i++) {
157
+ const item = clipboardItems[i];
158
+ if (item.type.indexOf("image") !== -1) {
159
+ // 阻止默认粘贴图片的名字
160
+ event.preventDefault();
161
+ const blob = item.getAsFile();
162
+ const file = new File([blob], new Date().getTime() + "-" + blob.name, { type: blob.type });
163
+ if (!this.showUploader) this.showUploader = true;
164
+ await this.$nextTick();
165
+ if (this.$refs.uploader) {
166
+ this.$refs.uploader.addFile(file);
167
+ }
168
+ }
169
+ }
170
+ },
152
171
  },
153
172
  };
154
173
  </script>
@@ -260,6 +260,9 @@ export default {
260
260
  color: #fff;
261
261
  margin-left: 5px;
262
262
  cursor: default;
263
+ display: inline-flex;
264
+ align-items: center;
265
+ justify-content: center;
263
266
  }
264
267
  .u-top {
265
268
  background-color: #6f42c1;
@@ -13,6 +13,7 @@
13
13
  with-credentials
14
14
  :on-exceed="onExceed"
15
15
  :on-change="onChange"
16
+ :on-remove="onRemove"
16
17
  :on-success="onSuccess"
17
18
  :on-error="onError"
18
19
  >
@@ -50,6 +51,7 @@ export default {
50
51
  dialogVisible: false,
51
52
  fileList: [],
52
53
  successList: [],
54
+ uploadedMap: {},
53
55
 
54
56
  acceptedExtensions: ["jpg", "jpeg", "png", "gif"],
55
57
  maxCount: 5,
@@ -74,27 +76,49 @@ export default {
74
76
  });
75
77
  },
76
78
  onChange(file, fileList) {
77
- if (file.status == "ready") {
78
- if (file.size > this.maxSize) {
79
- this.$notify({
80
- title: "",
81
- message: this.$jx3boxT(
82
- "jx3boxUi.commentUpload.maxSize",
83
- "单张图片大小不能超过 {size} MB!",
84
- {
85
- size: this.maxSize / 1024 / 1024,
86
- }
87
- ),
88
- type: "error",
89
- duration: 3000,
90
- position: "bottom-right",
91
- });
92
- fileList.pop();
93
- } else {
94
- this.fileList = fileList;
95
- }
79
+ this.fileList = fileList;
80
+ if (file.status !== "ready" || !file.raw) return;
81
+
82
+ const ext = (file.name.split(".").pop() || "").toLowerCase();
83
+ if (!this.acceptedExtensions.includes(ext)) {
84
+ this.$notify({
85
+ title: "",
86
+ message: this.$jx3boxT(
87
+ "jx3boxUi.commentUpload.onlyTypes",
88
+ "仅支持 {types} 格式图片!",
89
+ { types: this.acceptedExtensions.join(" / ").toUpperCase() }
90
+ ),
91
+ type: "error",
92
+ duration: 3000,
93
+ position: "bottom-right",
94
+ });
95
+ this.removeFile(file.uid);
96
+ return;
97
+ }
98
+
99
+ if (file.size > this.maxSize) {
100
+ this.$notify({
101
+ title: "",
102
+ message: this.$jx3boxT(
103
+ "jx3boxUi.commentUpload.maxSize",
104
+ "单张图片大小不能超过 {size} MB!",
105
+ {
106
+ size: this.maxSize / 1024 / 1024,
107
+ }
108
+ ),
109
+ type: "error",
110
+ duration: 3000,
111
+ position: "bottom-right",
112
+ });
113
+ this.removeFile(file.uid);
114
+ return;
96
115
  }
97
116
  },
117
+ onRemove(file, fileList) {
118
+ this.fileList = fileList;
119
+ if (file?.uid && this.uploadedMap[file.uid]) delete this.uploadedMap[file.uid];
120
+ this.successList = this.fileList.map((f) => this.uploadedMap[f.uid]).filter(Boolean);
121
+ },
98
122
  upload() {
99
123
  if (this.fileList.length > 0) {
100
124
  this.$refs.upload.submit();
@@ -102,12 +126,19 @@ export default {
102
126
  this.$emit("onFinish", []);
103
127
  }
104
128
  },
105
- onSuccess(response) {
106
- this.successList = this.successList.concat(response.data);
129
+ onSuccess(response, file, fileList) {
130
+ this.fileList = fileList;
131
+ const url = response?.data?.[0];
132
+ if (url && file?.uid) {
133
+ this.uploadedMap[file.uid] = url;
134
+ file.url = url;
135
+ }
136
+ this.successList = this.fileList.map((f) => this.uploadedMap[f.uid]).filter(Boolean);
107
137
  if (this.successList.length == this.fileList.length) {
108
138
  this.$emit("onFinish", this.successList || []);
109
139
  this.fileList = [];
110
140
  this.successList = [];
141
+ this.uploadedMap = {};
111
142
  }
112
143
  },
113
144
  onError() {
@@ -121,6 +152,16 @@ export default {
121
152
  this.$emit("onError");
122
153
  this.fileList = [];
123
154
  },
155
+ addFile(file) {
156
+ if (this.$refs.upload && this.$refs.upload.handleStart) {
157
+ this.$refs.upload.handleStart(file);
158
+ }
159
+ },
160
+ removeFile(uid) {
161
+ this.fileList = this.fileList.filter((item) => item.uid !== uid);
162
+ if (uid && this.uploadedMap[uid]) delete this.uploadedMap[uid];
163
+ this.successList = this.fileList.map((f) => this.uploadedMap[f.uid]).filter(Boolean);
164
+ },
124
165
  },
125
166
  };
126
167
  </script>
@@ -16,7 +16,9 @@
16
16
  <template v-if="titleExtra">
17
17
  <span class="u-client" :class="'i-client-' + client">{{ showClientLabel(client) }}</span>
18
18
  <span class="u-client u-zlp" v-if="zlp">{{ zlp }}</span>
19
- <span class="u-client i-client-wujie" v-if="is_wujie">{{ $jx3boxT("jx3boxUi.postHeader.wujie", "无界") }}</span>
19
+ <span class="u-client i-client-wujie" v-if="is_wujie">{{
20
+ $jx3boxT("jx3boxUi.postHeader.wujie", "无界")
21
+ }}</span>
20
22
  </template>
21
23
  </span>
22
24
  </div>
@@ -29,7 +31,9 @@
29
31
  <img svg-inline src="../../assets/img/single/author.svg" />
30
32
  </i>
31
33
  <a class="u-name" :href="author_link" v-if="!anonymous">{{ author_name }}</a>
32
- <span class="u-name u-anonymous" v-else>{{ $jx3boxT("jx3boxUi.postHeader.mysterious", "神秘侠士") }}</span>
34
+ <span class="u-name u-anonymous" v-else>{{
35
+ $jx3boxT("jx3boxUi.postHeader.mysterious", "神秘侠士")
36
+ }}</span>
33
37
  </div>
34
38
 
35
39
  <!-- 自定义字段 -->
@@ -45,7 +49,9 @@
45
49
  <div class="u-meta u-sub-block">
46
50
  <em class="u-label">{{ $jx3boxT("jx3boxUi.postHeader.client", "适用客户端") }}</em>
47
51
  <span class="u-value u-client" :class="client">{{ showClientLabel(client) }}</span>
48
- <span class="u-value u-client wujie" v-if="is_wujie">{{ $jx3boxT("jx3boxUi.postHeader.wujie", "无界") }}</span>
52
+ <span class="u-value u-client wujie" v-if="is_wujie">{{
53
+ $jx3boxT("jx3boxUi.postHeader.wujie", "无界")
54
+ }}</span>
49
55
  </div>
50
56
 
51
57
  <!-- 发布日期 -->
@@ -99,7 +105,6 @@ import JX3BOX from "@jx3box/jx3box-common/data/jx3box.json";
99
105
  import { showDate, showTime } from "@jx3box/jx3box-common/js/moment";
100
106
  import { editLink, authorLink } from "@jx3box/jx3box-common/js/utils.js";
101
107
  import User from "@jx3box/jx3box-common/js/user.js";
102
- import $ from "jquery";
103
108
  import i18nMixin from "../../i18n/mixin";
104
109
  const { __clients } = JX3BOX;
105
110
 
@@ -170,12 +175,13 @@ export default {
170
175
  return this.post?.client || "std";
171
176
  },
172
177
  is_wujie: function () {
173
- return this.post?.is_wujie
178
+ return this.post?.is_wujie;
174
179
  },
175
180
  },
176
181
  watch: {
177
182
  post: {
178
183
  deep: true,
184
+ immediate: true,
179
185
  handler: function () {
180
186
  this.countWords();
181
187
  },
@@ -187,20 +193,60 @@ export default {
187
193
  },
188
194
  countWords: function () {
189
195
  this.$nextTick(() => {
190
- // 需要去除空格 \n \g
191
- // eslint-disable-next-line no-useless-escape
192
- const text = $(".c-article")
193
- .text()
194
- ?.replace(
195
- /[\s|\n|\r|\t|\g|\ |\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?|\,|\。|\?|\:|\;|\‘|\’|\”|\“|\、|\·|\!|\(|\)|\》|\《|\『|\』]/g,
196
- ""
197
- );
198
-
199
- this.wordCount = text?.length || 0;
196
+ const target = document.querySelector(".c-article");
197
+ if (target) {
198
+ this._doCount(target);
199
+ this._observeTarget(target);
200
+ } else {
201
+ this._observeBody();
202
+ }
203
+ });
204
+ },
205
+ _doCount: function (target) {
206
+ // 需要去除空格 \n \g
207
+ // eslint-disable-next-line no-useless-escape
208
+ const text = target.textContent?.replace(
209
+ /[\s|\n|\r|\t|\g|\ |\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?|\,|\。|\?|\:|\;|\‘|\’|\”|\“|\、|\·|\!|\(|\)|\》|\《|\『|\』]/g,
210
+ ""
211
+ );
212
+
213
+ this.wordCount = text?.length || 0;
214
+ },
215
+ _observeTarget: function (target) {
216
+ if (this.targetObserver) this.targetObserver.disconnect();
217
+ this.targetObserver = new MutationObserver(() => {
218
+ this._doCount(target);
219
+ });
220
+ this.targetObserver.observe(target, {
221
+ childList: true,
222
+ subtree: true,
223
+ characterData: true,
224
+ });
225
+ },
226
+ _observeBody: function () {
227
+ if (this.bodyObserver) return;
228
+ this.bodyObserver = new MutationObserver((mutations, observer) => {
229
+ const target = document.querySelector(".c-article");
230
+ if (target) {
231
+ this._doCount(target);
232
+ this._observeTarget(target);
233
+ observer.disconnect();
234
+ this.bodyObserver = null;
235
+ }
236
+ });
237
+ this.bodyObserver.observe(document.body, {
238
+ childList: true,
239
+ subtree: true,
200
240
  });
201
241
  },
202
242
  },
203
- mounted: function () {},
243
+ mounted: function () {
244
+ this.countWords();
245
+ },
246
+ beforeUnmount: function () {
247
+ if (this.targetObserver) this.targetObserver.disconnect();
248
+ if (this.bodyObserver) this.bodyObserver.disconnect();
249
+ },
204
250
  };
205
251
  </script>
206
252
 
@@ -279,7 +325,7 @@ export default {
279
325
  // .y(-4px);
280
326
  margin-right: 5px;
281
327
  color: #111;
282
- top:2px;
328
+ top: 2px;
283
329
  .pr;
284
330
  }
285
331
  }
@@ -300,8 +346,6 @@ export default {
300
346
  }
301
347
 
302
348
  .m-single-info {
303
-
304
-
305
349
  margin-top: 10px;
306
350
  .clearfix;
307
351
  .fz(12px, 20px);