feat: 国际化
This commit is contained in:
parent
6378e1ea30
commit
13087a37fe
|
@ -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',
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
export default {
|
||||
// 消息提醒相关
|
||||
'message.errorTip': '错误提示',
|
||||
'message.logouting': '正在退出登录...',
|
||||
'message.logoutSuccess': '登出成功',
|
||||
'message.loadingDefaultTip': '加载中...',
|
||||
'message.menuLoading': '菜单加载中...',
|
||||
'message.menuLoadSuccess': '菜单加载成功',
|
||||
'message.menuLoadError': '菜单加载失败',
|
||||
|
|
|
@ -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');
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue