| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <script setup lang="ts">
- import { computed, ref } from 'vue';
- import { loadLocaleMessages } from '@vben/locales';
- import { preferences, updatePreferences } from '@vben/preferences';
- import { Dropdown } from 'antdv-next';
- const items = [
- {
- key: 'en-US',
- label: 'English',
- },
- {
- key: 'zh-CN',
- label: '中文',
- },
- ];
- const show = ref(false);
- const currentLabel = computed(() => {
- const selected = items.find((item) => item.key === preferences.app.locale);
- return selected?.label ?? 'Language';
- });
- const onOpenChange = (open: boolean) => {
- show.value = open;
- };
- const onMenuClick = (info: any) => {
- if (preferences.app.locale === info.key) {
- return;
- }
- updatePreferences({
- app: {
- locale: info.key,
- },
- });
- loadLocaleMessages(info.key);
- };
- </script>
- <template>
- <Dropdown
- :menu="{ items }"
- placement="bottom"
- @menu-click="onMenuClick"
- @open-change="onOpenChange"
- >
- <div class="flex cursor-pointer items-center gap-2">
- <img
- alt="earth"
- height="20px"
- src="@/assets/image/earth_18301626@2x.png"
- width="20px"
- />
- <span>{{ currentLabel }}</span>
- <img
- :class="show ? 'rotate-180' : ''"
- alt="polygon"
- height="6px"
- src="@/assets/image/Polygon 2.png"
- width="7px"
- />
- </div>
- </Dropdown>
- </template>
- <style scoped></style>
|