update applications
This commit is contained in:
1 parent
1e837571e2
commit
5d28ab219f
7 files changed
+34
-10
No files matched your search
@@ -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'
|
||||
|
||||
@@ -20,7 +20,7 @@ export interface ICredential {
|
||||
}
|
||||
|
||||
export interface IApplication {
|
||||
id?: string;
|
||||
id: string;
|
||||
api?: IApi;
|
||||
type?: IApplicationType;
|
||||
api_id?: string;
|
||||
|
||||
@@ -7,7 +7,7 @@ export interface IApplicationQuery {
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
type?: IApplicationType;
|
||||
api_id?: string;
|
||||
api_id?: string | string[];
|
||||
ordering?: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -20,6 +20,23 @@ class MidjourneyOperator {
|
||||
);
|
||||
}
|
||||
|
||||
async tasks(ids: string[]): Promise<AxiosResponse<IMidjourneyImagineTask[]>> {
|
||||
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: {
|
||||
|
||||
@@ -6,7 +6,7 @@ export interface IApiUsageQuery {
|
||||
user_id?: string;
|
||||
offset?: number;
|
||||
limit?: number;
|
||||
application_id?: string;
|
||||
application_id?: string | string[];
|
||||
ordering?: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<el-button type="primary" @click="onGenerate"> 生成 </el-button>
|
||||
</div>
|
||||
<div class="tasks">
|
||||
<task-brief-list v-model:active-task="task" :application="application" @custom="onCustom" />
|
||||
<task-brief-list v-model:active-task="task" :applications="applications" @custom="onCustom" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user