Merge branch 'wzxjohn-feature/wellknown'

This commit is contained in:
creamlike1024
2025-04-28 12:55:06 +08:00
3 changed files with 26 additions and 6 deletions

View File

@@ -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,

View File

@@ -1,6 +1,7 @@
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
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
} }

View File

@@ -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 = () => {
}; };
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 = () => {
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'];