-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.vue
210 lines (185 loc) · 5.3 KB
/
default.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<template>
<div id="app">
<div
id="main"
:style="{
marginLeft: userProfile.uid && (route.path !== '/signUp' && route.path !== '/about') ? isPhone ? '0px' : '64px' : '0px',
marginBottom: userProfile.uid && (route.path !== '/signUp' && route.path !== '/about') ? isPhone ? '64px' : '0px' : '0px'
}"
>
<div v-if="isLoad">
<Loading />
</div>
<div v-else>
<AppBar v-if="userProfile.uid && (route.path !== '/signUp' && route.path !== '/about')" />
<div v-if="!userProfile.uid && (route.path === '/' || route.path === '/taskboard' || route.path === '/setting')" id="main-contents-login">
<LogInPage />
</div>
<div v-else id="main-contents">
<NavigationBar v-if="!isPhone && (route.path !== '/signUp' && route.path !== '/about')" />
<BottomNavigationBar v-if="isPhone && (route.path !== '/signUp' && route.path !== '/about')" />
<Nuxt />
<TaskModal />
<SnackBar />
</div>
</div>
</div>
</div>
</template>
<script lang="ts">
import {
defineComponent,
inject,
ref,
onMounted,
provide,
useRoute,
onBeforeMount,
watch,
} from '@nuxtjs/composition-api'
// components
import LogInPage from '../components/layouts/LogInPage.vue'
import Loading from '~/components/layouts/Loading.vue'
import NavigationBar from '~/components/utils/NavigationBar.vue'
import BottomNavigationBar from '~/components/utils/BottomNavigationBar.vue'
import TaskModal from '~/components/task/TaskModal.vue'
import AppBar from '~/components/utils/AppBar.vue'
import SnackBar from '~/components/utils/SnackBar.vue'
// composable
import getIsPhone from '~/composable/utils/isPhone'
// composition
import usePageTransition, { pageTransitionType, pageTransitionKey } from '~/composition/pageTransition'
import useUserProfile, { userProfileKey, userProfileType } from '~/composition/userProfile'
import useUserTaskData, { userTaskDataKey, userTaskDataType } from '~/composition/userTaskData'
import useUserPlanetData, { userPlanetDataKey, userPlanetDataType } from '~/composition/userPlanetData'
import useSnackBarNoticeData, { snackBarNoticeDataKey } from '~/composition/snackBarNoticeData'
export default defineComponent({
components: { NavigationBar, BottomNavigationBar, TaskModal, AppBar, LogInPage, Loading, SnackBar },
setup () {
provide(pageTransitionKey, usePageTransition())
provide(userProfileKey, useUserProfile())
provide(userTaskDataKey, useUserTaskData())
provide(userPlanetDataKey, useUserPlanetData())
provide(snackBarNoticeDataKey, useSnackBarNoticeData())
// const
const isPhone = ref<boolean>(false)
const route = useRoute()
const {
scssVariables,
} = inject(pageTransitionKey, usePageTransition()) as pageTransitionType
const {
userProfile,
isLoad,
} = inject(userProfileKey, useUserProfile()) as userProfileType
const {
getUserTaskData,
} = inject(userTaskDataKey, useUserTaskData()) as userTaskDataType
const {
getUserPlanetData,
} = inject(userPlanetDataKey, useUserPlanetData()) as userPlanetDataType
// let, computed
// watch
watch(userProfile, async (newUserProfile) => {
await getUserTaskData(newUserProfile.uid!)
await getUserPlanetData(newUserProfile.uid!)
})
// methods
const resizeEvent = () => {
isPhone.value = getIsPhone().isPhone
}
// lifeCycle
onBeforeMount(async () => {
await getUserTaskData(userProfile.uid!)
await getUserPlanetData(userProfile.uid!)
})
onMounted(() => {
window.addEventListener('resize', resizeEvent)
resizeEvent()
document.documentElement.style.setProperty('--transition-left', scssVariables.value.left)
document.documentElement.style.setProperty('--transition-top', scssVariables.value.top)
})
// other
return {
isPhone,
isLoad,
route,
scssVariables,
userProfile,
}
},
})
</script>
<style lang="scss">
:root {
--transition-left: 0%;
--transition-top: 0%;
--is-phone: 'false';
}
html {
width: 100%;
overscroll-behavior-y: none;
background-color: $background;
-ms-overflow-style: none;
scrollbar-width: none;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
&::-webkit-scrollbar {
display: none;
}
}
body {
font-family: 'M PLUS 1', sans-serif;
user-select: none;
scrollbar-width: none;
margin: 0px;
}
#main {
height: 100%;
}
#main-contents {
position: relative;
max-width: calc(100vw - 48px);
margin: 24px;
}
#main-contents-login {
position: relative;
max-width: calc(100vw - 48px);
padding: 24px;
height: calc(100vh - 48px);
}
#header {
display: flex;
}
.page {
&-enter {
left: var(--transition-left);
top: var(--transition-top);
opacity: 0;
&-active {
position: relative;
max-width: 100%;
transition: all .3s cubic-bezier(0.25, 1, 0.5, 1);
}
&-to {
left: 0px;
top: 0px;
opacity: 1;
}
}
&-leave {
left: 0px;
top: 0px;
opacity: 1;
&-active {
position: relative;
max-width: 100%;
transition: all .3s cubic-bezier(0.25, 1, 0.5, 1);
}
&-to {
left: calc(-1 * var(--transition-left));
top: calc(-1 * var(--transition-top));
opacity: 0;
}
}
}
</style>