App.vue
1.38 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
<template>
<nav class="navbar navbar-expand-sm bg-primary navbar-dark">
<a class="navbar-brand" href="#">梦幻合合合</a>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">玩家修改</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#/playerquery">玩家查询</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#/mail">邮件</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#/server">服务器</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#/other">其他</a>
</li>
</ul>
</nav>
<component :is="currentView" />
</template>
<script setup>
import { ref, computed } from 'vue'
import NotFound from './components/NotFound.vue'
import Home from './components/PlayerEdit.vue'
import PlayerQuery from './components/PlayerQuery.vue'
import Mail from './components/Mail.vue'
import Server from './components/Server.vue'
import Other from './components/Other.vue'
const routes = {
'/': Home,
'/playerquery': PlayerQuery,
'/mail': Mail,
'/server': Server,
'/other': Other,
}
const currentPath = ref(window.location.hash)
window.addEventListener('hashchange', () => {
currentPath.value = window.location.hash
})
const currentView = computed(() => {
return routes[currentPath.value.slice(1) || '/'] || NotFound
})
</script>