0f27bfa999
CI/CD Pipeline / Canary Release to Production (push) Failing after 1165h33m40s
CI/CD Pipeline / Production Browser E2E (push) Failing after 1165h54m7s
CI/CD Pipeline / Deploy Production (push) Failing after 1165h54m8s
CI/CD Pipeline / CI Gate (push) Failing after 1165h54m9s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 1165h54m9s
CI/CD Pipeline / Build Production Web Image (push) Failing after 1165h54m9s
CI/CD Pipeline / Build Production API Image (push) Failing after 1165h54m10s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 1166h3m9s
CI/CD Pipeline / PR Build Web Image (push) Failing after 1166h3m11s
CI/CD Pipeline / PR Build API Image (push) Failing after 1166h3m13s
CI/CD Pipeline / Frontend Lint (push) Failing after 1166h3m37s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 1166h5m10s
CI/CD Pipeline / Unit Tests (push) Successful in 9m26s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 3m46s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 5m53s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 1m54s
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 1m59s
CI/CD Pipeline / Integration Tests (push) Successful in 2m45s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 4m27s
CI/CD Pipeline / Build Staging API Image (push) Successful in 14m48s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 5m36s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 3m3s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m2s
CI/CD Pipeline / Staging API Integration Tests (push) Successful in 3m39s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 44s
Co-authored-by: xiaoxia <dev@xiaoxiajianji.com> Co-committed-by: xiaoxia <dev@xiaoxiajianji.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
|
import { message } from "antd"
|
|
import { createTitle, updateTitle, deleteTitle } from "@/api/titles"
|
|
|
|
export const useTitleMutations = () => {
|
|
const queryClient = useQueryClient()
|
|
|
|
const createMutation = useMutation({
|
|
mutationFn: (content: string) => createTitle({ content }),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ["titles"] })
|
|
},
|
|
onError: () => message.error("创建标题失败"),
|
|
})
|
|
|
|
const updateMutation = useMutation({
|
|
mutationFn: ({ id, content }: { id: string; content: string }) => updateTitle(id, { content }),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ["titles"] })
|
|
},
|
|
onError: () => message.error("更新标题失败"),
|
|
})
|
|
|
|
const deleteMutation = useMutation({
|
|
mutationFn: (id: string) => deleteTitle(id),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ["titles"] })
|
|
message.success("标题已删除")
|
|
},
|
|
onError: () => message.error("删除标题失败"),
|
|
})
|
|
|
|
return { createMutation, updateMutation, deleteMutation }
|
|
}
|