Skip to content

Commit

Permalink
Fix the site init issue (#53)
Browse files Browse the repository at this point in the history
Co-authored-by: Germey <germey@acedata.cloud>
  • Loading branch information
Germey and Germey authored Jun 17, 2024
1 parent fe8eeee commit 0008ae2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix the auth init issue",
"packageName": "@acedatacloud/nexior",
"email": "germey@acedata.cloud",
"dependentChangeType": "patch"
}
9 changes: 9 additions & 0 deletions src/components/common/AuthPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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') {
Expand Down
10 changes: 7 additions & 3 deletions src/store/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ export const getToken = async ({ commit }: ActionContext<IRootState, IRootState>
export const initializeSite = async ({ state, commit }: ActionContext<IRootState, IRootState>) => {
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<IRootState, IRootState>) => {
Expand Down

0 comments on commit 0008ae2

Please sign in to comment.