From bbe37c04dc112ccb6794dc95338e3c65ad2ac7ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com>
Date: Thu, 5 May 2022 18:39:22 +0800
Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=A0=E5=A4=9A=E8=AF=AD?=
=?UTF-8?q?=E8=A8=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
package.json | 1 +
src/App.vue | 39 +++++++++++-
src/components/LangSelect/index.vue | 40 ++++++++++++
src/components/SizeSelect/index.vue | 6 +-
src/i18n/index.js | 25 ++++++++
src/i18n/lang/en.js | 64 ++++++++++++++++++++
src/i18n/lang/zh-cn.js | 64 ++++++++++++++++++++
src/i18n/lang/zh-tw.js | 64 ++++++++++++++++++++
src/i18n/pages/login/en.js | 10 +++
src/i18n/pages/login/zh-cn.js | 10 +++
src/i18n/pages/login/zh-tw.js | 10 +++
src/layout/components/Navbar.vue | 15 +++--
src/layout/components/Settings/index.vue | 22 +++----
src/layout/components/TagsView/index.vue | 12 ++--
src/main.js | 7 ++-
src/store/getters.js | 1 +
src/store/modules/app.js | 14 ++++-
src/views/index.vue | 77 +++++++++---------------
src/views/login.vue | 32 +++++-----
vite.config.js | 20 +++---
20 files changed, 428 insertions(+), 105 deletions(-)
create mode 100644 src/components/LangSelect/index.vue
create mode 100644 src/i18n/index.js
create mode 100644 src/i18n/lang/en.js
create mode 100644 src/i18n/lang/zh-cn.js
create mode 100644 src/i18n/lang/zh-tw.js
create mode 100644 src/i18n/pages/login/en.js
create mode 100644 src/i18n/pages/login/zh-cn.js
create mode 100644 src/i18n/pages/login/zh-tw.js
diff --git a/package.json b/package.json
index ab24bdd..77f7c23 100644
--- a/package.json
+++ b/package.json
@@ -32,6 +32,7 @@
"sortablejs": "^1.15.0",
"vue": "3.2.26",
"vue-cropper": "1.0.2",
+ "vue-i18n": "^9.1.10",
"vue-router": "4.0.12",
"vue3-seamless-scroll": "^1.2.0",
"vuex": "4.0.2",
diff --git a/src/App.vue b/src/App.vue
index 2fec866..b203b80 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,12 +1,30 @@
-
+
+
+
diff --git a/src/components/LangSelect/index.vue b/src/components/LangSelect/index.vue
new file mode 100644
index 0000000..87d2b72
--- /dev/null
+++ b/src/components/LangSelect/index.vue
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+ {{ item.label }}
+
+
+
+
+
+
+
+
+
+
diff --git a/src/components/SizeSelect/index.vue b/src/components/SizeSelect/index.vue
index de13e6d..2fd737a 100644
--- a/src/components/SizeSelect/index.vue
+++ b/src/components/SizeSelect/index.vue
@@ -20,9 +20,9 @@ const route = useRoute()
const router = useRouter()
const { proxy } = getCurrentInstance()
const sizeOptions = ref([
- { label: '较大', value: 'large' },
- { label: '默认', value: 'default' },
- { label: '稍小', value: 'small' },
+ { label: proxy.$t('layout.large'), value: 'large' },
+ { label: proxy.$t('layout.default'), value: 'default' },
+ { label: proxy.$t('layout.small'), value: 'small' },
])
function refreshView() {
diff --git a/src/i18n/index.js b/src/i18n/index.js
new file mode 100644
index 0000000..fd08727
--- /dev/null
+++ b/src/i18n/index.js
@@ -0,0 +1,25 @@
+import { createI18n } from 'vue-i18n';
+import store from '@/store/index';
+
+import zhCn from './lang/zh-cn';
+import en from './lang/en';
+import zhTw from './lang/zh-tw';
+
+import pageLoginCn from './pages/login/zh-cn'
+import pageLoginEn from './pages/login/en'
+import pageLoginTw from './pages/login/zh-tw'
+
+const i18n = createI18n({
+ // 全局注入 $t 函数
+ globalInjection: true,
+ fallbackLocale: 'zh-cn',
+ locale: store.getters.language, //默认选择的语言
+ legacy: false, // 使用 Composition API 模式,则需要将其设置为false
+ messages: {
+ 'zh-cn': { ...zhCn, ...pageLoginCn },
+ 'zh-tw': { ...zhTw, ...pageLoginTw },
+ 'en': { ...en, ...pageLoginEn }
+ }
+})
+
+export default i18n;
\ No newline at end of file
diff --git a/src/i18n/lang/en.js b/src/i18n/lang/en.js
new file mode 100644
index 0000000..e06a6d3
--- /dev/null
+++ b/src/i18n/lang/en.js
@@ -0,0 +1,64 @@
+// 定义内容
+export default {
+ menu: {
+ home: 'home',
+ system: 'system',
+ systemMenu: 'systemMenu',
+ systemRole: 'systemRole',
+ systemUser: 'systemUser',
+ systemDept: 'systemDept',
+ systemDic: 'systemDic',
+ limits: 'limits',
+ },
+ tagsView: {
+ refresh: 'refresh',
+ close: 'close',
+ closeOther: 'closeOther',
+ closeLeft: 'closeLeft',
+ closeRight: 'closeRight',
+ closeAll: 'closeAll',
+ fullscreen: 'fullscreen',
+ closeFullscreen: 'closeFullscreen',
+ },
+ layout: {
+ tip1: 'If you feel good, welcome to ⭐ Star ⭐ Collect it so that the author can continue to be free. Thank you!',
+ contactUs: 'contact us',
+ donationSupport: 'donation support',
+ officialWebsite: 'Official website',
+ qqGroup: 'QQ Group',
+ changeLog: 'change log',
+ currentVersion: 'current version',
+ codeSourceAddress: 'source address',
+ fullscreen: 'fullscreen',
+ sizeSelect: 'size',
+ personalCenter: 'Personal center',
+ layoutSetting: 'layout setting',
+ logOut: 'Login out',
+ themeStyleSet: 'theme style settings',
+ themeColor: 'theme color',
+ sysLayoutSet: 'system layout settings',
+ open: 'open',
+ fixed: 'fixed',
+ show: 'show',
+ dynamicTitle: 'dynamic title',
+ darkMode: 'dark mode',
+ saveConfig: 'save',
+ resetConfig: 'reset',
+ logOutConfirm: 'Are you sure you want to exit the current login?',
+ large: 'Large',
+ default: 'Default',
+ small: 'Small'
+ },
+ common: {
+ ok: 'Ok',
+ cancel: 'Cancel',
+ tips: 'tips'
+ },
+ btn: {
+ add: 'Add',
+ delete: 'Delete',
+ edit: 'Edit',
+ search: 'Search',
+ reset: 'Reset',
+ }
+};
\ No newline at end of file
diff --git a/src/i18n/lang/zh-cn.js b/src/i18n/lang/zh-cn.js
new file mode 100644
index 0000000..711a2c6
--- /dev/null
+++ b/src/i18n/lang/zh-cn.js
@@ -0,0 +1,64 @@
+// 定义内容
+export default {
+ menu: {
+ home: '首页',
+ system: '系统设置',
+ systemMenu: '菜单管理',
+ systemRole: '角色管理',
+ systemUser: '用户管理',
+ systemDept: '部门管理',
+ systemDic: '字典管理',
+ limits: '权限管理',
+ },
+ tagsView: {
+ refresh: '刷新页面',
+ close: '关闭当前',
+ closeOther: '关闭其它',
+ closeLeft: '关闭左侧',
+ closeRight: '关闭右侧',
+ closeAll: '全部关闭',
+ fullscreen: '当前页全屏',
+ closeFullscreen: '关闭全屏',
+ },
+ layout: {
+ tip1: '如果觉得不错欢迎给个⭐Star⭐收藏一下,这样作者才有继续免费下去的动力,谢谢!',
+ contactUs: '联系信息',
+ donationSupport: '捐贈支持',
+ officialWebsite: '官网',
+ qqGroup: 'QQ群',
+ changeLog: '更新日志',
+ currentVersion: '当前版本',
+ codeSourceAddress: '源码地址',
+ fullscreen: '全屏',
+ sizeSelect: '大小设置',
+ personalCenter: '个人中心',
+ layoutSetting: '布局设置',
+ logOut: '退出登录',
+ themeStyleSet: '主题风格设置',
+ themeColor: '主题颜色',
+ sysLayoutSet: '系统风格设置',
+ open: '开启',
+ fixed: '固定',
+ show: '显示',
+ dynamicTitle: '动态标题',
+ darkMode: '深色模式',
+ saveConfig: '保存配置',
+ resetConfig: '重置配置',
+ logOutConfirm: '你確定要退出当前登录吗?',
+ large: '较大',
+ default: '默认',
+ small: '较小'
+ },
+ common: {
+ ok: '确定',
+ cancel: '取消',
+ tips: '提示'
+ },
+ btn: {
+ add: '新增',
+ delete: '删除',
+ edit: '编辑',
+ search: '搜索',
+ reset: '重置',
+ }
+};
\ No newline at end of file
diff --git a/src/i18n/lang/zh-tw.js b/src/i18n/lang/zh-tw.js
new file mode 100644
index 0000000..c46364f
--- /dev/null
+++ b/src/i18n/lang/zh-tw.js
@@ -0,0 +1,64 @@
+// 定义内容
+export default {
+ menu: {
+ home: '首頁',
+ system: '系統設置',
+ systemMenu: '選單管理',
+ systemRole: '角色管理',
+ systemUser: '用戶管理',
+ systemDept: '部門管理',
+ systemDic: '字典管理',
+ limits: '許可權管理',
+ },
+ tagsView: {
+ refresh: '重繪',
+ close: '關閉',
+ closeOther: '關閉其它',
+ closeLeft: '關閉左侧',
+ closeRight: '關閉右侧',
+ closeAll: '全部關閉',
+ fullscreen: '當前頁全屏',
+ closeFullscreen: '關閉全屏',
+ },
+ layout: {
+ tip1: '如果覺得不錯歡迎給個⭐Star⭐收藏壹下,這樣作者才有繼續免費下去的動力,謝謝!',
+ contactUs: '聯繫信息',
+ donationSupport: '捐贈支持',
+ officialWebsite: '官網',
+ qqGroup: 'QQ群',
+ changeLog: '更新日誌',
+ currentVersion: '當前版本',
+ codeSourceAddress: '源碼地址',
+ fullscreen: '全屏',
+ sizeSelect: '大小設置',
+ personalCenter: '個人中心',
+ layoutSetting: '佈局設置',
+ logOut: '退出登錄',
+ themeStyleSet: '主題風格設置',
+ themeColor: '主題顏色',
+ sysLayoutSet: '系統風格設置',
+ open: '開啟',
+ fixed: '固定',
+ show: '顯示',
+ dynamicTitle: '動態標題',
+ darkMode: '深色模式',
+ saveConfig: '保存配置',
+ resetConfig: '重置配置',
+ logOutConfirm: '你確定要退出当前登录吗?',
+ large: '較大',
+ default: '默認',
+ small: '較小'
+ },
+ common: {
+ ok: '確定',
+ cancel: '取消',
+ tips: '提示'
+ },
+ btn: {
+ add: '新增',
+ delete: '刪除',
+ edit: '編輯',
+ search: '搜索',
+ reset: '重置',
+ }
+};
\ No newline at end of file
diff --git a/src/i18n/pages/login/en.js b/src/i18n/pages/login/en.js
new file mode 100644
index 0000000..2f8c943
--- /dev/null
+++ b/src/i18n/pages/login/en.js
@@ -0,0 +1,10 @@
+export default {
+ login: {
+ account: 'ID',
+ password: 'Password',
+ captcha: 'Captcha',
+ btnLogin: 'Login',
+ rememberMe: 'Remember Me',
+ loginSuccess: 'login success'
+ }
+}
\ No newline at end of file
diff --git a/src/i18n/pages/login/zh-cn.js b/src/i18n/pages/login/zh-cn.js
new file mode 100644
index 0000000..346ff3c
--- /dev/null
+++ b/src/i18n/pages/login/zh-cn.js
@@ -0,0 +1,10 @@
+export default {
+ login: {
+ account: '账号',
+ password: '密码',
+ captcha: '验证码',
+ btnLogin: '登录',
+ rememberMe: '记住密码',
+ loginSuccess: '登录成功'
+ }
+}
\ No newline at end of file
diff --git a/src/i18n/pages/login/zh-tw.js b/src/i18n/pages/login/zh-tw.js
new file mode 100644
index 0000000..33eaab0
--- /dev/null
+++ b/src/i18n/pages/login/zh-tw.js
@@ -0,0 +1,10 @@
+export default {
+ login: {
+ account: '賬號',
+ password: '密碼',
+ captcha: '驗證碼',
+ btnLogin: '登錄',
+ rememberMe: '記住密碼',
+ loginSuccess: '登錄成功'
+ }
+}
\ No newline at end of file
diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index 3a06c83..1363ebd 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -11,6 +11,7 @@
+
@@ -23,13 +24,13 @@
- 个人中心
+ {{ $t('layout.personalCenter') }}
- 布局设置
+ {{ $t('layout.layoutSetting') }}
- 退出登录
+ {{ $t('layout.logOut') }}
@@ -49,7 +50,9 @@ import HeaderSearch from '@/components/HeaderSearch'
import ZrGit from '@/components/Zr/Git'
import ZrDoc from '@/components/Zr/Doc'
import Notice from '@/components/Notice/Index'
+import LangSelect from '@/components/LangSelect/index'
+const { proxy } = getCurrentInstance()
const store = useStore()
const getters = computed(() => store.getters)
const sideTheme = computed(() => store.state.settings.sideTheme)
@@ -71,9 +74,9 @@ function handleCommand(command) {
}
function logout() {
- ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
+ ElMessageBox.confirm(proxy.$t('layout.logOutConfirm'), proxy.$t('common.tips'), {
+ confirmButtonText: proxy.$t('common.ok'),
+ cancelButtonText: proxy.$t('common.cancel'),
type: 'warning',
})
.then(() => {
diff --git a/src/layout/components/Settings/index.vue b/src/layout/components/Settings/index.vue
index fb5a2e5..8416639 100644
--- a/src/layout/components/Settings/index.vue
+++ b/src/layout/components/Settings/index.vue
@@ -1,7 +1,7 @@
-
主题风格设置
+ {{ $t('layout.themeStyleSet') }}
@@ -21,48 +21,48 @@
- 深色模式
+ {{ $t('layout.darkMode') }}
- 主题颜色
+ {{ $t('layout.themeColor') }}
- 系统布局配置
+ {{ $t('layout.sysLayoutSet') }}
- 开启 TopNav
+ {{ $t('layout.open') }} TopNav
- 开启 Tags-Views
+ {{ $t('layout.open') }} Tags-Views
- 固定 Header
+ {{ $t('layout.fixed') }} Header
- 显示 Logo
+ {{ $t('layout.show') }} Logo
- 动态标题
+ {{ $t('layout.dynamicTitle') }}
@@ -70,8 +70,8 @@
- 保存配置
- 重置配置
+ {{ $t('layout.saveConfig') }}
+ {{ $t('layout.resetConfig') }}
diff --git a/src/layout/components/TagsView/index.vue b/src/layout/components/TagsView/index.vue
index 1d643bc..9c073af 100644
--- a/src/layout/components/TagsView/index.vue
+++ b/src/layout/components/TagsView/index.vue
@@ -19,12 +19,12 @@
diff --git a/src/main.js b/src/main.js
index fc9d8c0..b0ae4af 100644
--- a/src/main.js
+++ b/src/main.js
@@ -2,7 +2,7 @@ import { createApp } from 'vue'
import Cookies from 'js-cookie'
import ElementPlus from 'element-plus'
-import locale from 'element-plus/lib/locale/lang/zh-cn' // 中文语言
+import elZhCn from 'element-plus/lib/locale/lang/zh-cn' // 中文语言
import 'dayjs/locale/zh-cn'
import '@/assets/styles/index.scss' // global css
@@ -14,6 +14,7 @@ import directive from './directive' // directive
import plugins from './plugins' // plugins
// import { download } from '@/utils/request'
import signalR from '@/utils/signalR'
+import vueI18n from './i18n/index'
// svg图标
import 'virtual:svg-icons-register'
@@ -69,12 +70,12 @@ app.use(router)
app.use(store)
app.use(plugins)
app.use(elementIcons)
+app.use(vueI18n)
directive(app)
-
// 使用element-plus 并且设置全局的大小
app.use(ElementPlus, {
- locale: locale,
+ // locale: elZhCn,
// 支持 large、default、small
size: Cookies.get('size') || 'small'
})
diff --git a/src/store/getters.js b/src/store/getters.js
index 52841cf..762a9fb 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -2,6 +2,7 @@ const getters = {
sidebar: state => state.app.sidebar,
size: state => state.app.size,
device: state => state.app.device,
+ language: state => state.app.lang,
visitedViews: state => state.tagsView.visitedViews,
cachedViews: state => state.tagsView.cachedViews,
token: state => state.user.token,
diff --git a/src/store/modules/app.js b/src/store/modules/app.js
index 8c0dbae..8cad3dc 100644
--- a/src/store/modules/app.js
+++ b/src/store/modules/app.js
@@ -7,7 +7,8 @@ const state = {
hide: false
},
device: 'desktop',
- size: Cookies.get('size') || 'default'
+ size: Cookies.get('size') || 'default',
+ lang: Cookies.get('lang') || 'zh-cn'
}
const mutations = {
@@ -37,7 +38,11 @@ const mutations = {
},
SET_SIDEBAR_HIDE: (state, status) => {
state.sidebar.hide = status
- }
+ },
+ SET_LANG: (state, lang) => {
+ state.lang = lang
+ Cookies.set('lang', lang)
+ },
}
const actions = {
@@ -55,7 +60,10 @@ const actions = {
},
toggleSideBarHide({ commit }, status) {
commit('SET_SIDEBAR_HIDE', status)
- }
+ },
+ setLang({ commit }, lang) {
+ commit('SET_LANG', lang)
+ },
}
export default {
diff --git a/src/views/index.vue b/src/views/index.vue
index cfe814a..5df9c79 100644
--- a/src/views/index.vue
+++ b/src/views/index.vue
@@ -5,22 +5,16 @@
领取七牛云通用云产品优惠券
-
- https://s.qiniu.com/FzEfay
-
+ https://s.qiniu.com/FzEfay
领取腾讯云通用云产品新用户专属大礼包2860优惠券,每种代金券限量500张,先到先得。
-
- https://curl.qcloud.com/5J4nag8D
-
+ https://curl.qcloud.com/5J4nag8D
腾讯云限时秒杀活动
-
- https://curl.qcloud.com/4yEoRquq
-
+ https://curl.qcloud.com/4yEoRquq
华为特惠专区,多款产品限时特价
@@ -44,37 +38,17 @@
代码完全免费开源,易读易懂、界面简洁美观,给你的项目多一种选择与参考。
- 当前版本: v{{ version }}
- 更新日志
+ {{ $t('layout.currentVersion') }}: v{{ version }}
+ {{ $t('layout.changeLog') }}
- 访问码云
-
- Github
-
+ 访问码云
+ Github
- 如果觉得不错欢迎给个⭐Star⭐收藏一下,这样作者才有继续免费下去的动力,谢谢!
+ {{ $t('layout.tip1') }}
技术选型
@@ -88,6 +62,8 @@
MySql
Mapster
Epplus
+ Redis
+ Signalr
...
@@ -100,8 +76,9 @@
Axios
Sass
Wangeditor
- Vite
- Composition api
+ Vite
+ Composition api
+ I18n
...
@@ -112,11 +89,22 @@
- 联系信息
+ {{ $t('layout.donationSupport') }}
+
+
+
打赏作者喝杯咖啡表示鼓励
+

+
+
+
+
+
+
+ {{ $t('layout.contactUs') }}
- 官网:
+ {{ $t('layout.officialWebsite') }}:
http://www.izhaorui.cn/doc
@@ -133,17 +121,6 @@
-
-
-
- 捐赠支持
-
-
-
打赏作者喝杯咖啡表示鼓励
-

-
-
-
+
+