Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
dd9ddbe7
authored
Jan 21, 2025
by
Calcium-Ion
Committed by
GitHub
Jan 21, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #699 from detecti1/feat/show-log-with-channel-name
Feat: 日志查询增加渠道名称显示
parents
57d867f0
37226d65
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
model/log.go
+9
-0
web/src/components/LogsTable.js
+15
-3
No files found.
model/log.go
View file @
dd9ddbe7
...
...
@@ -27,6 +27,7 @@ type Log struct {
UseTime
int
`json:"use_time" gorm:"default:0"`
IsStream
bool
`json:"is_stream" gorm:"default:false"`
ChannelId
int
`json:"channel" gorm:"index"`
ChannelName
string
`json:"channel_name" gorm:"->"`
TokenId
int
`json:"token_id" gorm:"default:0;index"`
Group
string
`json:"group" gorm:"index"`
Other
string
`json:"other"`
...
...
@@ -130,6 +131,10 @@ func GetAllLogs(logType int, startTimestamp int64, endTimestamp int64, modelName
}
else
{
tx
=
LOG_DB
.
Where
(
"type = ?"
,
logType
)
}
tx
=
tx
.
Joins
(
"LEFT JOIN channels ON logs.channel_id = channels.id"
)
tx
=
tx
.
Select
(
"logs.*, channels.name as channel_name"
)
if
modelName
!=
""
{
tx
=
tx
.
Where
(
"model_name like ?"
,
modelName
)
}
...
...
@@ -169,6 +174,10 @@ func GetUserLogs(userId int, logType int, startTimestamp int64, endTimestamp int
}
else
{
tx
=
LOG_DB
.
Where
(
"user_id = ? and type = ?"
,
userId
,
logType
)
}
tx
=
tx
.
Joins
(
"LEFT JOIN channels ON logs.channel_id = channels.id"
)
tx
=
tx
.
Select
(
"logs.*, channels.name as channel_name"
)
if
modelName
!=
""
{
tx
=
tx
.
Where
(
"model_name like ?"
,
modelName
)
}
...
...
web/src/components/LogsTable.js
View file @
dd9ddbe7
...
...
@@ -157,6 +157,7 @@ const LogsTable = () => {
record
.
type
===
0
||
record
.
type
===
2
?
(
<
div
>
{
<
Tooltip
content
=
{
record
.
channel_name
||
'[未知]'
}
>
<
Tag
color
=
{
colors
[
parseInt
(
text
)
%
colors
.
length
]}
size
=
'large'
...
...
@@ -164,6 +165,7 @@ const LogsTable = () => {
{
' '
}
{
text
}{
' '
}
<
/Tag
>
<
/Tooltip
>
}
<
/div
>
)
:
(
...
...
@@ -234,7 +236,12 @@ const LogsTable = () => {
<
/
>
);
}
else
{
let
other
=
JSON
.
parse
(
record
.
other
);
let
other
=
null
;
try
{
other
=
JSON
.
parse
(
record
.
other
);
}
catch
(
e
)
{
console
.
error
(
`Failed to parse record.other: "
${
record
.
other
}
".`
,
e
);
}
if
(
other
===
null
)
{
return
<><
/>
;
}
...
...
@@ -544,6 +551,12 @@ const LogsTable = () => {
// value: content,
// })
}
if
(
isAdminUser
&&
(
logs
[
i
].
type
===
0
||
logs
[
i
].
type
===
2
))
{
expandDataLocal
.
push
({
key
:
t
(
'渠道信息'
),
value
:
`
${
logs
[
i
].
channel
}
-
${
logs
[
i
].
channel_name
||
'[未知]'
}
`
});
}
if
(
other
?.
ws
||
other
?.
audio
)
{
expandDataLocal
.
push
({
key
:
t
(
'语音输入'
),
...
...
@@ -595,13 +608,12 @@ const LogsTable = () => {
key
:
t
(
'计费过程'
),
value
:
content
,
});
}
}
expandDatesLocal
[
logs
[
i
].
key
]
=
expandDataLocal
;
}
setExpandData
(
expandDatesLocal
);
setLogs
(
logs
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment