Skip to content

Commit

Permalink
feat: admin common login screen
Browse files Browse the repository at this point in the history
  • Loading branch information
qin-guan committed Sep 24, 2023
1 parent 3ce1e2d commit 48a1da1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
14 changes: 0 additions & 14 deletions components/admin/home/page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,8 @@ const props = defineProps<{
f7route: Router.Route
}>()
const auth = useCurrentUser()
const authLoaded = useIsCurrentUserLoaded()
const { data: user } = useUser()
const state = reactive({
showLoginScreen: false,
})
watch([authLoaded, auth], (values) => {
setTimeout(() => { // This shows too fast, so it's better to lag for 1 second to prevent jarring layout changes
state.showLoginScreen = values[0] && !values[1]
}, 1000)
})
const showForbidden = computed(() => {
if (!user.value) // Should load placeholder data
return false
Expand All @@ -30,8 +18,6 @@ const showForbidden = computed(() => {

<template>
<f7Page>
<CommonLoginScreen v-model:opened="state.showLoginScreen" />

<f7Navbar>
<f7NavLeft v-if="!showForbidden">
<f7Link panel-open="left" icon-ios="f7:menu" icon-md="material:menu" />
Expand Down
25 changes: 23 additions & 2 deletions pages/admin/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Framework7 from 'framework7/lite-bundle'
import Framework7Vue from 'framework7-vue/bundle'
import { f7App, f7View } from 'framework7-vue'
import { AdminHomePage, AdminMembersPage, AdminSettingsPage } from '#components'
import { useIsCurrentUserLoaded } from 'vuefire'
import { AdminHomePage, AdminMembersPage } from '#components'
Framework7.use(Framework7Vue)
Expand All @@ -20,6 +21,11 @@ const appRoutes = [
path: '/admin',
component: AdminHomePage,
},
{
name: 'members',
path: '/admin/members',
component: AdminMembersPage,
},
]
useSeoMeta({
Expand Down Expand Up @@ -49,6 +55,19 @@ useHeadSafe({
})
const route = useRoute()
const auth = useCurrentUser()
const authLoaded = useIsCurrentUserLoaded()
const state = reactive({
showLoginScreen: false,
})
watch([authLoaded, auth], (values) => {
setTimeout(() => { // This shows too fast, so it's better to lag for 1 second to prevent jarring layout changes
state.showLoginScreen = values[0] && !values[1]
}, 1000)
})
</script>

<template>
Expand All @@ -61,6 +80,8 @@ const route = useRoute()
:master-detail-breakpoint="768"
ios-swipe-back
preload-previous-page
/>
>
<CommonLoginScreen v-model:opened="state.showLoginScreen" />
</f7View>
</f7App>
</template>

0 comments on commit 48a1da1

Please # to comment.