refactor: 优化登录和菜单加载相关提示
This commit is contained in:
parent
90d825a02f
commit
d080120d42
@ -1,6 +1,6 @@
|
|||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { Message } from '@arco-design/web-vue';
|
import { Notification } from '@arco-design/web-vue';
|
||||||
|
|
||||||
import { useLoginStore } from '@/store';
|
import { useLoginStore } from '@/store';
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ export default function useUser() {
|
|||||||
const logout = async (logoutTo?: string) => {
|
const logout = async (logoutTo?: string) => {
|
||||||
await loginStore.logout();
|
await loginStore.logout();
|
||||||
const currentRoute = router.currentRoute.value;
|
const currentRoute = router.currentRoute.value;
|
||||||
Message.success(t('login.form.logout.success'));
|
Notification.success(t('login.form.logout.success'));
|
||||||
router.push({
|
router.push({
|
||||||
name: logoutTo && typeof logoutTo === 'string' ? logoutTo : 'login',
|
name: logoutTo && typeof logoutTo === 'string' ? logoutTo : 'login',
|
||||||
query: {
|
query: {
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { Notification } from '@arco-design/web-vue';
|
import { h } from 'vue';
|
||||||
import type { NotificationReturn } from '@arco-design/web-vue/es/notification/interface';
|
import { Message } from '@arco-design/web-vue';
|
||||||
|
import {
|
||||||
|
IconCheckCircleFill,
|
||||||
|
IconCloseCircleFill,
|
||||||
|
} from '@arco-design/web-vue/es/icon';
|
||||||
|
import type { MessageReturn } from '@arco-design/web-vue/es/message/interface';
|
||||||
import type { RouteRecordNormalized } from 'vue-router';
|
import type { RouteRecordNormalized } from 'vue-router';
|
||||||
import defaultSettings from '@/config/settings.json';
|
import defaultSettings from '@/config/settings.json';
|
||||||
import { listRoute } from '@/api/auth/login';
|
import { listRoute } from '@/api/auth/login';
|
||||||
@ -66,26 +71,26 @@ const useAppStore = defineStore('app', {
|
|||||||
this.hideMenu = value;
|
this.hideMenu = value;
|
||||||
},
|
},
|
||||||
async fetchServerMenuConfig() {
|
async fetchServerMenuConfig() {
|
||||||
let notifyInstance: NotificationReturn | null = null;
|
let messageInstance: MessageReturn | null = null;
|
||||||
try {
|
try {
|
||||||
notifyInstance = Notification.info({
|
messageInstance = Message.loading({
|
||||||
id: 'menuNotice', // Keep the instance id the same
|
id: 'menuNotice', // Keep the instance id the same
|
||||||
content: '菜单加载中...',
|
content: '菜单加载中',
|
||||||
closable: true,
|
|
||||||
});
|
});
|
||||||
const { data } = await listRoute();
|
const { data } = await listRoute();
|
||||||
this.serverMenu = data;
|
this.serverMenu = data;
|
||||||
notifyInstance = Notification.success({
|
messageInstance = Message.success({
|
||||||
id: 'menuNotice',
|
id: 'menuNotice',
|
||||||
content: '菜单加载成功',
|
content: '菜单加载成功',
|
||||||
closable: true,
|
duration: 1000,
|
||||||
|
icon: () => h(IconCheckCircleFill),
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
notifyInstance = Notification.error({
|
messageInstance = Message.error({
|
||||||
id: 'menuNotice',
|
id: 'menuNotice',
|
||||||
content: '菜单加载失败',
|
content: '菜单加载失败',
|
||||||
closable: true,
|
icon: () => h(IconCloseCircleFill),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -160,7 +160,7 @@
|
|||||||
const { rememberMe } = loginConfig.value;
|
const { rememberMe } = loginConfig.value;
|
||||||
const { username } = values;
|
const { username } = values;
|
||||||
loginConfig.value.username = rememberMe ? username : '';
|
loginConfig.value.username = rememberMe ? username : '';
|
||||||
proxy.$message.success(t('login.form.login.success'));
|
proxy.$notification.success(t('login.form.login.success'));
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
getCaptcha();
|
getCaptcha();
|
||||||
|
Loading…
Reference in New Issue
Block a user