Просмотр исходного кода

fix(log): 对普通用户隐藏 Chat ID 和 Upstream ID

后端 GetUserLogs 返回前清空 chat_id/upstream_id(omitempty 不输出),
前端搜索框和展开行详情加 isAdminUser 守卫。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
master
fengsilin 4 дней назад
Родитель
Сommit
e1b6aff7e1
3 измененных файлов: 24 добавлений и 20 удалений
  1. +4
    -0
      controller/log.go
  2. +18
    -18
      web/src/components/table/usage-logs/UsageLogsFilters.jsx
  3. +2
    -2
      web/src/hooks/usage-logs/useUsageLogsData.jsx

+ 4
- 0
controller/log.go Просмотреть файл

@@ -51,6 +51,10 @@ func GetUserLogs(c *gin.Context) {
common.ApiError(c, err)
return
}
for i := range logs {
logs[i].ChatId = ""
logs[i].UpstreamId = ""
}
pageInfo.SetTotal(int(total))
pageInfo.SetItems(logs)
common.ApiSuccess(c, pageInfo)


+ 18
- 18
web/src/components/table/usage-logs/UsageLogsFilters.jsx Просмотреть файл

@@ -102,26 +102,26 @@ const LogsFilters = ({
size='small'
/>

<Form.Input
field='chat_id'
prefix={<IconSearch />}
placeholder={t('Chat ID')}
showClear
pure
size='small'
/>

<Form.Input
field='upstream_id'
prefix={<IconSearch />}
placeholder={t('Upstream ID')}
showClear
pure
size='small'
/>

{isAdminUser && (
<>
<Form.Input
field='chat_id'
prefix={<IconSearch />}
placeholder={t('Chat ID')}
showClear
pure
size='small'
/>

<Form.Input
field='upstream_id'
prefix={<IconSearch />}
placeholder={t('Upstream ID')}
showClear
pure
size='small'
/>

<Form.Input
field='channel'
prefix={<IconSearch />}


+ 2
- 2
web/src/hooks/usage-logs/useUsageLogsData.jsx Просмотреть файл

@@ -369,13 +369,13 @@ export const useLogsData = () => {
value: logs[i].request_id,
});
}
if (logs[i].chat_id) {
if (isAdminUser && logs[i].chat_id) {
expandDataLocal.push({
key: t('Chat ID'),
value: logs[i].chat_id,
});
}
if (logs[i].upstream_id) {
if (isAdminUser && logs[i].upstream_id) {
expandDataLocal.push({
key: t('Upstream ID'),
value: logs[i].upstream_id,


Загрузка…
Отмена
Сохранить