diff --git a/change/@acedatacloud-nexior-67d24505-cdc1-4e88-a0bf-63f6cce4ff0e.json b/change/@acedatacloud-nexior-67d24505-cdc1-4e88-a0bf-63f6cce4ff0e.json new file mode 100644 index 00000000..81102f6a --- /dev/null +++ b/change/@acedatacloud-nexior-67d24505-cdc1-4e88-a0bf-63f6cce4ff0e.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix the auth init issue", + "packageName": "@acedatacloud/nexior", + "email": "germey@acedata.cloud", + "dependentChangeType": "patch" +} diff --git a/src/components/common/AuthPanel.vue b/src/components/common/AuthPanel.vue index 79854af8..30963378 100644 --- a/src/components/common/AuthPanel.vue +++ b/src/components/common/AuthPanel.vue @@ -28,6 +28,7 @@ import { ElDialog } from 'element-plus'; import { getBaseUrlAuth } from '@/utils'; import { getCookie } from 'typescript-cookie'; import QrCode from 'vue-qrcode'; +import { ROUTE_SITE_INDEX } from '@/router'; export default defineComponent({ name: 'AuthPanel', @@ -76,6 +77,14 @@ export default defineComponent({ }; await this.$store.dispatch('setToken', token); await this.$store.dispatch('getUser'); + // if the site is not initialized, initialize it + if (this.$store.state.site?.origin) { + await this.$store.dispatch('initializeSite'); + // after initialization, navigate to the site config page + await this.$router.push({ + name: ROUTE_SITE_INDEX + }); + } window.location.reload(); } if (event.data.name === 'show_qr') { diff --git a/src/store/common/actions.ts b/src/store/common/actions.ts index 6a60bde2..1ad7dd63 100644 --- a/src/store/common/actions.ts +++ b/src/store/common/actions.ts @@ -62,9 +62,13 @@ export const getToken = async ({ commit }: ActionContext export const initializeSite = async ({ state, commit }: ActionContext) => { log(initializeSite, 'start to initialize site'); const origin = getSiteOrigin(state?.site); - const { data } = await siteOperator.initialize({ origin }); - commit('setSite', data); - log(initializeSite, 'initialize site success', data); + try { + const { data } = await siteOperator.initialize({ origin }); + commit('setSite', data); + log(initializeSite, 'initialize site success', data); + } catch (error) { + log(initializeSite, 'initialize site failed', error); + } }; export const getSite = async ({ state, commit }: ActionContext) => {