diff --git a/src/api/common/login.ts b/src/api/common/login.ts index f3e5c17..c9c1548 100644 --- a/src/api/common/login.ts +++ b/src/api/common/login.ts @@ -96,6 +96,11 @@ export const loginByPassword = (data: LoginByPasswordDTO) => { return http.request>("post", "/auth/login", { data }); }; +/** 登出接口 */ +export const userLogout = () => { + return http.request>("post", "/auth/logout"); +}; + /** 获取当前登录用户接口 */ export const getLoginUserInfo = () => { return http.request>("get", "/getLoginUserInfo"); diff --git a/src/api/system/config.ts b/src/api/system/config.ts index f21e0da..4d7469f 100644 --- a/src/api/system/config.ts +++ b/src/api/system/config.ts @@ -39,13 +39,9 @@ export interface UpdateConfigRequest { /** 获取配置列表 */ export const getConfigListApi = (params?: ConfigQuery) => { - return http.request>>( - "get", - "/system/configs", - { - params - } - ); + return http.request>("get", "/system/configs", { + params + }); }; /** 获取配置信息 */ diff --git a/src/api/system/monitor.ts b/src/api/system/monitor.ts index 53ddfd8..796f820 100644 --- a/src/api/system/monitor.ts +++ b/src/api/system/monitor.ts @@ -18,13 +18,9 @@ export interface OnlineUserInfo { /** 获取操作日志列表 */ export const getOnlineUserListApi = (params?: OnlineUserQuery) => { - return http.request>>( - "get", - "/monitor/onlineUsers", - { - params - } - ); + return http.request>("get", "/monitor/onlineUsers", { + params + }); }; /** 强制登出用户 */ diff --git a/src/api/system/notice.ts b/src/api/system/notice.ts index 62931e4..c81ea4f 100644 --- a/src/api/system/notice.ts +++ b/src/api/system/notice.ts @@ -26,13 +26,9 @@ export type SystemNoticeRequest = { /** 获取系统通知列表 */ export const getSystemNoticeListApi = (params?: SystemNoticeQuery) => { - return http.request>>( - "get", - "/system/notices", - { - params - } - ); + return http.request>("get", "/system/notices", { + params + }); }; /** 添加系统通知 */ diff --git a/src/api/system/role.ts b/src/api/system/role.ts index 41771a9..05fa5c2 100644 --- a/src/api/system/role.ts +++ b/src/api/system/role.ts @@ -21,13 +21,9 @@ export interface RoleDTO { } export function getRoleListApi(params: RoleQuery) { - return http.request>>( - "get", - "/system/role/list", - { - params - } - ); + return http.request>("get", "/system/role/list", { + params + }); } export function getRoleInfoApi(roleId: number) { diff --git a/src/api/system/user.ts b/src/api/system/user.ts index aeaaf59..c0125a7 100644 --- a/src/api/system/user.ts +++ b/src/api/system/user.ts @@ -86,7 +86,7 @@ export interface PasswordRequest { /** 获取用户列表 */ export const getUserListApi = (params?: UserQuery) => { - return http.request>>("get", "/system/users", { + return http.request>("get", "/system/users", { params }); }; diff --git a/src/utils/auth.ts b/src/utils/auth.ts index 422f54d..fb4b971 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -40,8 +40,8 @@ export function setTokenFromBackend(data: TokenDTO): void { const cookieString = JSON.stringify(data); Cookies.set(tokenKey, cookieString); - // useUserStoreHook().SET_USERNAME(data.currentUser.userInfo.username); - // useUserStoreHook().SET_ROLES([data.currentUser.roleKey]); + useUserStoreHook().SET_USERNAME(data.currentUser.userInfo.username); + useUserStoreHook().SET_ROLES([data.currentUser.roleKey]); storageSession().setItem(sessionKey, data); } diff --git a/src/views/system/config/utils/hook.tsx b/src/views/system/config/utils/hook.tsx index 7b726a9..bfe5b85 100644 --- a/src/views/system/config/utils/hook.tsx +++ b/src/views/system/config/utils/hook.tsx @@ -101,14 +101,14 @@ export function useHook() { CommonUtils.fillPaginationParams(searchFormParams, pagination); pageLoading.value = true; - const { data } = await getConfigListApi(toRaw(searchFormParams)).finally( - () => { - pageLoading.value = false; - } - ); + const { rows, total } = await getConfigListApi( + toRaw(searchFormParams) + ).finally(() => { + pageLoading.value = false; + }); - dataList.value = data.rows; - pagination.total = data.total; + dataList.value = rows; + pagination.total = total; } async function handleRefresh() { diff --git a/src/views/system/monitor/onlineUser/utils/hook.tsx b/src/views/system/monitor/onlineUser/utils/hook.tsx index 103517e..dc4609e 100644 --- a/src/views/system/monitor/onlineUser/utils/hook.tsx +++ b/src/views/system/monitor/onlineUser/utils/hook.tsx @@ -86,14 +86,14 @@ export function useHook() { pageLoading.value = true; - const { data } = await getOnlineUserListApi( + const { rows } = await getOnlineUserListApi( toRaw(searchFormParams) ).finally(() => { pageLoading.value = false; }); - originalDataList = data.rows; - pagination.total = data.rows.length; + originalDataList = rows; + pagination.total = rows.length; getList(); } diff --git a/src/views/system/notice/utils/hook.tsx b/src/views/system/notice/utils/hook.tsx index 7518ae1..50a3130 100644 --- a/src/views/system/notice/utils/hook.tsx +++ b/src/views/system/notice/utils/hook.tsx @@ -153,14 +153,14 @@ export function useNoticeHook() { CommonUtils.fillPaginationParams(searchFormParams, pagination); pageLoading.value = true; - const { data } = await getSystemNoticeListApi( + const { rows, total } = await getSystemNoticeListApi( toRaw(searchFormParams) ).finally(() => { pageLoading.value = false; }); - dataList.value = data.rows; - pagination.total = data.total; + dataList.value = rows; + pagination.total = total; } async function handleDelete(row) { diff --git a/src/views/system/role/utils/hook.tsx b/src/views/system/role/utils/hook.tsx index 280ad5b..1a8dd61 100644 --- a/src/views/system/role/utils/hook.tsx +++ b/src/views/system/role/utils/hook.tsx @@ -151,10 +151,10 @@ export function useRole() { async function onSearch() { try { loading.value = true; - const { data } = await getRoleListApi(toRaw(form)); - console.log("role list", data); - dataList.value = data.rows; - pagination.total = data.total; + const { rows, total } = await getRoleListApi(toRaw(form)); + console.log("role list", rows); + dataList.value = rows; + pagination.total = total; } catch (e) { console.error(e); ElMessage.error((e as Error)?.message || "加载失败"); diff --git a/src/views/system/user/hook.tsx b/src/views/system/user/hook.tsx index 11461fc..2b14729 100644 --- a/src/views/system/user/hook.tsx +++ b/src/views/system/user/hook.tsx @@ -338,14 +338,14 @@ export function useHook() { CommonUtils.fillTimeRangeParams(searchFormParams, timeRange.value); pageLoading.value = true; - const { data } = await getUserListApi(toRaw(searchFormParams)).finally( - () => { - pageLoading.value = false; - } - ); + const { rows, total } = await getUserListApi( + toRaw(searchFormParams) + ).finally(() => { + pageLoading.value = false; + }); - dataList.value = data.rows; - pagination.total = data.total; + dataList.value = rows; + pagination.total = total; } const resetForm = formEl => { @@ -366,7 +366,7 @@ export function useHook() { postOptions.value = postResponse.data.rows; const roleResponse = await getRoleListApi({}); - roleOptions.value = roleResponse.data.rows; + roleOptions.value = roleResponse.rows; }); return {