【增加】Dall 增加 style 选择

pull/453/head
cherishsince 2024-05-27 14:40:10 +08:00
parent fd4ef4b172
commit 2ae7838aeb
1 changed files with 88 additions and 3 deletions

View File

@ -50,6 +50,26 @@
</div>
</el-space>
</div>
<div class="image-style">
<div>
<el-text tag="b">样式</el-text>
</div>
<el-space wrap class="image-style-list">
<div
:class="selectImageStyle === imageStyle ? 'image-style-item selectImageStyle' : 'image-style-item'"
v-for="imageStyle in imageStyleList"
:key="imageStyle"
>
<el-image
:src="imageStyle.image"
fit="contain"
@click="handlerStyleClick(imageStyle)"
/>
<div class="style-font">{{imageStyle.name}}</div>
</div>
</el-space>
</div>
<div class="image-size">
<div>
<el-text tag="b">尺寸</el-text>
@ -72,6 +92,7 @@
</div>
</template>
<script setup lang="ts">
import {ImageApi, ImageDallReqVO} from '@/api/ai/image';
// image
interface ImageModelVO {
@ -90,10 +111,24 @@ interface ImageSizeVO {
const prompt = ref<string>('') //
const selectHotWord = ref<string>('') //
const hotWords = ref<string[]>(['中国旗袍', '古装美女', '卡通头像', '机甲战士', '童话小屋', '中国长城']) //
const selectModel = ref<any>() //
const selectModel = ref<any>() //
const models = ref<ImageModelVO[]>([
{
key: 'qinxi',
key: 'dall2',
name: 'dall2',
image: 'https://h5.cxyhub.com/images/model_1.png',
},
{
key: 'dall3',
name: 'dall3',
image: 'https://h5.cxyhub.com/images/model_2.png',
},
]) //
const selectImageStyle = ref<any>() // style
const imageStyleList = ref<ImageModelVO[]>([
{
key: 'qingxi',
name: '清晰',
image: 'https://h5.cxyhub.com/images/model_1.png',
},
@ -147,6 +182,17 @@ const handlerModelClick = async (model: ImageModelVO) => {
selectModel.value = model
}
/**
* 样式 - click
*/
const handlerStyleClick = async (imageStyle: ImageModelVO) => {
if (selectImageStyle.value === imageStyle) {
selectImageStyle.value = {} as ImageModelVO
return
}
selectImageStyle.value = imageStyle
}
/**
* size - click
*/
@ -156,7 +202,6 @@ const handlerSizeClick = async (imageSize: ImageSizeVO) => {
return
}
selectImageSize.value = imageSize
console.log(imageSize)
}
/**
@ -164,7 +209,16 @@ const handlerSizeClick = async (imageSize: ImageSizeVO) => {
*/
const handlerGenerateImage = async () => {
// todo @
const form = {
prompt: prompt.value, //
model: selectModel.value, //
style: selectImageStyle.value, //
size: selectImageSize.value, // size
} as ImageDallReqVO
//
await ImageApi.dall(form)
}
</script>
<style scoped lang="scss">
@ -223,6 +277,37 @@ const handlerGenerateImage = async () => {
}
// style
.image-style {
margin-top: 30px;
.image-style-list {
margin-top: 15px;
.image-style-item {
width: 110px;
//outline: 1px solid blue;
overflow: hidden;
display: flex;
flex-direction: column;
align-items: center;
border: 3px solid transparent;
cursor: pointer;
.style-font {
font-size: 14px;
color: #3e3e3e;
font-weight: bold;
}
}
.selectImageStyle {
border: 3px solid #1293ff;
border-radius: 5px;
}
}
}
//
.image-size {
width: 100%;