System log management adapts to sqlite
This commit is contained in:
1
src/global.d.ts
vendored
1
src/global.d.ts
vendored
@@ -204,7 +204,6 @@ interface UserChangePasswordParam {
|
|||||||
|
|
||||||
interface SysLogGetParam extends PageParam {
|
interface SysLogGetParam extends PageParam {
|
||||||
searchRequestUrl?: string
|
searchRequestUrl?: string
|
||||||
searchRegex?: boolean
|
|
||||||
searchStartTime?: string
|
searchStartTime?: string
|
||||||
searchEndTime?: string
|
searchEndTime?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import {
|
import { COLOR_FONT_SECONDARY, DATABASE_SELECT_SUCCESS } from '@/constants/common.constants'
|
||||||
COLOR_ERROR_SECONDARY,
|
|
||||||
COLOR_FONT_SECONDARY,
|
|
||||||
DATABASE_SELECT_SUCCESS
|
|
||||||
} from '@/constants/common.constants'
|
|
||||||
import { useUpdatedEffect } from '@/util/hooks'
|
import { useUpdatedEffect } from '@/util/hooks'
|
||||||
import { dayjsToUtc, utcToLocalTime } from '@/util/datetime'
|
import { dayjsToUtc, utcToLocalTime } from '@/util/datetime'
|
||||||
import { r_sys_log_get } from '@/services/system'
|
import { r_sys_log_get } from '@/services/system'
|
||||||
@@ -28,8 +24,6 @@ const Log: React.FC = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
const [searchRequestUrl, setSearchRequestUrl] = useState('')
|
const [searchRequestUrl, setSearchRequestUrl] = useState('')
|
||||||
const [useRegex, setUseRegex] = useState(false)
|
|
||||||
const [isRegexLegal, setIsRegexLegal] = useState(true)
|
|
||||||
const [timeRange, setTimeRange] = useState<[string, string]>()
|
const [timeRange, setTimeRange] = useState<[string, string]>()
|
||||||
|
|
||||||
const dataColumns: _ColumnsType<SysLogGetVo> = [
|
const dataColumns: _ColumnsType<SysLogGetVo> = [
|
||||||
@@ -163,17 +157,6 @@ const Log: React.FC = () => {
|
|||||||
|
|
||||||
const handleOnSearchUrlChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleOnSearchUrlChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setSearchRequestUrl(e.target.value)
|
setSearchRequestUrl(e.target.value)
|
||||||
|
|
||||||
if (useRegex) {
|
|
||||||
try {
|
|
||||||
RegExp(e.target.value)
|
|
||||||
setIsRegexLegal(!(e.target.value.includes('{}') || e.target.value.includes('[]')))
|
|
||||||
} catch (e) {
|
|
||||||
setIsRegexLegal(false)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setIsRegexLegal(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleOnSearchUrlKeyDown = (e: React.KeyboardEvent) => {
|
const handleOnSearchUrlKeyDown = (e: React.KeyboardEvent) => {
|
||||||
@@ -182,22 +165,6 @@ const Log: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleOnUseRegexChange = (e: _CheckboxChangeEvent) => {
|
|
||||||
setUseRegex(e.target.checked)
|
|
||||||
if (e.target.checked) {
|
|
||||||
try {
|
|
||||||
RegExp(searchRequestUrl)
|
|
||||||
setIsRegexLegal(
|
|
||||||
!(searchRequestUrl.includes('{}') || searchRequestUrl.includes('[]'))
|
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
setIsRegexLegal(false)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setIsRegexLegal(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleOnDateRangeChange = (dates: [dayjs.Dayjs | null, dayjs.Dayjs | null] | null) => {
|
const handleOnDateRangeChange = (dates: [dayjs.Dayjs | null, dayjs.Dayjs | null] | null) => {
|
||||||
if (dates && dates[0] && dates[1]) {
|
if (dates && dates[0] && dates[1]) {
|
||||||
setTimeRange([dayjsToUtc(dates[0]), dayjsToUtc(dates[1])])
|
setTimeRange([dayjsToUtc(dates[0]), dayjsToUtc(dates[1])])
|
||||||
@@ -215,11 +182,6 @@ const Log: React.FC = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isRegexLegal) {
|
|
||||||
void message.error('非法正则表达式')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
void r_sys_log_get({
|
void r_sys_log_get({
|
||||||
@@ -232,7 +194,6 @@ const Log: React.FC = () => {
|
|||||||
sortOrder:
|
sortOrder:
|
||||||
tableParams.sortField && tableParams.sortOrder ? tableParams.sortOrder : undefined,
|
tableParams.sortField && tableParams.sortOrder ? tableParams.sortOrder : undefined,
|
||||||
searchRequestUrl: searchRequestUrl.trim().length ? searchRequestUrl : undefined,
|
searchRequestUrl: searchRequestUrl.trim().length ? searchRequestUrl : undefined,
|
||||||
searchRegex: useRegex ? useRegex : undefined,
|
|
||||||
searchStartTime: timeRange && timeRange[0],
|
searchStartTime: timeRange && timeRange[0],
|
||||||
searchEndTime: timeRange && timeRange[1],
|
searchEndTime: timeRange && timeRange[1],
|
||||||
...tableParams.filters
|
...tableParams.filters
|
||||||
@@ -282,21 +243,10 @@ const Log: React.FC = () => {
|
|||||||
请求 Url
|
请求 Url
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
suffix={
|
|
||||||
<>
|
|
||||||
{!isRegexLegal ? (
|
|
||||||
<span style={{ color: COLOR_ERROR_SECONDARY }}>非法表达式</span>
|
|
||||||
) : undefined}
|
|
||||||
<AntdCheckbox checked={useRegex} onChange={handleOnUseRegexChange}>
|
|
||||||
<AntdTooltip title={'正则表达式'}>.*</AntdTooltip>
|
|
||||||
</AntdCheckbox>
|
|
||||||
</>
|
|
||||||
}
|
|
||||||
allowClear
|
allowClear
|
||||||
value={searchRequestUrl}
|
value={searchRequestUrl}
|
||||||
onChange={handleOnSearchUrlChange}
|
onChange={handleOnSearchUrlChange}
|
||||||
onKeyDown={handleOnSearchUrlKeyDown}
|
onKeyDown={handleOnSearchUrlKeyDown}
|
||||||
status={isRegexLegal ? undefined : 'error'}
|
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
<Card style={{ overflow: 'inherit', flex: '0 0 auto' }}>
|
<Card style={{ overflow: 'inherit', flex: '0 0 auto' }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user