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
8bea1397
authored
Apr 28, 2025
by
creamlike1024
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'wzxjohn-feature/wellknown'
parents
4f123cf9
9f165b89
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
6 deletions
+26
-6
controller/log.go
+1
-1
model/log.go
+22
-3
web/src/components/SystemSetting.js
+3
-2
No files found.
controller/log.go
View file @
8bea1397
...
@@ -196,7 +196,7 @@ func DeleteHistoryLogs(c *gin.Context) {
...
@@ -196,7 +196,7 @@ func DeleteHistoryLogs(c *gin.Context) {
})
})
return
return
}
}
count
,
err
:=
model
.
DeleteOldLog
(
targetTimestamp
)
count
,
err
:=
model
.
DeleteOldLog
(
c
.
Request
.
Context
(),
targetTimestamp
,
100
)
if
err
!=
nil
{
if
err
!=
nil
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
c
.
JSON
(
http
.
StatusOK
,
gin
.
H
{
"success"
:
false
,
"success"
:
false
,
...
...
model/log.go
View file @
8bea1397
package
model
package
model
import
(
import
(
"context"
"fmt"
"fmt"
"one-api/common"
"one-api/common"
"os"
"os"
...
@@ -340,7 +341,25 @@ func SumUsedToken(logType int, startTimestamp int64, endTimestamp int64, modelNa
...
@@ -340,7 +341,25 @@ func SumUsedToken(logType int, startTimestamp int64, endTimestamp int64, modelNa
return
token
return
token
}
}
func
DeleteOldLog
(
targetTimestamp
int64
)
(
int64
,
error
)
{
func
DeleteOldLog
(
ctx
context
.
Context
,
targetTimestamp
int64
,
limit
int
)
(
int64
,
error
)
{
result
:=
LOG_DB
.
Where
(
"created_at < ?"
,
targetTimestamp
)
.
Delete
(
&
Log
{})
var
total
int64
=
0
return
result
.
RowsAffected
,
result
.
Error
for
{
if
nil
!=
ctx
.
Err
()
{
return
total
,
ctx
.
Err
()
}
result
:=
LOG_DB
.
Where
(
"created_at < ?"
,
targetTimestamp
)
.
Limit
(
limit
)
.
Delete
(
&
Log
{})
if
nil
!=
result
.
Error
{
return
total
,
result
.
Error
}
total
+=
result
.
RowsAffected
if
result
.
RowsAffected
<
int64
(
limit
)
{
break
}
}
return
total
,
nil
}
}
web/src/components/SystemSetting.js
View file @
8bea1397
...
@@ -19,6 +19,7 @@ import {
...
@@ -19,6 +19,7 @@ import {
verifyJSON
,
verifyJSON
,
}
from
'../helpers/utils'
;
}
from
'../helpers/utils'
;
import
{
API
}
from
'../helpers/api'
;
import
{
API
}
from
'../helpers/api'
;
import
axios
from
"axios"
;
const
SystemSetting
=
()
=>
{
const
SystemSetting
=
()
=>
{
let
[
inputs
,
setInputs
]
=
useState
({
let
[
inputs
,
setInputs
]
=
useState
({
...
@@ -374,7 +375,7 @@ const SystemSetting = () => {
...
@@ -374,7 +375,7 @@ const SystemSetting = () => {
};
};
const
submitOIDCSettings
=
async
()
=>
{
const
submitOIDCSettings
=
async
()
=>
{
if
(
inputs
[
'oidc.well_known'
]
!==
''
)
{
if
(
inputs
[
'oidc.well_known'
]
&&
inputs
[
'oidc.well_known'
]
!==
''
)
{
if
(
if
(
!
inputs
[
'oidc.well_known'
].
startsWith
(
'http://'
)
&&
!
inputs
[
'oidc.well_known'
].
startsWith
(
'http://'
)
&&
!
inputs
[
'oidc.well_known'
].
startsWith
(
'https://'
)
!
inputs
[
'oidc.well_known'
].
startsWith
(
'https://'
)
...
@@ -383,7 +384,7 @@ const SystemSetting = () => {
...
@@ -383,7 +384,7 @@ const SystemSetting = () => {
return
;
return
;
}
}
try
{
try
{
const
res
=
await
API
.
get
(
inputs
[
'oidc.well_known'
]);
const
res
=
await
axios
.
create
()
.
get
(
inputs
[
'oidc.well_known'
]);
inputs
[
'oidc.authorization_endpoint'
]
=
inputs
[
'oidc.authorization_endpoint'
]
=
res
.
data
[
'authorization_endpoint'
];
res
.
data
[
'authorization_endpoint'
];
inputs
[
'oidc.token_endpoint'
]
=
res
.
data
[
'token_endpoint'
];
inputs
[
'oidc.token_endpoint'
]
=
res
.
data
[
'token_endpoint'
];
...
...
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