Update pagnation experience (#295)

This commit is contained in:
Germey authored and GitHub committed 2025-12-07 00:53:54 +08:00
1 parent aa2c2cd2f7
commit 0a94199d06
37 files changed
+1389 -747

No files matched your search

+1 -2
View File
@@ -255,7 +255,6 @@
<script lang="ts">
import { defineComponent } from 'vue';
import {
IApi,
IApplication,
IApplicationListResponse,
IApplicationType,
@@ -440,7 +439,7 @@ export default defineComponent({
plugins: {
legend: {
position: 'top' as const,
onClick: (e: unknown, legendItem: any, legend: any) => {
onClick: (_event: unknown, legendItem: any, legend: any) => {
const chart = legend?.chart;
if (!chart || legendItem?.datasetIndex === undefined) return;
const index: number = legendItem.datasetIndex;
+42 -19
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerate" />
</template>
<template #result>
<recent-panel @reach-top="onReachTop" />
<recent-panel ref="recentPanel" :loading="loadingMore" @reach-top="onReachTop" />
</template>
</layout>
</template>
@@ -19,12 +19,15 @@ import { ElMessage } from 'element-plus';
import { ERROR_CODE_USED_UP } from '@/constants';
import RecentPanel from '@/components/flux/RecentPanel.vue';
import { IFluxTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/flux';
interface IData {
task: IFluxTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -38,13 +41,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.flux?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.flux?.status?.getTasks === Status.Request || this.fetchingTasks;
},
credential() {
return this.$store.state.flux?.credential;
},
@@ -91,9 +99,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -108,27 +124,30 @@ export default defineComponent({
await this.onGetTasks();
},
async onScrollDown() {
setTimeout(() => {
// scroll to bottom for `.tasks`
const el = document.querySelector('.tasks');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 1000);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('flux/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('flux/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerate() {
const request = {
@@ -162,6 +181,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+42 -18
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerate" />
</template>
<template #result>
<recent-panel @reach-top="onReachTop" />
<recent-panel ref="recentPanel" :loading="loadingMore" @reach-top="onReachTop" />
</template>
</layout>
</template>
@@ -19,12 +19,15 @@ import { ElMessage } from 'element-plus';
import { ERROR_CODE_USED_UP } from '@/constants';
import RecentPanel from '@/components/hailuo/RecentPanel.vue';
import { IHailuoTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/hailuo';
interface IData {
task: IHailuoTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -40,13 +43,18 @@ export default defineComponent({
task: undefined,
job: 0,
// @ts-ignore
timer: undefined
timer: undefined,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.hailuo?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.hailuo?.status?.getTasks === Status.Request || this.fetchingTasks;
},
credential() {
return this.$store.state.hailuo.credential;
},
@@ -93,9 +101,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -110,26 +126,30 @@ export default defineComponent({
await this.onGetTasks();
},
async onScrollDown() {
setTimeout(() => {
const el = document.querySelector('.tasks');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('hailuo/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('hailuo/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerate() {
const request = {
@@ -163,6 +183,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+42 -19
View File
@@ -14,7 +14,7 @@
@refresh="onGetApplication"
@select="$store.dispatch('headshots/setApplication', $event)"
/>
<recent-panel class="panel recent" @reach-top="onReachTop" />
<recent-panel ref="recentPanel" class="panel recent" :loading="loadingMore" @reach-top="onReachTop" />
<!-- <operation-panel class="panel operation" @generate="onGenerate" /> -->
</template>
</layout>
@@ -31,12 +31,15 @@ import { ERROR_CODE_DUPLICATION, ERROR_CODE_USED_UP } from '@/constants';
import ApplicationStatus from '@/components/application/Status.vue';
import RecentPanel from '@/components/headshots/RecentPanel.vue';
import { IHeadshotsTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/headshots';
interface IData {
task: IHeadshotsTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -51,13 +54,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.headshots?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.headshots?.status?.getTasks === Status.Request || this.fetchingTasks;
},
service() {
return this.$store.state.headshots.service;
},
@@ -116,9 +124,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -149,27 +165,30 @@ export default defineComponent({
});
},
async onScrollDown() {
setTimeout(() => {
// scroll to bottom for `.recent`
const el = document.querySelector('.recent');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('headshots/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('headshots/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGeneratePicture() {
const request = {
@@ -206,6 +225,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+41 -18
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerate" />
</template>
<template #result>
<recent-panel @reach-top="onReachTop" />
<recent-panel ref="recentPanel" :loading="loadingMore" @reach-top="onReachTop" />
</template>
</layout>
</template>
@@ -19,12 +19,15 @@ import { ElMessage } from 'element-plus';
import { ERROR_CODE_USED_UP } from '@/constants';
import RecentPanel from '@/components/kling/RecentPanel.vue';
import { IKlingTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/kling';
interface IData {
task: IKlingTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -38,13 +41,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.kling?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.kling?.status?.getTasks === Status.Request || this.fetchingTasks;
},
credential() {
return this.$store.state.kling.credential;
},
@@ -88,9 +96,16 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -105,26 +120,30 @@ export default defineComponent({
await this.onGetTasks();
},
async onScrollDown() {
setTimeout(() => {
const el = document.querySelector('.tasks');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('kling/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('kling/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerate() {
const request = {
@@ -158,6 +177,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+42 -18
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerate" />
</template>
<template #result>
<recent-panel @reach-top="onReachTop" @extend="$emit('extend')" />
<recent-panel ref="recentPanel" :loading="loadingMore" @reach-top="onReachTop" @extend="$emit('extend')" />
</template>
</layout>
</template>
@@ -19,12 +19,15 @@ import { ElMessage } from 'element-plus';
import { ERROR_CODE_USED_UP } from '@/constants';
import RecentPanel from '@/components/luma/RecentPanel.vue';
import { ILumaTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/luma';
interface IData {
task: ILumaTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -39,13 +42,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.luma?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.luma?.status?.getTasks === Status.Request || this.fetchingTasks;
},
credential() {
return this.$store.state.luma.credential;
},
@@ -92,9 +100,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -110,26 +126,30 @@ export default defineComponent({
},
async onScrollDown() {
console.debug('scrolling down');
setTimeout(() => {
const el = document.querySelector('.tasks');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('luma/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('luma/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerate() {
const request = {
@@ -163,6 +183,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+40 -16
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerate" />
</template>
<template #results>
<task-list @custom="onCustom" @reach-top="onReachTop" />
<task-list ref="taskList" :loading="loadingMore" @custom="onCustom" @reach-top="onReachTop" />
</template>
</layout>
</template>
@@ -32,10 +32,13 @@ import {
MIDJOURNEY_DEFAULT_MODE,
MIDJOURNEY_DEFAULT_QUALITY
} from '@/constants';
import { loadPreviousPage } from '@/utils/pagination';
interface IData {
operating: boolean;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
const CALLBACK_URL = 'https://webhook.acedata.cloud/midjourney';
@@ -51,7 +54,9 @@ export default defineComponent({
data(): IData {
return {
operating: false,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
@@ -67,6 +72,9 @@ export default defineComponent({
loading() {
return this.$store.state.midjourney.status.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.midjourney.status.getTasks === Status.Request || this.fetchingTasks;
},
application() {
return this.$store.state.midjourney.application;
},
@@ -176,8 +184,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.loading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -335,30 +352,37 @@ export default defineComponent({
},
async onScrollDown() {
await this.$nextTick();
setTimeout(() => {
const el = document.querySelector('.tasks');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.loading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('midjourney/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('midjourney/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
// await this.$store.dispatch('midjourney/getTasks', {
// limit: 30,
// offset: 0
// });
},
getTasksScrollElement(): HTMLElement | undefined {
const list = this.$refs.taskList as any;
return list?.getScrollElement?.();
}
}
});
+42 -19
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerate" />
</template>
<template #result>
<recent-panel class="panel recent" @reach-top="onReachTop" />
<recent-panel ref="recentPanel" class="panel recent" :loading="loadingMore" @reach-top="onReachTop" />
</template>
</layout>
</template>
@@ -19,12 +19,15 @@ import { ElMessage } from 'element-plus';
import { ERROR_CODE_DUPLICATION, ERROR_CODE_USED_UP } from '@/constants';
import RecentPanel from '@/components/pika/RecentPanel.vue';
import { IPikaTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/pika';
interface IData {
task: IPikaTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -38,13 +41,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.pika?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.pika?.status?.getTasks === Status.Request || this.fetchingTasks;
},
service() {
return this.$store.state.pika.service;
},
@@ -103,9 +111,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -136,27 +152,30 @@ export default defineComponent({
});
},
async onScrollDown() {
setTimeout(() => {
// scroll to bottom for `.recent`
const el = document.querySelector('.recent');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('pika/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('pika/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerate() {
const request = {
@@ -193,6 +212,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+42 -18
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerate" />
</template>
<template #result>
<recent-panel @reach-top="onReachTop" />
<recent-panel ref="recentPanel" :loading="loadingMore" @reach-top="onReachTop" />
</template>
</layout>
</template>
@@ -19,12 +19,15 @@ import { ElMessage } from 'element-plus';
import { ERROR_CODE_USED_UP } from '@/constants';
import RecentPanel from '@/components/pixverse/RecentPanel.vue';
import { IPixverseTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/pixverse';
interface IData {
task: IPixverseTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -38,13 +41,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.pixverse?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.pixverse?.status?.getTasks === Status.Request || this.fetchingTasks;
},
credential() {
return this.$store.state.pixverse.credential;
},
@@ -88,9 +96,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -105,26 +121,30 @@ export default defineComponent({
await this.onGetTasks();
},
async onScrollDown() {
setTimeout(() => {
const el = document.querySelector('.tasks');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('pixverse/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('pixverse/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerate() {
const request = {
@@ -158,6 +178,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+42 -19
View File
@@ -14,7 +14,7 @@
@refresh="onGetApplication"
@select="$store.dispatch('qrart/setApplication', $event)"
/>
<recent-panel class="panel recent" @reach-top="onReachTop" />
<recent-panel ref="recentPanel" class="panel recent" :loading="loadingMore" @reach-top="onReachTop" />
</template>
</layout>
</template>
@@ -30,12 +30,15 @@ import { ERROR_CODE_DUPLICATION, ERROR_CODE_USED_UP } from '@/constants';
import ApplicationStatus from '@/components/application/Status.vue';
import RecentPanel from '@/components/qrart/RecentPanel.vue';
import { IQrartTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/qrart';
interface IData {
task: IQrartTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -50,13 +53,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.qrart?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.qrart?.status?.getTasks === Status.Request || this.fetchingTasks;
},
service() {
return this.$store.state.qrart.service;
},
@@ -115,9 +123,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -148,27 +164,30 @@ export default defineComponent({
});
},
async onScrollDown() {
setTimeout(() => {
// scroll to bottom for `.recent`
const el = document.querySelector('.recent');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('qrart/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('qrart/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerate() {
const request = {
@@ -222,6 +241,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+42 -18
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerate" />
</template>
<template #result>
<recent-panel @reach-top="onReachTop" />
<recent-panel ref="recentPanel" :loading="loadingMore" @reach-top="onReachTop" />
</template>
</layout>
</template>
@@ -19,12 +19,15 @@ import { ElMessage } from 'element-plus';
import { ERROR_CODE_USED_UP } from '@/constants';
import RecentPanel from '@/components/sora/RecentPanel.vue';
import { ISoraTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/sora';
interface IData {
task: ISoraTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -38,13 +41,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.sora?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.sora?.status?.getTasks === Status.Request || this.fetchingTasks;
},
credential() {
return this.$store.state.sora.credential;
},
@@ -88,9 +96,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -105,26 +121,30 @@ export default defineComponent({
await this.onGetTasks();
},
async onScrollDown() {
setTimeout(() => {
const el = document.querySelector('.tasks');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('sora/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('sora/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerate() {
const request = {
@@ -158,6 +178,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+42 -19
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerateAudio" />
</template>
<template #result>
<recent-panel class="panel recent" @reach-top="onReachTop" />
<recent-panel ref="recentPanel" class="panel recent" :loading="loadingMore" @reach-top="onReachTop" />
</template>
<template #preview>
<preview-panel />
@@ -23,12 +23,15 @@ import { ERROR_CODE_DUPLICATION } from '@/constants';
import ConfigPanel from '@/components/suno/ConfigPanel.vue';
import RecentPanel from '@/components/suno/RecentPanel.vue';
import PreviewPanel from '@/components/suno/PreviewPanel.vue';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/suno';
interface IData {
task: ISunoTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -43,13 +46,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.suno?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.suno?.status?.getTasks === Status.Request || this.fetchingTasks;
},
service() {
return this.$store.state.suno.service;
},
@@ -108,9 +116,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -141,27 +157,30 @@ export default defineComponent({
});
},
async onScrollDown() {
setTimeout(() => {
// scroll to bottom for `.recent`
const el = document.querySelector('.recent');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 1000);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('suno/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('suno/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerateAudio() {
const request = {
@@ -190,6 +209,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});
+42 -18
View File
@@ -4,7 +4,7 @@
<config-panel @generate="onGenerate" />
</template>
<template #result>
<recent-panel @reach-top="onReachTop" />
<recent-panel ref="recentPanel" :loading="loadingMore" @reach-top="onReachTop" />
</template>
</layout>
</template>
@@ -19,12 +19,15 @@ import { ElMessage } from 'element-plus';
import { ERROR_CODE_USED_UP } from '@/constants';
import RecentPanel from '@/components/veo/RecentPanel.vue';
import { IVeoTask } from '@/models';
import { loadPreviousPage } from '@/utils/pagination';
const CALLBACK_URL = 'https://webhook.acedata.cloud/veo';
interface IData {
task: IVeoTask | undefined;
job: number;
loadingMore: boolean;
fetchingTasks: boolean;
}
export default defineComponent({
@@ -38,13 +41,18 @@ export default defineComponent({
data(): IData {
return {
task: undefined,
job: 0
job: 0,
loadingMore: false,
fetchingTasks: false
};
},
computed: {
loading() {
applicationsLoading() {
return this.$store.state.veo?.status?.getApplications === Status.Request;
},
tasksLoading() {
return this.$store.state.veo?.status?.getTasks === Status.Request || this.fetchingTasks;
},
credential() {
return this.$store.state.veo.credential;
},
@@ -88,9 +96,17 @@ export default defineComponent({
},
methods: {
async onReachTop() {
console.debug('reached top');
await this.onGetTasks({
createdAtMax: this.tasks?.items?.[0]?.created_at
await loadPreviousPage({
tasks: this.tasks,
getTasks: () => this.tasks,
loading: this.loadingMore,
setLoading: (v) => (this.loadingMore = v),
isBlocked: () => this.tasksLoading || this.applicationsLoading,
fetch: (createdAtMax) =>
this.onGetTasks({
createdAtMax
}),
getScrollElement: () => this.getTasksScrollElement()
});
},
async onGetService() {
@@ -105,26 +121,30 @@ export default defineComponent({
await this.onGetTasks();
},
async onScrollDown() {
setTimeout(() => {
const el = document.querySelector('.tasks');
if (el) {
el.scrollTop = el.scrollHeight;
}
}, 500);
await this.$nextTick();
const el = this.getTasksScrollElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
},
async onGetTasks(payload?: { limit?: number; createdAtMin?: number; createdAtMax?: number }) {
if (this.loading) {
if (this.applicationsLoading || this.fetchingTasks) {
console.debug('loading');
return;
}
console.debug('start onGetTasks', payload);
const { limit = 5, createdAtMin, createdAtMax } = payload || {};
console.debug('limit', limit, 'createdAtMin', createdAtMin, 'createdAtMax', createdAtMax);
await this.$store.dispatch('veo/getTasks', {
limit,
createdAtMin,
createdAtMax
});
this.fetchingTasks = true;
try {
await this.$store.dispatch('veo/getTasks', {
limit,
createdAtMin,
createdAtMax
});
} finally {
this.fetchingTasks = false;
}
},
async onGenerate() {
const request = {
@@ -158,6 +178,10 @@ export default defineComponent({
await this.onScrollDown();
}, 1000);
});
},
getTasksScrollElement(): HTMLElement | undefined {
const panel = this.$refs.recentPanel as any;
return panel?.getScrollElement?.();
}
}
});