jscdn.ink/dist/app.vue

71 lines
1.3 KiB
Vue
Raw Normal View History

2022-12-29 19:05:15 +08:00
<template>
2023-03-09 19:42:22 +08:00
<Header :searchInput="$store.searchInput" />
2023-01-16 18:17:30 +08:00
<div class="main-body"><router-view /></div>
2022-12-29 19:05:15 +08:00
<Footer />
</template>
<script>
import Header from './components/header.vue'
import Footer from './components/footer.vue'
2023-04-21 10:53:54 +08:00
import fetch from '@/lib/fetch.js'
2022-12-29 19:05:15 +08:00
export default {
2023-01-16 18:17:30 +08:00
components: { Header, Footer },
mounted() {
var user = localStorage.getItem('user')
2023-04-21 10:53:54 +08:00
var checked = sessionStorage.getItem('session_checked')
2023-03-09 19:42:22 +08:00
2023-01-16 18:17:30 +08:00
if (user) {
2023-04-21 10:53:54 +08:00
if (checked) {
return (this.$store.user = JSON.parse(user))
}
fetch('/login/check')
.then(r => {
localStorage.setItem('token', r.data.token)
sessionStorage.setItem('session_checked', 1)
this.$store.user = JSON.parse(user)
})
.catch(r => {
localStorage.removeItem('token')
localStorage.removeItem('user')
})
2023-01-16 18:17:30 +08:00
}
}
2022-12-29 19:05:15 +08:00
}
</script>
<style lang="scss">
2023-01-16 18:17:30 +08:00
::-webkit-scrollbar {
width: 6px;
background: var(--color-plain-3);
}
::-webkit-scrollbar-thumb {
background: var(--color-dark-a);
&:hover {
background: var(--color-dark-1);
}
}
2022-12-29 19:05:15 +08:00
body {
line-height: 1.5;
font-size: 14px;
color: var(--color-dark-1);
}
a {
color: inherit;
text-decoration: none;
}
.app {
display: flex;
flex-direction: column;
width: 100%;
min-height: 100vh;
}
.main-body {
flex: 1;
}
</style>