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
69940e27
authored
Jul 13, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码评审】AI:绘图 other 优化
parent
369860a0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
77 deletions
+24
-77
src/views/ai/image/index/components/other/index.vue
+17
-21
src/views/ai/image/index/index.vue
+2
-1
src/views/ai/utils/constants.ts
+5
-55
No files found.
src/views/ai/image/index/components/other/index.vue
View file @
69940e27
...
@@ -36,7 +36,13 @@
...
@@ -36,7 +36,13 @@
<el-text
tag=
"b"
>
平台
</el-text>
<el-text
tag=
"b"
>
平台
</el-text>
</div>
</div>
<el-space
wrap
class=
"group-item-body"
>
<el-space
wrap
class=
"group-item-body"
>
<el-select
v-model=
"otherPlatform"
placeholder=
"Select"
size=
"large"
class=
"!w-350px"
@
change=
"handlerPlatformChange"
>
<el-select
v-model=
"otherPlatform"
placeholder=
"Select"
size=
"large"
class=
"!w-350px"
@
change=
"handlerPlatformChange"
>
<el-option
<el-option
v-for=
"item in OtherPlatformEnum"
v-for=
"item in OtherPlatformEnum"
:key=
"item.key"
:key=
"item.key"
...
@@ -52,16 +58,11 @@
...
@@ -52,16 +58,11 @@
</div>
</div>
<el-space
wrap
class=
"group-item-body"
>
<el-space
wrap
class=
"group-item-body"
>
<el-select
v-model=
"model"
placeholder=
"Select"
size=
"large"
class=
"!w-350px"
>
<el-select
v-model=
"model"
placeholder=
"Select"
size=
"large"
class=
"!w-350px"
>
<el-option
<el-option
v-for=
"item in models"
:key=
"item.key"
:label=
"item.name"
:value=
"item.key"
/>
v-for=
"item in models"
:key=
"item.key"
:label=
"item.name"
:value=
"item.key"
/>
</el-select>
</el-select>
</el-space>
</el-space>
</div>
</div>
<div
class=
"group-item"
v-if=
"otherPlatform !== AiPlatformEnum.CHATGLM"
>
<div
class=
"group-item"
>
<div>
<div>
<el-text
tag=
"b"
>
图片尺寸
</el-text>
<el-text
tag=
"b"
>
图片尺寸
</el-text>
</div>
</div>
...
@@ -77,9 +78,10 @@
...
@@ -77,9 +78,10 @@
</div>
</div>
</
template
>
</
template
>
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
ImageApi
,
ImageDrawReqVO
,
ImageVO
}
from
'@/api/ai/image'
import
{
ImageApi
,
ImageDrawReqVO
,
ImageVO
}
from
'@/api/ai/image'
import
{
import
{
AiPlatformEnum
,
ChatGlmModels
,
AiPlatformEnum
,
ChatGlmModels
,
ImageHotWords
,
ImageHotWords
,
ImageModelVO
,
ImageModelVO
,
OtherPlatformEnum
,
OtherPlatformEnum
,
...
@@ -100,7 +102,6 @@ const otherPlatform = ref<string>(AiPlatformEnum.TONG_YI) // 平台
...
@@ -100,7 +102,6 @@ const otherPlatform = ref<string>(AiPlatformEnum.TONG_YI) // 平台
const
models
=
ref
<
ImageModelVO
[]
>
(
TongYiWanXiangModels
)
// 模型 TongYiWanXiangModels、QianFanModels
const
models
=
ref
<
ImageModelVO
[]
>
(
TongYiWanXiangModels
)
// 模型 TongYiWanXiangModels、QianFanModels
const
model
=
ref
<
string
>
(
models
.
value
[
0
].
key
)
// 模型
const
model
=
ref
<
string
>
(
models
.
value
[
0
].
key
)
// 模型
const
emits
=
defineEmits
([
'onDrawStart'
,
'onDrawComplete'
])
// 定义 emits
const
emits
=
defineEmits
([
'onDrawStart'
,
'onDrawComplete'
])
// 定义 emits
/** 选择热词 */
/** 选择热词 */
...
@@ -132,9 +133,8 @@ const handleGenerateImage = async () => {
...
@@ -132,9 +133,8 @@ const handleGenerateImage = async () => {
prompt
:
prompt
.
value
,
// 提示词
prompt
:
prompt
.
value
,
// 提示词
width
:
width
.
value
,
// 图片宽度
width
:
width
.
value
,
// 图片宽度
height
:
height
.
value
,
// 图片高度
height
:
height
.
value
,
// 图片高度
options
:
{
options
:
{}
}
}
as
unknown
as
ImageDrawReqVO
}
as
ImageDrawReqVO
await
ImageApi
.
drawImage
(
form
)
await
ImageApi
.
drawImage
(
form
)
}
finally
{
}
finally
{
// 回调
// 回调
...
@@ -149,28 +149,24 @@ const settingValues = async (detail: ImageVO) => {
...
@@ -149,28 +149,24 @@ const settingValues = async (detail: ImageVO) => {
prompt
.
value
=
detail
.
prompt
prompt
.
value
=
detail
.
prompt
width
.
value
=
detail
.
width
width
.
value
=
detail
.
width
height
.
value
=
detail
.
height
height
.
value
=
detail
.
height
}
}
/** 平台切换 */
/** 平台切换 */
const
handlerPlatformChange
=
async
(
platform
)
=>
{
const
handlerPlatformChange
=
async
(
platform
:
string
)
=>
{
// 切换平台,切换模型、风格
// 切换平台,切换模型、风格
if
(
AiPlatformEnum
.
TONG_YI
===
platform
)
{
if
(
AiPlatformEnum
.
TONG_YI
===
platform
)
{
models
.
value
=
TongYiWanXiangModels
models
.
value
=
TongYiWanXiangModels
}
else
if
(
AiPlatformEnum
.
YI_YAN
===
platform
)
{
}
else
if
(
AiPlatformEnum
.
YI_YAN
===
platform
)
{
models
.
value
=
QianFanModels
models
.
value
=
QianFanModels
}
else
if
(
AiPlatformEnum
.
CHATGLM
===
platform
)
{
}
else
if
(
AiPlatformEnum
.
ZHI_PU
===
platform
)
{
models
.
value
=
ChatGlmModels
models
.
value
=
ChatGlmModels
// ChatGlm 模型没有 width、height 随便默认一个值过后台必填检测
height
.
value
=
512
width
.
value
=
512
}
else
{
}
else
{
models
.
value
=
[]
models
.
value
=
[]
}
}
// 切换平台,默认选择一个风格
// 切换平台,默认选择一个风格
if
(
models
.
value
.
length
>
0
)
{
if
(
models
.
value
.
length
>
0
)
{
model
.
value
=
models
.
value
[
0
].
key
model
.
value
=
models
.
value
[
0
].
key
}
else
{
}
else
{
model
.
value
=
''
model
.
value
=
''
}
}
}
}
...
...
src/views/ai/image/index/index.vue
View file @
69940e27
...
@@ -62,7 +62,7 @@ const platformOptions = [
...
@@ -62,7 +62,7 @@ const platformOptions = [
value
:
AiPlatformEnum
.
STABLE_DIFFUSION
value
:
AiPlatformEnum
.
STABLE_DIFFUSION
},
},
{
{
label
:
'其
他
'
,
label
:
'其
它
'
,
value
:
'other'
value
:
'other'
}
}
]
]
...
@@ -88,6 +88,7 @@ const handleRegeneration = async (image: ImageVO) => {
...
@@ -88,6 +88,7 @@ const handleRegeneration = async (image: ImageVO) => {
}
else
if
(
image
.
platform
===
AiPlatformEnum
.
STABLE_DIFFUSION
)
{
}
else
if
(
image
.
platform
===
AiPlatformEnum
.
STABLE_DIFFUSION
)
{
stableDiffusionRef
.
value
.
settingValues
(
image
)
stableDiffusionRef
.
value
.
settingValues
(
image
)
}
}
// TODO @fan:貌似 other 重新设置不行?
}
}
</
script
>
</
script
>
...
...
src/views/ai/utils/constants.ts
View file @
69940e27
...
@@ -20,11 +20,10 @@ export const AiPlatformEnum = {
...
@@ -20,11 +20,10 @@ export const AiPlatformEnum = {
Ollama
:
'Ollama'
,
Ollama
:
'Ollama'
,
STABLE_DIFFUSION
:
'StableDiffusion'
,
// Stability AI
STABLE_DIFFUSION
:
'StableDiffusion'
,
// Stability AI
MIDJOURNEY
:
'Midjourney'
,
// Midjourney
MIDJOURNEY
:
'Midjourney'
,
// Midjourney
SUNO
:
'Suno'
,
// Suno AI
SUNO
:
'Suno'
// Suno AI
CHATGLM
:
'ChatGlm'
,
// ChatGlm
}
}
export
const
OtherPlatformEnum
:
ImageModelVO
[]
=
[
export
const
OtherPlatformEnum
:
ImageModelVO
[]
=
[
{
{
key
:
AiPlatformEnum
.
TONG_YI
,
key
:
AiPlatformEnum
.
TONG_YI
,
name
:
'通义万相'
name
:
'通义万相'
...
@@ -34,8 +33,8 @@ export const OtherPlatformEnum:ImageModelVO [] = [
...
@@ -34,8 +33,8 @@ export const OtherPlatformEnum:ImageModelVO [] = [
name
:
'百度千帆'
name
:
'百度千帆'
},
},
{
{
key
:
AiPlatformEnum
.
CHATGLM
,
key
:
AiPlatformEnum
.
ZHI_PU
,
name
:
'智
铺 ChatGlm
'
name
:
'智
谱 AI
'
}
}
]
]
...
@@ -205,54 +204,6 @@ export const StableDiffusionStylePresets: ImageModelVO[] = [
...
@@ -205,54 +204,6 @@ export const StableDiffusionStylePresets: ImageModelVO[] = [
}
}
]
]
// todo @芋艿 这些是通义的风格,看要不要删除
export
const
TongYiWanXiangStylePresets
:
ImageModelVO
[]
=
[
{
key
:
'-1'
,
name
:
'上传图像风格'
},
{
key
:
'0'
,
name
:
'复古漫画'
},
{
key
:
'1'
,
name
:
'3D童话'
},
{
key
:
'2'
,
name
:
'二次元'
},
{
key
:
'3'
,
name
:
'小清新'
},
{
key
:
'4'
,
name
:
'未来科技'
},
{
key
:
'5'
,
name
:
'国画古风'
},
{
key
:
'6'
,
name
:
'将军百战'
},
{
key
:
'7'
,
name
:
'炫彩卡通'
},
{
key
:
'8'
,
name
:
'清雅国风'
},
{
key
:
'9'
,
name
:
'喜迎新年'
}
]
export
const
TongYiWanXiangModels
:
ImageModelVO
[]
=
[
export
const
TongYiWanXiangModels
:
ImageModelVO
[]
=
[
{
{
key
:
'wanx-v1'
,
key
:
'wanx-v1'
,
...
@@ -278,7 +229,6 @@ export const ChatGlmModels: ImageModelVO[] = [
...
@@ -278,7 +229,6 @@ export const ChatGlmModels: ImageModelVO[] = [
}
}
]
]
export
const
StableDiffusionClipGuidancePresets
:
ImageModelVO
[]
=
[
export
const
StableDiffusionClipGuidancePresets
:
ImageModelVO
[]
=
[
{
{
key
:
'NONE'
,
key
:
'NONE'
,
...
@@ -338,7 +288,7 @@ export const Dall3StyleList: ImageModelVO[] = [
...
@@ -338,7 +288,7 @@ export const Dall3StyleList: ImageModelVO[] = [
export
interface
ImageSizeVO
{
export
interface
ImageSizeVO
{
key
:
string
key
:
string
name
:
string
name
?
:
string
style
:
string
style
:
string
width
:
string
width
:
string
height
:
string
height
:
string
...
...
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