优化创建

This commit is contained in:
王佑琳 2026-04-17 18:55:15 +08:00
parent d73a71d00f
commit c000a8c19f
4 changed files with 8 additions and 28 deletions

View File

@ -56,8 +56,8 @@
<template #action-list>
<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;">
<i-ep-loading />
<el-button v-if="isgerenate" round color="#626aef">
<i-ep-loading style="animation: spin 1s linear infinite;" />
</el-button>
<div v-else class="gerenate" :class="{ isprompt: prompt }" @click="handleStart">
<img v-if="!prompt" src="@/assets/dialog/darkArrow.svg" alt="" />

View File

@ -69,24 +69,3 @@ export function result(result) {
}
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 }
}

View File

@ -25,5 +25,5 @@ export async function getTask(result) {
const urls = result.data.map(item => item.fileUrl)
return { type: true, urls: urls }
}
return { type: false, message: result.data?.exception_message || '生成失败' }
return { type: false, message: result.data.exception_message || '生成失败' }
}

View File

@ -37,17 +37,18 @@ export function websocketError(code, msg) {
}
ElNotification({
title: '生成通知',
title: '生成失败',
message: h('i', { style: 'color: teal' }, message),
type: 'error'
type: 'error',
duration: 6000 // 增加持续时间以适应更多信息
})
}
export function websocketSuccess() {
// 合并两个通知为一个
ElNotification({
title: '生成通知',
title: '生成成功',
message: h('div', [
h('div', { style: 'font-weight: bold; color: teal;' }, '生成成功!'),
h('br'),
@ -153,7 +154,7 @@ export async function generate(data, generateData) {
websocketSuccess()
} else {
websocketError(4403, res.message)
websocketError(4403, result.message)
}
} else {
websocketError(event.code, event.reason)