【增加】openai 重新生成

pull/470/MERGE
cherishsince 2024-07-04 15:01:19 +08:00
parent 39facc2f49
commit bb34c2b75c
1 changed files with 23 additions and 30 deletions

View File

@ -37,7 +37,7 @@
</div> </div>
<el-space wrap class="model-list"> <el-space wrap class="model-list">
<div <div
:class="selectModel === model ? 'modal-item selectModel' : 'modal-item'" :class="selectModel === model.key ? 'modal-item selectModel' : 'modal-item'"
v-for="model in models" v-for="model in models"
:key="model.key" :key="model.key"
@ -57,7 +57,7 @@
</div> </div>
<el-space wrap class="image-style-list"> <el-space wrap class="image-style-list">
<div <div
:class="selectImageStyle === imageStyle ? 'image-style-item selectImageStyle' : 'image-style-item'" :class="selectImageStyle === imageStyle.key ? 'image-style-item selectImageStyle' : 'image-style-item'"
v-for="imageStyle in imageStyleList" v-for="imageStyle in imageStyleList"
:key="imageStyle.key" :key="imageStyle.key"
> >
@ -79,7 +79,7 @@
v-for="imageSize in imageSizeList" v-for="imageSize in imageSizeList"
:key="imageSize.key" :key="imageSize.key"
@click="handlerSizeClick(imageSize)"> @click="handlerSizeClick(imageSize)">
<div :class="selectImageSize === imageSize ? 'size-wrapper selectImageSize' : 'size-wrapper'"> <div :class="selectImageSize === imageSize.key ? 'size-wrapper selectImageSize' : 'size-wrapper'">
<div :style="imageSize.style"></div> <div :style="imageSize.style"></div>
</div> </div>
<div class="size-font">{{ imageSize.name }}</div> <div class="size-font">{{ imageSize.name }}</div>
@ -120,7 +120,7 @@ const prompt = ref<string>('') // 提示词
const drawIn = ref<boolean>(false) // const drawIn = ref<boolean>(false) //
const selectHotWord = ref<string>('') // const selectHotWord = ref<string>('') //
const hotWords = ref<string[]>(['中国旗袍', '古装美女', '卡通头像', '机甲战士', '童话小屋', '中国长城']) // const hotWords = ref<string[]>(['中国旗袍', '古装美女', '卡通头像', '机甲战士', '童话小屋', '中国长城']) //
const selectModel = ref<any>({}) // const selectModel = ref<string>('dall-e-3') //
// message // message
const message = useMessage() const message = useMessage()
// TODO @fanimage // TODO @fanimage
@ -137,9 +137,8 @@ const models = ref<ImageModelVO[]>([
image: 'https://h5.cxyhub.com/images/model_1.png', image: 'https://h5.cxyhub.com/images/model_1.png',
}, },
]) // ]) //
selectModel.value = models.value[0]
const selectImageStyle = ref<any>({}) // style const selectImageStyle = ref<string>('vivid') // style
// TODO @fanimage // TODO @fanimage
const imageStyleList = ref<ImageModelVO[]>([ const imageStyleList = ref<ImageModelVO[]>([
{ {
@ -153,9 +152,8 @@ const imageStyleList = ref<ImageModelVO[]>([
image: 'https://h5.cxyhub.com/images/model_2.png', image: 'https://h5.cxyhub.com/images/model_2.png',
}, },
]) // style ]) // style
selectImageStyle.value = imageStyleList.value[0]
const selectImageSize = ref<ImageSizeVO>({} as ImageSizeVO) // size const selectImageSize = ref<string>('1024x1024') // size
const imageSizeList = ref<ImageSizeVO[]>([ const imageSizeList = ref<ImageSizeVO[]>([
{ {
key: '1024x1024', key: '1024x1024',
@ -179,7 +177,6 @@ const imageSizeList = ref<ImageSizeVO[]>([
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({})
@ -203,29 +200,17 @@ const handlerHotWordClick = async (hotWord: string) => {
/** 模型 - click */ /** 模型 - click */
const handlerModelClick = async (model: ImageModelVO) => { const handlerModelClick = async (model: ImageModelVO) => {
if (selectModel.value === model) { selectModel.value = model.key
selectModel.value = {} as ImageModelVO
return
}
selectModel.value = model
} }
/** 样式 - click */ /** 样式 - click */
const handlerStyleClick = async (imageStyle: ImageModelVO) => { const handlerStyleClick = async (imageStyle: ImageModelVO) => {
if (selectImageStyle.value === imageStyle) { selectImageStyle.value = imageStyle.key
selectImageStyle.value = {} as ImageModelVO
return
}
selectImageStyle.value = imageStyle
} }
/** size - click */ /** size - click */
const handlerSizeClick = async (imageSize: ImageSizeVO) => { const handlerSizeClick = async (imageSize: ImageSizeVO) => {
if (selectImageSize.value === imageSize) { selectImageSize.value = imageSize.key
selectImageSize.value = {} as ImageSizeVO
return
}
selectImageSize.value = imageSize
} }
/** 图片生产 */ /** 图片生产 */
@ -236,22 +221,23 @@ const handlerGenerateImage = async () => {
// //
drawIn.value = true drawIn.value = true
// //
emits('onDrawStart', selectModel.value.key) emits('onDrawStart', selectModel.value)
const imageSize = imageSizeList.value.find(item => item.key === selectImageSize.value) as ImageSizeVO
const form = { const form = {
platform: 'OpenAI', platform: 'OpenAI',
prompt: prompt.value, // prompt: prompt.value, //
model: selectModel.value.key, // model: selectModel.value, //
width: selectImageSize.value.width, // size width: imageSize.width, // size
height: selectImageSize.value.height, // size height: imageSize.height, // size
options: { options: {
style: selectImageStyle.value.key, // style: selectImageStyle.value, //
} }
} as ImageDrawReqVO } as ImageDrawReqVO
// //
await ImageApi.drawImage(form) await ImageApi.drawImage(form)
} finally { } finally {
// //
emits('onDrawComplete', selectModel.value.key) emits('onDrawComplete', selectModel.value)
// //
drawIn.value = false drawIn.value = false
} }
@ -260,6 +246,13 @@ const handlerGenerateImage = async () => {
/** 填充值 */ /** 填充值 */
const settingValues = async (imageDetail: ImageVO) => { const settingValues = async (imageDetail: ImageVO) => {
prompt.value = imageDetail.prompt prompt.value = imageDetail.prompt
selectModel.value = imageDetail.model
//
selectImageStyle.value = imageDetail.options?.style
//
const imageSize = imageSizeList.value.find(item => item.key === `${imageDetail.width}x${imageDetail.height}`) as ImageSizeVO
console.log('imageSize', imageSize)
await handlerSizeClick(imageSize)
} }
/** 暴露组件方法 */ /** 暴露组件方法 */