feat: 前端平台规则页面支持文档上传 + AI 解析

- 新增前端类型定义 (ParsedRulesData, BrandPlatformRuleResponse 等)
- 新增 4 个 API 方法 (parsePlatformRule, confirmPlatformRule, listBrandPlatformRules, deletePlatformRule)
- 重写品牌方规则页面平台规则 tab,支持文档上传→AI解析→确认/编辑→生效流程
- 保留违禁词/竞品/白名单三个 tab 原有功能
- 支持 USE_MOCK 双模式

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Your Name 2026-02-10 13:32:13 +08:00
parent fed361b9b3
commit 3a2598c956
4 changed files with 653 additions and 596 deletions

View File

@ -109,6 +109,7 @@ class ScriptReviewRequest(BaseModel):
platform: Platform = Field(..., description="投放平台")
brand_id: str = Field(..., description="品牌 ID")
required_points: Optional[list[str]] = Field(None, description="必要卖点列表")
blacklist_words: Optional[list[dict]] = Field(None, description="Brief 黑名单词 [{word, reason}]")
soft_risk_context: Optional[SoftRiskContext] = Field(None, description="软性风控上下文")

File diff suppressed because it is too large Load Diff

View File

@ -56,6 +56,11 @@ import type {
PlatformListResponse,
RuleValidateRequest,
RuleValidateResponse,
PlatformRuleParseRequest,
PlatformRuleParseResponse,
PlatformRuleConfirmRequest,
BrandPlatformRuleResponse,
BrandPlatformRuleListResponse,
} from '@/types/rules'
import type {
AIConfigUpdate,
@ -857,6 +862,37 @@ class ApiClient {
return response.data
}
/**
* AI
*/
async parsePlatformRule(data: PlatformRuleParseRequest): Promise<PlatformRuleParseResponse> {
const response = await this.client.post<PlatformRuleParseResponse>('/rules/platform-rules/parse', data)
return response.data
}
/**
* /
*/
async confirmPlatformRule(ruleId: string, data: PlatformRuleConfirmRequest): Promise<BrandPlatformRuleResponse> {
const response = await this.client.put<BrandPlatformRuleResponse>(`/rules/platform-rules/${ruleId}/confirm`, data)
return response.data
}
/**
*
*/
async listBrandPlatformRules(params?: { brand_id?: string; platform?: string; status?: string }): Promise<BrandPlatformRuleListResponse> {
const response = await this.client.get<BrandPlatformRuleListResponse>('/rules/platform-rules', { params })
return response.data
}
/**
*
*/
async deletePlatformRule(ruleId: string): Promise<void> {
await this.client.delete(`/rules/platform-rules/${ruleId}`)
}
// ==================== AI 配置 ====================
/**

View File

@ -79,6 +79,54 @@ export interface PlatformListResponse {
total: number
}
// ===== 品牌方平台规则(文档上传 + AI 解析) =====
export interface ParsedRulesData {
forbidden_words: string[]
restricted_words: { word: string; condition: string; suggestion: string }[]
duration: { min_seconds?: number; max_seconds?: number } | null
content_requirements: string[]
other_rules: { rule: string; description: string }[]
}
export interface PlatformRuleParseRequest {
document_url: string
document_name: string
platform: string
brand_id: string
}
export interface PlatformRuleParseResponse {
id: string
platform: string
brand_id: string
document_url: string
document_name: string
parsed_rules: ParsedRulesData
status: string
}
export interface PlatformRuleConfirmRequest {
parsed_rules: ParsedRulesData
}
export interface BrandPlatformRuleResponse {
id: string
platform: string
brand_id: string
document_url: string
document_name: string
parsed_rules: ParsedRulesData
status: string // draft / active / inactive
created_at: string
updated_at: string
}
export interface BrandPlatformRuleListResponse {
items: BrandPlatformRuleResponse[]
total: number
}
// ===== 规则冲突检测 =====
export interface RuleValidateRequest {