Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d9ebb61d
authored
May 27, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】AI Image 增加 dall 绘画
parent
2ae7838a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
15 deletions
+32
-15
src/api/ai/image/index.ts
+10
-1
src/views/ai/image/dall3/index.vue
+22
-14
No files found.
src/api/ai/image/index.ts
View file @
d9ebb61d
...
@@ -12,6 +12,7 @@ export interface ImageDetailVO {
...
@@ -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 {
...
@@ -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 = {
...
@@ -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
})
},
}
}
src/views/ai/image/dall3/index.vue
View file @
d9ebb61d
...
@@ -82,7 +82,7 @@
...
@@ -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 {
...
@@ -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) => {
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment