@jx3box/jx3box-common-ui 8.0.13 → 8.0.15
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 +1 -1
- package/src/App.vue +1 -1
- package/src/single/PostHeader.vue +27 -2
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -59,6 +59,11 @@
|
|
|
59
59
|
{{ views }}
|
|
60
60
|
</span>
|
|
61
61
|
|
|
62
|
+
<span class="u-word-count u-sub-block" v-if="wordCount" title="累计字数">
|
|
63
|
+
<i class="el-icon-sunny"></i>
|
|
64
|
+
{{ wordCount }}
|
|
65
|
+
</span>
|
|
66
|
+
|
|
62
67
|
<!-- 编辑 -->
|
|
63
68
|
<a class="u-edit u-sub-block" :href="edit_link" v-if="canEdit">
|
|
64
69
|
<i class="u-icon-edit el-icon-edit-outline"></i>
|
|
@@ -73,11 +78,14 @@ import { __Root,__clients } from "@jx3box/jx3box-common/data/jx3box.json";
|
|
|
73
78
|
import { showDate, showTime } from "@jx3box/jx3box-common/js/moment";
|
|
74
79
|
import { editLink, authorLink } from "@jx3box/jx3box-common/js/utils.js";
|
|
75
80
|
import User from "@jx3box/jx3box-common/js/user.js";
|
|
81
|
+
import $ from "jquery";
|
|
76
82
|
export default {
|
|
77
83
|
name: "single-header",
|
|
78
84
|
props: ["post", "stat"],
|
|
79
85
|
data: function() {
|
|
80
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
wordCount: 0,
|
|
88
|
+
};
|
|
81
89
|
},
|
|
82
90
|
computed: {
|
|
83
91
|
url: function() {
|
|
@@ -120,12 +128,29 @@ export default {
|
|
|
120
128
|
return this.post?.client || "std";
|
|
121
129
|
},
|
|
122
130
|
},
|
|
131
|
+
watch: {
|
|
132
|
+
post: {
|
|
133
|
+
deep: true,
|
|
134
|
+
handler: function(val) {
|
|
135
|
+
this.countWords();
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
},
|
|
123
139
|
methods: {
|
|
124
140
|
showClientLabel: function(val) {
|
|
125
141
|
return __clients[val];
|
|
126
142
|
},
|
|
143
|
+
countWords: function (){
|
|
144
|
+
this.$nextTick(() => {
|
|
145
|
+
// 需要去除空格 \n \g
|
|
146
|
+
const text = $('.c-article').text()?.replace(/[\s|\n|\r|\t|\g|\ |\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?|\,|\。|\?|\:|\;|\‘|\’|\”|\“|\、|\·|\!|\(|\)|\》|\《|\『|\』]/g, '');
|
|
147
|
+
|
|
148
|
+
this.wordCount = text?.length || 0;
|
|
149
|
+
})
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
mounted: function() {
|
|
127
153
|
},
|
|
128
|
-
mounted: function() {},
|
|
129
154
|
};
|
|
130
155
|
</script>
|
|
131
156
|
|