Migrate new service (#1)
This commit is contained in:
1 parent
f13ca37d63
commit
28da0263dc
109 files changed
+1160
-1053
No files matched your search
@@ -14,7 +14,7 @@
|
||||
</div>
|
||||
<div v-else-if="tasks.length > 0" class="tasks">
|
||||
<div v-for="(task, taskKey) in tasks" :key="taskKey" class="task">
|
||||
<task-preview :full="false" :model-value="task" :applications="applications" @custom="$emit('custom', $event)" />
|
||||
<task-preview :full="false" :model-value="task" @custom="$emit('custom', $event)" />
|
||||
</div>
|
||||
<el-button type="primary" class="btn mb-4" @click="onLoadHistory">{{ $t('midjourney.button.history') }}</el-button>
|
||||
</div>
|
||||
@@ -25,7 +25,7 @@ import { defineComponent } from 'vue';
|
||||
import TaskPreview from './TaskPreview.vue';
|
||||
import { ROUTE_MIDJOURNEY_HISTORY } from '@/router';
|
||||
import { ElButton, ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { Status } from '@/models';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskBriefList',
|
||||
@@ -44,17 +44,18 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
loading() {
|
||||
return this.$store.state.midjourney.getImagineTasksStatus === Status.Request;
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.midjourney.imagineTasks;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getImagineTasks();
|
||||
}, 5000);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div v-if="tasks" class="tasks">
|
||||
<div v-for="(task, taskKey) in tasks" :key="taskKey" class="task">
|
||||
<task-preview :full="true" :model-value="task" :applications="applications" @custom="onCustom($event)" />
|
||||
<task-preview :full="true" :model-value="task" @custom="onCustom($event)" />
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="tasks">
|
||||
@@ -23,8 +23,12 @@
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskPreview from './TaskPreview.vue';
|
||||
import Pagination from '@/components/common/Pagination.vue';
|
||||
import { ElRow, ElCol, ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/store/common/models';
|
||||
import { ElCard, ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/models';
|
||||
|
||||
interface IData {
|
||||
job: number | undefined;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'TaskFullList',
|
||||
@@ -36,9 +40,9 @@ export default defineComponent({
|
||||
ElCard
|
||||
},
|
||||
emits: ['update:modelValue', 'custom'],
|
||||
data() {
|
||||
data(): IData {
|
||||
return {
|
||||
job: 0
|
||||
job: undefined
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -55,13 +59,13 @@ export default defineComponent({
|
||||
return 12;
|
||||
},
|
||||
loading() {
|
||||
return this.$store.state.midjourney.getImagineTasksStatus === Status.Request;
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
return this.$store.state.midjourney.imagineTasks;
|
||||
},
|
||||
applications() {
|
||||
return this.$store.state.midjourney.applications;
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -74,6 +78,7 @@ export default defineComponent({
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getImagineTasks();
|
||||
}, 5000);
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="right">
|
||||
<el-tag v-if="channel" type="info" class="channel">
|
||||
<font-awesome-icon :class="{ icon: true, [channel.name]: true }" :icon="channel?.icon" />
|
||||
{{ channel?.displayName }}
|
||||
<el-tag v-if="mode" type="info" class="channel">
|
||||
<font-awesome-icon :class="{ icon: true, [mode.name]: true }" :icon="mode.icon" />
|
||||
{{ mode?.displayName }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,8 +45,8 @@
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-circle-info" class="mr-1" />
|
||||
{{ $t('midjourney.field.failureReason') }}:
|
||||
{{ modelValue?.response?.detail }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.detail!" class="btn-copy" />
|
||||
{{ modelValue?.response?.error?.message }}
|
||||
<copy-to-clipboard :content="modelValue?.response?.error?.message!" class="btn-copy" />
|
||||
</p>
|
||||
<p class="description">
|
||||
<font-awesome-icon icon="fa-solid fa-hashtag" class="mr-1" />
|
||||
@@ -56,7 +56,6 @@
|
||||
</p>
|
||||
</el-alert>
|
||||
</div>
|
||||
|
||||
<div v-else :class="{ content: true, full: full }">
|
||||
<el-image
|
||||
v-if="modelValue?.response?.image_url"
|
||||
@@ -92,9 +91,9 @@
|
||||
</p>
|
||||
</div>
|
||||
<div class="extra">
|
||||
<p class="datetime">
|
||||
<p v-if="modelValue?.created_at" class="datetime">
|
||||
<font-awesome-icon icon="fa-regular fa-clock" class="mr-1" />
|
||||
{{ $dayjs.format(modelValue?.created_at) }}
|
||||
{{ $dayjs.format(new Date(parseFloat(modelValue?.created_at) * 1000)) }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -103,17 +102,15 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import { ElImage, ElTag, ElButton, ElTooltip, ElSkeleton, ElAlert } from 'element-plus';
|
||||
import { IApplication, IMidjourneyImagineTask, MidjourneyImagineAction, MidjourneyImagineState } from '@/operators';
|
||||
import {
|
||||
API_ID_MIDJOURNEY_FAST,
|
||||
API_ID_MIDJOURNEY_RELAX,
|
||||
API_ID_MIDJOURNEY_TURBO,
|
||||
MIDJOURNEY_CHANNEL_FAST,
|
||||
MIDJOURNEY_CHANNEL_RELAX,
|
||||
MIDJOURNEY_CHANNEL_TURBO
|
||||
} from '@/operators/midjourney/constants';
|
||||
IMidjourneyImagineTask,
|
||||
MidjourneyImagineAction,
|
||||
MidjourneyImagineMode,
|
||||
MidjourneyImagineState
|
||||
} from '@/models';
|
||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||
import { MIDJOURNEY_MODE_FAST, MIDJOURNEY_MODE_RELAX, MIDJOURNEY_MODE_TURBO } from '@/constants';
|
||||
|
||||
interface IData {
|
||||
midjourneyImagineState: typeof MidjourneyImagineState;
|
||||
@@ -138,10 +135,6 @@ export default defineComponent({
|
||||
type: Object as () => IMidjourneyImagineTask | undefined,
|
||||
required: true
|
||||
},
|
||||
applications: {
|
||||
type: Object as () => IApplication[] | undefined,
|
||||
required: true
|
||||
},
|
||||
full: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@@ -153,22 +146,26 @@ export default defineComponent({
|
||||
midjourneyImagineState: MidjourneyImagineState,
|
||||
actionMapping: {
|
||||
[MidjourneyImagineAction.GENERATE]: 'Generate',
|
||||
[MidjourneyImagineAction.UPSAMPLE1]: 'U1',
|
||||
[MidjourneyImagineAction.UPSAMPLE2]: 'U2',
|
||||
[MidjourneyImagineAction.UPSAMPLE3]: 'U3',
|
||||
[MidjourneyImagineAction.UPSAMPLE4]: 'U4',
|
||||
[MidjourneyImagineAction.UPSCALE1]: 'U1',
|
||||
[MidjourneyImagineAction.UPSCALE2]: 'U2',
|
||||
[MidjourneyImagineAction.UPSCALE3]: 'U3',
|
||||
[MidjourneyImagineAction.UPSCALE4]: 'U4',
|
||||
[MidjourneyImagineAction.VARIATION1]: 'V1',
|
||||
[MidjourneyImagineAction.VARIATION2]: 'V2',
|
||||
[MidjourneyImagineAction.VARIATION3]: 'V3',
|
||||
[MidjourneyImagineAction.VARIATION4]: 'V4',
|
||||
[MidjourneyImagineAction.HIGH_VARIATION]: 'Vary (Strong)',
|
||||
[MidjourneyImagineAction.LOW_VARIATION]: 'Vary (Subtle)',
|
||||
[MidjourneyImagineAction.VARIATION_STRONG]: 'Vary (Strong)',
|
||||
[MidjourneyImagineAction.VARIATION_SUBTLE]: 'Vary (Subtle)',
|
||||
[MidjourneyImagineAction.UPSCALE_CREATIVE]: 'Upscale (Creative)',
|
||||
[MidjourneyImagineAction.UPSCALE_SUBTLE]: 'Upscale (Subtle)',
|
||||
[MidjourneyImagineAction.ZOOM_OUT_2X]: 'Zoom Out 2x',
|
||||
[MidjourneyImagineAction.ZOOM_OUT_1_5X]: 'Zoom Out 1.5x',
|
||||
[MidjourneyImagineAction.UPSAMPLE_2X]: 'Upsample 2x',
|
||||
[MidjourneyImagineAction.UPSAMPLE_4X]: 'Upsample 4x',
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_2X]: 'Redo Upsample 2x',
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_4X]: 'Redo Upsample 4x',
|
||||
[MidjourneyImagineAction.UPSCALE_2X]: 'Upscale 2x',
|
||||
[MidjourneyImagineAction.UPSCALE_4X]: 'Upscale 4x',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_2X]: 'Redo Upscale 2x',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_4X]: 'Redo Upscale 4x',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_SUBTLE]: 'Redo Upscale (Subtle)',
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_CREATIVE]: 'Redo Upscale (Creative)',
|
||||
[MidjourneyImagineAction.SQUARE]: 'Make Square',
|
||||
[MidjourneyImagineAction.PAN_LEFT]: '⬅️',
|
||||
[MidjourneyImagineAction.PAN_UP]: '⬆️',
|
||||
@@ -178,22 +175,26 @@ export default defineComponent({
|
||||
},
|
||||
descriptionMapping: {
|
||||
[MidjourneyImagineAction.GENERATE]: this.$t('midjourney.description.generate'),
|
||||
[MidjourneyImagineAction.UPSAMPLE1]: this.$t('midjourney.description.upsample1'),
|
||||
[MidjourneyImagineAction.UPSAMPLE2]: this.$t('midjourney.description.upsample2'),
|
||||
[MidjourneyImagineAction.UPSAMPLE3]: this.$t('midjourney.description.upsample3'),
|
||||
[MidjourneyImagineAction.UPSAMPLE4]: this.$t('midjourney.description.upsample4'),
|
||||
[MidjourneyImagineAction.UPSCALE1]: this.$t('midjourney.description.upscale1'),
|
||||
[MidjourneyImagineAction.UPSCALE2]: this.$t('midjourney.description.upscale2'),
|
||||
[MidjourneyImagineAction.UPSCALE3]: this.$t('midjourney.description.upscale3'),
|
||||
[MidjourneyImagineAction.UPSCALE4]: this.$t('midjourney.description.upscale4'),
|
||||
[MidjourneyImagineAction.VARIATION1]: this.$t('midjourney.description.variation1'),
|
||||
[MidjourneyImagineAction.VARIATION2]: this.$t('midjourney.description.variation2'),
|
||||
[MidjourneyImagineAction.VARIATION3]: this.$t('midjourney.description.variation3'),
|
||||
[MidjourneyImagineAction.VARIATION4]: this.$t('midjourney.description.variation4'),
|
||||
[MidjourneyImagineAction.HIGH_VARIATION]: this.$t('midjourney.description.high_variation'),
|
||||
[MidjourneyImagineAction.LOW_VARIATION]: this.$t('midjourney.description.low_variation'),
|
||||
[MidjourneyImagineAction.VARIATION_STRONG]: this.$t('midjourney.description.variation_strong'),
|
||||
[MidjourneyImagineAction.VARIATION_SUBTLE]: this.$t('midjourney.description.variation_subtle'),
|
||||
[MidjourneyImagineAction.ZOOM_OUT_2X]: this.$t('midjourney.description.zoom_out_2x'),
|
||||
[MidjourneyImagineAction.ZOOM_OUT_1_5X]: this.$t('midjourney.description.zoom_out_1_5x'),
|
||||
[MidjourneyImagineAction.UPSAMPLE_2X]: this.$t('midjourney.description.upsample_2x'),
|
||||
[MidjourneyImagineAction.UPSAMPLE_4X]: this.$t('midjourney.description.upsample_4x'),
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_2X]: this.$t('midjourney.description.redo_upsample_2x'),
|
||||
[MidjourneyImagineAction.REDO_UPSAMPLE_4X]: this.$t('midjourney.description.redo_upsample_4x'),
|
||||
[MidjourneyImagineAction.UPSCALE_2X]: this.$t('midjourney.description.upscale_2x'),
|
||||
[MidjourneyImagineAction.UPSCALE_4X]: this.$t('midjourney.description.upscale_4x'),
|
||||
[MidjourneyImagineAction.UPSCALE_SUBTLE]: this.$t('midjourney.description.upscale_subtle'),
|
||||
[MidjourneyImagineAction.UPSCALE_CREATIVE]: this.$t('midjourney.description.upscale_creative'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_2X]: this.$t('midjourney.description.redo_upscale_2x'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_4X]: this.$t('midjourney.description.redo_upscale_4x'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_SUBTLE]: this.$t('midjourney.description.redo_upscale_subtle'),
|
||||
[MidjourneyImagineAction.REDO_UPSCALE_CREATIVE]: this.$t('midjourney.description.redo_upscale_creative'),
|
||||
[MidjourneyImagineAction.SQUARE]: this.$t('midjourney.description.square'),
|
||||
[MidjourneyImagineAction.PAN_LEFT]: this.$t('midjourney.description.pan_left'),
|
||||
[MidjourneyImagineAction.PAN_UP]: this.$t('midjourney.description.pan_up'),
|
||||
@@ -205,19 +206,19 @@ export default defineComponent({
|
||||
},
|
||||
computed: {
|
||||
application() {
|
||||
return this.applications?.find((application) => {
|
||||
return application.id === this.modelValue?.request?.application_id;
|
||||
});
|
||||
return this.$store.state.midjourney.application;
|
||||
},
|
||||
channel() {
|
||||
if (this.application?.api_id === API_ID_MIDJOURNEY_FAST) {
|
||||
return MIDJOURNEY_CHANNEL_FAST;
|
||||
} else if (this.application?.api_id === API_ID_MIDJOURNEY_RELAX) {
|
||||
return MIDJOURNEY_CHANNEL_RELAX;
|
||||
} else if (this.application?.api_id === API_ID_MIDJOURNEY_TURBO) {
|
||||
return MIDJOURNEY_CHANNEL_TURBO;
|
||||
mode() {
|
||||
switch (this.modelValue?.mode) {
|
||||
case MidjourneyImagineMode.FAST:
|
||||
return MIDJOURNEY_MODE_FAST;
|
||||
case MidjourneyImagineMode.TURBO:
|
||||
return MIDJOURNEY_MODE_TURBO;
|
||||
case MidjourneyImagineMode.RELAX:
|
||||
return MIDJOURNEY_MODE_RELAX;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -233,6 +234,16 @@ export default defineComponent({
|
||||
link.href = url;
|
||||
link.download = url.split('/').pop() as string;
|
||||
link.click();
|
||||
},
|
||||
getModeIcon(mode: MidjourneyImagineMode): string | undefined {
|
||||
switch (mode) {
|
||||
case MidjourneyImagineMode.FAST:
|
||||
return MIDJOURNEY_MODE_FAST.icon;
|
||||
case MidjourneyImagineMode.TURBO:
|
||||
return MIDJOURNEY_MODE_TURBO.icon;
|
||||
case MidjourneyImagineMode.RELAX:
|
||||
return MIDJOURNEY_MODE_RELAX.icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user