| 1 | /* |
| 2 | * @Author: nevin |
| 3 | * @Date: 2025-02-22 12:02:55 |
| 4 | * @LastEditTime: 2025-03-02 22:21:01 |
| 5 | * @LastEditors: nevin |
| 6 | * @Description: 工具 |
| 7 | */ |
| 8 | import http from './request'; |
| 9 | import { AiCreateType } from './types/tools'; |
| 10 | |
| 11 | export const toolsApi = { |
| 12 | /** |
| 13 | * 获取智能标题 |
| 14 | * @param url |
| 15 | * @param type 1=标题 2=描述 |
| 16 | * @param max |
| 17 | */ |
| 18 | apiVideoAiTitle(url: string, type: AiCreateType, max: number) { |
| 19 | return http.post<string>( |
| 20 | '/tools/ai/video/title', |
| 21 | { |
| 22 | url, |
| 23 | type, |
| 24 | max: max - 10, |
| 25 | }, |
| 26 | { |
| 27 | isToken: true, |
| 28 | }, |
| 29 | ); |
| 30 | }, |
| 31 | |
| 32 | /** |
| 33 | * 智能图文 |
| 34 | */ |
| 35 | apiReviewImgAi(data: { |
| 36 | imgUrl: string; |
| 37 | title?: string; |
| 38 | desc?: string; |
| 39 | max?: number; |
| 40 | }) { |
| 41 | return http.post<string>('/tools/ai/reviewImg', data, { |
| 42 | isToken: true, |
| 43 | }); |
| 44 | }, |
| 45 | |
| 46 | /** |
| 47 | * 智能评论 |
| 48 | */ |
| 49 | apiReviewAi(data: { title: string; desc?: string; max?: number }) { |
| 50 | return http.post<string>('/tools/ai/review', data, { |
| 51 | isToken: true, |
| 52 | }); |
| 53 | }, |
| 54 | |
| 55 | /** |
| 56 | * 智能评论回复 |
| 57 | */ |
| 58 | apiReviewAiRecover(data: { |
| 59 | content: string; |
| 60 | title?: string; |
| 61 | desc?: string; |
| 62 | max?: number; |
| 63 | }) { |
| 64 | return http.post<string>('/tools/ai/recover/review', data, { |
| 65 | isToken: true, |
| 66 | }); |
| 67 | }, |
| 68 | |
| 69 | /** |
| 70 | * 生成AI的html图文 弃用: 时间太长得走sse |
| 71 | */ |
| 72 | aiArticleHtml(content: string) { |
| 73 | return http.post<string>( |
| 74 | '/tools/ai/article/html', |
| 75 | { |
| 76 | content, |
| 77 | }, |
| 78 | { |
| 79 | isToken: true, |
| 80 | }, |
| 81 | ); |
| 82 | }, |
| 83 | |
| 84 | // TODO: sse生成AI的html图文 |
| 85 | // /tools/ai/article/html/sse |
| 86 | |
| 87 | /** |
| 88 | * 上传文件 |
| 89 | */ |
| 90 | uploadFile(file: Blob) { |
| 91 | const formData = new FormData(); |
| 92 | formData.append('file', file); |
| 93 | return http.post<{ |
| 94 | name: string; |
| 95 | }>('/oss/upload/permanent', formData, { |
| 96 | headers: { |
| 97 | 'Content-Type': 'multipart/form-data', |
| 98 | }, |
| 99 | }); |
| 100 | }, |
| 101 | |
| 102 | /** |
| 103 | * 上传文件临时 |
| 104 | */ |
| 105 | uploadFileTemp(file: Blob) { |
| 106 | const formData = new FormData(); |
| 107 | formData.append('file', file); |
| 108 | return http.post<{ |
| 109 | name: string; |
| 110 | }>('/oss/upload', formData, { |
| 111 | headers: { |
| 112 | 'Content-Type': 'multipart/form-data', |
| 113 | }, |
| 114 | }); |
| 115 | }, |
| 116 | |
| 117 | /** |
| 118 | * 文本内容安全 |
| 119 | */ |
| 120 | textModeration(content: string) { |
| 121 | return http.post<string>( |
| 122 | '/tools/common/text/moderation', |
| 123 | { |
| 124 | content, |
| 125 | }, |
| 126 | { |
| 127 | isToken: true, |
| 128 | }, |
| 129 | ); |
| 130 | }, |
| 131 | }; |
| 132 |