正在显示
7 个修改的文件
包含
27 行增加
和
43 行删除
@@ -20,7 +20,6 @@ import { handle as zuotangHandler } from "../../zuotang"; | @@ -20,7 +20,6 @@ import { handle as zuotangHandler } from "../../zuotang"; | ||
20 | //20250328新增PPT API | 20 | //20250328新增PPT API |
21 | import { handle as docmeeHandler } from "../../docmee"; | 21 | import { handle as docmeeHandler } from "../../docmee"; |
22 | import { handle as generateImgHandler } from "../../generateImg"; | 22 | import { handle as generateImgHandler } from "../../generateImg"; |
23 | -import { handle as tencentCosHandler } from "../../tencentCos"; | ||
24 | 23 | ||
25 | async function handle( | 24 | async function handle( |
26 | req: NextRequest, | 25 | req: NextRequest, |
@@ -64,8 +63,6 @@ async function handle( | @@ -64,8 +63,6 @@ async function handle( | ||
64 | return docmeeHandler(req, { params }); | 63 | return docmeeHandler(req, { params }); |
65 | case ApiPath.OpenAiImg: | 64 | case ApiPath.OpenAiImg: |
66 | return generateImgHandler(req, { params }); | 65 | return generateImgHandler(req, { params }); |
67 | - case ApiPath.TencentCos: | ||
68 | - return tencentCosHandler(req, { params }); | ||
69 | default: | 66 | default: |
70 | return proxyHandler(req, { params }); | 67 | return proxyHandler(req, { params }); |
71 | } | 68 | } |
1 | import { getServerSideConfig } from "@/app/config/server"; | 1 | import { getServerSideConfig } from "@/app/config/server"; |
2 | import { NextRequest, NextResponse } from "next/server"; | 2 | import { NextRequest, NextResponse } from "next/server"; |
3 | - | 3 | +import md5 from "spark-md5"; |
4 | // 处理每日使用限制逻辑 | 4 | // 处理每日使用限制逻辑 |
5 | -function parseDailyUsage(allowNum: string, configMax: number): number { | 5 | +function parseDailyUsage( |
6 | + allowNum: string, | ||
7 | + accessCode: string, | ||
8 | + maxDailyUse: string, | ||
9 | +): number { | ||
10 | + let configMax = 0; | ||
11 | + if (maxDailyUse) { | ||
12 | + configMax = JSON.parse(maxDailyUse)[accessCode]; | ||
13 | + } | ||
6 | if (allowNum === "first") return configMax; | 14 | if (allowNum === "first") return configMax; |
7 | const parsed = parseInt(allowNum, 10); | 15 | const parsed = parseInt(allowNum, 10); |
8 | return Number.isNaN(parsed) ? configMax : parsed; | 16 | return Number.isNaN(parsed) ? configMax : parsed; |
@@ -26,9 +34,9 @@ export async function handle( | @@ -26,9 +34,9 @@ export async function handle( | ||
26 | // 提取 accessCode 和 max_use 参数 | 34 | // 提取 accessCode 和 max_use 参数 |
27 | const uid = parsedBody.accessCode; | 35 | const uid = parsedBody.accessCode; |
28 | let maxUse = parsedBody.max_use; | 36 | let maxUse = parsedBody.max_use; |
29 | - if (!uid) { | 37 | + if (!uid || !config.codes.has(md5.hash(uid))) { |
30 | return NextResponse.json({ | 38 | return NextResponse.json({ |
31 | - data: "请前往设置页面输入登录密码", | 39 | + data: "请检查登录密码", |
32 | status: 400, | 40 | status: 400, |
33 | }); | 41 | }); |
34 | } | 42 | } |
@@ -38,7 +46,7 @@ export async function handle( | @@ -38,7 +46,7 @@ export async function handle( | ||
38 | status: 400, | 46 | status: 400, |
39 | }); | 47 | }); |
40 | } | 48 | } |
41 | - maxUse = parseDailyUsage(maxUse, config.docmeeMaxDailyUses); | 49 | + maxUse = parseDailyUsage(maxUse, uid, config.docmeeMaxDailyUses); |
42 | 50 | ||
43 | const headers = new Headers({ | 51 | const headers = new Headers({ |
44 | "Api-Key": config.docmeeApiKey, | 52 | "Api-Key": config.docmeeApiKey, |
app/api/tencentCos.ts
已删除
100644 → 0
1 | -import { NextRequest, NextResponse } from "next/server"; | ||
2 | - | ||
3 | -export async function handle( | ||
4 | - req: NextRequest, | ||
5 | - { params }: { params: { path: string[] } }, | ||
6 | -) { | ||
7 | - return NextResponse.json( | ||
8 | - { | ||
9 | - success: true, | ||
10 | - data: { | ||
11 | - msg: "success", | ||
12 | - }, | ||
13 | - }, | ||
14 | - { status: 200 }, | ||
15 | - ); | ||
16 | -} |
@@ -31,8 +31,15 @@ function createErrorResponse( | @@ -31,8 +31,15 @@ function createErrorResponse( | ||
31 | }); | 31 | }); |
32 | } | 32 | } |
33 | 33 | ||
34 | -// 处理每日使用限制逻辑 | ||
35 | -function parseDailyUsage(allowNum: string, configMax: number): number { | 34 | +function parseDailyUsage( |
35 | + allowNum: string, | ||
36 | + accessCode: string, | ||
37 | + maxDailyUse: string, | ||
38 | +): number { | ||
39 | + let configMax = 0; | ||
40 | + if (maxDailyUse) { | ||
41 | + configMax = JSON.parse(maxDailyUse)[accessCode]; | ||
42 | + } | ||
36 | if (allowNum === "first") return configMax; | 43 | if (allowNum === "first") return configMax; |
37 | const parsed = parseInt(allowNum, 10); | 44 | const parsed = parseInt(allowNum, 10); |
38 | return Number.isNaN(parsed) ? configMax : parsed; | 45 | return Number.isNaN(parsed) ? configMax : parsed; |
@@ -67,7 +74,8 @@ export async function handle( | @@ -67,7 +74,8 @@ export async function handle( | ||
67 | } | 74 | } |
68 | const maxDailyUses = parseDailyUsage( | 75 | const maxDailyUses = parseDailyUsage( |
69 | localDataObj.maxDailyUses, | 76 | localDataObj.maxDailyUses, |
70 | - config.maxDailyUses, | 77 | + accessCode, |
78 | + config.bgRemoveMaxDailyUses, | ||
71 | ); | 79 | ); |
72 | 80 | ||
73 | if (maxDailyUses <= 0) { | 81 | if (maxDailyUses <= 0) { |
@@ -13,7 +13,6 @@ import { useChatStore } from "@/app/store"; | @@ -13,7 +13,6 @@ import { useChatStore } from "@/app/store"; | ||
13 | import { getBgPrompt } from "@/app/utils/prompt"; | 13 | import { getBgPrompt } from "@/app/utils/prompt"; |
14 | import { cosUploadImage } from "@/app/utils/tencentCos"; | 14 | import { cosUploadImage } from "@/app/utils/tencentCos"; |
15 | import { getFileByUrl } from "@/app/utils/fileUtil"; | 15 | import { getFileByUrl } from "@/app/utils/fileUtil"; |
16 | -import { getServerSideConfig } from "@/app/config/server"; | ||
17 | // 错误消息映射函数 | 16 | // 错误消息映射函数 |
18 | const getErrorMessage = (state: number): string => { | 17 | const getErrorMessage = (state: number): string => { |
19 | const errorMap: { [key: number]: string } = { | 18 | const errorMap: { [key: number]: string } = { |
@@ -519,17 +518,6 @@ export function BgPanel(props: PanelProps) { | @@ -519,17 +518,6 @@ export function BgPanel(props: PanelProps) { | ||
519 | onClick={() => handleProcessImage("visual/r-background")} | 518 | onClick={() => handleProcessImage("visual/r-background")} |
520 | disabled={isLoading} | 519 | disabled={isLoading} |
521 | /> | 520 | /> |
522 | - <IconButton | ||
523 | - text="测试" | ||
524 | - type="primary" | ||
525 | - shadow | ||
526 | - onClick={() => { | ||
527 | - const config = getServerSideConfig(); | ||
528 | - | ||
529 | - console.log("**********************************", bgremovalModel); | ||
530 | - }} | ||
531 | - disabled={isLoading} | ||
532 | - /> | ||
533 | </div> | 521 | </div> |
534 | </ControlParamItem> | 522 | </ControlParamItem> |
535 | </> | 523 | </> |
@@ -96,12 +96,12 @@ declare global { | @@ -96,12 +96,12 @@ declare global { | ||
96 | //佐糖抠图API URL | 96 | //佐糖抠图API URL |
97 | BACKGROUND_REMOVAL_URL: string; | 97 | BACKGROUND_REMOVAL_URL: string; |
98 | BACKGROUND_REMOVAL_API_KEY: string; | 98 | BACKGROUND_REMOVAL_API_KEY: string; |
99 | - MAX_DAILY_USES: number; | 99 | + BGREMOVE_MAX_DAILY_USES: string; |
100 | 100 | ||
101 | //AI PPT | 101 | //AI PPT |
102 | DOCMEE_URL: string; | 102 | DOCMEE_URL: string; |
103 | DOCMEE_API_KEY: string; | 103 | DOCMEE_API_KEY: string; |
104 | - DOCMEE_MAX_DAILY_USES: number; | 104 | + DOCMEE_MAX_DAILY_USES: string; |
105 | 105 | ||
106 | //腾讯云 | 106 | //腾讯云 |
107 | TENCENT_COS_SECRETKEY: string; | 107 | TENCENT_COS_SECRETKEY: string; |
@@ -285,7 +285,7 @@ export const getServerSideConfig = () => { | @@ -285,7 +285,7 @@ export const getServerSideConfig = () => { | ||
285 | //20250320新增 佐糖抠图API URL | 285 | //20250320新增 佐糖抠图API URL |
286 | bgRemovalUrl: process.env.BACKGROUND_REMOVAL_URL ?? "", | 286 | bgRemovalUrl: process.env.BACKGROUND_REMOVAL_URL ?? "", |
287 | bgRemovalApiKey: process.env.BACKGROUND_REMOVAL_API_KEY ?? "", | 287 | bgRemovalApiKey: process.env.BACKGROUND_REMOVAL_API_KEY ?? "", |
288 | - maxDailyUses: process.env.MAX_DAILY_USES, | 288 | + bgRemoveMaxDailyUses: process.env.BGREMOVE_MAX_DAILY_USES, |
289 | //20250328新增 ppt api | 289 | //20250328新增 ppt api |
290 | docmeeUrl: process.env.DOCMEE_URL, | 290 | docmeeUrl: process.env.DOCMEE_URL, |
291 | docmeeApiKey: process.env.DOCMEE_API_KEY ?? "", | 291 | docmeeApiKey: process.env.DOCMEE_API_KEY ?? "", |
@@ -81,7 +81,6 @@ export enum ApiPath { | @@ -81,7 +81,6 @@ export enum ApiPath { | ||
81 | ZuoTang = "/api/tasks", | 81 | ZuoTang = "/api/tasks", |
82 | Docmee = "/api/ppt", | 82 | Docmee = "/api/ppt", |
83 | OpenAiImg = "/api/v1", | 83 | OpenAiImg = "/api/v1", |
84 | - TencentCos = "/api/cos", | ||
85 | } | 84 | } |
86 | ///api/tasks/visual/segmentation | 85 | ///api/tasks/visual/segmentation |
87 | //api/tasks/visual/segmentation/{task_id} | 86 | //api/tasks/visual/segmentation/{task_id} |
-
请 注册 或 登录 后发表评论