index.vue
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<template>
<el-dropdown
placement="bottom"
size="small"
@command="onChangeLocale">
<el-button
class="d2-mr btn-text can-hover"
type="text">
<d2-icon
name="language"
style="font-size: 16px;" />
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
v-for="(language, index) in $languages"
:key="index"
:command="language.value">
<d2-icon
:name="$i18n.locale === language.value ? 'dot-circle-o' : 'circle-o'"
class="d2-mr-5" />
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
<script>
export default {
methods: {
onChangeLocale(command) {
this.$i18n.locale = command
let message = `当前语言:${this.$t('_name')} [ ${this.$i18n.locale} ]`
if (!['TRAVIS', 'NETLIFY'].includes(process.env.VUE_APP_BUILD_MODE)) {
message = [
`当前语言:${this.$t('_name')} [ ${this.$i18n.locale} ]`,
'仅提供切换功能,没有配置具体的语言数据 ',
'文档参考:<a class="el-link el-link--primary is-underline" target="_blank" href="https://doc.d2admin.fairyever.com/zh/sys-locales/">《国际化 | D2Admin》</a>'
].join('<br/>')
}
this.$notify({
title: '语言变更',
dangerouslyUseHTMLString: true,
message
})
}
}
}
</script>