Files
xiaoxia-saas/apps/web/src/api/scripts/scripts.ts
T
xiaoxia 7209b7d481
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (push) Successful in 1s
CI/CD Pipeline / Check push changed paths (push) Successful in 4s
CI/CD Pipeline / Build Staging API Image (push) Successful in 31s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 36s
CI/CD Pipeline / Validate - Style (push) Successful in 1m21s
CI/CD Pipeline / Validate - Python (mypy + alembic) (push) Successful in 1m46s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 1m48s
CI/CD Pipeline / Integration Tests (push) Successful in 3m15s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m29s
CI/CD Pipeline / Validate - Security (push) Successful in 4m30s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 1m46s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 5m34s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 2m14s
CI/CD Pipeline / Unit Tests (push) Successful in 7m47s
CI/CD Pipeline / Production Browser E2E (push) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 22m59s
CI/CD Pipeline / Canary Release to Production (push) Failing after 173h57m47s
CI/CD Pipeline / Build Production API Image (push) Failing after 174h16m42s
CI/CD Pipeline / Deploy Production (push) Failing after 174h16m40s
CI/CD Pipeline / Retag skipped Staging Worker Image (push) Failing after 174h22m33s
CI/CD Pipeline / CI Gate (push) Failing after 174h16m41s
CI/CD Pipeline / Retag skipped Staging API Image (push) Failing after 174h22m35s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 174h16m41s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 174h24m31s
CI/CD Pipeline / PR Build API Image (push) Failing after 174h24m31s
CI/CD Pipeline / Frontend Lint (push) Failing after 174h24m32s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 174h24m35s
CI/CD Pipeline / Build Production Web Image (push) Failing after 174h51m27s
CI/CD Pipeline / Retag skipped Staging Web Image (push) Failing after 174h57m19s
CI/CD Pipeline / PR Build Web Image (push) Failing after 174h59m17s
feat: #1811 新增文案库独立页面 (#1812)
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com>
Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
2026-09-09 08:59:27 +08:00

38 lines
1.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 文案库 API
* 对接后端 /api/v1/scriptsCRUD + 列表解包)
*/
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}`)
}