Fix the site init issue (#53)

This commit is contained in:
AceDataCloud
2024-06-17 16:39:13 +00:00
parent 5f93958ddf
commit 76c0477cb1
3 changed files with 23 additions and 3 deletions
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix the auth init issue",
"packageName": "@acedatacloud/nexior",
"email": "germey@acedata.cloud",
"dependentChangeType": "patch"
}
+9
View File
@@ -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') {
+7 -3
View File
@@ -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>) => {