feat(vuepress-plugin-comments): internationalization
This commit is contained in:
parent
0269874546
commit
7cb0bc796d
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<span v-if="$themeConfig.valineConfig && $themeConfig.valineConfig.visitor != false" :id="getIdVal(idVal)" class="leancloud-visitors" :data-flag-title="flagTitle">
|
||||
<span :id="getIdVal(idVal)" class="leancloud-visitors" :data-flag-title="flagTitle">
|
||||
<a class="leancloud-visitors-count" :style="numStyle"></a>
|
||||
</span>
|
||||
</template>
|
||||
|
@ -31,15 +31,16 @@ export default {
|
||||
solution () {
|
||||
const {
|
||||
commentsOptions: { solution: slt },
|
||||
$themeConfig: { valineConfig, vssueConfig }
|
||||
$themeConfig: { valineConfig, vssueConfig },
|
||||
$themeLocaleConfig: { valineConfig: valineLocalConfig, vssueConfig: vssueLocalConfig }
|
||||
} = this
|
||||
|
||||
let solution = ''
|
||||
if (slt !== undefined) {
|
||||
solution = slt
|
||||
} else if (valineConfig !== undefined) {
|
||||
} else if (valineLocalConfig !== undefined || valineConfig !== undefined) {
|
||||
solution = 'valine'
|
||||
} else if (vssueConfig !== undefined) {
|
||||
} else if (vssueLocalConfig !== undefined || vssueConfig !== undefined) {
|
||||
solution = 'vssue'
|
||||
}
|
||||
return solution
|
||||
@ -47,15 +48,16 @@ export default {
|
||||
options () {
|
||||
const {
|
||||
commentsOptions: { options: opt },
|
||||
$themeConfig: { valineConfig, vssueConfig }
|
||||
$themeConfig: { valineConfig, vssueConfig },
|
||||
$themeLocaleConfig: { valineConfig: valineLocalConfig, vssueConfig: vssueLocalConfig }
|
||||
} = this
|
||||
|
||||
if (opt !== undefined) {
|
||||
return opt
|
||||
} else if (valineConfig !== undefined) {
|
||||
return valineConfig
|
||||
} else if (vssueConfig !== undefined) {
|
||||
return vssueConfig
|
||||
} else if (valineLocalConfig !== undefined || valineConfig !== undefined) {
|
||||
return valineLocalConfig || valineConfig
|
||||
} else if (vssueLocalConfig !== undefined || vssueConfig !== undefined) {
|
||||
return vssueLocalConfig || vssueConfig
|
||||
}
|
||||
return null
|
||||
},
|
||||
|
@ -16,28 +16,12 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
lang () {
|
||||
const { $lang } = this
|
||||
if (/^zh\-(CN|SG)$/.test($lang)) {
|
||||
return 'zh-CN'
|
||||
}
|
||||
if (/^zh\-(HK|MO|TW)$/.test($lang)) {
|
||||
return 'zh-TW'
|
||||
}
|
||||
if (/^ja\-JP$/.test($lang)) {
|
||||
return 'ja'
|
||||
}
|
||||
return 'en'
|
||||
}
|
||||
},
|
||||
mounted: function () {
|
||||
this.initValine()
|
||||
},
|
||||
methods: {
|
||||
initValine () {
|
||||
const Valine = require('valine')
|
||||
const lang = this.lang
|
||||
const valineOptions = {
|
||||
el: '#valine',
|
||||
placeholder: 'just go go',
|
||||
@ -47,7 +31,6 @@ export default {
|
||||
visitor: true,
|
||||
recordIP: false,
|
||||
path: window.location.pathname,
|
||||
lang,
|
||||
...this.options
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
{{ new Date().getFullYear() }}
|
||||
</a>
|
||||
</span>
|
||||
<span v-show="$themeConfig.valineConfig !== undefined">
|
||||
<span v-show="showAccessNumber">
|
||||
<i class="iconfont reco-eye"></i>
|
||||
<AccessNumber idVal="/" />
|
||||
</span>
|
||||
@ -36,6 +36,20 @@ export default {
|
||||
return {
|
||||
version
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
showAccessNumber () {
|
||||
const {
|
||||
$themeConfig: { valineConfig },
|
||||
$themeLocaleConfig: { valineConfig: valineLocalConfig }
|
||||
} = this
|
||||
|
||||
const vc = valineLocalConfig || valineConfig
|
||||
if (vc && vc.visitor != false) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -101,7 +101,16 @@ export default {
|
||||
return (showComment !== false && isShowComments !== false) || (showComment === false && isShowComments === true)
|
||||
},
|
||||
showAccessNumber () {
|
||||
return this.$themeConfig.valineConfig !== undefined
|
||||
const {
|
||||
$themeConfig: { valineConfig },
|
||||
$themeLocaleConfig: { valineConfig: valineLocalConfig }
|
||||
} = this
|
||||
|
||||
const vc = valineLocalConfig || valineConfig
|
||||
if (vc && vc.visitor != false) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
lastUpdated () {
|
||||
return this.$page.lastUpdated
|
||||
|
Loading…
Reference in New Issue
Block a user