fix
This commit is contained in:
1 parent
96708de3a4
commit
9706a816b6
4 files changed
+56
-9
No files matched your search
@@ -16,7 +16,7 @@
|
||||
item: true,
|
||||
active: value.includes(item.value)
|
||||
}"
|
||||
@click="onChoose(item.value)"
|
||||
@click="onToggle(item.value)"
|
||||
>
|
||||
<el-image :src="item.image" fit="fill" class="preview" />
|
||||
<span class="name">{{ item.label }}</span>
|
||||
@@ -125,9 +125,15 @@ export default defineComponent({
|
||||
this.$emit('update:modelValue', this.value);
|
||||
},
|
||||
methods: {
|
||||
onChoose(value: string) {
|
||||
this.value.push(value);
|
||||
this.$emit('update:modelValue', this.value);
|
||||
onToggle(value: string) {
|
||||
if (this.value.includes(value)) {
|
||||
this.value.splice(this.value.indexOf(value), 1);
|
||||
this.$emit('update:modelValue', this.value);
|
||||
return;
|
||||
} else {
|
||||
this.value.push(value);
|
||||
this.$emit('update:modelValue', this.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -8,9 +8,14 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElSlider } from 'element-plus';
|
||||
import TaskPreview from './TaskPreview.vue';
|
||||
import { IApplication, IMidjourneyImagineTask, apiUsageOperator, midjourneyOperator } from '@/operators';
|
||||
import {
|
||||
IApplication,
|
||||
IMidjourneyImagineTask,
|
||||
MidjourneyImagineState,
|
||||
apiUsageOperator,
|
||||
midjourneyOperator
|
||||
} from '@/operators';
|
||||
|
||||
interface IData {
|
||||
historyTasks: IMidjourneyImagineTask[];
|
||||
@@ -31,7 +36,7 @@ export default defineComponent({
|
||||
required: true
|
||||
}
|
||||
},
|
||||
emits: ['update:modelValue', 'custom'],
|
||||
emits: ['update:modelValue', 'custom', 'update:activeTask'],
|
||||
data(): IData {
|
||||
return {
|
||||
historyTasks: []
|
||||
@@ -47,6 +52,16 @@ export default defineComponent({
|
||||
if (val) {
|
||||
this.getHistoryTasks();
|
||||
}
|
||||
},
|
||||
activeTask(val: IMidjourneyImagineTask | undefined, oldVal: IMidjourneyImagineTask | undefined) {
|
||||
if (
|
||||
(val?.state === MidjourneyImagineState.FINISHED && oldVal?.state !== MidjourneyImagineState.FINISHED) ||
|
||||
(val?.state === MidjourneyImagineState.FAILED && oldVal?.state !== MidjourneyImagineState.FAILED)
|
||||
) {
|
||||
console.log('need to refresh history tasks');
|
||||
this.getHistoryTasks();
|
||||
this.$emit('update:activeTask', undefined);
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -64,6 +79,9 @@ export default defineComponent({
|
||||
apiUsages.map(async (apiUsage) => {
|
||||
const taskId = apiUsage.metadata?.task_id;
|
||||
const { data: task } = await midjourneyOperator.task(taskId);
|
||||
if (task.response?.success === false) {
|
||||
task.state = MidjourneyImagineState.FAILED;
|
||||
}
|
||||
return task;
|
||||
})
|
||||
);
|
||||
|
||||
@@ -8,12 +8,24 @@
|
||||
<div class="right"></div>
|
||||
</div>
|
||||
<div v-if="modelValue?.state === midjourneyImagineState.PENDING" class="content">
|
||||
<p>图像生成中...</p>
|
||||
<el-image class="image">
|
||||
<template #error>
|
||||
<div class="image-slot">Loading...</div>
|
||||
</template>
|
||||
</el-image>
|
||||
</div>
|
||||
<div v-else-if="modelValue?.state === midjourneyImagineState.FAILED" class="content">
|
||||
<el-image class="image">
|
||||
<template #error>
|
||||
<div class="image-slot">{{ modelValue?.response?.detail }}</div>
|
||||
</template>
|
||||
</el-image>
|
||||
</div>
|
||||
<div v-else class="content">
|
||||
<el-image
|
||||
v-if="modelValue?.response?.image_url"
|
||||
:src="modelValue?.response?.image_url"
|
||||
:preview-src-list="[modelValue?.response?.image_url as string]"
|
||||
fit="fill"
|
||||
class="image"
|
||||
/>
|
||||
@@ -120,6 +132,17 @@ export default defineComponent({
|
||||
margin-bottom: 10px;
|
||||
.image {
|
||||
width: 100%;
|
||||
min-height: 200px;
|
||||
.image-slot {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-secondary);
|
||||
// font-size: 30px;
|
||||
}
|
||||
}
|
||||
.progress {
|
||||
position: absolute;
|
||||
|
||||
Reference in new issue
Block a user