generated from kevisual/vite-react-template
feat: 优化mark接口文档和工作空间页面字段
This commit is contained in:
@@ -7,7 +7,11 @@ import { toast } from 'sonner';
|
||||
|
||||
type WorkspaceItem = {
|
||||
id: string;
|
||||
name: string;
|
||||
title: string;
|
||||
tags?: string[];
|
||||
link?: string;
|
||||
summary?: string;
|
||||
description?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
data?: any;
|
||||
@@ -28,8 +32,8 @@ type WorkspaceState = {
|
||||
setEditingItem: (item: WorkspaceItem | null) => void;
|
||||
// 数据操作
|
||||
getList: (params?: { search?: string, page?: number, pageSize?: number }) => Promise<void>;
|
||||
createItem: (data: { name: string, data?: any }) => Promise<void>;
|
||||
updateItem: (id: string, data: { name?: string, data?: any }) => Promise<void>;
|
||||
createItem: (data: { title: string, tags?: string[], link?: string, summary?: string, description?: string, data?: any }) => Promise<void>;
|
||||
updateItem: (id: string, data: { title?: string, tags?: string[], link?: string, summary?: string, description?: string, data?: any }) => Promise<void>;
|
||||
deleteItem: (id: string) => Promise<void>;
|
||||
getItem: (id: string) => Promise<WorkspaceItem | null>;
|
||||
}
|
||||
@@ -76,8 +80,12 @@ export const useWorkspaceStore = create<WorkspaceState>((set, get) => ({
|
||||
createItem: async (data) => {
|
||||
try {
|
||||
const res = await queryApi.mark.create({
|
||||
name: data.name,
|
||||
title: data.title,
|
||||
markType: 'cnb',
|
||||
tags: data.tags || [],
|
||||
link: data.link || '',
|
||||
summary: data.summary || '',
|
||||
description: data.description || '',
|
||||
data: data.data || {}
|
||||
});
|
||||
if (res.code === 200) {
|
||||
@@ -97,7 +105,13 @@ export const useWorkspaceStore = create<WorkspaceState>((set, get) => ({
|
||||
try {
|
||||
const res = await queryApi.mark.update({
|
||||
id,
|
||||
...data
|
||||
data: {
|
||||
title: data.title || '',
|
||||
tags: data.tags || [],
|
||||
link: data.link || '',
|
||||
summary: data.summary || '',
|
||||
description: data.description || ''
|
||||
}
|
||||
});
|
||||
if (res.code === 200) {
|
||||
toast.success('更新成功');
|
||||
|
||||
Reference in New Issue
Block a user