Skip to content

Commit

Permalink
refactor: 优化登录和菜单加载相关提示
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Sep 19, 2023
1 parent 90d825a commit d080120
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions continew-admin-ui/src/hooks/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { Message } from '@arco-design/web-vue';
import { Notification } from '@arco-design/web-vue';

import { useLoginStore } from '@/store';

Expand All @@ -11,7 +11,7 @@ export default function useUser() {
const logout = async (logoutTo?: string) => {
await loginStore.logout();
const currentRoute = router.currentRoute.value;
Message.success(t('login.form.logout.success'));
Notification.success(t('login.form.logout.success'));
router.push({
name: logoutTo && typeof logoutTo === 'string' ? logoutTo : 'login',
query: {
Expand Down
25 changes: 15 additions & 10 deletions continew-admin-ui/src/store/modules/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { defineStore } from 'pinia';
import { Notification } from '@arco-design/web-vue';
import type { NotificationReturn } from '@arco-design/web-vue/es/notification/interface';
import { h } from 'vue';
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 defaultSettings from '@/config/settings.json';
import { listRoute } from '@/api/auth/login';
Expand Down Expand Up @@ -66,26 +71,26 @@ const useAppStore = defineStore('app', {
this.hideMenu = value;
},
async fetchServerMenuConfig() {
let notifyInstance: NotificationReturn | null = null;
let messageInstance: MessageReturn | null = null;
try {
notifyInstance = Notification.info({
messageInstance = Message.loading({
id: 'menuNotice', // Keep the instance id the same
content: '菜单加载中...',
closable: true,
content: '菜单加载中',
});
const { data } = await listRoute();
this.serverMenu = data;
notifyInstance = Notification.success({
messageInstance = Message.success({
id: 'menuNotice',
content: '菜单加载成功',
closable: true,
duration: 1000,
icon: () => h(IconCheckCircleFill),
});
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
notifyInstance = Notification.error({
messageInstance = Message.error({
id: 'menuNotice',
content: '菜单加载失败',
closable: true,
icon: () => h(IconCloseCircleFill),
});
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
const { rememberMe } = loginConfig.value;
const { username } = values;
loginConfig.value.username = rememberMe ? username : '';
proxy.$message.success(t('login.form.login.success'));
proxy.$notification.success(t('login.form.login.success'));
})
.catch(() => {
getCaptcha();
Expand Down

0 comments on commit d080120

Please sign in to comment.