App.vue
1.35 KB
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
<template>
<div id="app">
<keep-alive>
<div>
<dashboard v-if="hasToken"></dashboard>
<login v-else></login>
<!-- 全局loading提示 -->
<loading v-if="showLoading"></loading>
</div>
</keep-alive>
</div>
</template>
<script>
import Dashboard from '@/views/Dashboard';
import Login from '@/views/Login';
import Loading from 'components/Loading/Loading';
import { onCreated, onMounted, computed, reactive, toRefs } from 'vue';
import { useStore } from 'vuex';
export default {
name: "App",
components: {
Dashboard,
Login,
Loading
},
setup () {
const store = useStore();
let hasToken = computed(() => {
return !!store.getters.token;
})
let showLoading = computed(() => {
return store.getters.showLoading;
})
return {
hasToken,
showLoading
}
}
}
</script>
<style lang="less">
.layout-container {
height: 100vh;
#desktop-right-sider .trigger {
font-size: 18px;
line-height: 64px;
padding: 0 24px;
cursor: pointer;
transition: color 0.3s;
}
#desktop-right-sider .trigger:hover {
color: #1890ff;
}
#desktop-right-sider .logo {
height: 32px;
background: rgba(255, 255, 255, 0.2);
margin: 16px;
}
}
</style>