mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-10-01 23:56:39 +08:00
add token limit
This commit is contained in:
parent
48cf006f83
commit
529ccbc2fa
@ -25,7 +25,11 @@ async function handle(
|
||||
id: user_id,
|
||||
},
|
||||
});
|
||||
if (current_user && current_user.everyLimitToken !== 0) {
|
||||
if (
|
||||
current_user &&
|
||||
current_user.everyLimitToken &&
|
||||
current_user.everyLimitToken > 0
|
||||
) {
|
||||
current_day_limit_token = current_user.everyLimitToken * 1000;
|
||||
} else {
|
||||
current_day_limit_token = 0;
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
Space,
|
||||
Table,
|
||||
Input,
|
||||
InputNumber,
|
||||
Button,
|
||||
notification as notificationModule,
|
||||
Checkbox,
|
||||
@ -127,6 +128,9 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
|
||||
<Form.Item name="emailVerified" label="emailVerified">
|
||||
<Input disabled />
|
||||
</Form.Item>
|
||||
<Form.Item name="everyLimitToken" label="每日限额">
|
||||
<InputNumber addonAfter={"k"} />
|
||||
</Form.Item>
|
||||
<Form.Item name="createdAt" label="createdAt">
|
||||
<Input disabled />
|
||||
</Form.Item>
|
||||
@ -163,6 +167,7 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
|
||||
allowToLogin: values.allowToLogin ?? true,
|
||||
isAdmin: values.isAdmin ?? false,
|
||||
password: values.password ?? null,
|
||||
everyLimitToken: values.everyLimitToken ?? 0,
|
||||
};
|
||||
fetch(`/api/admin/users/${values.id}`, {
|
||||
method: method,
|
||||
@ -228,13 +233,20 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
|
||||
});
|
||||
};
|
||||
const columns: TableColumnsType<User> = [
|
||||
{ title: "姓名", dataIndex: "name", width: 80 },
|
||||
{ title: "姓名", dataIndex: "name", width: 80, align: "center" },
|
||||
{
|
||||
title: "用户名",
|
||||
dataIndex: "username",
|
||||
width: 80,
|
||||
align: "center",
|
||||
},
|
||||
{ title: "邮箱", dataIndex: "email", width: 180, align: "right" },
|
||||
{
|
||||
title: "每日限额",
|
||||
dataIndex: "everyLimitToken",
|
||||
width: 60,
|
||||
align: "right",
|
||||
},
|
||||
{ title: "邮箱", dataIndex: "email", width: 180 },
|
||||
{
|
||||
title: "createdAt",
|
||||
dataIndex: "createdAt",
|
||||
@ -301,7 +313,7 @@ function UsersTable({ users, setUsers, loading }: UserInterface) {
|
||||
<Table
|
||||
dataSource={users}
|
||||
rowKey="id"
|
||||
size="middle"
|
||||
size="small"
|
||||
columns={columns}
|
||||
loading={loading as boolean}
|
||||
scroll={{
|
||||
|
@ -1478,7 +1478,13 @@ function _Chat() {
|
||||
title={
|
||||
<span style={{ color: "black" }}>
|
||||
{localStorage.getItem("current_day_token") ?? 0}{" "}
|
||||
<span style={{ color: "black" }}>/ 200000</span>
|
||||
<span style={{ color: "black" }}>
|
||||
/{" "}
|
||||
{parseInt(
|
||||
localStorage.getItem("current_day_limit_token") ??
|
||||
"200000",
|
||||
)}
|
||||
</span>
|
||||
</span>
|
||||
}
|
||||
color={"var(--second)"}
|
||||
@ -1488,7 +1494,10 @@ function _Chat() {
|
||||
<Progress
|
||||
percent={
|
||||
(parseInt(localStorage.getItem("current_day_token") ?? "0") /
|
||||
parseInt(localStorage.getItem("limit_token") ?? "200000")) *
|
||||
parseInt(
|
||||
localStorage.getItem("current_day_limit_token") ??
|
||||
"200000",
|
||||
)) *
|
||||
100
|
||||
}
|
||||
size="small"
|
||||
|
Loading…
Reference in New Issue
Block a user