From 20184c6e01e62e8682d2bbf6843420b4cbc03ea9 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Tue, 9 Apr 2024 21:34:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=AE=A1=E7=90=86=EF=BC=88=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E3=80=81=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/index.ts | 2 + src/apis/system/index.ts | 1 + src/apis/system/log.ts | 14 ++ src/apis/system/type.ts | 33 +++++ src/utils/http.ts | 14 +- src/views/system/log/LoginLog.vue | 115 +++++++++++++++ src/views/system/log/OperationLog.vue | 136 ++++++++++++++++++ .../system/log/OperationLogDetailDrawer.vue | 127 ++++++++++++++++ src/views/system/log/index.vue | 48 +++++++ 9 files changed, 487 insertions(+), 3 deletions(-) create mode 100644 src/apis/system/index.ts create mode 100644 src/apis/system/log.ts create mode 100644 src/apis/system/type.ts create mode 100644 src/views/system/log/LoginLog.vue create mode 100644 src/views/system/log/OperationLog.vue create mode 100644 src/views/system/log/OperationLogDetailDrawer.vue create mode 100644 src/views/system/log/index.vue diff --git a/src/apis/index.ts b/src/apis/index.ts index 8cb69aa..a3a8862 100644 --- a/src/apis/index.ts +++ b/src/apis/index.ts @@ -2,9 +2,11 @@ export * from './area' export * from './auth' export * from './common' export * from './monitor' +export * from './system' export * from './area/type' export * from './auth/type' export * from './common/type' export * from './monitor/type' +export * from './system/type' diff --git a/src/apis/system/index.ts b/src/apis/system/index.ts new file mode 100644 index 0000000..1f9f80b --- /dev/null +++ b/src/apis/system/index.ts @@ -0,0 +1 @@ +export * from './log' diff --git a/src/apis/system/log.ts b/src/apis/system/log.ts new file mode 100644 index 0000000..fa0e248 --- /dev/null +++ b/src/apis/system/log.ts @@ -0,0 +1,14 @@ +import http from '@/utils/http' +import type * as System from './type' + +const BASE_URL = '/system/log' + +/** @desc 查询日志列表 */ +export function listLog(query: System.LogQuery) { + return http.get>(`${BASE_URL}`, query) +} + +/** @desc 查询日志详情 */ +export function getLog(id: string) { + return http.get(`${BASE_URL}/${id}`) +} diff --git a/src/apis/system/type.ts b/src/apis/system/type.ts new file mode 100644 index 0000000..536c2f8 --- /dev/null +++ b/src/apis/system/type.ts @@ -0,0 +1,33 @@ +/** 系统日志类型 */ +export interface LogResp { + id: string + description: string + module: string + timeTaken: number + ip: string + address: string + browser: string + os: string + status: number + errorMsg: string + createUserString: string + createTime: string +} +export interface LogDetailResp extends LogResp { + traceId: string + requestUrl: string + requestMethod: string + requestHeaders: string + requestBody: string + statusCode: number + responseHeaders: string + responseBody: string +} +export interface LogQuery extends PageQuery { + description?: string + module?: string + ip?: string + createUserString?: string + createTime?: string + status?: number +} diff --git a/src/utils/http.ts b/src/utils/http.ts index cecbd8a..dc7c2ac 100644 --- a/src/utils/http.ts +++ b/src/utils/http.ts @@ -1,4 +1,5 @@ import axios from 'axios' +import qs from 'query-string' import type { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios' import { useUserStore } from '@/stores' import { getToken } from '@/utils/auth' @@ -8,7 +9,6 @@ import notificationErrorWrapper from '@/utils/notification-error-wrapper' import NProgress from 'nprogress' import 'nprogress/nprogress.css' import router from '@/router' -import qs from 'query-string' NProgress.configure({ showSpinner: false }) // NProgress Configuration @@ -114,7 +114,15 @@ const request = (config: AxiosRequestConfig): Promise> => http .request(config) .then((res: AxiosResponse) => resolve(res.data)) - .catch((err: { message: string }) => reject(err)) + .catch((err: { msg: string }) => reject(err)) + }) +} + +const requestNative = (config: AxiosRequestConfig): Promise => { + return new Promise((resolve, reject) => { + http + .request(config) + .catch((err: { msg: string }) => reject(err)) }) } @@ -166,4 +174,4 @@ const del = (url: string, params?: object, config?: AxiosRequestConfig) }) } -export default { get, post, put, patch, del } +export default { get, post, put, patch, del, request, requestNative } diff --git a/src/views/system/log/LoginLog.vue b/src/views/system/log/LoginLog.vue new file mode 100644 index 0000000..175dbea --- /dev/null +++ b/src/views/system/log/LoginLog.vue @@ -0,0 +1,115 @@ + + + + + diff --git a/src/views/system/log/OperationLog.vue b/src/views/system/log/OperationLog.vue new file mode 100644 index 0000000..9d15370 --- /dev/null +++ b/src/views/system/log/OperationLog.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/src/views/system/log/OperationLogDetailDrawer.vue b/src/views/system/log/OperationLogDetailDrawer.vue new file mode 100644 index 0000000..e3e9fb0 --- /dev/null +++ b/src/views/system/log/OperationLogDetailDrawer.vue @@ -0,0 +1,127 @@ + + + + + diff --git a/src/views/system/log/index.vue b/src/views/system/log/index.vue new file mode 100644 index 0000000..2bcc576 --- /dev/null +++ b/src/views/system/log/index.vue @@ -0,0 +1,48 @@ + + + + +