gaoluyang
2026-06-24 712aa51536236d43e87273e4ce45ac5691dffad8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import type { PageParam, PageResult } from '..\..\..\packages\effects\request\src';
 
import { requestClient } from '#/api/request';
 
export namespace MpDraftApi {
  /** 草稿文章信息 */
  export interface Article {
    title: string;
    author: string;
    digest: string;
    content: string;
    contentSourceUrl: string;
    thumbMediaId: string;
    showCoverPic: number;
    needOpenComment: number;
    onlyFansCanComment: number;
  }
 
  /** 草稿信息 */
  export interface Draft {
    id?: number;
    accountId: number;
    mediaId: string;
    articles: Article[];
    createTime?: Date;
  }
 
  /** 图文项(包含预览字段) */
  export interface NewsItem {
    title: string;
    thumbMediaId: string;
    author: string;
    digest: string;
    showCoverPic: number;
    content: string;
    contentSourceUrl: string;
    needOpenComment: number;
    onlyFansCanComment: number;
    thumbUrl: string;
    picUrl?: string; // 用于预览封面
  }
 
  /** 图文列表 */
  export interface NewsItemList {
    newsItem: NewsItem[];
  }
 
  /** 草稿文章(用于展示) */
  export interface DraftArticle {
    mediaId: string;
    content: NewsItemList;
    updateTime: number;
  }
}
 
/** 创建空的图文项 */
export function createEmptyNewsItem(): MpDraftApi.NewsItem {
  return {
    title: '',
    thumbMediaId: '',
    author: '',
    digest: '',
    showCoverPic: 0,
    content: '',
    contentSourceUrl: '',
    needOpenComment: 0,
    onlyFansCanComment: 0,
    thumbUrl: '',
  };
}
 
/** 查询草稿列表 */
export function getDraftPage(params: PageParam) {
  return requestClient.get<PageResult<MpDraftApi.Draft>>('/mp/draft/page', {
    params,
  });
}
 
/** 创建草稿 */
export function createDraft(accountId: number, articles: MpDraftApi.Article[]) {
  return requestClient.post(
    '/mp/draft/create',
    { articles },
    {
      params: { accountId },
    },
  );
}
 
/** 更新草稿 */
export function updateDraft(
  accountId: number,
  mediaId: string,
  articles: MpDraftApi.Article[],
) {
  return requestClient.put('/mp/draft/update', articles, {
    params: { accountId, mediaId },
  });
}
 
/** 删除草稿 */
export function deleteDraft(accountId: number, mediaId: string) {
  return requestClient.delete('/mp/draft/delete', {
    params: { accountId, mediaId },
  });
}