Skip to content

Commit 7cb0bc7

Browse files
author
reco_luan
committed
feat(vuepress-plugin-comments): internationalization
1 parent 0269874 commit 7cb0bc7

File tree

5 files changed

+36
-28
lines changed

5 files changed

+36
-28
lines changed

packages/@vuepress-reco/vuepress-plugin-comments/bin/AccessNumber.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<span v-if="$themeConfig.valineConfig && $themeConfig.valineConfig.visitor != false" :id="getIdVal(idVal)" class="leancloud-visitors" :data-flag-title="flagTitle">
2+
<span :id="getIdVal(idVal)" class="leancloud-visitors" :data-flag-title="flagTitle">
33
<a class="leancloud-visitors-count" :style="numStyle"></a>
44
</span>
55
</template>

packages/@vuepress-reco/vuepress-plugin-comments/bin/Comments.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,33 @@ export default {
3131
solution () {
3232
const {
3333
commentsOptions: { solution: slt },
34-
$themeConfig: { valineConfig, vssueConfig }
34+
$themeConfig: { valineConfig, vssueConfig },
35+
$themeLocaleConfig: { valineConfig: valineLocalConfig, vssueConfig: vssueLocalConfig }
3536
} = this
3637
3738
let solution = ''
3839
if (slt !== undefined) {
3940
solution = slt
40-
} else if (valineConfig !== undefined) {
41+
} else if (valineLocalConfig !== undefined || valineConfig !== undefined) {
4142
solution = 'valine'
42-
} else if (vssueConfig !== undefined) {
43+
} else if (vssueLocalConfig !== undefined || vssueConfig !== undefined) {
4344
solution = 'vssue'
4445
}
4546
return solution
4647
},
4748
options () {
4849
const {
4950
commentsOptions: { options: opt },
50-
$themeConfig: { valineConfig, vssueConfig }
51+
$themeConfig: { valineConfig, vssueConfig },
52+
$themeLocaleConfig: { valineConfig: valineLocalConfig, vssueConfig: vssueLocalConfig }
5153
} = this
5254
5355
if (opt !== undefined) {
5456
return opt
55-
} else if (valineConfig !== undefined) {
56-
return valineConfig
57-
} else if (vssueConfig !== undefined) {
58-
return vssueConfig
57+
} else if (valineLocalConfig !== undefined || valineConfig !== undefined) {
58+
return valineLocalConfig || valineConfig
59+
} else if (vssueLocalConfig !== undefined || vssueConfig !== undefined) {
60+
return vssueLocalConfig || vssueConfig
5961
}
6062
return null
6163
},

packages/@vuepress-reco/vuepress-plugin-comments/bin/Valine.vue

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,12 @@ export default {
1616
}
1717
}
1818
},
19-
computed: {
20-
lang () {
21-
const { $lang } = this
22-
if (/^zh\-(CN|SG)$/.test($lang)) {
23-
return 'zh-CN'
24-
}
25-
if (/^zh\-(HK|MO|TW)$/.test($lang)) {
26-
return 'zh-TW'
27-
}
28-
if (/^ja\-JP$/.test($lang)) {
29-
return 'ja'
30-
}
31-
return 'en'
32-
}
33-
},
3419
mounted: function () {
3520
this.initValine()
3621
},
3722
methods: {
3823
initValine () {
3924
const Valine = require('valine')
40-
const lang = this.lang
4125
const valineOptions = {
4226
el: '#valine',
4327
placeholder: 'just go go',
@@ -47,7 +31,6 @@ export default {
4731
visitor: true,
4832
recordIP: false,
4933
path: window.location.pathname,
50-
lang,
5134
...this.options
5235
}
5336

packages/vuepress-theme-reco/components/Footer.vue

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
{{ new Date().getFullYear() }}
1818
</a>
1919
</span>
20-
<span v-show="$themeConfig.valineConfig !== undefined">
20+
<span v-show="showAccessNumber">
2121
<i class="iconfont reco-eye"></i>
2222
<AccessNumber idVal="/" />
2323
</span>
@@ -36,6 +36,20 @@ export default {
3636
return {
3737
version
3838
}
39+
},
40+
computed: {
41+
showAccessNumber () {
42+
const {
43+
$themeConfig: { valineConfig },
44+
$themeLocaleConfig: { valineConfig: valineLocalConfig }
45+
} = this
46+
47+
const vc = valineLocalConfig || valineConfig
48+
if (vc && vc.visitor != false) {
49+
return true
50+
}
51+
return false
52+
}
3953
}
4054
}
4155
</script>

packages/vuepress-theme-reco/components/Page.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,16 @@ export default {
101101
return (showComment !== false && isShowComments !== false) || (showComment === false && isShowComments === true)
102102
},
103103
showAccessNumber () {
104-
return this.$themeConfig.valineConfig !== undefined
104+
const {
105+
$themeConfig: { valineConfig },
106+
$themeLocaleConfig: { valineConfig: valineLocalConfig }
107+
} = this
108+
109+
const vc = valineLocalConfig || valineConfig
110+
if (vc && vc.visitor != false) {
111+
return true
112+
}
113+
return false
105114
},
106115
lastUpdated () {
107116
return this.$page.lastUpdated

0 commit comments

Comments
 (0)