From 13087a37fee324d77a7db3d5d7db391e344e0d32 Mon Sep 17 00:00:00 2001 From: baiqi Date: Sun, 25 Jun 2023 15:59:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/locale/en-US/sys.ts | 2 ++ frontend/src/locale/zh-CN/sys.ts | 2 ++ frontend/src/store/modules/app/index.ts | 8 +++++--- frontend/src/store/modules/user/index.ts | 8 +++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/src/locale/en-US/sys.ts b/frontend/src/locale/en-US/sys.ts index cf4dd1d564..7b51da253d 100644 --- a/frontend/src/locale/en-US/sys.ts +++ b/frontend/src/locale/en-US/sys.ts @@ -1,7 +1,9 @@ export default { // 消息提醒相关 'message.errorTip': 'Error Tip', + 'message.logouting': 'Logging out...', 'message.logoutSuccess': 'Logout success', + 'message.loadingDefaultTip': 'Loading...', 'message.menuLoading': 'Loading the menu...', 'message.menuLoadSuccess': 'Menu loaded successfully', 'message.menuLoadError': 'Menu load failed', diff --git a/frontend/src/locale/zh-CN/sys.ts b/frontend/src/locale/zh-CN/sys.ts index 2f3a1c220c..08859168b3 100644 --- a/frontend/src/locale/zh-CN/sys.ts +++ b/frontend/src/locale/zh-CN/sys.ts @@ -1,7 +1,9 @@ export default { // 消息提醒相关 'message.errorTip': '错误提示', + 'message.logouting': '正在退出登录...', 'message.logoutSuccess': '登出成功', + 'message.loadingDefaultTip': '加载中...', 'message.menuLoading': '菜单加载中...', 'message.menuLoadSuccess': '菜单加载成功', 'message.menuLoadError': '菜单加载失败', diff --git a/frontend/src/store/modules/app/index.ts b/frontend/src/store/modules/app/index.ts index 7844da7053..73eefaad98 100644 --- a/frontend/src/store/modules/app/index.ts +++ b/frontend/src/store/modules/app/index.ts @@ -89,16 +89,18 @@ const useAppStore = defineStore('app', { /** * 显示全局 loading */ - showLoading(tip = '加载中...') { + showLoading(tip = '') { + const { t } = useI18n(); this.loading = true; - this.loadingTip = tip; + this.loadingTip = tip || t('message.loadingDefaultTip'); }, /** * 隐藏全局 loading */ hideLoading() { + const { t } = useI18n(); this.loading = false; - this.loadingTip = '加载中...'; + this.loadingTip = t('message.loadingDefaultTip'); }, }, }); diff --git a/frontend/src/store/modules/user/index.ts b/frontend/src/store/modules/user/index.ts index f774ef9bf6..6985477acd 100644 --- a/frontend/src/store/modules/user/index.ts +++ b/frontend/src/store/modules/user/index.ts @@ -2,10 +2,11 @@ import { defineStore } from 'pinia'; import { login as userLogin, logout as userLogout, getUserInfo } from '@/api/modules/user'; import { setToken, clearToken } from '@/utils/auth'; import { removeRouteListener } from '@/utils/route-listener'; +import useAppStore from '../app'; +import { useI18n } from '@/hooks/useI18n'; import type { LoginData } from '@/models/user'; -import { UserState } from './types'; -import useAppStore from '../app'; +import type { UserState } from './types'; const useUserStore = defineStore('user', { state: (): UserState => ({ @@ -79,8 +80,9 @@ const useUserStore = defineStore('user', { // 登出 async logout() { try { + const { t } = useI18n(); const appStore = useAppStore(); - appStore.showLoading('正在退出登录...'); + appStore.showLoading(t('message.logouting')); await userLogout(); } finally { this.logoutCallBack();