index.ts 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import request from '@/config/axios'
  2. // AI 绘图 VO
  3. export interface ImageVO {
  4. id: number // 编号
  5. platform: string // 平台
  6. model: string // 模型
  7. prompt: string // 提示词
  8. width: number // 图片宽度
  9. height: number // 图片高度
  10. status: number // 状态
  11. publicStatus: boolean // 公开状态
  12. picUrl: string // 任务地址
  13. errorMessage: string // 错误信息
  14. options: any // 配置 Map<string, string>
  15. taskId: number // 任务编号
  16. buttons: ImageMidjourneyButtonsVO[] // mj 操作按钮
  17. createTime: Date // 创建时间
  18. finishTime: Date // 完成时间
  19. }
  20. export interface ImageDrawReqVO {
  21. platform: string // 平台
  22. prompt: string // 提示词
  23. model: string // 模型
  24. style: string // 图像生成的风格
  25. width: string // 图片宽度
  26. height: string // 图片高度
  27. options: object // 绘制参数,Map<String, String>
  28. }
  29. export interface ImageMidjourneyImagineReqVO {
  30. prompt: string // 提示词
  31. model: string // 模型 mj nijj
  32. base64Array: string[] // size不能为空
  33. width: string // 图片宽度
  34. height: string // 图片高度
  35. version: string // 版本
  36. }
  37. export interface ImageMidjourneyActionVO {
  38. id: number // 图片编号
  39. customId: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
  40. }
  41. export interface ImageMidjourneyButtonsVO {
  42. customId: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
  43. emoji: string // 图标 emoji
  44. label: string // Make Variations 文本
  45. style: number // 样式: 2(Primary)、3(Green)
  46. }
  47. // AI 图片 API
  48. export const ImageApi = {
  49. // 获取【我的】绘图分页
  50. getImagePageMy: async (params: PageParam) => {
  51. return await request.get({ url: `/ai/image/my-page`, params })
  52. },
  53. // 获取公开的绘图记录
  54. getImagePagePublic: async (params: PageParam) => {
  55. return await request.get({ url: `/ai/image/public-page`, params })
  56. },
  57. // 获取【我的】绘图记录
  58. getImageMy: async (id: number) => {
  59. return await request.get({ url: `/ai/image/get-my?id=${id}` })
  60. },
  61. // 获取【我的】绘图记录列表
  62. getImageListMyByIds: async (ids: number[]) => {
  63. return await request.get({ url: `/ai/image/my-list-by-ids`, params: { ids: ids.join(',') } })
  64. },
  65. // 生成图片
  66. drawImage: async (data: ImageDrawReqVO) => {
  67. return await request.post({ url: `/ai/image/draw`, data })
  68. },
  69. // 删除【我的】绘画记录
  70. deleteImageMy: async (id: number) => {
  71. return await request.delete({ url: `/ai/image/delete-my?id=${id}` })
  72. },
  73. // ================ midjourney 专属 ================
  74. // 【Midjourney】生成图片
  75. midjourneyImagine: async (data: ImageMidjourneyImagineReqVO) => {
  76. return await request.post({ url: `/ai/image/midjourney/imagine`, data })
  77. },
  78. // 【Midjourney】Action 操作(二次生成图片)
  79. midjourneyAction: async (data: ImageMidjourneyActionVO) => {
  80. return await request.post({ url: `/ai/image/midjourney/action`, data })
  81. },
  82. // ================ 绘图管理 ================
  83. // 查询绘画分页
  84. getImagePage: async (params: any) => {
  85. return await request.get({ url: `/ai/image/page`, params })
  86. },
  87. // 更新绘画发布状态
  88. updateImage: async (data: any) => {
  89. return await request.put({ url: '/ai/image/update-public-status', data })
  90. },
  91. // 删除绘画
  92. deleteImage: async (id: number) => {
  93. return await request.delete({ url: `/ai/image/delete?id=` + id })
  94. }
  95. }