Optimize the auth flow (#68)
Co-authored-by: AceDataCloud <office@acedata.cloud>
This commit is contained in:
1 parent
033cbc082c
commit
85aef535f6
23 files changed
+215
-245
No files matched your search
@@ -97,7 +97,6 @@ import {
|
||||
ROUTE_PROFILE_INDEX,
|
||||
ROUTE_DISTRIBUTION_INDEX,
|
||||
ROUTE_INDEX,
|
||||
ROUTE_MIDJOURNEY_HISTORY,
|
||||
ROUTE_MIDJOURNEY_INDEX,
|
||||
ROUTE_QRART_INDEX,
|
||||
ROUTE_QRART_HISTORY,
|
||||
@@ -150,7 +149,7 @@ export default defineComponent({
|
||||
},
|
||||
displayName: this.$t('common.nav.midjourney'),
|
||||
icon: 'fa-solid fa-palette',
|
||||
routes: [ROUTE_MIDJOURNEY_INDEX, ROUTE_MIDJOURNEY_HISTORY]
|
||||
routes: [ROUTE_MIDJOURNEY_INDEX]
|
||||
});
|
||||
}
|
||||
|
||||
@@ -201,16 +200,6 @@ export default defineComponent({
|
||||
!this.$store?.state?.site?.distribution?.force_inviter_id ||
|
||||
this.$store.getters.user?.id === this.$store?.state?.site?.distribution?.force_inviter_id
|
||||
);
|
||||
},
|
||||
collapsed: {
|
||||
get() {
|
||||
return this.$store.state.setting?.navigationCollapsed;
|
||||
},
|
||||
set(val: boolean) {
|
||||
this.$store.commit('setSetting', {
|
||||
navigationCollapsed: val
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -229,18 +218,8 @@ export default defineComponent({
|
||||
name: ROUTE_DISTRIBUTION_INDEX
|
||||
});
|
||||
},
|
||||
async onOpenMenu() {
|
||||
this.collapsed = false;
|
||||
},
|
||||
async onCollapseMenu() {
|
||||
this.collapsed = true;
|
||||
},
|
||||
async onLogout() {
|
||||
await this.$store.dispatch('resetAll');
|
||||
await this.$store.dispatch('chat/resetAll');
|
||||
await this.$store.dispatch('midjourney/resetAll');
|
||||
await this.$store.dispatch('chatdoc/resetAll');
|
||||
await this.$store.dispatch('qrart/resetAll');
|
||||
await this.$store.dispatch('logout');
|
||||
},
|
||||
onConsole() {
|
||||
this.$router.push({ name: ROUTE_CONSOLE_ROOT });
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent } from 'vue';
|
||||
import TaskItem from './TaskItem.vue';
|
||||
import { ROUTE_MIDJOURNEY_HISTORY } from '@/router';
|
||||
import { ElSkeleton, ElSkeletonItem } from 'element-plus';
|
||||
import { Status } from '@/models';
|
||||
|
||||
@@ -49,9 +48,6 @@ export default defineComponent({
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
loading() {
|
||||
return this.$store.state.midjourney.status.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||
return this.$store.state.midjourney.tasks?.items?.reverse();
|
||||
@@ -59,42 +55,6 @@ export default defineComponent({
|
||||
application() {
|
||||
return this.$store.state.midjourney.application;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
tasks: {
|
||||
handler(val, oldVal) {
|
||||
if (val && oldVal && JSON.stringify(val) !== JSON.stringify(oldVal)) {
|
||||
this.$emit('refresh', val);
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('midjourney/setTasks', undefined);
|
||||
this.getTasks();
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getTasks();
|
||||
}, 5000);
|
||||
},
|
||||
unmounted() {
|
||||
clearInterval(this.job);
|
||||
},
|
||||
methods: {
|
||||
async onLoadHistory() {
|
||||
this.$router.push({ name: ROUTE_MIDJOURNEY_HISTORY });
|
||||
},
|
||||
async getTasks() {
|
||||
// ensure that the previous request has been completed
|
||||
if (this.loading) {
|
||||
return;
|
||||
}
|
||||
await this.$store.dispatch('midjourney/getTasks', {
|
||||
limit: 30,
|
||||
offset: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -47,9 +47,6 @@ export default defineComponent({
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
loading() {
|
||||
return this.$store.state.qrart?.status?.getApplication === Status.Request;
|
||||
},
|
||||
tasks() {
|
||||
// reverse the order of the tasks.items
|
||||
return {
|
||||
@@ -57,39 +54,6 @@ export default defineComponent({
|
||||
items: this.$store.state.qrart?.tasks?.items?.slice().reverse()
|
||||
};
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
await this.$store.dispatch('qrart/setTasks', undefined);
|
||||
await this.getTasks();
|
||||
await this.onScrollDown();
|
||||
// @ts-ignore
|
||||
this.job = setInterval(() => {
|
||||
this.getTasks();
|
||||
}, 5000);
|
||||
},
|
||||
async unmounted() {
|
||||
clearInterval(this.job);
|
||||
},
|
||||
methods: {
|
||||
async onScrollDown() {
|
||||
setTimeout(() => {
|
||||
// scroll to bottom for `.recent`
|
||||
const el = document.querySelector('.recent');
|
||||
if (el) {
|
||||
el.scrollTop = el.scrollHeight;
|
||||
}
|
||||
}, 500);
|
||||
},
|
||||
async getTasks() {
|
||||
// ensure that the previous request has been completed
|
||||
if (this.loading) {
|
||||
return;
|
||||
}
|
||||
await this.$store.dispatch('qrart/getTasks', {
|
||||
limit: 50,
|
||||
offset: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user