mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-17 06:23:44 +08:00
限制每天使用量
This commit is contained in:
@@ -48,7 +48,7 @@ export default function SetPasswordPage() {
|
||||
if (result["result"] == "ok") {
|
||||
signOut({ redirect: true, callbackUrl: "/login" });
|
||||
}
|
||||
console.log("--------", result);
|
||||
// console.log("--------", result);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -205,6 +205,6 @@ export function useGetMidjourneySelfProxyUrl(url: string) {
|
||||
const accessStore = useAccessStore.getState();
|
||||
console.log("useMjImgSelfProxy", accessStore.useMjImgSelfProxy);
|
||||
|
||||
console.log("---------", url);
|
||||
// console.log("---------", url);
|
||||
return url.replace("cdn.discordapp.com", "cdnig.duckagi.com");
|
||||
}
|
||||
|
||||
@@ -105,6 +105,8 @@ import { useAllModels } from "../utils/hooks";
|
||||
import { MultimodalContent } from "../client/api";
|
||||
// import { getTokenLength } from "@/lib/utils";
|
||||
import VoiceInput from "./voice-input";
|
||||
import { Progress, Tooltip } from "antd";
|
||||
import { white } from "kleur/colors";
|
||||
// import GptPrompts from "./gpt-prompts";
|
||||
// const VoiceInput = dynamic(
|
||||
// () => import('@/app/components/voice-input'), { ssr: false });
|
||||
@@ -1281,7 +1283,7 @@ function _Chat() {
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((result) => {
|
||||
console.log("请求成功,", result);
|
||||
// console.log("请求成功,", result);
|
||||
localStorage.setItem(
|
||||
"current_day_token",
|
||||
result["result"]["current_token"],
|
||||
@@ -1333,11 +1335,29 @@ function _Chat() {
|
||||
{!session.topic ? DEFAULT_TOPIC : session.topic}
|
||||
</div>
|
||||
<div className="window-header-sub-title">
|
||||
{Locale.Chat.SubTitle(session.messages.length)}
|
||||
<span>
|
||||
当天使用:
|
||||
{localStorage.getItem("current_day_token") ?? 0}
|
||||
</span>
|
||||
{/*{Locale.Chat.SubTitle(session.messages.length)} */}
|
||||
<Tooltip
|
||||
title={
|
||||
<span style={{ color: "black" }}>
|
||||
{localStorage.getItem("current_day_token") ?? 0}{" "}
|
||||
<span style={{ color: "black" }}>/ 100000</span>
|
||||
</span>
|
||||
}
|
||||
color={"var(--second)"}
|
||||
placement="bottom"
|
||||
>
|
||||
当天使用:
|
||||
<Progress
|
||||
percent={
|
||||
(parseInt(localStorage.getItem("current_day_token") ?? "0") /
|
||||
100000) *
|
||||
100
|
||||
}
|
||||
size="small"
|
||||
showInfo={false}
|
||||
strokeColor={{ from: "green", to: "red" }}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
</div>
|
||||
<div className="window-actions">
|
||||
|
||||
@@ -514,6 +514,26 @@ export const useChatStore = createPersistStore(
|
||||
botMessage,
|
||||
]);
|
||||
});
|
||||
|
||||
const current_day_token = parseInt(
|
||||
localStorage.getItem("current_day_token") ?? "0",
|
||||
);
|
||||
// console.log('---------', current_day_token)
|
||||
if (current_day_token >= 100000) {
|
||||
botMessage.content +=
|
||||
"\n\n" +
|
||||
prettyObject({
|
||||
error: true,
|
||||
message: "当日请求过多。",
|
||||
});
|
||||
botMessage.streaming = false;
|
||||
get().onNewMessage(botMessage);
|
||||
set(() => ({}));
|
||||
extAttr?.setAutoScroll(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
content.toLowerCase().startsWith("/mj") ||
|
||||
content.toLowerCase().startsWith("/MJ")
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
|
||||
.window-header-sub-title {
|
||||
font-size: 14px;
|
||||
width: 150px;
|
||||
.ant-progress {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user