f4cac1dc6e
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 33s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 1m1s
CI/CD Pipeline / PR Build Web Image (pull_request) Successful in 2m26s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 2m59s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m3s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m32s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 3m32s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m9s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m48s
CI/CD Pipeline / Frontend Unit Tests (pull_request) Successful in 6m29s
AI Code Review / AI Code Review (pull_request) Successful in 7m8s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 9m28s
CI/CD Pipeline / Validate - Security (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Failing after 162h22m35s
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Failing after 162h22m55s
CI/CD Pipeline / Staging API Integration Tests (pull_request) Failing after 162h22m40s
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Failing after 162h23m0s
CI/CD Pipeline / Staging E2E Tests (pull_request) Failing after 162h22m44s
CI/CD Pipeline / Build Staging Worker Image (pull_request) Failing after 162h23m10s
CI/CD Pipeline / Build Staging Web Image (pull_request) Failing after 162h23m10s
CI/CD Pipeline / Check push changed paths (pull_request) Failing after 162h23m12s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Failing after 162h57m36s
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Failing after 162h57m52s
CI/CD Pipeline / Build Staging API Image (pull_request) Failing after 162h57m57s
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
/**
|
||
* 文案库 API
|
||
* 对接后端 /api/v1/scripts(CRUD + 列表解包)
|
||
*/
|
||
import apiClient from "../client"
|
||
import type {
|
||
ScriptItem,
|
||
ScriptListResponse,
|
||
CreateScriptRequest,
|
||
UpdateScriptRequest,
|
||
} from "./types"
|
||
|
||
/** 获取文案列表 — 必须解包 items(后端返回 {items,total})*/
|
||
export const getScripts = async (): Promise<ScriptItem[]> => {
|
||
const response = await apiClient.get<ScriptListResponse | ScriptItem[]>("/scripts")
|
||
const data = response.data as unknown
|
||
if (Array.isArray(data)) return data
|
||
const items = (data as { items?: ScriptItem[] })?.items
|
||
return Array.isArray(items) ? items : []
|
||
}
|
||
|
||
/** 新建文案 */
|
||
export const createScript = async (data: CreateScriptRequest): Promise<ScriptItem> => {
|
||
const response = await apiClient.post<ScriptItem>("/scripts", data)
|
||
return response.data
|
||
}
|
||
|
||
/** 更新文案 */
|
||
export const updateScript = async (id: string, data: UpdateScriptRequest): Promise<ScriptItem> => {
|
||
const response = await apiClient.put<ScriptItem>(`/scripts/${id}`, data)
|
||
return response.data
|
||
}
|
||
|
||
/** 删除文案 */
|
||
export const deleteScript = async (id: string): Promise<void> => {
|
||
await apiClient.delete(`/scripts/${id}`)
|
||
}
|