diff --git a/src/api/LogApi.ts b/src/api/LogApi.ts index 59c7381..c8e0ae7 100644 --- a/src/api/LogApi.ts +++ b/src/api/LogApi.ts @@ -5,10 +5,16 @@ const LogUriBase = '/api/log'; export interface Record { id: number; + faceName: string; eventType: string; + subEventType: string; + uri: string; + method: string; + parameters: string; + requestSuccess: boolean; + userName: string; fromUserId: number; mobile: string; - userName: string; createDateTime: string; } diff --git a/src/api/UserApi.ts b/src/api/UserApi.ts index b3f09c4..5d1ce10 100644 --- a/src/api/UserApi.ts +++ b/src/api/UserApi.ts @@ -72,3 +72,46 @@ export async function pageQuery( }); return response.data; } + +/** + * 用户登出 + */ +export async function logout(): Promise { + const response = await api.post(`${UserUriBase}/logout`); + return response.data; +} + +interface tokenInfo { + token: string; + remainingSecond: number; +} + +/** + * 刷新token + */ +export async function refreshToken(): Promise { + const response = await api.post(`${UserUriBase}/refresh/token`); + return response.data; +} + +export interface role { + id: number; + name: string; + roleConfig: { + lineId: number; + lineType: string; + }; +} +interface userInfo { + remainingSecond: number; + roles: role[]; + defaultRole: string; +} + +/** + * 获取用户信息 + */ +export async function getUserInfo(): Promise { + const response = await api.post(`${UserUriBase}/info`); + return response.data; +} diff --git a/src/layouts/MainLayout.vue b/src/layouts/MainLayout.vue index f35de31..f676b83 100644 --- a/src/layouts/MainLayout.vue +++ b/src/layouts/MainLayout.vue @@ -124,6 +124,8 @@ import { webSocketConnect, closeWebSocketConnect, } from 'src/components/webSocketConnect'; +import { logout } from 'src/api/UserApi'; +import { ApiError } from 'src/boot/axios'; const leftDrawerOpen = ref(false); const router = useRouter(); @@ -210,9 +212,18 @@ function logOut() { message: '确认是否登出?', cancel: true, persistent: true, - }).onOk(() => { - clearJwtToken(); - router.push({ name: 'login' }); + }).onOk(async () => { + try { + await logout(); + clearJwtToken(); + router.push({ name: 'login' }); + } catch (err) { + const apiErr = err as ApiError; + $q.notify({ + type: 'negative', + message: apiErr.title, + }); + } }); } diff --git a/src/pages/LoginRecord.vue b/src/pages/LoginRecord.vue index e7a312b..c3a6d48 100644 --- a/src/pages/LoginRecord.vue +++ b/src/pages/LoginRecord.vue @@ -2,7 +2,7 @@
+