Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/components/LanguageSwitcher.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<template>
<t-dropdown trigger="click">
<t-button theme="default" shape="square" variant="text">
<translate-icon />
</t-button>
<t-dropdown-menu>
<t-dropdown-item
v-for="(lang, index) in langList"
:key="index"
:value="lang.value"
@click="(options) => changeLang(options.value as string)"
>{{ lang.content }}</t-dropdown-item
></t-dropdown-menu
>
</t-dropdown>
</template>
<script setup lang="ts">
import { TranslateIcon } from 'tdesign-icons-vue-next';

import { langList } from '@/locales';
import { useLocale } from '@/locales/useLocale';

const { changeLocale } = useLocale();

const changeLang = (lang: string) => {
changeLocale(lang);
};
</script>
26 changes: 4 additions & 22 deletions src/layouts/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,7 @@
<t-icon name="help-circle" />
</t-button>
</t-tooltip>
<t-dropdown trigger="click">
<t-button theme="default" shape="square" variant="text">
<translate-icon />
</t-button>
<t-dropdown-menu>
<t-dropdown-item
v-for="(lang, index) in langList"
:key="index"
:value="lang.value"
@click="(options) => changeLang(options.value as string)"
>{{ lang.content }}</t-dropdown-item
></t-dropdown-menu
>
</t-dropdown>
<language-switcher />
<t-dropdown :min-column-width="120" trigger="click">
<template #dropdown>
<t-dropdown-item class="operations-dropdown-container-item" @click="handleNav('/user/index')">
Expand Down Expand Up @@ -75,15 +62,15 @@
</div>
</template>
<script setup lang="ts">
import { ChevronDownIcon, PoweroffIcon, SettingIcon, TranslateIcon, UserCircleIcon } from 'tdesign-icons-vue-next';
import { ChevronDownIcon, PoweroffIcon, SettingIcon, UserCircleIcon } from 'tdesign-icons-vue-next';
import type { PropType } from 'vue';
import { computed } from 'vue';
import { useRouter } from 'vue-router';

import LogoFull from '@/assets/assets-logo-full.svg?component';
import LanguageSwitcher from '@/components/LanguageSwitcher.vue';
import { prefix } from '@/config/global';
import { langList, t } from '@/locales';
import { useLocale } from '@/locales/useLocale';
import { t } from '@/locales';
import { getActive } from '@/router';
import { useSettingStore, useUserStore } from '@/store';
import type { MenuRoute, ModeType } from '@/types/interface';
Expand Down Expand Up @@ -150,11 +137,6 @@ const menuCls = computed(() => {
const menuTheme = computed(() => theme as ModeType);

// 切换语言
const { changeLocale } = useLocale();
const changeLang = (lang: string) => {
changeLocale(lang);
};

const changeCollapsed = () => {
settingStore.updateConfig({
isSidebarCompact: !settingStore.isSidebarCompact,
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/en_US/pages/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default {
wechatLogin: 'Login with WeChat',
accountLogin: 'Login with Account',
phoneLogin: 'Login with Mobile Phone',
loginSuccess: 'Login successful',
input: {
account: 'please enter account',
password: 'please enter password',
Expand Down
1 change: 1 addition & 0 deletions src/locales/lang/zh_CN/pages/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default {
wechatLogin: '使用微信扫一扫登录',
accountLogin: '使用账号登录',
phoneLogin: '使用手机号登录',
loginSuccess: '登录成功',
input: {
account: '请输入账号',
password: '请输入登录密码',
Expand Down
3 changes: 3 additions & 0 deletions src/pages/login/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<t-button theme="default" shape="square" variant="text" @click="navToHelper">
<t-icon name="help-circle" class="icon" />
</t-button>
<language-switcher />
<t-button theme="default" shape="square" variant="text" @click="toggleSettingPanel">
<t-icon name="setting" class="icon" />
</t-button>
Expand All @@ -16,9 +17,11 @@
</template>
<script setup lang="ts">
import LogoFullIcon from '@/assets/assets-logo-full.svg?component';
import LanguageSwitcher from '@/components/LanguageSwitcher.vue';
import { useSettingStore } from '@/store';

const settingStore = useSettingStore();

const toggleSettingPanel = () => {
settingStore.updateConfig({
showSettingPanel: true,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/login/components/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const onSubmit = async (ctx: SubmitContext) => {
try {
await userStore.login(formData.value);

MessagePlugin.success('登录成功');
MessagePlugin.success(t('pages.login.loginSuccess'));
const redirect = route.query.redirect as string;
const redirectUrl = redirect ? decodeURIComponent(redirect) : '/dashboard';
router.push(redirectUrl);
Expand Down