切换导航条
此项目
正在载入...
登录
baolinai
/
nextchat
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
202304001
17 days ago
提交
356076de5ca6ff7b92c75841ff18d2ac4c05ff44
1 个父辈
530c1da9
修改密码次数限制
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
27 行增加
和
43 行删除
app/api/[provider]/[...path]/route.ts
app/api/docmee.ts
app/api/tencentCos.ts
app/api/zuotang.ts
app/components/bgRemoval/bg-removal-panel.tsx
app/config/server.ts
app/constant.ts
app/api/[provider]/[...path]/route.ts
查看文件 @
356076d
...
...
@@ -20,7 +20,6 @@ import { handle as zuotangHandler } from "../../zuotang";
//20250328新增PPT API
import { handle as docmeeHandler } from "../../docmee";
import { handle as generateImgHandler } from "../../generateImg";
import { handle as tencentCosHandler } from "../../tencentCos";
async function handle(
req: NextRequest,
...
...
@@ -64,8 +63,6 @@ async function handle(
return docmeeHandler(req, { params });
case ApiPath.OpenAiImg:
return generateImgHandler(req, { params });
case ApiPath.TencentCos:
return tencentCosHandler(req, { params });
default:
return proxyHandler(req, { params });
}
...
...
app/api/docmee.ts
查看文件 @
356076d
import { getServerSideConfig } from "@/app/config/server";
import { NextRequest, NextResponse } from "next/server";
import md5 from "spark-md5";
// 处理每日使用限制逻辑
function parseDailyUsage(allowNum: string, configMax: number): number {
function parseDailyUsage(
allowNum: string,
accessCode: string,
maxDailyUse: string,
): number {
let configMax = 0;
if (maxDailyUse) {
configMax = JSON.parse(maxDailyUse)[accessCode];
}
if (allowNum === "first") return configMax;
const parsed = parseInt(allowNum, 10);
return Number.isNaN(parsed) ? configMax : parsed;
...
...
@@ -26,9 +34,9 @@ export async function handle(
// 提取 accessCode 和 max_use 参数
const uid = parsedBody.accessCode;
let maxUse = parsedBody.max_use;
if (!uid) {
if (!uid
|| !config.codes.has(md5.hash(uid))
) {
return NextResponse.json({
data: "请
前往设置页面输入
登录密码",
data: "请
检查
登录密码",
status: 400,
});
}
...
...
@@ -38,7 +46,7 @@ export async function handle(
status: 400,
});
}
maxUse = parseDailyUsage(maxUse, config.docmeeMaxDailyUses);
maxUse = parseDailyUsage(maxUse,
uid,
config.docmeeMaxDailyUses);
const headers = new Headers({
"Api-Key": config.docmeeApiKey,
...
...
app/api/tencentCos.ts
已删除
100644 → 0
查看文件 @
530c1da
import { NextRequest, NextResponse } from "next/server";
export async function handle(
req: NextRequest,
{ params }: { params: { path: string[] } },
) {
return NextResponse.json(
{
success: true,
data: {
msg: "success",
},
},
{ status: 200 },
);
}
app/api/zuotang.ts
查看文件 @
356076d
...
...
@@ -31,8 +31,15 @@ function createErrorResponse(
});
}
// 处理每日使用限制逻辑
function parseDailyUsage(allowNum: string, configMax: number): number {
function parseDailyUsage(
allowNum: string,
accessCode: string,
maxDailyUse: string,
): number {
let configMax = 0;
if (maxDailyUse) {
configMax = JSON.parse(maxDailyUse)[accessCode];
}
if (allowNum === "first") return configMax;
const parsed = parseInt(allowNum, 10);
return Number.isNaN(parsed) ? configMax : parsed;
...
...
@@ -67,7 +74,8 @@ export async function handle(
}
const maxDailyUses = parseDailyUsage(
localDataObj.maxDailyUses,
config.maxDailyUses,
accessCode,
config.bgRemoveMaxDailyUses,
);
if (maxDailyUses <= 0) {
...
...
app/components/bgRemoval/bg-removal-panel.tsx
查看文件 @
356076d
...
...
@@ -13,7 +13,6 @@ import { useChatStore } from "@/app/store";
import { getBgPrompt } from "@/app/utils/prompt";
import { cosUploadImage } from "@/app/utils/tencentCos";
import { getFileByUrl } from "@/app/utils/fileUtil";
import { getServerSideConfig } from "@/app/config/server";
// 错误消息映射函数
const getErrorMessage = (state: number): string => {
const errorMap: { [key: number]: string } = {
...
...
@@ -519,17 +518,6 @@ export function BgPanel(props: PanelProps) {
onClick={() => handleProcessImage("visual/r-background")}
disabled={isLoading}
/>
<IconButton
text="测试"
type="primary"
shadow
onClick={() => {
const config = getServerSideConfig();
console.log("**********************************", bgremovalModel);
}}
disabled={isLoading}
/>
</div>
</ControlParamItem>
</>
...
...
app/config/server.ts
查看文件 @
356076d
...
...
@@ -96,12 +96,12 @@ declare global {
//佐糖抠图API URL
BACKGROUND_REMOVAL_URL: string;
BACKGROUND_REMOVAL_API_KEY: string;
MAX_DAILY_USES: number
;
BGREMOVE_MAX_DAILY_USES: string
;
//AI PPT
DOCMEE_URL: string;
DOCMEE_API_KEY: string;
DOCMEE_MAX_DAILY_USES:
number
;
DOCMEE_MAX_DAILY_USES:
string
;
//腾讯云
TENCENT_COS_SECRETKEY: string;
...
...
@@ -285,7 +285,7 @@ export const getServerSideConfig = () => {
//20250320新增 佐糖抠图API URL
bgRemovalUrl: process.env.BACKGROUND_REMOVAL_URL ?? "",
bgRemovalApiKey: process.env.BACKGROUND_REMOVAL_API_KEY ?? "",
maxDailyUses: process.env.
MAX_DAILY_USES,
bgRemoveMaxDailyUses: process.env.BGREMOVE_
MAX_DAILY_USES,
//20250328新增 ppt api
docmeeUrl: process.env.DOCMEE_URL,
docmeeApiKey: process.env.DOCMEE_API_KEY ?? "",
...
...
app/constant.ts
查看文件 @
356076d
...
...
@@ -81,7 +81,6 @@ export enum ApiPath {
ZuoTang = "/api/tasks",
Docmee = "/api/ppt",
OpenAiImg = "/api/v1",
TencentCos = "/api/cos",
}
///api/tasks/visual/segmentation
//api/tasks/visual/segmentation/{task_id}
...
...
请
注册
或
登录
后发表评论