Change to use tasks for mj (#65)

Co-authored-by: Germey <germey@acedata.cloud>
This commit is contained in:
GermeyandGermey authored and GitHub committed 2024-07-02 16:29:11 +00:00
1 parent 4d179f306a
commit 01d44e75f2
16 files changed
+194 -67

No files matched your search

+9 -8
View File
@@ -1,5 +1,5 @@
<template>
<div class="item">
<div v-if="modelValue?.type === 'imagine'" class="item">
<div class="left">
<el-image src="https://cdn.acedata.cloud/05daz4.png" class="avatar" />
</div>
@@ -121,7 +121,7 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ElImage, ElButton, ElTooltip, ElAlert } from 'element-plus';
import { IMidjourneyImagineTask, MidjourneyImagineAction, MidjourneyImagineState } from '@/models';
import { IMidjourneyTask, MidjourneyImagineAction, MidjourneyImagineState } from '@/models';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
@@ -143,7 +143,7 @@ export default defineComponent({
},
props: {
modelValue: {
type: Object as () => IMidjourneyImagineTask | undefined,
type: Object as () => IMidjourneyTask | undefined,
required: true
},
full: {
@@ -241,10 +241,12 @@ export default defineComponent({
target.src = url.toString();
},
onCustom(action: string) {
this.$emit('custom', {
action,
image_id: this.modelValue?.response?.image_id
});
if (this.modelValue?.type === 'imagine') {
this.$emit('custom', {
action,
image_id: this.modelValue?.response?.image_id
});
}
},
onOpenUrl(url: string) {
window.open(url, '_blank');
@@ -332,7 +334,6 @@ $left-width: 70px;
}
}
}
.content {
width: 100%;
position: relative;
+7 -7
View File
@@ -54,7 +54,7 @@ export default defineComponent({
},
tasks() {
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
return this.$store.state.midjourney.imagineTasks?.reverse();
return this.$store.state.midjourney.tasks?.items?.reverse();
},
application() {
return this.$store.state.midjourney.application;
@@ -71,11 +71,11 @@ export default defineComponent({
}
},
async mounted() {
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
this.getImagineTasks();
await this.$store.dispatch('midjourney/setTasks', undefined);
this.getTasks();
// @ts-ignore
this.job = setInterval(() => {
this.getImagineTasks();
this.getTasks();
}, 5000);
},
unmounted() {
@@ -85,12 +85,12 @@ export default defineComponent({
async onLoadHistory() {
this.$router.push({ name: ROUTE_MIDJOURNEY_HISTORY });
},
async getImagineTasks() {
async getTasks() {
// ensure that the previous request has been completed
if (this.loading) {
return;
}
await this.$store.dispatch('midjourney/getImagineTasks', {
await this.$store.dispatch('midjourney/getTasks', {
limit: 30,
offset: 0
});
@@ -133,7 +133,7 @@ export default defineComponent({
.main {
width: calc(100% - 70px);
flex: 1;
padding: 0 10px;
padding: 10px;
.icon {
display: flex;