diff --git a/frontend/src/api/logs.js b/frontend/src/api/logs.js index efaa370..8ea1049 100644 --- a/frontend/src/api/logs.js +++ b/frontend/src/api/logs.js @@ -60,7 +60,7 @@ export const getLogOtherTableListApi = (params) => { } //获取外部日志表信息 export const getLogOtherTableInfoApi = (params) => { - return post(`/api/log/other/table`, params) + return get(`/api/log/other/table`, params) } //新增外部日志表信息 export const addLogOtherTableApi = (params) => { diff --git a/frontend/src/views/logs/component/FullLogs/component/ConfigLogRuleModal/index.jsx b/frontend/src/views/logs/component/FullLogs/component/ConfigLogRuleModal/index.jsx index efdddc3..7be0530 100644 --- a/frontend/src/views/logs/component/FullLogs/component/ConfigLogRuleModal/index.jsx +++ b/frontend/src/views/logs/component/FullLogs/component/ConfigLogRuleModal/index.jsx @@ -99,7 +99,6 @@ const ConfigLogRuleModal = ({ modalVisible, closeModal, logRuleInfo }) => { .validateFields({}) .then(() => { const formState = form.getFieldsValue(true) - // console.log(formState) const logRuleParams = { ...formState, } @@ -133,7 +132,14 @@ const ConfigLogRuleModal = ({ modalVisible, closeModal, logRuleInfo }) => { let result = form.getFieldValue('routeRule') || [] Object.entries(res?.routeRule)?.forEach(([key, value]) => { - if (result) + // 检查当前 result 中是否已经存在该 key + const existingIndex = result.findIndex((item) => item?.key?.key === key) + + if (existingIndex > -1) { + // 如果已存在,替换对应的 value + result[existingIndex].value = value + } else { + // 如果不存在,则新增项 result.push({ key: { key: key, @@ -142,8 +148,13 @@ const ConfigLogRuleModal = ({ modalVisible, closeModal, logRuleInfo }) => { }, value: value, }) + } }) + + // 过滤掉无效项 result = result.filter((item) => item?.key && item.value) + + // 更新表单值 form.setFieldValue('routeRule', result) }) } @@ -194,6 +205,7 @@ const ConfigLogRuleModal = ({ modalVisible, closeModal, logRuleInfo }) => { @@ -204,7 +216,7 @@ const ConfigLogRuleModal = ({ modalVisible, closeModal, logRuleInfo }) => {
解析规则 - 用于将日志文本解析为独立的字段,加快检索速度。请使用 + 点击规则查询对应服务的日志。请使用 VRL diff --git a/frontend/src/views/logs/component/FullLogs/component/SerarchBar/RawLogQuery/FullTextSearch/index.jsx b/frontend/src/views/logs/component/FullLogs/component/SerarchBar/RawLogQuery/FullTextSearch/index.jsx index 4b4a578..8020c2f 100644 --- a/frontend/src/views/logs/component/FullLogs/component/SerarchBar/RawLogQuery/FullTextSearch/index.jsx +++ b/frontend/src/views/logs/component/FullLogs/component/SerarchBar/RawLogQuery/FullTextSearch/index.jsx @@ -1,9 +1,7 @@ import { Button, Col, Form, Input, Popover, Row } from 'antd' import React, { useEffect, useState } from 'react' -import { useLogsContext } from 'src/contexts/LogsContext' -const FullTextSearch = () => { - const { query, updateQuery } = useLogsContext() +const FullTextSearch = ({ searchValue, setSearchValue }) => { const [form] = Form.useForm() const [open, setOpen] = useState(false) @@ -18,12 +16,12 @@ const FullTextSearch = () => { const clickSubmit = () => { form.validateFields().then(() => { const formState = form.getFieldsValue(true) - let newQuery = query + let newQuery = searchValue if (newQuery.length > 0) { newQuery += ' AND ' } - newQuery += '`' + formState.key + '` like ' + `'` + formState.value + `'` - updateQuery(newQuery) + newQuery += '`' + formState.key + '` LIKE ' + `'%` + formState.value + `%'` + setSearchValue(newQuery) hide() }) } diff --git a/frontend/src/views/logs/component/FullLogs/component/SerarchBar/RawLogQuery/index.jsx b/frontend/src/views/logs/component/FullLogs/component/SerarchBar/RawLogQuery/index.jsx index ebc68d2..531208c 100644 --- a/frontend/src/views/logs/component/FullLogs/component/SerarchBar/RawLogQuery/index.jsx +++ b/frontend/src/views/logs/component/FullLogs/component/SerarchBar/RawLogQuery/index.jsx @@ -8,8 +8,9 @@ import { useLogsContext } from 'src/contexts/LogsContext' import { ISOToTimestamp } from 'src/utils/time' import { useSearchParams } from 'react-router-dom' import FullTextSearch from './FullTextSearch' +import { LuRefreshCw } from 'react-icons/lu' const RawLogQuery = () => { - const { query, updateQuery, fetchData } = useLogsContext() + const { query, updateQuery, getLogTableInfo } = useLogsContext() // 分析字段的代码提示 const [analysisFieldTips, setAnalysisFieldTips] = useState([]) // 输入框自动填充历史记录 @@ -30,10 +31,15 @@ const RawLogQuery = () => { setSearchValue(query) }, [query]) + const clickFullTextSearch = (value) => { + setSearchValue(value) + updateQuery(value) + } + return ( <>
- +
{ icon={} onClick={() => updateQuery(queryKeyword)} > + {/* */}
)