Fix init issue for site (#50)

This commit is contained in:
AceDataCloud committed 2024-06-17 03:28:39 +00:00
1 parent beb85b8ebd
commit 223e14222d
6 files changed
+57 -31

No files matched your search

+7 -1
View File
@@ -130,5 +130,11 @@ export const initializeFavicon = async () => {
* Need to initialize site before render contents
*/
export const initializeSite = async () => {
await store.dispatch('initializeSite');
await store.dispatch('getSite');
// after getSite, the site should have been set
const site = store.state.site;
// if site is not set, try to initialize site
if (!site) {
await store.dispatch('initializeSite');
}
};
+17
View File
@@ -0,0 +1,17 @@
import { ISite } from '@/models';
import { v4 as uuid } from 'uuid';
export const getSiteOrigin = (site?: ISite) => {
if (site?.origin) {
return site?.origin;
}
const host = window.location.host;
// if localhost, try to generate uuid
if (host.includes('localhost')) {
// generate uuid
const randomId = uuid();
return `http://localhost-${randomId}`;
} else {
return window.location.origin;
}
};