【代码调整】AI:MJ 二次 Action 的接口修改
parent
7fe8b8b7a9
commit
36dc3c0b5c
|
@ -1,51 +1,28 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// AI API 密钥 VO
|
||||
// TODO @fan:要不前端不弄太多 VO,就用这个 ImageDetailVO?!
|
||||
export interface ImageDetailVO {
|
||||
export interface ImageRespVO {
|
||||
id: number // 编号
|
||||
prompt: string // 提示词
|
||||
status: number // 状态
|
||||
errorMessage: string // 错误信息
|
||||
type: string // 模型下分不同的类型(清晰、真实...)
|
||||
taskId: number // dr 任务id
|
||||
picUrl: string // 任务地址
|
||||
originalPicUrl: string // 绘制图片地址
|
||||
platform: string // 平台
|
||||
model: string // 模型
|
||||
style: string // 图像生成的风格
|
||||
size: string // 图片尺寸
|
||||
prompt: string // 提示词
|
||||
width: number // 图片宽度
|
||||
height: number // 图片高度
|
||||
status: number // 状态
|
||||
publicStatus: string // 公开状态
|
||||
picUrl: string // 任务地址
|
||||
errorMessage: string // 错误信息
|
||||
options: object // 配置 Map<string, string>
|
||||
taskId: number // 任务编号
|
||||
buttons: ImageMjButtonsVO[] // mj 操作按钮
|
||||
createTime: string // 创建时间
|
||||
updateTime: string // 更新事件
|
||||
}
|
||||
|
||||
export interface ImageMjButtonsVO {
|
||||
customId: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
|
||||
emoji: string // 图标 emoji
|
||||
label: string // Make Variations 文本
|
||||
style: number // 样式: 2(Primary)、3(Green)
|
||||
}
|
||||
|
||||
export interface ImageMjActionVO {
|
||||
id: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
|
||||
customId: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
|
||||
}
|
||||
|
||||
|
||||
export interface ImagePageReqVO {
|
||||
pageNo: number // 分页编号
|
||||
pageSize: number // 分页大小
|
||||
}
|
||||
|
||||
export interface ImageDallReqVO {
|
||||
prompt: string // 提示词
|
||||
model: string // 模型
|
||||
style: string // 图像生成的风格
|
||||
width: string // 图片宽度
|
||||
height: string // 图片高度
|
||||
}
|
||||
|
||||
export interface ImageDrawReqVO {
|
||||
platform: string // 平台
|
||||
prompt: string // 提示词
|
||||
|
@ -65,34 +42,45 @@ export interface ImageMidjourneyImagineReqVO {
|
|||
version: string // 版本
|
||||
}
|
||||
|
||||
// TODO 芋艿:review 下整体注释、方法名
|
||||
export interface ImageMjActionVO {
|
||||
id: number // 图片编号
|
||||
customId: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
|
||||
}
|
||||
|
||||
export interface ImageMjButtonsVO {
|
||||
customId: string // MJ::JOB::upsample::1::85a4b4c1-8835-46c5-a15c-aea34fad1862 动作标识
|
||||
emoji: string // 图标 emoji
|
||||
label: string // Make Variations 文本
|
||||
style: number // 样式: 2(Primary)、3(Green)
|
||||
}
|
||||
|
||||
// AI API 密钥 API
|
||||
export const ImageApi = {
|
||||
// 获取 image 列表
|
||||
getImageList: async (params: ImagePageReqVO) => {
|
||||
// 获取我的图片列表
|
||||
getImagePageMy: async (params: ImagePageReqVO) => {
|
||||
return await request.get({ url: `/ai/image/my-page`, params })
|
||||
},
|
||||
// 获取 image 详细信息
|
||||
getImageDetail: async (id: number) => {
|
||||
// 获取我的图片
|
||||
getImageMy: async (id: number) => {
|
||||
return await request.get({ url: `/ai/image/get-my?id=${id}`})
|
||||
},
|
||||
// 生成图片
|
||||
drawImage: async (data: ImageDrawReqVO)=> {
|
||||
return await request.post({ url: `/ai/image/draw`, data })
|
||||
},
|
||||
// 删除
|
||||
deleteImage: async (id: number)=> {
|
||||
// 删除我的图片
|
||||
deleteImageMy: async (id: number)=> {
|
||||
return await request.delete({ url: `/ai/image/delete-my?id=${id}`})
|
||||
},
|
||||
|
||||
// ------------ midjourney
|
||||
// ================ midjourney 专属 ================
|
||||
|
||||
// midjourney - imagine
|
||||
// 【Midjourney】生成图片
|
||||
midjourneyImagine: async (data: ImageMidjourneyImagineReqVO)=> {
|
||||
return await request.post({ url: `/ai/image/midjourney/imagine`, data })
|
||||
},
|
||||
// midjourney - action
|
||||
midjourneyAction: async (params: ImageMjActionVO)=> {
|
||||
return await request.get({ url: `/ai/image/midjourney/action`, params })
|
||||
// 【Midjourney】Action 操作(二次生成图片)
|
||||
midjourneyAction: async (data: ImageMjActionVO)=> {
|
||||
return await request.post({ url: `/ai/image/midjourney/action`, data })
|
||||
},
|
||||
}
|
||||
|
|
|
@ -60,11 +60,11 @@
|
|||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {ImageApi, ImageDetailVO} from '@/api/ai/image';
|
||||
import {ImageApi, ImageRespVO} from '@/api/ai/image';
|
||||
import ImageTaskCard from './ImageTaskCard.vue';
|
||||
|
||||
const showDrawer = ref<boolean>(false) // 是否显示
|
||||
const imageDetail = ref<ImageDetailVO>({} as ImageDetailVO) // 图片详细信息
|
||||
const imageDetail = ref<ImageRespVO>({} as ImageRespVO) // 图片详细信息
|
||||
|
||||
const props = defineProps({
|
||||
show: {
|
||||
|
@ -86,7 +86,7 @@ const handlerDrawerClose = async () => {
|
|||
/** 获取 - 图片 detail */
|
||||
const getImageDetail = async (id) => {
|
||||
// 获取图片详细
|
||||
imageDetail.value = await ImageApi.getImageDetail(id)
|
||||
imageDetail.value = await ImageApi.getImageMy(id)
|
||||
}
|
||||
|
||||
/** 任务 - detail */
|
||||
|
|
|
@ -26,14 +26,14 @@
|
|||
/>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {ImageApi, ImageDetailVO, ImageMjActionVO, ImageMjButtonsVO} from '@/api/ai/image';
|
||||
import {ImageApi, ImageRespVO, ImageMjActionVO, ImageMjButtonsVO} from '@/api/ai/image';
|
||||
import ImageDetailDrawer from './ImageDetailDrawer.vue'
|
||||
import ImageTaskCard from './ImageTaskCard.vue'
|
||||
import {ElLoading, LoadingOptionsResolved} from "element-plus";
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const imageList = ref<ImageDetailVO[]>([]) // image 列表
|
||||
const imageList = ref<ImageRespVO[]>([]) // image 列表
|
||||
const imageListInterval = ref<any>() // image 列表定时器,刷新列表
|
||||
const isShowImageDetail = ref<boolean>(false) // 是否显示 task 详情
|
||||
const showImageDetailId = ref<number>(0) // 是否显示 task 详情
|
||||
|
@ -64,7 +64,7 @@ const getImageList = async (apply:boolean = false) => {
|
|||
target: imageTaskRef.value,
|
||||
text: '加载中...'
|
||||
} as LoadingOptionsResolved)
|
||||
const { list, total } = await ImageApi.getImageList({pageNo: pageNo.value, pageSize: pageSize.value})
|
||||
const { list, total } = await ImageApi.getImagePageMy({pageNo: pageNo.value, pageSize: pageSize.value})
|
||||
if (apply) {
|
||||
imageList.value = [...imageList.value, ...list]
|
||||
} else {
|
||||
|
@ -80,7 +80,7 @@ const getImageList = async (apply:boolean = false) => {
|
|||
}
|
||||
|
||||
/** 图片 - btn click */
|
||||
const handlerImageBtnClick = async (type, imageDetail: ImageDetailVO) => {
|
||||
const handlerImageBtnClick = async (type, imageDetail: ImageRespVO) => {
|
||||
// 获取 image detail id
|
||||
showImageDetailId.value = imageDetail.id
|
||||
console.log('type', imageDetail.id)
|
||||
|
@ -89,7 +89,7 @@ const handlerImageBtnClick = async (type, imageDetail: ImageDetailVO) => {
|
|||
await handlerDrawerOpen()
|
||||
} else if (type === 'delete') {
|
||||
await message.confirm(`是否删除照片?`)
|
||||
await ImageApi.deleteImage(imageDetail.id)
|
||||
await ImageApi.deleteImageMy(imageDetail.id)
|
||||
await getImageList()
|
||||
await message.success("删除成功!")
|
||||
} else if (type === 'download') {
|
||||
|
@ -98,14 +98,14 @@ const handlerImageBtnClick = async (type, imageDetail: ImageDetailVO) => {
|
|||
}
|
||||
|
||||
/** 图片 - mj btn click */
|
||||
const handlerImageMjBtnClick = async (button: ImageMjButtonsVO, imageDetail: ImageDetailVO) => {
|
||||
const handlerImageMjBtnClick = async (button: ImageMjButtonsVO, imageDetail: ImageRespVO) => {
|
||||
// 1、构建 params 参数
|
||||
const params = {
|
||||
const data = {
|
||||
id: imageDetail.id,
|
||||
customId: button.customId,
|
||||
} as ImageMjActionVO
|
||||
// 2、发送 action
|
||||
await ImageApi.midjourneyAction(params)
|
||||
await ImageApi.midjourneyAction(data)
|
||||
// 3、刷新列表
|
||||
await getImageList()
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
</template>
|
||||
<script setup lang="ts">
|
||||
import {Delete, Download, More} from "@element-plus/icons-vue";
|
||||
import {ImageDetailVO, ImageMjButtonsVO} from "@/api/ai/image";
|
||||
import {ImageRespVO, ImageMjButtonsVO} from "@/api/ai/image";
|
||||
import {PropType} from "vue";
|
||||
import {ElLoading, ElMessageBox} from "element-plus";
|
||||
|
||||
|
@ -41,13 +41,13 @@ const cardImageLoadingInstance = ref<any>() // 卡片 image ref
|
|||
const message = useMessage()
|
||||
const props = defineProps({
|
||||
imageDetail: {
|
||||
type: Object as PropType<ImageDetailVO>,
|
||||
type: Object as PropType<ImageRespVO>,
|
||||
require: true
|
||||
}
|
||||
})
|
||||
|
||||
/** 按钮 - 点击事件 */
|
||||
const handlerBtnClick = async (type, imageDetail: ImageDetailVO) => {
|
||||
const handlerBtnClick = async (type, imageDetail: ImageRespVO) => {
|
||||
emits('onBtnClick', type, imageDetail)
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,6 @@ const imageSizeList = ref<ImageSizeVO[]>([
|
|||
]) // size
|
||||
selectImageSize.value = imageSizeList.value[0]
|
||||
|
||||
|
||||
// version
|
||||
let versionList = ref<any>([]) // version 列表
|
||||
const midjourneyVersionList = ref<any>([
|
||||
|
@ -204,9 +203,6 @@ const nijiVersionList = ref<any>([
|
|||
const selectVersion = ref<any>('6.0') // 选中的 version
|
||||
versionList.value = midjourneyVersionList.value // 默认选择 midjourney
|
||||
|
||||
// 定义 Props
|
||||
const props = defineProps({})
|
||||
|
||||
/** 热词 - click */
|
||||
const handlerHotWordClick = async (hotWord: string) => {
|
||||
// 取消
|
||||
|
|
Loading…
Reference in New Issue