Commit ed74b28d authored by 周成波's avatar 周成波

v20240129

parent 90719b8a
...@@ -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']
}
} }
...@@ -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 通讯失败");
});
} }
} }
@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);
} }
} }
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
}
}
This diff is collapsed.
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
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment