diff --git a/change/@acedatacloud-nexior-e748743e-a214-4d17-b505-4bb106dbfcdc.json b/change/@acedatacloud-nexior-e748743e-a214-4d17-b505-4bb106dbfcdc.json new file mode 100644 index 00000000..ee58dc25 --- /dev/null +++ b/change/@acedatacloud-nexior-e748743e-a214-4d17-b505-4bb106dbfcdc.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "optimize auth flow", + "packageName": "@acedatacloud/nexior", + "email": "office@acedata.cloud", + "dependentChangeType": "patch" +} diff --git a/src/App.vue b/src/App.vue index 6cb7f6b5..445070ac 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,7 +1,6 @@ @@ -9,12 +8,10 @@ import { defineComponent } from 'vue'; import { ElConfigProvider } from 'element-plus'; import zhCn from 'element-plus/dist/locale/zh-cn.mjs'; -import AuthPanel from './components/common/AuthPanel.vue'; export default defineComponent({ components: { - ElConfigProvider, - AuthPanel + ElConfigProvider }, data() { return { diff --git a/src/components/common/Navigator.vue b/src/components/common/Navigator.vue index 05d33436..1a1c020b 100644 --- a/src/components/common/Navigator.vue +++ b/src/components/common/Navigator.vue @@ -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 }); diff --git a/src/components/midjourney/tasks/TaskList.vue b/src/components/midjourney/tasks/TaskList.vue index 39eae70c..9ef54e9c 100644 --- a/src/components/midjourney/tasks/TaskList.vue +++ b/src/components/midjourney/tasks/TaskList.vue @@ -31,7 +31,6 @@ diff --git a/src/components/qrart/RecentPanel.vue b/src/components/qrart/RecentPanel.vue index a9e72656..64b4fbfe 100644 --- a/src/components/qrart/RecentPanel.vue +++ b/src/components/qrart/RecentPanel.vue @@ -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 - }); - } } }); diff --git a/src/layouts/Chat.vue b/src/layouts/Chat.vue index 2a17c002..b25ff03e 100644 --- a/src/layouts/Chat.vue +++ b/src/layouts/Chat.vue @@ -35,22 +35,6 @@ export default defineComponent({ return { drawer: false }; - }, - async mounted() { - await this.onGetService(); - await this.onGetApplication(); - await this.onGetConversations(); - }, - methods: { - async onGetService() { - await this.$store.dispatch('chat/getService'); - }, - async onGetApplication() { - await this.$store.dispatch('chat/getApplication'); - }, - async onGetConversations() { - await this.$store.dispatch('chat/getConversations'); - } } }); diff --git a/src/layouts/Midjourney.vue b/src/layouts/Midjourney.vue index 9fc73f4a..58cd791e 100644 --- a/src/layouts/Midjourney.vue +++ b/src/layouts/Midjourney.vue @@ -29,21 +29,8 @@ export default defineComponent({ }, data() { return { - drawer: false, - drawer2: false + drawer: false }; - }, - async mounted() { - await this.onGetService(); - await this.onGetApplication(); - }, - methods: { - async onGetService() { - await this.$store.dispatch('midjourney/getService'); - }, - async onGetApplication() { - await this.$store.dispatch('midjourney/getApplication'); - } } }); diff --git a/src/layouts/Qrart.vue b/src/layouts/Qrart.vue index 92758d23..20606ef1 100644 --- a/src/layouts/Qrart.vue +++ b/src/layouts/Qrart.vue @@ -31,18 +31,6 @@ export default defineComponent({ return { drawer: false }; - }, - async mounted() { - await this.onGetService(); - await this.onGetApplication(); - }, - methods: { - async onGetService() { - await this.$store.dispatch('qrart/getService'); - }, - async onGetApplication() { - await this.$store.dispatch('qrart/getApplication'); - } } }); diff --git a/src/main.ts b/src/main.ts index ec414b2b..e8694d67 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,6 +13,8 @@ import { initializeCookies, initializeDescription, initializeFavicon, + initializeToken, + initializeUser, initializeKeywords, initializeSite, initializeTitle @@ -20,6 +22,8 @@ import { const main = async () => { await initializeCookies(); + await initializeToken(); + await initializeUser(); await initializeSite(); await initializeTitle(); await initializeDescription(); diff --git a/src/operators/common.ts b/src/operators/common.ts index bcc422dd..92d040b9 100644 --- a/src/operators/common.ts +++ b/src/operators/common.ts @@ -28,7 +28,7 @@ httpClient.interceptors.response.use( }, (error) => { if (error?.response?.status === 401) { - store.dispatch('resetToken'); + store.dispatch('login'); } return Promise.reject(error); } diff --git a/src/pages/auth/Callback.vue b/src/pages/auth/Callback.vue index 688c3c71..483da9c8 100644 --- a/src/pages/auth/Callback.vue +++ b/src/pages/auth/Callback.vue @@ -1,46 +1,20 @@