优化创建
This commit is contained in:
parent
d73a71d00f
commit
c000a8c19f
|
|
@ -56,8 +56,8 @@
|
||||||
|
|
||||||
<template #action-list>
|
<template #action-list>
|
||||||
<div style="display: flex; align-items: center; gap: 8px; height: 100%;">
|
<div style="display: flex; align-items: center; gap: 8px; height: 100%;">
|
||||||
<el-button v-if="isgerenate" round color="#626aef" style="animation: spin 1s linear infinite;">
|
<el-button v-if="isgerenate" round color="#626aef">
|
||||||
<i-ep-loading />
|
<i-ep-loading style="animation: spin 1s linear infinite;" />
|
||||||
</el-button>
|
</el-button>
|
||||||
<div v-else class="gerenate" :class="{ isprompt: prompt }" @click="handleStart">
|
<div v-else class="gerenate" :class="{ isprompt: prompt }" @click="handleStart">
|
||||||
<img v-if="!prompt" src="@/assets/dialog/darkArrow.svg" alt="" />
|
<img v-if="!prompt" src="@/assets/dialog/darkArrow.svg" alt="" />
|
||||||
|
|
|
||||||
|
|
@ -69,24 +69,3 @@ export function result(result) {
|
||||||
}
|
}
|
||||||
return { type: false, message: result.data.exception_message }
|
return { type: false, message: result.data.exception_message }
|
||||||
}
|
}
|
||||||
function getWidthHeight(data) {
|
|
||||||
let resolution = data.resolution * 1
|
|
||||||
|
|
||||||
let widthRatio = 16
|
|
||||||
let heightRatio = 9
|
|
||||||
if (data.proportion) {
|
|
||||||
const aspectRatioParts = data.proportion.split(':') || data.proportion.split(':')
|
|
||||||
widthRatio = Number.parseInt(aspectRatioParts[0]) || 16
|
|
||||||
heightRatio = Number.parseInt(aspectRatioParts[1]) || 9
|
|
||||||
}
|
|
||||||
let width, height
|
|
||||||
if (widthRatio > heightRatio) {
|
|
||||||
height = resolution
|
|
||||||
width = Math.round(resolution * widthRatio / heightRatio)
|
|
||||||
} else {
|
|
||||||
width = resolution
|
|
||||||
height = Math.round(resolution * heightRatio / widthRatio)
|
|
||||||
}
|
|
||||||
console.log(width, height)
|
|
||||||
return { width, height }
|
|
||||||
}
|
|
||||||
|
|
@ -25,5 +25,5 @@ export async function getTask(result) {
|
||||||
const urls = result.data.map(item => item.fileUrl)
|
const urls = result.data.map(item => item.fileUrl)
|
||||||
return { type: true, urls: urls }
|
return { type: true, urls: urls }
|
||||||
}
|
}
|
||||||
return { type: false, message: result.data?.exception_message || '生成失败' }
|
return { type: false, message: result.data.exception_message || '生成失败' }
|
||||||
}
|
}
|
||||||
|
|
@ -37,17 +37,18 @@ export function websocketError(code, msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ElNotification({
|
ElNotification({
|
||||||
title: '生成通知',
|
title: '生成失败',
|
||||||
|
|
||||||
message: h('i', { style: 'color: teal' }, message),
|
message: h('i', { style: 'color: teal' }, message),
|
||||||
type: 'error'
|
type: 'error',
|
||||||
|
duration: 6000 // 增加持续时间以适应更多信息
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function websocketSuccess() {
|
export function websocketSuccess() {
|
||||||
// 合并两个通知为一个
|
// 合并两个通知为一个
|
||||||
ElNotification({
|
ElNotification({
|
||||||
title: '生成通知',
|
title: '生成成功',
|
||||||
message: h('div', [
|
message: h('div', [
|
||||||
h('div', { style: 'font-weight: bold; color: teal;' }, '生成成功!'),
|
h('div', { style: 'font-weight: bold; color: teal;' }, '生成成功!'),
|
||||||
h('br'),
|
h('br'),
|
||||||
|
|
@ -153,7 +154,7 @@ export async function generate(data, generateData) {
|
||||||
|
|
||||||
websocketSuccess()
|
websocketSuccess()
|
||||||
} else {
|
} else {
|
||||||
websocketError(4403, res.message)
|
websocketError(4403, result.message)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
websocketError(event.code, event.reason)
|
websocketError(event.code, event.reason)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue