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
b648b3cf
authored
May 05, 2025
by
tbphp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 缩进修复还原
parent
9e2af598
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
48 deletions
+46
-48
middleware/model-rate-limit.go
+1
-2
model/option.go
+1
-2
web/src/components/RateLimitSetting.js
+44
-44
web/src/pages/Setting/RateLimit/SettingsRequestRateLimit.js
+0
-0
No files found.
middleware/model-rate-limit.go
View file @
b648b3cf
...
...
@@ -194,4 +194,4 @@ func ModelRequestRateLimit() func(c *gin.Context) {
memoryRateLimitHandler
(
duration
,
totalMaxCount
,
successMaxCount
)(
c
)
}
}
}
\ No newline at end of file
}
model/option.go
View file @
b648b3cf
...
...
@@ -402,4 +402,4 @@ func handleConfigUpdate(key, value string) bool {
config
.
UpdateConfigFromMap
(
cfg
,
configMap
)
return
true
// 已处理
}
\ No newline at end of file
}
web/src/components/RateLimitSetting.js
View file @
b648b3cf
...
...
@@ -9,62 +9,62 @@ import RequestRateLimit from '../pages/Setting/RateLimit/SettingsRequestRateLimi
const
RateLimitSetting
=
()
=>
{
const
{
t
}
=
useTranslation
();
let
[
inputs
,
setInputs
]
=
useState
({
ModelRequestRateLimitEnabled
:
false
,
ModelRequestRateLimitCount
:
0
,
ModelRequestRateLimitSuccessCount
:
1000
,
ModelRequestRateLimitDurationMinutes
:
1
,
ModelRequestRateLimitGroup
:
''
,
ModelRequestRateLimitEnabled
:
false
,
ModelRequestRateLimitCount
:
0
,
ModelRequestRateLimitSuccessCount
:
1000
,
ModelRequestRateLimitDurationMinutes
:
1
,
ModelRequestRateLimitGroup
:
''
,
});
let
[
loading
,
setLoading
]
=
useState
(
false
);
const
getOptions
=
async
()
=>
{
const
res
=
await
API
.
get
(
'/api/option/'
);
const
{
success
,
message
,
data
}
=
res
.
data
;
if
(
success
)
{
let
newInputs
=
{};
data
.
forEach
((
item
)
=>
{
if
(
item
.
key
===
'ModelRequestRateLimitGroup'
)
{
item
.
value
=
JSON
.
stringify
(
JSON
.
parse
(
item
.
value
),
null
,
2
);
}
const
res
=
await
API
.
get
(
'/api/option/'
);
const
{
success
,
message
,
data
}
=
res
.
data
;
if
(
success
)
{
let
newInputs
=
{};
data
.
forEach
((
item
)
=>
{
if
(
item
.
key
===
'ModelRequestRateLimitGroup'
)
{
item
.
value
=
JSON
.
stringify
(
JSON
.
parse
(
item
.
value
),
null
,
2
);
}
if
(
item
.
key
.
endsWith
(
'Enabled'
))
{
newInputs
[
item
.
key
]
=
item
.
value
===
'true'
?
true
:
false
;
}
else
{
newInputs
[
item
.
key
]
=
item
.
value
;
}
});
setInputs
(
newInputs
);
}
else
{
showError
(
message
);
}
if
(
item
.
key
.
endsWith
(
'Enabled'
))
{
newInputs
[
item
.
key
]
=
item
.
value
===
'true'
?
true
:
false
;
}
else
{
newInputs
[
item
.
key
]
=
item
.
value
;
}
});
setInputs
(
newInputs
);
}
else
{
showError
(
message
);
}
};
async
function
onRefresh
()
{
try
{
setLoading
(
true
);
await
getOptions
();
// showSuccess('刷新成功');
}
catch
(
error
)
{
showError
(
'刷新失败'
);
}
finally
{
setLoading
(
false
);
}
try
{
setLoading
(
true
);
await
getOptions
();
// showSuccess('刷新成功');
}
catch
(
error
)
{
showError
(
'刷新失败'
);
}
finally
{
setLoading
(
false
);
}
}
useEffect
(()
=>
{
onRefresh
();
onRefresh
();
},
[]);
return
(
<>
<
Spin
spinning
=
{
loading
}
size
=
'large'
>
{
/* AI请求速率限制 */
}
<
Card
style
=
{{
marginTop
:
'10px'
}}
>
<
RequestRateLimit
options
=
{
inputs
}
refresh
=
{
onRefresh
}
/
>
<
/Card
>
<
/Spin
>
<
/
>
<>
<
Spin
spinning
=
{
loading
}
size
=
'large'
>
{
/* AI请求速率限制 */
}
<
Card
style
=
{{
marginTop
:
'10px'
}}
>
<
RequestRateLimit
options
=
{
inputs
}
refresh
=
{
onRefresh
}
/
>
<
/Card
>
<
/Spin
>
<
/
>
);
};
...
...
web/src/pages/Setting/RateLimit/SettingsRequestRateLimit.js
View file @
b648b3cf
This diff is collapsed.
Click to expand it.
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