Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
text2video-frontend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周成波
text2video-frontend
Commits
ed74b28d
Commit
ed74b28d
authored
Jan 29, 2024
by
周成波
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v20240129
parent
90719b8a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
415 additions
and
115 deletions
+415
-115
components.d.ts
components.d.ts
+9
-0
text2videoService.ts
src/api/service/text2videoService.ts
+62
-2
main.css
src/assets/main.css
+1
-2
utils.ts
src/utils/utils.ts
+35
-0
index.vue
src/views/home/index.vue
+296
-96
lib.wm.api.d.ts
typings/types/wm/lib.wm.api.d.ts
+12
-15
No files found.
components.d.ts
View file @
ed74b28d
...
@@ -8,14 +8,20 @@ export {}
...
@@ -8,14 +8,20 @@ export {}
declare
module
'vue'
{
declare
module
'vue'
{
export
interface
GlobalComponents
{
export
interface
GlobalComponents
{
ElButton
:
typeof
import
(
'element-plus/es'
)[
'ElButton'
]
ElButton
:
typeof
import
(
'element-plus/es'
)[
'ElButton'
]
ElDescriptions
:
typeof
import
(
'element-plus/es'
)[
'ElDescriptions'
]
ElDescriptionsItem
:
typeof
import
(
'element-plus/es'
)[
'ElDescriptionsItem'
]
ElDivider
:
typeof
import
(
'element-plus/es'
)[
'ElDivider'
]
ElDivider
:
typeof
import
(
'element-plus/es'
)[
'ElDivider'
]
ElElFormItem
:
typeof
import
(
'element-plus/es'
)[
'ElElFormItem'
]
ElElFormItem
:
typeof
import
(
'element-plus/es'
)[
'ElElFormItem'
]
ElForm
:
typeof
import
(
'element-plus/es'
)[
'ElForm'
]
ElForm
:
typeof
import
(
'element-plus/es'
)[
'ElForm'
]
ElFormItem
:
typeof
import
(
'element-plus/es'
)[
'ElFormItem'
]
ElFormItem
:
typeof
import
(
'element-plus/es'
)[
'ElFormItem'
]
ElIcon
:
typeof
import
(
'element-plus/es'
)[
'ElIcon'
]
ElIcon
:
typeof
import
(
'element-plus/es'
)[
'ElIcon'
]
ElImage
:
typeof
import
(
'element-plus/es'
)[
'ElImage'
]
ElInput
:
typeof
import
(
'element-plus/es'
)[
'ElInput'
]
ElInput
:
typeof
import
(
'element-plus/es'
)[
'ElInput'
]
ElOption
:
typeof
import
(
'element-plus/es'
)[
'ElOption'
]
ElOption
:
typeof
import
(
'element-plus/es'
)[
'ElOption'
]
ElSelect
:
typeof
import
(
'element-plus/es'
)[
'ElSelect'
]
ElSelect
:
typeof
import
(
'element-plus/es'
)[
'ElSelect'
]
ElTable
:
typeof
import
(
'element-plus/es'
)[
'ElTable'
]
ElTableColumn
:
typeof
import
(
'element-plus/es'
)[
'ElTableColumn'
]
ElTag
:
typeof
import
(
'element-plus/es'
)[
'ElTag'
]
ElUpload
:
typeof
import
(
'element-plus/es'
)[
'ElUpload'
]
ElUpload
:
typeof
import
(
'element-plus/es'
)[
'ElUpload'
]
HelloWorld
:
typeof
import
(
'./src/components/HelloWorld.vue'
)[
'default'
]
HelloWorld
:
typeof
import
(
'./src/components/HelloWorld.vue'
)[
'default'
]
IconCommunity
:
typeof
import
(
'./src/components/icons/IconCommunity.vue'
)[
'default'
]
IconCommunity
:
typeof
import
(
'./src/components/icons/IconCommunity.vue'
)[
'default'
]
...
@@ -28,4 +34,7 @@ declare module 'vue' {
...
@@ -28,4 +34,7 @@ declare module 'vue' {
TheWelcome
:
typeof
import
(
'./src/components/TheWelcome.vue'
)[
'default'
]
TheWelcome
:
typeof
import
(
'./src/components/TheWelcome.vue'
)[
'default'
]
WelcomeItem
:
typeof
import
(
'./src/components/WelcomeItem.vue'
)[
'default'
]
WelcomeItem
:
typeof
import
(
'./src/components/WelcomeItem.vue'
)[
'default'
]
}
}
export
interface
ComponentCustomProperties
{
vLoading
:
typeof
import
(
'element-plus/es'
)[
'ElLoadingDirective'
]
}
}
}
src/api/service/text2videoService.ts
View file @
ed74b28d
...
@@ -4,7 +4,67 @@
...
@@ -4,7 +4,67 @@
import
request
from
'@/api/request'
import
request
from
'@/api/request'
export
default
{
export
default
{
genScriptsByGpt
(
postData
:
any
)
{
submitGpt
(
prompt
:
string
):
Promise
<
string
>
{
return
request
.
post
(
'/text2video/gen_scripts_by_gpt'
,
postData
)
if
(
!
prompt
)
{
return
Promise
.
reject
(
"输入不能为空"
);
}
const
post_data
=
{
source_text
:
prompt
}
return
request
.
post
(
'/text2video/text2gpt'
,
post_data
)
.
then
((
res
:
any
)
=>
{
// console.log(res);
if
(
res
&&
res
.
code
===
0
)
{
return
res
.
data
.
result
.
answer
;
}
else
{
const
errorMessage
=
res
?
res
.
message
:
"未知错误"
;
return
Promise
.
reject
(
errorMessage
);
}
})
.
catch
((
err
:
any
)
=>
{
console
.
log
(
err
);
return
Promise
.
reject
(
"chatgpt通讯失败"
);
});
},
submitSD
(
task_id
:
string
=
""
,
img_idx
:
string
=
""
,
prompt
:
string
=
""
,
negative_prompt
:
string
=
""
,
sampler_index
:
string
=
"DPM++ SDE"
,
seed
:
string
=
"-1"
,
steps
:
string
=
"20"
,
width
:
string
=
"960"
,
height
:
string
=
"512"
,
cfg_scale
:
string
=
"9"
):
Promise
<
string
>
{
if
(
!
prompt
)
{
return
Promise
.
reject
(
"SD提示词不能为空"
);
}
const
post_data
=
{
task_id
:
task_id
,
img_idx
:
img_idx
,
prompt
:
prompt
,
negative_prompt
:
negative_prompt
,
sampler_index
:
sampler_index
,
seed
:
seed
,
steps
:
steps
,
width
:
width
,
height
:
height
,
cfg_scale
:
cfg_scale
,
}
return
request
.
post
(
'/text2video/text2img'
,
post_data
)
.
then
((
res
:
any
)
=>
{
// console.log(res);
if
(
res
&&
res
.
code
===
0
)
{
return
res
.
data
.
result
;
}
else
{
const
errorMessage
=
res
?
res
.
message
:
"未知错误"
;
return
Promise
.
reject
(
errorMessage
);
}
})
.
catch
((
err
:
any
)
=>
{
console
.
log
(
err
);
return
Promise
.
reject
(
"stable-diffusion-webui Api 通讯失败"
);
});
}
}
}
}
src/assets/main.css
View file @
ed74b28d
@import
'./base.css'
;
@import
'./base.css'
;
#app
{
#app
{
max-width
:
1280px
;
/* max-width: 1280px; */
margin
:
0
auto
;
margin
:
0
auto
;
padding
:
2rem
;
padding
:
2rem
;
display
:
flex
;
display
:
flex
;
...
@@ -21,4 +21,3 @@ a,
...
@@ -21,4 +21,3 @@ a,
background-color
:
hsla
(
160
,
100%
,
37%
,
0.2
);
background-color
:
hsla
(
160
,
100%
,
37%
,
0.2
);
}
}
}
}
src/utils/utils.ts
0 → 100644
View file @
ed74b28d
export
default
class
utils
{
// 格式化为json字符串
static
formatJson
(
jsonString
:
string
)
{
try
{
return
JSON
.
stringify
(
JSON
.
parse
(
jsonString
),
null
,
2
);
// 对JSON字符串进行格式化处理
}
catch
(
error
)
{
return
'Invalid JSON'
}
}
// 格式化为json
static
formatJsonObj
(
jsonString
:
string
)
{
try
{
return
JSON
.
parse
(
jsonString
)
// 对JSON字符串进行格式化处理
}
catch
(
error
)
{
return
JSON
.
parse
(
'{"error": "Invalid JSON"}'
)
}
}
// 生成年月日时分秒毫秒字符串
static
genDateTimeStr
()
{
const
now
=
new
Date
();
const
year
=
now
.
getFullYear
();
const
month
=
(
now
.
getMonth
()
+
1
).
toString
().
padStart
(
2
,
'0'
);
const
day
=
now
.
getDate
().
toString
().
padStart
(
2
,
'0'
);
const
hours
=
now
.
getHours
().
toString
().
padStart
(
2
,
'0'
);
const
minutes
=
now
.
getMinutes
().
toString
().
padStart
(
2
,
'0'
);
const
seconds
=
now
.
getSeconds
().
toString
().
padStart
(
2
,
'0'
);
const
milliseconds
=
now
.
getMilliseconds
().
toString
().
padStart
(
3
,
'0'
);
const
formattedDateTime
=
`
${
year
}${
month
}${
day
}${
hours
}${
minutes
}${
seconds
}${
milliseconds
}
`
;
// console.log(formattedDateTime); // 输出类似:20221231120530123
return
formattedDateTime
}
}
src/views/home/index.vue
View file @
ed74b28d
This diff is collapsed.
Click to expand it.
typings/types/wm/lib.wm.api.d.ts
View file @
ed74b28d
declare
namespace
Wm
{
declare
namespace
Wm
{
// api回复
interface
ApiResult
{
result
:
ApiResultItem
}
interface
ApiResultItem
{
code
:
int
data
:
any
message
:
string
}
interface
ScriptsItem
{
interface
ScriptsItem
{
序
号
:
string
编
号
:
string
场景
:
string
场景
描述
:
string
人物
:
string
场景关键词
:
string
分镜内容
:
string
角色
:
string
旁白
:
string
角色关键词
:
string
}
}
interface
AiDrawItem
{
编号
:
string
场景描述
:
string
画面描述词
:
string
本镜配图
:
string
task_id
:
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