fix: temporarily disable product planning advanced analysis
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-04-30 15:53:36 +08:00
parent 48c6cd0f87
commit 40ca6d5eb8
8 changed files with 89 additions and 8 deletions

View File

@ -2,6 +2,10 @@ import { generateText } from "ai";
import { NextRequest, NextResponse } from "next/server";
import { z } from "zod";
import { inlineVisionImages } from "@/lib/ai/vision-inline";
import {
PRODUCT_PLANNING_ADVANCED_DISABLED,
PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE,
} from "@/lib/product-planning/advanced-disabled";
import { resolveProductPlanningVisionModel } from "@/lib/product-planning/model-runtime";
import {
isProductPlanningEnabled,
@ -50,6 +54,10 @@ function buildImageAnalyzePrompt(params: { itemId: string; title?: string }) {
}
export async function POST(request: NextRequest) {
if (PRODUCT_PLANNING_ADVANCED_DISABLED) {
return jsonError(503, PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE);
}
const token = await getProductPlanningToken(request);
if (!token?.sub) {
return jsonError(401, "未登录");

View File

@ -2,6 +2,10 @@ import { generateText } from "ai";
import { NextRequest, NextResponse } from "next/server";
import { z } from "zod";
import { buildProductPlanningSkuAnalyzePrompt } from "@/lib/product-planning/analyze";
import {
PRODUCT_PLANNING_ADVANCED_DISABLED,
PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE,
} from "@/lib/product-planning/advanced-disabled";
import { resolveProductPlanningTextModel } from "@/lib/product-planning/model-runtime";
import {
isProductPlanningEnabled,
@ -39,6 +43,10 @@ function jsonError(status: number, error: string) {
}
export async function POST(request: NextRequest) {
if (PRODUCT_PLANNING_ADVANCED_DISABLED) {
return jsonError(503, PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE);
}
const token = await getProductPlanningToken(request);
if (!token?.sub) {
return jsonError(401, "未登录");

View File

@ -1,4 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
import {
PRODUCT_PLANNING_ADVANCED_DISABLED,
PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE,
} from "@/lib/product-planning/advanced-disabled";
import { getResolvedProductPlanningApiConfig } from "@/lib/product-planning/server-config";
import {
isProductPlanningEnabled,
@ -19,6 +23,10 @@ function jsonError(status: number, error: string) {
}
export async function GET(request: NextRequest) {
if (PRODUCT_PLANNING_ADVANCED_DISABLED) {
return jsonError(503, PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE);
}
const token = await getProductPlanningToken(request);
if (!token?.sub) {
return jsonError(401, "未登录");

View File

@ -1,4 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
import {
PRODUCT_PLANNING_ADVANCED_DISABLED,
PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE,
} from "@/lib/product-planning/advanced-disabled";
import { getResolvedProductPlanningApiConfig } from "@/lib/product-planning/server-config";
import {
isProductPlanningEnabled,
@ -80,6 +84,10 @@ function normalizeGroups(items: unknown) {
}
export async function GET(request: NextRequest) {
if (PRODUCT_PLANNING_ADVANCED_DISABLED) {
return jsonError(503, "", PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE);
}
const token = await getProductPlanningToken(request);
if (!token?.sub) {
return jsonError(401, "", "未登录");

View File

@ -1,4 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
import {
PRODUCT_PLANNING_ADVANCED_DISABLED,
PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE,
} from "@/lib/product-planning/advanced-disabled";
import { getResolvedProductPlanningApiConfig } from "@/lib/product-planning/server-config";
import {
isProductPlanningEnabled,
@ -19,6 +23,10 @@ function jsonError(status: number, error: string) {
}
export async function GET(request: NextRequest) {
if (PRODUCT_PLANNING_ADVANCED_DISABLED) {
return jsonError(503, PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE);
}
const token = await getProductPlanningToken(request);
if (!token?.sub) {
return jsonError(401, "未登录");

View File

@ -1,4 +1,8 @@
import { NextRequest, NextResponse } from "next/server";
import {
PRODUCT_PLANNING_ADVANCED_DISABLED,
PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE,
} from "@/lib/product-planning/advanced-disabled";
import { getResolvedProductPlanningApiConfig } from "@/lib/product-planning/server-config";
import {
isProductPlanningEnabled,
@ -21,6 +25,10 @@ function jsonError(status: number, itemId: string, error: string) {
}
export async function GET(request: NextRequest) {
if (PRODUCT_PLANNING_ADVANCED_DISABLED) {
return jsonError(503, "", PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE);
}
const token = await getProductPlanningToken(request);
if (!token?.sub) {
return jsonError(401, "", "未登录");

View File

@ -32,6 +32,10 @@ import {
downloadMarkdownFile,
downloadSalesWorkbook,
} from "@/lib/product-planning/export";
import {
PRODUCT_PLANNING_ADVANCED_DISABLED,
PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE,
} from "@/lib/product-planning/advanced-disabled";
import {
parseKeywordInputFile,
parseManualSegmentationFile,
@ -1076,6 +1080,13 @@ export function ProductPlanningPage({
void loadTemplates();
}, []);
useEffect(() => {
if (PRODUCT_PLANNING_ADVANCED_DISABLED && mainTab === "advanced") {
setMainTab("keywords");
toast.info(PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE);
}
}, [mainTab]);
useEffect(() => {
try {
const raw = sessionStorage.getItem(PRODUCT_PLANNING_SESSION_KEY);
@ -1092,7 +1103,13 @@ export function ProductPlanningPage({
return;
}
if (typeof parsed.mainTab === "string") setMainTab(parsed.mainTab);
if (typeof parsed.mainTab === "string") {
setMainTab(
PRODUCT_PLANNING_ADVANCED_DISABLED && parsed.mainTab === "advanced"
? "keywords"
: parsed.mainTab
);
}
if (typeof parsed.manualSegmentationMode === "boolean") {
setManualSegmentationMode(parsed.manualSegmentationMode);
}
@ -2325,7 +2342,17 @@ export function ProductPlanningPage({
</CardContent>
</Card>
<Tabs onValueChange={setMainTab} value={mainTab}>
<Tabs
onValueChange={(value) => {
if (PRODUCT_PLANNING_ADVANCED_DISABLED && value === "advanced") {
toast.info(PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE);
setMainTab("keywords");
return;
}
setMainTab(value);
}}
value={mainTab}
>
<TabsList className="mb-6 h-auto w-full justify-start gap-6 rounded-none border-border border-b bg-transparent p-0">
<TabsTrigger
className="rounded-none px-1 py-3 font-medium text-muted-foreground text-sm transition-none data-[state=active]:border-primary data-[state=active]:border-b-2 data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none"
@ -2339,12 +2366,14 @@ export function ProductPlanningPage({
>
评价 / 问大家分析
</TabsTrigger>
<TabsTrigger
className="rounded-none px-1 py-3 font-medium text-muted-foreground text-sm transition-none data-[state=active]:border-primary data-[state=active]:border-b-2 data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none"
value="advanced"
>
拓展分析
</TabsTrigger>
{PRODUCT_PLANNING_ADVANCED_DISABLED ? null : (
<TabsTrigger
className="rounded-none px-1 py-3 font-medium text-muted-foreground text-sm transition-none data-[state=active]:border-primary data-[state=active]:border-b-2 data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none"
value="advanced"
>
拓展分析
</TabsTrigger>
)}
</TabsList>
<TabsContent className="space-y-6" value="keywords">

View File

@ -0,0 +1,4 @@
export const PRODUCT_PLANNING_ADVANCED_DISABLED = true;
export const PRODUCT_PLANNING_ADVANCED_DISABLED_MESSAGE =
"商品策划工具「拓展分析」功能临时维护中,请稍后再试。";