【增加】AI Image 增加 dall 绘画

This commit is contained in:
cherishsince 2024-05-27 15:28:53 +08:00
parent 2ae7838aeb
commit d9ebb61dc1
2 changed files with 32 additions and 15 deletions

View File

@ -12,6 +12,7 @@ export interface ImageDetailVO {
originalPicUrl: string // 绘制图片地址 originalPicUrl: string // 绘制图片地址
platform: string // 平台 platform: string // 平台
model: string // 模型 model: string // 模型
style: string // 图像生成的风格
} }
export interface ImagePageReqVO { export interface ImagePageReqVO {
@ -19,6 +20,12 @@ export interface ImagePageReqVO {
pageSize: number // 分页大小 pageSize: number // 分页大小
} }
export interface ImageDallReqVO {
prompt: string // 提示词
model: string // 模型
style: string // 图像生成的风格
size: string // size不能为空
}
// AI API 密钥 API // AI API 密钥 API
export const ImageApi = { export const ImageApi = {
@ -52,5 +59,7 @@ export const ImageApi = {
model: 'dr' model: 'dr'
} as ImageDetailVO } as ImageDetailVO
}, },
dall: async (data: ImageDallReqVO)=> {
return await request.post({ url: `/ai/image/dall`, data })
},
} }

View File

@ -82,7 +82,7 @@
<div :class="selectImageSize === imageSize ? 'size-wrapper selectImageSize' : 'size-wrapper'"> <div :class="selectImageSize === imageSize ? 'size-wrapper selectImageSize' : 'size-wrapper'">
<div :style="imageSize.style"></div> <div :style="imageSize.style"></div>
</div> </div>
<div class="size-font">{{ imageSize.key }}</div> <div class="size-font">{{ imageSize.name }}</div>
</div> </div>
</el-space> </el-space>
</div> </div>
@ -111,49 +111,55 @@ interface ImageSizeVO {
const prompt = ref<string>('') // const prompt = ref<string>('') //
const selectHotWord = ref<string>('') // const selectHotWord = ref<string>('') //
const hotWords = ref<string[]>(['中国旗袍', '古装美女', '卡通头像', '机甲战士', '童话小屋', '中国长城']) // const hotWords = ref<string[]>(['中国旗袍', '古装美女', '卡通头像', '机甲战士', '童话小屋', '中国长城']) //
const selectModel = ref<any>() // const selectModel = ref<any>({}) //
const models = ref<ImageModelVO[]>([ const models = ref<ImageModelVO[]>([
{ {
key: 'dall2', key: 'dall-e-2',
name: 'dall2', name: 'dall2',
image: 'https://h5.cxyhub.com/images/model_1.png', image: 'https://h5.cxyhub.com/images/model_1.png',
}, },
{ {
key: 'dall3', key: 'dall-e-3',
name: 'dall3', name: 'dall3',
image: 'https://h5.cxyhub.com/images/model_2.png', image: 'https://h5.cxyhub.com/images/model_2.png',
}, },
]) // ]) //
selectModel.value = models.value[0]
const selectImageStyle = ref<any>() // style const selectImageStyle = ref<any>({}) // style
const imageStyleList = ref<ImageModelVO[]>([ const imageStyleList = ref<ImageModelVO[]>([
{ {
key: 'qingxi', key: 'vivid',
name: '清晰', name: '清晰',
image: 'https://h5.cxyhub.com/images/model_1.png', image: 'https://h5.cxyhub.com/images/model_1.png',
}, },
{ {
key: 'ziran', key: 'natural',
name: '自然', name: '自然',
image: 'https://h5.cxyhub.com/images/model_2.png', image: 'https://h5.cxyhub.com/images/model_2.png',
}, },
]) // ]) // style
selectImageStyle.value = imageStyleList.value[0]
const selectImageSize = ref<ImageSizeVO>({} as ImageSizeVO) // size const selectImageSize = ref<ImageSizeVO>({} as ImageSizeVO) // size
const imageSizeList = ref<ImageSizeVO[]>([ const imageSizeList = ref<ImageSizeVO[]>([
{ {
key: '1:1', key: '1024x1024',
name: '1:1',
style: 'width: 30px; height: 30px;background-color: #dcdcdc;', style: 'width: 30px; height: 30px;background-color: #dcdcdc;',
}, },
{ {
key: '3:5', key: '1024x1792',
name: '3:5',
style: 'width: 30px; height: 50px;background-color: #dcdcdc;', style: 'width: 30px; height: 50px;background-color: #dcdcdc;',
}, },
{ {
key: '5:3', key: '1792x1024',
name: '5:3',
style: 'width: 50px; height: 30px;background-color: #dcdcdc;', style: 'width: 50px; height: 30px;background-color: #dcdcdc;',
} }
]) // size ]) // size
selectImageSize.value = imageSizeList.value[0]
// Props // Props
const props = defineProps({}) const props = defineProps({})
@ -209,11 +215,13 @@ const handlerSizeClick = async (imageSize: ImageSizeVO) => {
*/ */
const handlerGenerateImage = async () => { const handlerGenerateImage = async () => {
// todo @ // todo @
console.log('prompt.value', prompt)
console.log('prompt.value', prompt.value)
const form = { const form = {
prompt: prompt.value, // prompt: prompt.value, //
model: selectModel.value, // model: selectModel.value.key, //
style: selectImageStyle.value, // style: selectImageStyle.value.key, //
size: selectImageSize.value, // size size: selectImageSize.value.key, // size
} as ImageDallReqVO } as ImageDallReqVO
// //
await ImageApi.dall(form) await ImageApi.dall(form)