|
1 |
| -<template> |
2 |
| - <a-dropdown :trigger="['click']"> |
3 |
| - <a class="ant-dropdown-link" @click="e => e.preventDefault()" :style="{ color: titleColor, fontSize: titleSize }"> {{ i18n.languageName }}<DownOutlined /></a> |
4 |
| - <template v-slot:overlay> |
5 |
| - <a-menu class="dropdown-panel"> |
6 |
| - <a-menu-item v-for="(value, key) of LanguageNameList" :key="key" @click="changeLanguage"> |
7 |
| - <span :style="{ color: textColor }">{{ LanguageNameList[key] }}</span> |
8 |
| - </a-menu-item> |
9 |
| - </a-menu> |
10 |
| - </template> |
11 |
| - </a-dropdown> |
12 |
| -</template> |
13 |
| - |
14 |
| -<script> |
15 |
| -import { defineComponent } from 'vue' |
16 |
| -import { setLang, i18nInstance, LanguageNameList } from '../i18n/index' |
17 |
| -import { message } from 'ant-design-vue' |
18 |
| -import { DownOutlined } from '@ant-design/icons-vue' |
19 |
| -
|
20 |
| -export default defineComponent({ |
21 |
| - props: { |
22 |
| - titleColor: { |
23 |
| - type: String, |
24 |
| - default: '#fff' |
25 |
| - }, |
26 |
| - textColor: { |
27 |
| - type: String, |
28 |
| - default: '#fff' |
29 |
| - }, |
30 |
| - titleSize: { |
31 |
| - type: String, |
32 |
| - default: '16px' |
33 |
| - } |
34 |
| - }, |
35 |
| - components: { |
36 |
| - DownOutlined |
37 |
| - }, |
38 |
| - setup() { |
39 |
| - const { i18n } = i18nInstance |
40 |
| - const changeLanguage = e => { |
41 |
| - const lang = e.key |
42 |
| - setLang(lang).then(result => { |
43 |
| - if (result === lang) { |
44 |
| - message.success(`${i18n.value['Current Language:']} ${i18n.value.languageName}`) |
45 |
| - } |
46 |
| - }) |
47 |
| - } |
48 |
| - return { |
49 |
| - LanguageNameList, |
50 |
| - changeLanguage, |
51 |
| - i18n |
52 |
| - } |
53 |
| - } |
54 |
| -}) |
55 |
| -</script> |
56 |
| - |
57 |
| -<style lang="less" scoped> |
58 |
| -.dropdown-panel { |
59 |
| - background: rgba(255, 255, 255, 0.3); |
60 |
| - margin-top: 10px; |
61 |
| - /deep/ .ant-dropdown-menu-item-active { |
62 |
| - background: transparent; |
63 |
| - transform: translateX(2px); |
64 |
| - transition: all 0.2s ease-in-out; |
65 |
| - } |
66 |
| -} |
67 |
| -.dropdown-panel::before { |
68 |
| - content: ''; |
69 |
| - display: block; |
70 |
| - border: 10px solid transparent; |
71 |
| - border-bottom-color: rgba(255, 255, 255, 0.3); |
72 |
| - position: absolute; |
73 |
| - top: -20px; |
74 |
| - left: 50%; |
75 |
| - transform: translateX(-50%); |
76 |
| -} |
77 |
| -</style> |
| 1 | +<template> |
| 2 | + <a-dropdown :trigger="['click']"> |
| 3 | + <a class="ant-dropdown-link" @click="e => e.preventDefault()" :style="{ color: titleColor, fontSize: titleSize }"> {{ i18n.languageName }}<DownOutlined /></a> |
| 4 | + <template v-slot:overlay> |
| 5 | + <a-menu class="dropdown-panel"> |
| 6 | + <a-menu-item v-for="(value, key) of LanguageNameList" :key="key" @click="changeLanguage"> |
| 7 | + <span :style="{ color: textColor }">{{ LanguageNameList[key] }}</span> |
| 8 | + </a-menu-item> |
| 9 | + </a-menu> |
| 10 | + </template> |
| 11 | + </a-dropdown> |
| 12 | +</template> |
| 13 | + |
| 14 | +<script> |
| 15 | +import { defineComponent } from 'vue' |
| 16 | +import { setLang, i18nInstance, LanguageNameList } from '../i18n/index' |
| 17 | +import { message } from 'ant-design-vue' |
| 18 | +import { DownOutlined } from '@ant-design/icons-vue' |
| 19 | +
|
| 20 | +export default defineComponent({ |
| 21 | + props: { |
| 22 | + titleColor: { |
| 23 | + type: String, |
| 24 | + default: '#fff' |
| 25 | + }, |
| 26 | + textColor: { |
| 27 | + type: String, |
| 28 | + default: '#fff' |
| 29 | + }, |
| 30 | + titleSize: { |
| 31 | + type: String, |
| 32 | + default: '16px' |
| 33 | + } |
| 34 | + }, |
| 35 | + components: { |
| 36 | + DownOutlined |
| 37 | + }, |
| 38 | + setup() { |
| 39 | + const { i18n } = i18nInstance |
| 40 | + const changeLanguage = e => { |
| 41 | + const lang = e.key |
| 42 | + setLang(lang).then(result => { |
| 43 | + if (result === lang) { |
| 44 | + message.success(`${i18n.value['Current Language:']} ${i18n.value.languageName}`) |
| 45 | + } |
| 46 | + }) |
| 47 | + } |
| 48 | + return { |
| 49 | + LanguageNameList, |
| 50 | + changeLanguage, |
| 51 | + i18n |
| 52 | + } |
| 53 | + } |
| 54 | +}) |
| 55 | +</script> |
| 56 | + |
| 57 | +<style lang="less" scoped> |
| 58 | +.dropdown-panel { |
| 59 | + background: rgba(255, 255, 255, 0.3); |
| 60 | + margin-top: 10px; |
| 61 | + /deep/ .ant-dropdown-menu-item-active { |
| 62 | + background: transparent; |
| 63 | + transform: translateX(2px); |
| 64 | + transition: all 0.2s ease-in-out; |
| 65 | + } |
| 66 | +} |
| 67 | +.dropdown-panel::before { |
| 68 | + content: ''; |
| 69 | + display: block; |
| 70 | + border: 10px solid transparent; |
| 71 | + border-bottom-color: rgba(255, 255, 255, 0.3); |
| 72 | + position: absolute; |
| 73 | + top: -20px; |
| 74 | + left: 50%; |
| 75 | + transform: translateX(-50%); |
| 76 | +} |
| 77 | +</style> |
0 commit comments