feat: 国际化

This commit is contained in:
baiqi 2023-06-25 15:59:45 +08:00 committed by 刘瑞斌
parent 6378e1ea30
commit 13087a37fe
4 changed files with 14 additions and 6 deletions

View File

@ -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',

View File

@ -1,7 +1,9 @@
export default {
// 消息提醒相关
'message.errorTip': '错误提示',
'message.logouting': '正在退出登录...',
'message.logoutSuccess': '登出成功',
'message.loadingDefaultTip': '加载中...',
'message.menuLoading': '菜单加载中...',
'message.menuLoadSuccess': '菜单加载成功',
'message.menuLoadError': '菜单加载失败',

View File

@ -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');
},
},
});

View File

@ -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();