update multi fetch
This commit is contained in:
1 parent
5d28ab219f
commit
e4bd995e6c
6 files changed
+31
-17
No files matched your search
+3
-11
@@ -48,7 +48,7 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
application(val) {
|
||||
applications(val) {
|
||||
if (val) {
|
||||
this.getHistoryTasks();
|
||||
}
|
||||
@@ -75,16 +75,8 @@ export default defineComponent({
|
||||
limit: 5,
|
||||
ordering: '-created_at'
|
||||
});
|
||||
const tasks = await Promise.all(
|
||||
apiUsages.map(async (apiUsage) => {
|
||||
const taskId = apiUsage.metadata?.task_id;
|
||||
const { data: task } = await midjourneyOperator.task(taskId);
|
||||
if (task.response?.success === false) {
|
||||
task.state = MidjourneyImagineState.FAILED;
|
||||
}
|
||||
return task;
|
||||
})
|
||||
);
|
||||
const tasks = (await midjourneyOperator.tasks(apiUsages.map((apiUsage) => apiUsage.metadata?.task_id as string)))
|
||||
.data;
|
||||
this.historyTasks = tasks.filter((task) => task && task?.response);
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -1,12 +1,16 @@
|
||||
import router, { ROUTE_AUTH_LOGIN } from '@/router';
|
||||
import store from '@/store';
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import qs from 'qs';
|
||||
|
||||
const httpClient: AxiosInstance = axios.create({
|
||||
baseURL: '/api/v1',
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
Accept: 'application/json'
|
||||
},
|
||||
paramsSerializer: function (params) {
|
||||
return qs.stringify(params, { arrayFormat: 'repeat' });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ import {
|
||||
IMidjourneyImagineRequest
|
||||
} from '@/operators';
|
||||
import ApiStatus from '@/components/common/ApiStatus.vue';
|
||||
import TaskBriefList from '@/components/midjourney/TaskBriefList.vue';
|
||||
import TaskBriefList from '@/components/midjourney/tasks/TaskBriefList.vue';
|
||||
import FinalPrompt from '@/components/midjourney/FinalPrompt.vue';
|
||||
|
||||
interface IData {
|
||||
@@ -53,7 +53,6 @@ interface IData {
|
||||
ignore: string;
|
||||
initializing: boolean;
|
||||
applied: boolean | undefined;
|
||||
application: IApplication | undefined;
|
||||
applications: IApplication[];
|
||||
task: IMidjourneyImagineTask | undefined;
|
||||
}
|
||||
@@ -73,7 +72,6 @@ export default defineComponent({
|
||||
},
|
||||
data(): IData {
|
||||
return {
|
||||
application: undefined,
|
||||
applications: [],
|
||||
channel: MIDJOURNEY_CHANNEL_FAST,
|
||||
preset: {},
|
||||
@@ -86,6 +84,12 @@ export default defineComponent({
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
application() {
|
||||
if (this.applications && this.applications.length > 0) {
|
||||
return this.applications.filter((item) => item.api_id === this.channel.apiId)[0];
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
finalPrompt(): string {
|
||||
let content = '';
|
||||
if (this.prompt) {
|
||||
@@ -125,13 +129,13 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.onFetchApplication();
|
||||
this.onFetchApplications();
|
||||
},
|
||||
methods: {
|
||||
async onSelectChannel() {
|
||||
await this.onFetchApplication();
|
||||
await this.onFetchApplications();
|
||||
},
|
||||
async onFetchApplication() {
|
||||
async onFetchApplications() {
|
||||
this.initializing = true;
|
||||
const { data: applications } = await applicationOperator.getAll({
|
||||
user_id: this.$store.state.user.id,
|
||||
|
||||
Reference in new issue
Block a user