From e5f8ce3fd8ec25c6fdb122867cd33e4e84a6f43f Mon Sep 17 00:00:00 2001 From: vben Date: Wed, 25 Nov 2020 23:20:30 +0800 Subject: [PATCH] feat: multi-language layout --- mock/sys/user.ts | 2 +- src/components/Application/index.ts | 6 +- ...AppLocalPicker.vue => AppLocalePicker.vue} | 16 ++- src/components/Dropdown/src/Dropdown.tsx | 10 +- src/design/ant/index.less | 79 ++------------ src/design/ant/input.less | 15 --- src/design/color.less | 5 +- src/design/index.less | 17 +-- src/design/mixins.less | 10 +- src/design/public.less | 8 ++ src/design/reset.less | 103 ------------------ src/design/transition/base.less | 4 +- src/design/transition/fade.less | 2 +- src/design/var/index.less | 1 + src/hooks/setting/useLocaleSetting.ts | 12 +- src/hooks/web/useI18n.ts | 21 ++++ src/hooks/web/useLocale.ts | 7 -- src/layouts/default/footer/index.tsx | 7 +- src/layouts/default/header/LayoutHeader.tsx | 38 +++++-- src/layouts/default/header/UserDropdown.tsx | 17 ++- src/layouts/default/header/index.less | 11 ++ src/layouts/default/index.less | 3 +- src/layouts/default/lock/LockAction.tsx | 16 ++- src/layouts/default/multitabs/TabContent.tsx | 7 +- src/layouts/default/multitabs/data.ts | 16 ++- src/layouts/default/setting/SettingDrawer.tsx | 96 ++++++++-------- src/layouts/default/setting/enum.ts | 38 +++---- src/layouts/default/sider/index.tsx | 26 +++-- src/locales/lang/en/layout/footer.ts | 4 + src/locales/lang/en/layout/header.ts | 18 +++ src/locales/lang/en/layout/multipleTab.ts | 10 ++ src/locales/lang/en/layout/setting.ts | 73 +++++++++++++ src/locales/lang/zh_CN/layout/footer.ts | 4 + src/locales/lang/zh_CN/layout/header.ts | 19 ++++ src/locales/lang/zh_CN/layout/multipleTab.ts | 10 ++ src/locales/lang/zh_CN/layout/setting.ts | 72 ++++++++++++ src/settings/projectSetting.ts | 1 + src/types/config.d.ts | 1 + src/views/sys/error-log/DetailModal.vue | 6 +- src/views/sys/error-log/data.tsx | 15 ++- src/views/sys/error-log/index.vue | 6 +- src/views/sys/exception/Exception.tsx | 25 +++-- src/views/sys/lock/index.vue | 9 +- src/views/sys/login/Login.vue | 24 ++-- 44 files changed, 504 insertions(+), 386 deletions(-) rename src/components/Application/src/{AppLocalPicker.vue => AppLocalePicker.vue} (86%) delete mode 100644 src/design/reset.less create mode 100644 src/hooks/web/useI18n.ts create mode 100644 src/locales/lang/en/layout/footer.ts create mode 100644 src/locales/lang/en/layout/header.ts create mode 100644 src/locales/lang/en/layout/multipleTab.ts create mode 100644 src/locales/lang/en/layout/setting.ts create mode 100644 src/locales/lang/zh_CN/layout/footer.ts create mode 100644 src/locales/lang/zh_CN/layout/header.ts create mode 100644 src/locales/lang/zh_CN/layout/multipleTab.ts create mode 100644 src/locales/lang/zh_CN/layout/setting.ts diff --git a/mock/sys/user.ts b/mock/sys/user.ts index f89c0f13..fdf4ba33 100644 --- a/mock/sys/user.ts +++ b/mock/sys/user.ts @@ -6,7 +6,7 @@ function createFakeUserList() { { userId: '1', username: 'vben', - realName: 'Vben', + realName: 'Vben Admin', desc: 'manager', password: '123456', token: 'fakeToken1', diff --git a/src/components/Application/index.ts b/src/components/Application/index.ts index ee01d071..96205d7f 100644 --- a/src/components/Application/index.ts +++ b/src/components/Application/index.ts @@ -1,8 +1,8 @@ -import AppLocalPicker from './src/AppLocalPicker.vue'; +import AppLocalePicker from './src/AppLocalePicker.vue'; import AppPageFooter from './src/AppPageFooter.vue'; import AppLogo from './src/AppLogo.vue'; import { withInstall } from '../util'; -export { AppLocalPicker, AppPageFooter, AppLogo }; +export { AppLocalePicker, AppPageFooter, AppLogo }; -export default withInstall(AppLocalPicker, AppPageFooter, AppLogo); +export default withInstall(AppLocalePicker, AppPageFooter, AppLogo); diff --git a/src/components/Application/src/AppLocalPicker.vue b/src/components/Application/src/AppLocalePicker.vue similarity index 86% rename from src/components/Application/src/AppLocalPicker.vue rename to src/components/Application/src/AppLocalePicker.vue index b30472ef..397203d0 100644 --- a/src/components/Application/src/AppLocalPicker.vue +++ b/src/components/Application/src/AppLocalePicker.vue @@ -4,6 +4,7 @@ :dropMenuList="localeList" :selectedKeys="selectedKeys" @menuEvent="handleMenuEvent" + overlayClassName="app-locale-picker-overlay" > @@ -30,8 +31,12 @@ type: Boolean, default: true, }, + reload: { + type: Boolean, + default: false, + }, }, - setup() { + setup(props) { const { localeList } = useLocaleSetting(); const selectedKeys = ref([]); @@ -50,6 +55,7 @@ function toggleLocale(lang: LocaleType | string) { changeLocale(lang as LocaleType); selectedKeys.value = [lang as string]; + props.reload && location.reload(); } function handleMenuEvent(menu: DropMenu) { @@ -61,7 +67,13 @@ }); -