Change to use tasks for mj (#65)
Co-authored-by: Germey <germey@acedata.cloud>
This commit is contained in:
1 parent
4d179f306a
commit
01d44e75f2
16 files changed
+194
-67
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"type": "patch",
|
||||||
|
"comment": "upgrade to use tasks for mj",
|
||||||
|
"packageName": "@acedatacloud/nexior",
|
||||||
|
"email": "germey@acedata.cloud",
|
||||||
|
"dependentChangeType": "patch"
|
||||||
|
}
|
||||||
@@ -42,6 +42,10 @@ html.dark,
|
|||||||
color: var(--el-text-color-regular);
|
color: var(--el-text-color-regular);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.el-radio-group {
|
||||||
|
--el-border-radius-base: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
.el-textarea {
|
.el-textarea {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
textarea {
|
textarea {
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ export default defineComponent({
|
|||||||
background-color: var(--el-bg-color-page);
|
background-color: var(--el-bg-color-page);
|
||||||
color: var(--el-text-color-primary);
|
color: var(--el-text-color-primary);
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
text-align: right;
|
text-align: left;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
padding: 8px 15px;
|
padding: 8px 15px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="item">
|
<div v-if="modelValue?.type === 'imagine'" class="item">
|
||||||
<div class="left">
|
<div class="left">
|
||||||
<el-image src="https://cdn.acedata.cloud/05daz4.png" class="avatar" />
|
<el-image src="https://cdn.acedata.cloud/05daz4.png" class="avatar" />
|
||||||
</div>
|
</div>
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { ElImage, ElButton, ElTooltip, ElAlert } from 'element-plus';
|
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 { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||||
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Object as () => IMidjourneyImagineTask | undefined,
|
type: Object as () => IMidjourneyTask | undefined,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
full: {
|
full: {
|
||||||
@@ -241,10 +241,12 @@ export default defineComponent({
|
|||||||
target.src = url.toString();
|
target.src = url.toString();
|
||||||
},
|
},
|
||||||
onCustom(action: string) {
|
onCustom(action: string) {
|
||||||
this.$emit('custom', {
|
if (this.modelValue?.type === 'imagine') {
|
||||||
action,
|
this.$emit('custom', {
|
||||||
image_id: this.modelValue?.response?.image_id
|
action,
|
||||||
});
|
image_id: this.modelValue?.response?.image_id
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onOpenUrl(url: string) {
|
onOpenUrl(url: string) {
|
||||||
window.open(url, '_blank');
|
window.open(url, '_blank');
|
||||||
@@ -332,7 +334,6 @@ $left-width: 70px;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
tasks() {
|
tasks() {
|
||||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
// 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() {
|
application() {
|
||||||
return this.$store.state.midjourney.application;
|
return this.$store.state.midjourney.application;
|
||||||
@@ -71,11 +71,11 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
await this.$store.dispatch('midjourney/setImagineTasks', undefined);
|
await this.$store.dispatch('midjourney/setTasks', undefined);
|
||||||
this.getImagineTasks();
|
this.getTasks();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
this.job = setInterval(() => {
|
this.job = setInterval(() => {
|
||||||
this.getImagineTasks();
|
this.getTasks();
|
||||||
}, 5000);
|
}, 5000);
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
@@ -85,12 +85,12 @@ export default defineComponent({
|
|||||||
async onLoadHistory() {
|
async onLoadHistory() {
|
||||||
this.$router.push({ name: ROUTE_MIDJOURNEY_HISTORY });
|
this.$router.push({ name: ROUTE_MIDJOURNEY_HISTORY });
|
||||||
},
|
},
|
||||||
async getImagineTasks() {
|
async getTasks() {
|
||||||
// ensure that the previous request has been completed
|
// ensure that the previous request has been completed
|
||||||
if (this.loading) {
|
if (this.loading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await this.$store.dispatch('midjourney/getImagineTasks', {
|
await this.$store.dispatch('midjourney/getTasks', {
|
||||||
limit: 30,
|
limit: 30,
|
||||||
offset: 0
|
offset: 0
|
||||||
});
|
});
|
||||||
@@ -133,7 +133,7 @@ export default defineComponent({
|
|||||||
.main {
|
.main {
|
||||||
width: calc(100% - 70px);
|
width: calc(100% - 70px);
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0 10px;
|
padding: 10px;
|
||||||
|
|
||||||
.icon {
|
.icon {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -1,6 +1,27 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="panel recent tasks">
|
<div class="panel recent">
|
||||||
<task-preview v-for="(task, taskIndex) in tasks?.items" :key="taskIndex" :model-value="task" class="preview" />
|
<div v-if="tasks?.items === undefined" class="tasks">
|
||||||
|
<div v-for="_ in 3" :key="_" class="task placeholder">
|
||||||
|
<div class="left">
|
||||||
|
<el-skeleton animated>
|
||||||
|
<template #template>
|
||||||
|
<el-skeleton-item variant="image" class="avatar" />
|
||||||
|
</template>
|
||||||
|
</el-skeleton>
|
||||||
|
</div>
|
||||||
|
<div class="main">
|
||||||
|
<el-skeleton animated>
|
||||||
|
<template #template>
|
||||||
|
<el-skeleton-item variant="p" class="title" />
|
||||||
|
<el-skeleton-item variant="image" class="icon" />
|
||||||
|
</template>
|
||||||
|
</el-skeleton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-else-if="tasks?.items?.length && tasks?.items?.length > 0" class="tasks">
|
||||||
|
<task-preview v-for="(task, taskIndex) in tasks?.items" :key="taskIndex" :model-value="task" class="preview" />
|
||||||
|
</div>
|
||||||
<p v-if="tasks?.items?.length === 0" class="description">
|
<p v-if="tasks?.items?.length === 0" class="description">
|
||||||
{{ $t('qrart.message.noTasks') }}
|
{{ $t('qrart.message.noTasks') }}
|
||||||
</p>
|
</p>
|
||||||
@@ -11,11 +32,14 @@
|
|||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import TaskPreview from './task/Preview.vue';
|
import TaskPreview from './task/Preview.vue';
|
||||||
import { Status } from '@/models';
|
import { Status } from '@/models';
|
||||||
|
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'RecentPanel',
|
name: 'RecentPanel',
|
||||||
components: {
|
components: {
|
||||||
TaskPreview
|
TaskPreview,
|
||||||
|
ElSkeleton,
|
||||||
|
ElSkeletonItem
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -49,8 +73,8 @@ export default defineComponent({
|
|||||||
methods: {
|
methods: {
|
||||||
async onScrollDown() {
|
async onScrollDown() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// scroll to bottom for `.tasks`
|
// scroll to bottom for `.recent`
|
||||||
const el = document.querySelector('.tasks');
|
const el = document.querySelector('.recent');
|
||||||
if (el) {
|
if (el) {
|
||||||
el.scrollTop = el.scrollHeight;
|
el.scrollTop = el.scrollHeight;
|
||||||
}
|
}
|
||||||
@@ -91,6 +115,54 @@ export default defineComponent({
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: var(--el-text-color-secondary);
|
color: var(--el-text-color-secondary);
|
||||||
}
|
}
|
||||||
|
.tasks {
|
||||||
|
width: 100%;
|
||||||
|
.task {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
width: 100%;
|
||||||
|
height: fit-content;
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
|
&.placeholder {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
.left {
|
||||||
|
width: 70px;
|
||||||
|
padding: 10px;
|
||||||
|
|
||||||
|
.avatar {
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.main {
|
||||||
|
width: calc(100% - 70px);
|
||||||
|
flex: 1;
|
||||||
|
padding: 10px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
display: flex;
|
||||||
|
height: 200px;
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
display: block;
|
||||||
|
width: 200px;
|
||||||
|
height: 20px;
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.operations {
|
||||||
|
height: fit-content !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -60,6 +60,11 @@ export interface IMidjourneyImagineRequest {
|
|||||||
application_id?: string;
|
application_id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IMidjourneyDescribeRequest {
|
||||||
|
image_url: string;
|
||||||
|
application_id?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IMidjourneyImagineResponse {
|
export interface IMidjourneyImagineResponse {
|
||||||
task_id: string;
|
task_id: string;
|
||||||
progress: number;
|
progress: number;
|
||||||
@@ -75,18 +80,33 @@ export interface IMidjourneyImagineResponse {
|
|||||||
success?: boolean;
|
success?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IMidjourneyDescribeResponse {
|
||||||
|
descriptions: string[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface IMidjourneyImagineTask {
|
export interface IMidjourneyImagineTask {
|
||||||
id: string;
|
id: string;
|
||||||
|
type: 'imagine';
|
||||||
created_at?: string;
|
created_at?: string;
|
||||||
request?: IMidjourneyImagineRequest;
|
request?: IMidjourneyImagineRequest;
|
||||||
response?: IMidjourneyImagineResponse;
|
response?: IMidjourneyImagineResponse;
|
||||||
state?: MidjourneyImagineState;
|
state?: MidjourneyImagineState;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type IMidjourneyImagineTaskResponse = IMidjourneyImagineTask;
|
export interface IMidjourneyDescribeTask {
|
||||||
|
id: string;
|
||||||
|
type: 'describe';
|
||||||
|
created_at?: string;
|
||||||
|
request?: IMidjourneyDescribeRequest;
|
||||||
|
response?: IMidjourneyDescribeResponse;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IMidjourneyImagineTasksResponse {
|
export type IMidjourneyTask = IMidjourneyImagineTask | IMidjourneyDescribeTask;
|
||||||
items: IMidjourneyImagineTask[];
|
|
||||||
|
export type IMidjourneyTaskResponse = IMidjourneyTask;
|
||||||
|
|
||||||
|
export interface IMidjourneyTasksResponse {
|
||||||
|
items: IMidjourneyTask[];
|
||||||
count: number;
|
count: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ import axios, { AxiosResponse } from 'axios';
|
|||||||
import {
|
import {
|
||||||
IMidjourneyImagineRequest,
|
IMidjourneyImagineRequest,
|
||||||
IMidjourneyImagineResponse,
|
IMidjourneyImagineResponse,
|
||||||
IMidjourneyImagineTaskResponse,
|
IMidjourneyTaskResponse,
|
||||||
IMidjourneyImagineTasksResponse
|
IMidjourneyTasksResponse
|
||||||
} from '@/models';
|
} from '@/models';
|
||||||
import { BASE_URL_API } from '@/constants';
|
import { BASE_URL_API } from '@/constants';
|
||||||
|
|
||||||
class MidjourneyOperator {
|
class MidjourneyOperator {
|
||||||
async task(id: string, options: { token: string }): Promise<AxiosResponse<IMidjourneyImagineTaskResponse>> {
|
async task(id: string, options: { token: string }): Promise<AxiosResponse<IMidjourneyTaskResponse>> {
|
||||||
return await axios.post(
|
return await axios.post(
|
||||||
`/midjourney/tasks`,
|
`/midjourney/tasks`,
|
||||||
{
|
{
|
||||||
@@ -30,7 +30,7 @@ class MidjourneyOperator {
|
|||||||
async tasks(
|
async tasks(
|
||||||
filter: { ids?: string[]; applicationId?: string; limit?: number; offset?: number },
|
filter: { ids?: string[]; applicationId?: string; limit?: number; offset?: number },
|
||||||
options: { token: string }
|
options: { token: string }
|
||||||
): Promise<AxiosResponse<IMidjourneyImagineTasksResponse>> {
|
): Promise<AxiosResponse<IMidjourneyTasksResponse>> {
|
||||||
return await axios.post(
|
return await axios.post(
|
||||||
`/midjourney/tasks`,
|
`/midjourney/tasks`,
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -434,4 +434,10 @@ export default defineComponent({
|
|||||||
bottom: 40px;
|
bottom: 40px;
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 767px) {
|
||||||
|
.help {
|
||||||
|
top: 40px;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -94,8 +94,8 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
imagineTasks() {
|
tasks() {
|
||||||
return this.$store.state.midjourney.imagineTasks;
|
return this.$store.state.midjourney.tasks;
|
||||||
},
|
},
|
||||||
service() {
|
service() {
|
||||||
return this.$store.state.midjourney.service;
|
return this.$store.state.midjourney.service;
|
||||||
@@ -189,7 +189,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
imagineTasks: {
|
tasks: {
|
||||||
handler(val, oldVal) {
|
handler(val, oldVal) {
|
||||||
if (oldVal === undefined && val) {
|
if (oldVal === undefined && val) {
|
||||||
this.onScrollDown();
|
this.onScrollDown();
|
||||||
@@ -272,7 +272,7 @@ export default defineComponent({
|
|||||||
}, 500);
|
}, 500);
|
||||||
},
|
},
|
||||||
async onSyncTasks() {
|
async onSyncTasks() {
|
||||||
await this.$store.dispatch('midjourney/getImagineTasks', {
|
await this.$store.dispatch('midjourney/getTasks', {
|
||||||
limit: 30,
|
limit: 30,
|
||||||
offset: 0
|
offset: 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -73,6 +73,9 @@ export default defineComponent({
|
|||||||
user() {
|
user() {
|
||||||
return this.$store.getters.user;
|
return this.$store.getters.user;
|
||||||
},
|
},
|
||||||
|
showSite() {
|
||||||
|
return this.$store?.state?.site?.admins?.includes(this.$store.getters.user?.id);
|
||||||
|
},
|
||||||
links(): ILink[] {
|
links(): ILink[] {
|
||||||
let links: ILink[] = [
|
let links: ILink[] = [
|
||||||
{
|
{
|
||||||
@@ -105,12 +108,16 @@ export default defineComponent({
|
|||||||
name: ROUTE_DISTRIBUTION_INDEX,
|
name: ROUTE_DISTRIBUTION_INDEX,
|
||||||
icon: 'fa-solid fa-coins'
|
icon: 'fa-solid fa-coins'
|
||||||
},
|
},
|
||||||
{
|
...(this.showSite
|
||||||
key: 'site-index',
|
? [
|
||||||
text: this.$t('common.nav.site'),
|
{
|
||||||
name: ROUTE_SITE_INDEX,
|
key: 'site-index',
|
||||||
icon: 'fa-solid fa-gear'
|
text: this.$t('common.nav.site'),
|
||||||
},
|
name: ROUTE_SITE_INDEX,
|
||||||
|
icon: 'fa-solid fa-gear'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
: []),
|
||||||
{
|
{
|
||||||
key: 'dark-setting',
|
key: 'dark-setting',
|
||||||
text: this.$t('common.nav.darkMode'),
|
text: this.$t('common.nav.darkMode'),
|
||||||
|
|||||||
@@ -3,7 +3,14 @@ import { IMidjourneyState } from './models';
|
|||||||
import { ActionContext } from 'vuex';
|
import { ActionContext } from 'vuex';
|
||||||
import { log } from '@/utils/log';
|
import { log } from '@/utils/log';
|
||||||
import { IRootState } from '../common/models';
|
import { IRootState } from '../common/models';
|
||||||
import { IApplication, ICredential, IMidjourneyImagineTask, IMidjourneyPreset, IService } from '@/models';
|
import {
|
||||||
|
IApplication,
|
||||||
|
ICredential,
|
||||||
|
IMidjourneyPreset,
|
||||||
|
IMidjourneyTask,
|
||||||
|
IMidjourneyTasksResponse,
|
||||||
|
IService
|
||||||
|
} from '@/models';
|
||||||
import { Status } from '@/models/common';
|
import { Status } from '@/models/common';
|
||||||
import { MIDJOURNEY_SERVICE_ID } from '@/constants';
|
import { MIDJOURNEY_SERVICE_ID } from '@/constants';
|
||||||
|
|
||||||
@@ -62,8 +69,8 @@ export const getApplication = async ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setImagineTasks = ({ commit }: any, payload: IMidjourneyImagineTask[]) => {
|
export const setTasks = ({ commit }: any, payload: IMidjourneyTask[]) => {
|
||||||
commit('setImagineTasks', payload);
|
commit('setTasks', payload);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getService = async ({ commit, state }: ActionContext<IMidjourneyState, IRootState>): Promise<IService> => {
|
export const getService = async ({ commit, state }: ActionContext<IMidjourneyState, IRootState>): Promise<IService> => {
|
||||||
@@ -84,12 +91,12 @@ export const getService = async ({ commit, state }: ActionContext<IMidjourneySta
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getImagineTasks = async (
|
export const getTasks = async (
|
||||||
{ commit, state }: ActionContext<IMidjourneyState, IRootState>,
|
{ commit, state }: ActionContext<IMidjourneyState, IRootState>,
|
||||||
{ offset, limit }: { offset?: number; limit?: number }
|
{ offset, limit }: { offset?: number; limit?: number }
|
||||||
): Promise<IMidjourneyImagineTask[]> => {
|
): Promise<IMidjourneyTasksResponse> => {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
log(getImagineTasks, 'start to get imagine tasks', offset, limit);
|
log(getTasks, 'start to get tasks', offset, limit);
|
||||||
const credential = state.credential;
|
const credential = state.credential;
|
||||||
const token = credential?.token;
|
const token = credential?.token;
|
||||||
if (!token) {
|
if (!token) {
|
||||||
@@ -107,10 +114,9 @@ export const getImagineTasks = async (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
log(getImagineTasks, 'get imagine tasks success', response.data.items);
|
log(getTasks, 'get tasks success', response.data);
|
||||||
commit('setImagineTasks', response.data.items);
|
commit('setTasks', response.data);
|
||||||
commit('setImagineTasksTotal', response.data.count);
|
resolve(response.data);
|
||||||
resolve(response.data.items);
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
return reject(error);
|
return reject(error);
|
||||||
@@ -127,6 +133,6 @@ export default {
|
|||||||
setMode,
|
setMode,
|
||||||
setApplication,
|
setApplication,
|
||||||
getApplication,
|
getApplication,
|
||||||
setImagineTasks,
|
setTasks,
|
||||||
getImagineTasks
|
getTasks
|
||||||
};
|
};
|
||||||
@@ -1,15 +1,19 @@
|
|||||||
import { IApplication, ICredential, IMidjourneyImagineTask, IMidjourneyPreset, IService, Status } from '@/models';
|
import { IApplication, ICredential, IMidjourneyPreset, IMidjourneyTask, IService, Status } from '@/models';
|
||||||
|
|
||||||
export interface IMidjourneyState {
|
export interface IMidjourneyState {
|
||||||
service: IService | undefined;
|
service: IService | undefined;
|
||||||
application: IApplication | undefined;
|
application: IApplication | undefined;
|
||||||
imagineTasks: IMidjourneyImagineTask[] | undefined;
|
tasks:
|
||||||
imagineTasksTotal: number | undefined;
|
| {
|
||||||
|
items: IMidjourneyTask[] | undefined;
|
||||||
|
total: number | undefined;
|
||||||
|
}
|
||||||
|
| undefined;
|
||||||
credential: ICredential | undefined;
|
credential: ICredential | undefined;
|
||||||
preset: IMidjourneyPreset;
|
preset: IMidjourneyPreset;
|
||||||
status: {
|
status: {
|
||||||
getService: Status;
|
getService: Status;
|
||||||
getApplication: Status;
|
getApplication: Status;
|
||||||
getImagineTasks: Status;
|
getTasks: Status;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,10 @@ import { IMidjourneyState } from './models';
|
|||||||
export const resetAll = (state: IMidjourneyState): void => {
|
export const resetAll = (state: IMidjourneyState): void => {
|
||||||
state.application = undefined;
|
state.application = undefined;
|
||||||
state.preset = {};
|
state.preset = {};
|
||||||
state.imagineTasks = [];
|
state.tasks = {
|
||||||
|
items: undefined,
|
||||||
|
total: undefined
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setService = (state: IMidjourneyState, payload: IService): void => {
|
export const setService = (state: IMidjourneyState, payload: IService): void => {
|
||||||
@@ -23,12 +26,8 @@ export const setPreset = (state: IMidjourneyState, payload: IMidjourneyPreset):
|
|||||||
state.preset = payload;
|
state.preset = payload;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const setImagineTasks = (state: IMidjourneyState, payload: any): void => {
|
export const setTasks = (state: IMidjourneyState, payload: any): void => {
|
||||||
state.imagineTasks = payload;
|
state.tasks = payload;
|
||||||
};
|
|
||||||
|
|
||||||
export const setImagineTasksTotal = (state: IMidjourneyState, payload: number): void => {
|
|
||||||
state.imagineTasksTotal = payload;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -36,7 +35,6 @@ export default {
|
|||||||
setPreset,
|
setPreset,
|
||||||
setCredential,
|
setCredential,
|
||||||
setService,
|
setService,
|
||||||
setImagineTasks,
|
setTasks,
|
||||||
setImagineTasksTotal,
|
|
||||||
resetAll
|
resetAll
|
||||||
};
|
};
|
||||||
@@ -3,5 +3,5 @@ export default [
|
|||||||
'midjourney.credential',
|
'midjourney.credential',
|
||||||
'midjourney.mode',
|
'midjourney.mode',
|
||||||
'midjourney.application',
|
'midjourney.application',
|
||||||
'midjourney.imagineTasks'
|
'midjourney.tasks'
|
||||||
];
|
];
|
||||||
@@ -5,14 +5,16 @@ export default (): IMidjourneyState => {
|
|||||||
return {
|
return {
|
||||||
service: undefined,
|
service: undefined,
|
||||||
application: undefined,
|
application: undefined,
|
||||||
imagineTasks: undefined,
|
tasks: {
|
||||||
imagineTasksTotal: undefined,
|
items: undefined,
|
||||||
|
total: undefined
|
||||||
|
},
|
||||||
credential: undefined,
|
credential: undefined,
|
||||||
preset: {},
|
preset: {},
|
||||||
status: {
|
status: {
|
||||||
getService: Status.None,
|
getService: Status.None,
|
||||||
getApplication: Status.None,
|
getApplication: Status.None,
|
||||||
getImagineTasks: Status.None
|
getTasks: Status.None
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user