交付双端基础、实时联系人和隔离浏览器
This commit is contained in:
1 parent
43687d5e7e
commit
67fef3ff87
59 files changed
+5094
-1
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { createApp } from 'vue'
|
||||
import { createPinia } from 'pinia'
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import App from './App.vue'
|
||||
import AuthView from './views/AuthView.vue'
|
||||
import DeviceView from './views/DeviceView.vue'
|
||||
import ContactsView from './views/ContactsView.vue'
|
||||
import Workspace from './views/Workspace.vue'
|
||||
import { useSession } from './session'
|
||||
import './style.css'
|
||||
|
||||
const pinia = createPinia()
|
||||
const router = createRouter({
|
||||
history: createWebHashHistory(),
|
||||
routes: [
|
||||
{ path: '/', redirect: '/devices' },
|
||||
{ path: '/login', component: AuthView },
|
||||
{ path: '/', component: Workspace, children: [
|
||||
{ path: 'devices', component: DeviceView },
|
||||
{ path: 'contacts', component: ContactsView },
|
||||
] },
|
||||
{ path: '/:pathMatch(.*)*', redirect: '/' },
|
||||
],
|
||||
})
|
||||
|
||||
router.beforeEach((to) => {
|
||||
const signedIn = Boolean(useSession(pinia).identity)
|
||||
if (!signedIn && to.path !== '/login') return '/login'
|
||||
if (signedIn && to.path === '/login') return '/devices'
|
||||
})
|
||||
|
||||
createApp(App).use(pinia).use(router).mount('#app')
|
||||
Reference in new issue
Block a user