| 1 | import { PlatType } from '@@/AccountEnum'; |
| 2 | |
| 3 | /* |
| 4 | * @Author: nevin |
| 5 | * @Date: 2025-01-23 15:48:14 |
| 6 | * @LastEditTime: 2025-03-20 22:39:03 |
| 7 | * @LastEditors: nevin |
| 8 | * @Description: |
| 9 | */ |
| 10 | export type WorkData = { |
| 11 | dataId: string; |
| 12 | readCount?: number; |
| 13 | likeCount?: number; |
| 14 | collectCount?: number; |
| 15 | forwardCount?: number; |
| 16 | commentCount?: number; // 评论数量 |
| 17 | income?: number; |
| 18 | title?: string; |
| 19 | desc?: string; |
| 20 | coverUrl?: string; |
| 21 | videoUrl?: string; |
| 22 | option?: { |
| 23 | xsec_token: string; |
| 24 | }; |
| 25 | }; |
| 26 | |
| 27 | export type CommentData = { |
| 28 | dataId: string; |
| 29 | commentId: string; |
| 30 | parentCommentId?: string; // 上级评论ID |
| 31 | content: string; |
| 32 | likeCount?: number; // 点赞次数 |
| 33 | nikeName?: string; |
| 34 | headUrl?: string; |
| 35 | data: any; // 原数据 |
| 36 | subCommentList: CommentData[]; // 子数据 |
| 37 | }; |
| 38 | |
| 39 | /** |
| 40 | * 获取作品列表 |
| 41 | */ |
| 42 | export async function icpCreatorList(accountId: number, pcursor?: string) { |
| 43 | const res: { |
| 44 | list: WorkData[]; |
| 45 | pageInfo: { |
| 46 | count: number; |
| 47 | hasMore: boolean; |
| 48 | pcursor?: string; |
| 49 | }; |
| 50 | } = await window.ipcRenderer.invoke('ICP_CREATOR_LIST', accountId, pcursor); |
| 51 | return res; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * 获取评论列表 |
| 56 | */ |
| 57 | export async function icpGetCommentList( |
| 58 | accountId: number, |
| 59 | data: WorkData, |
| 60 | pcursor?: string, |
| 61 | ) { |
| 62 | const res: { |
| 63 | list: CommentData[]; |
| 64 | pageInfo: { |
| 65 | count: number; |
| 66 | hasMore: boolean; |
| 67 | pcursor?: string; |
| 68 | }; |
| 69 | } = await window.ipcRenderer.invoke( |
| 70 | 'ICP_COMMENT_LIST', |
| 71 | accountId, |
| 72 | data, |
| 73 | pcursor, |
| 74 | ); |
| 75 | return res; |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * 创建评论 |
| 80 | */ |
| 81 | export async function icpCreateComment( |
| 82 | accountId: number, |
| 83 | dataId: string, |
| 84 | content: string, |
| 85 | ) { |
| 86 | const res: boolean = await window.ipcRenderer.invoke( |
| 87 | 'ICP_CREATE_COMMENT', |
| 88 | accountId, |
| 89 | dataId, |
| 90 | content, |
| 91 | ); |
| 92 | return res; |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * 回复评论 |
| 97 | */ |
| 98 | export async function icpReplyComment( |
| 99 | accountId: number, |
| 100 | commentId: string, |
| 101 | content: string, |
| 102 | option: { |
| 103 | dataId?: string; // 作品ID |
| 104 | comment: any; // 辅助数据,原数据 |
| 105 | }, |
| 106 | ) { |
| 107 | const res: boolean = await window.ipcRenderer.invoke( |
| 108 | 'ICP_REPLY_COMMENT', |
| 109 | accountId, |
| 110 | commentId, |
| 111 | content, |
| 112 | option, |
| 113 | ); |
| 114 | return res; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * 一键作品回复评论 |
| 119 | */ |
| 120 | export async function icpReplyCommentList(accountId: number, data: WorkData) { |
| 121 | const res: boolean = await window.ipcRenderer.invoke( |
| 122 | 'ICP_REPLY_COMMENT_LIST_BY_AI', |
| 123 | accountId, |
| 124 | data, |
| 125 | ); |
| 126 | return res; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * 创建一键回复自动进程 |
| 131 | * @param data |
| 132 | */ |
| 133 | export async function ipcCreateAutoRunOfReply( |
| 134 | accountId: number, |
| 135 | data: WorkData, // 作品ID |
| 136 | cycleType: string, |
| 137 | ) { |
| 138 | const res: string = await window.ipcRenderer.invoke( |
| 139 | 'ICP_AUTO_RUN_CREATE_REPLY', |
| 140 | accountId, |
| 141 | data, |
| 142 | cycleType, |
| 143 | ); |
| 144 | return res; |
| 145 | } |
| 146 | |
| 147 | export enum AutorReplyCacheStatus { |
| 148 | DOING = 0, |
| 149 | DONE = 1, |
| 150 | REEOR = 2, |
| 151 | } |
| 152 | /** |
| 153 | * 获取一键回复的进程信息 |
| 154 | * @returns |
| 155 | */ |
| 156 | export async function ipcGetAutoRunOfReplyInfo() { |
| 157 | const res: { |
| 158 | status: AutorReplyCacheStatus; |
| 159 | message: string; |
| 160 | createTime?: number; |
| 161 | updateTime?: number; |
| 162 | title: string; |
| 163 | dataId?: string; |
| 164 | } = await window.ipcRenderer.invoke('ICP_GET_AUTO_REPLY_INFO'); |
| 165 | return res; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * 获取AI评论截流的记录列表 |
| 170 | * @param page |
| 171 | * @param query |
| 172 | */ |
| 173 | export async function ipcGetReplyCommentRecordList( |
| 174 | page: { |
| 175 | page_size: number; |
| 176 | page_no: number; |
| 177 | }, |
| 178 | query: { |
| 179 | accountId?: number; |
| 180 | type?: PlatType; |
| 181 | }, |
| 182 | ) { |
| 183 | const res: string = await window.ipcRenderer.invoke( |
| 184 | 'ICP_GET_REPLAY_COMMENT_RECORD_LIST', |
| 185 | page, |
| 186 | query, |
| 187 | ); |
| 188 | return res; |
| 189 | } |
| 190 |