Fix the site init issue (#53)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"type": "patch",
|
||||
"comment": "fix the auth init issue",
|
||||
"packageName": "@acedatacloud/nexior",
|
||||
"email": "germey@acedata.cloud",
|
||||
"dependentChangeType": "patch"
|
||||
}
|
||||
@@ -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') {
|
||||
|
||||
@@ -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>) => {
|
||||
|
||||
Reference in New Issue
Block a user