From 5d28ab219fa3ba57dd557340fb56862ad2edf666 Mon Sep 17 00:00:00 2001 From: AceDataCloud Date: Sun, 5 Nov 2023 00:03:42 +0800 Subject: [PATCH] update applications --- src/components/midjourney/TaskBriefList.vue | 6 +++--- src/operators/application/models.ts | 2 +- src/operators/application/operator.ts | 2 +- src/operators/midjourney/models.ts | 3 ++- src/operators/midjourney/operator.ts | 17 +++++++++++++++++ src/operators/usage/operator.ts | 2 +- src/pages/midjourney/Index.vue | 12 +++++++++--- 7 files changed, 34 insertions(+), 10 deletions(-) diff --git a/src/components/midjourney/TaskBriefList.vue b/src/components/midjourney/TaskBriefList.vue index bbbeda0e..229a38a6 100644 --- a/src/components/midjourney/TaskBriefList.vue +++ b/src/components/midjourney/TaskBriefList.vue @@ -31,8 +31,8 @@ export default defineComponent({ type: Object as () => IMidjourneyImagineTask | undefined, required: true }, - application: { - type: Object as () => IApplication | undefined, + applications: { + type: Object as () => IApplication[], required: true } }, @@ -70,7 +70,7 @@ export default defineComponent({ data: { items: apiUsages } } = await apiUsageOperator.getAll({ user_id: this.$store.state.user.id, - application_id: this.application?.id, + application_id: this.applications?.map((application) => application.id), offset: 0, limit: 5, ordering: '-created_at' diff --git a/src/operators/application/models.ts b/src/operators/application/models.ts index ceb50aa6..0d7313e2 100644 --- a/src/operators/application/models.ts +++ b/src/operators/application/models.ts @@ -20,7 +20,7 @@ export interface ICredential { } export interface IApplication { - id?: string; + id: string; api?: IApi; type?: IApplicationType; api_id?: string; diff --git a/src/operators/application/operator.ts b/src/operators/application/operator.ts index fdf92878..ffa07a8b 100644 --- a/src/operators/application/operator.ts +++ b/src/operators/application/operator.ts @@ -7,7 +7,7 @@ export interface IApplicationQuery { offset?: number; limit?: number; type?: IApplicationType; - api_id?: string; + api_id?: string | string[]; ordering?: string; } diff --git a/src/operators/midjourney/models.ts b/src/operators/midjourney/models.ts index 6e0c7023..cb5b1c39 100644 --- a/src/operators/midjourney/models.ts +++ b/src/operators/midjourney/models.ts @@ -15,7 +15,7 @@ export interface IMidjourneyPreset { quality?: string; wired?: number; raw?: boolean; - iw: number; + iw?: number; translation?: boolean; } @@ -56,6 +56,7 @@ export interface IMidjourneyImagineRequest { action?: MidjourneyImagineAction; prompt?: string; image_id?: string; + translation?: boolean; } export interface IMidjourneyImagineResponse { diff --git a/src/operators/midjourney/operator.ts b/src/operators/midjourney/operator.ts index 3ff6e1b5..bac1735b 100644 --- a/src/operators/midjourney/operator.ts +++ b/src/operators/midjourney/operator.ts @@ -20,6 +20,23 @@ class MidjourneyOperator { ); } + async tasks(ids: string[]): Promise> { + return await axios.post( + `/midjourney/tasks`, + { + action: 'retrieve_batch', + ids: ids + }, + { + headers: { + accept: 'application/json', + 'content-type': 'application/json' + }, + baseURL: ENDPOINT_API + } + ); + } + async imagine( data: IMidjourneyImagineRequest, options: { diff --git a/src/operators/usage/operator.ts b/src/operators/usage/operator.ts index 957db81f..3ac71372 100644 --- a/src/operators/usage/operator.ts +++ b/src/operators/usage/operator.ts @@ -6,7 +6,7 @@ export interface IApiUsageQuery { user_id?: string; offset?: number; limit?: number; - application_id?: string; + application_id?: string | string[]; ordering?: string; } diff --git a/src/pages/midjourney/Index.vue b/src/pages/midjourney/Index.vue index 88f41798..94ee1608 100644 --- a/src/pages/midjourney/Index.vue +++ b/src/pages/midjourney/Index.vue @@ -13,7 +13,7 @@ 生成
- +
@@ -33,6 +33,8 @@ import { IMidjourneyImagineResponse, IMidjourneyPreset, MIDJOURNEY_CHANNEL_FAST, + MIDJOURNEY_CHANNEL_TURBO, + MIDJOURNEY_CHANNEL_RELAX, applicationOperator, midjourneyOperator, MidjourneyImagineState, @@ -52,6 +54,7 @@ interface IData { initializing: boolean; applied: boolean | undefined; application: IApplication | undefined; + applications: IApplication[]; task: IMidjourneyImagineTask | undefined; } @@ -71,6 +74,7 @@ export default defineComponent({ data(): IData { return { application: undefined, + applications: [], channel: MIDJOURNEY_CHANNEL_FAST, preset: {}, prompt: '', @@ -131,9 +135,10 @@ export default defineComponent({ this.initializing = true; const { data: applications } = await applicationOperator.getAll({ user_id: this.$store.state.user.id, - api_id: this.channel.apiId + api_id: [MIDJOURNEY_CHANNEL_FAST.apiId, MIDJOURNEY_CHANNEL_RELAX.apiId, MIDJOURNEY_CHANNEL_TURBO.apiId] }); this.initializing = false; + this.applications = applications?.items; if (!applications || applications?.items?.length === 0) { this.applied = false; return; @@ -191,7 +196,8 @@ export default defineComponent({ async onGenerate() { const request = { prompt: this.prompt, - action: MidjourneyImagineAction.GENERATE + action: MidjourneyImagineAction.GENERATE, + translation: this.preset?.translation }; this.onStartTask(request); }