mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
34 lines
994 B
TypeScript
34 lines
994 B
TypeScript
|
|
import { toast } from 'vue-sonner';
|
|
|
|
async function loadData() {
|
|
const { loggedIn } = useUserSession();
|
|
if (!loggedIn.value) return;
|
|
const router = useRouter();
|
|
const projectStore = useProjectStore();
|
|
const snapshotStore = useSnapshotStore();
|
|
const domainStore = useDomainStore();
|
|
const premiumStore = usePremiumStore();
|
|
try {
|
|
await projectStore.fetchProjects();
|
|
if (projectStore.projects.length == 0) {
|
|
router.push('/create_project?first=true');
|
|
return false;
|
|
}
|
|
await projectStore.fetchActivePermissions();
|
|
await projectStore.fetchPendingInvites();
|
|
await snapshotStore.fetchSnapshots();
|
|
await domainStore.fetchDomains();
|
|
await premiumStore.fetchPremium();
|
|
return true;
|
|
} catch (ex: any) {
|
|
console.error(ex);
|
|
toast('Error', { description: ex.message, position: 'top-right' });
|
|
}
|
|
}
|
|
|
|
export function useAppStart() {
|
|
|
|
return { loadData }
|
|
|
|
} |