-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavbar.vue
85 lines (78 loc) · 2.56 KB
/
Navbar.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
<script setup lang="ts">
import type { Action } from 'element-plus'
import { ElMessageBox } from 'element-plus'
const route = useRoute()
const { navigation } = useContent()
const appConfig = useAppConfig()
const config = ref(useLocalStorage('app-config', appConfig))
const navTree = computed(() => {
return navigation.value.filter((item: any) => item._path !== '/')
})
onMounted(() => {
/* 更新版本号 */
if (config.value.version && config.value.version !== appConfig.version) {
ElMessageBox.alert(`当前版本:${config.value.version},发现新版本:${appConfig.version},请点击确定进行更新!`, '网站更新', {
callback: (action: Action) => {
if (action === 'confirm') {
config.value.version = appConfig.version
location.reload()
}
},
})
}
else {
config.value.version = appConfig.version
}
})
</script>
<template>
<el-menu class="navbar" mode="horizontal" :ellipsis="false" :default-active="route.path">
<el-link class="text-2xl font-serif" :underline="false" type="success" @click="navigateTo('/')">
<img src="/image/admin3-logo.png" class="h10 w10">
<span class="mx color-teal-7 font-bold">Admin 3</span>
<el-tag class="ml text-lg" type="success">
{{ config.version }}
</el-tag>
</el-link>
<div class="flex-grow" />
<el-sub-menu v-for="link of navTree" :key="link._path" :index="link._path">
<template #title>
<Icon :name="link.icon" />
<span class="text-lg font-bold">{{ link.title }}</span>
</template>
<el-menu-item
v-for="sublink of link.children" :key="sublink._path" :index="sublink._path"
@click="navigateTo(sublink._path)"
>
{{ sublink.title }}
</el-menu-item>
</el-sub-menu>
<el-tooltip content="项目源码">
<el-link :underline="false" @click="openUrl(appConfig.sourceUrl)">
<Icon
:name="appConfig.sourceUrl?.includes('github') ? 'i-logos-github-icon' : 'i-logos-gitlab'"
class="mx-2 text-xl"
/>
</el-link>
</el-tooltip>
<el-tooltip content="颜色主题">
<AdminDarkToggle class="mx-2 text-xl" />
</el-tooltip>
</el-menu>
</template>
<style scoped>
.navbar {
position: fixed;
z-index: 20;
top: 0;
left: 0;
right: 0;
height: var(--doc-navbar-height);
box-sizing: border-box;
border-bottom: 1px solid var(--doc-border);
background-color: var(--doc-bg-navbar);
transition: background-color var(--t-color), border-color var(--t-color);
padding-left: 20px;
padding-right: 20px;
}
</style>