Skip to content

Commit

Permalink
Refactor base-layout.vue for better code organization and readability
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyunchong committed May 24, 2024
1 parent 7867bc4 commit 3961921
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 55 deletions.
19 changes: 4 additions & 15 deletions src/config/base-layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,22 @@
</el-menu-item>
<el-menu-item v-if="loggedIn" index="/subscribe" class="block">
<router-link :to="{ path: '/subscribe' }">
<el-icon>
<ScaleToOriginal /> </el-icon
>关注
<el-icon> <ScaleToOriginal /> </el-icon>关注
</router-link>
</el-menu-item>
<el-menu-item index="/tag/subscribe/all" class="block">
<router-link :to="{ path: '/tag/subscribe/all' }">
<el-icon>
<CopyDocument /> </el-icon
>标签
<el-icon> <CopyDocument /> </el-icon>标签
</router-link>
</el-menu-item>
<el-menu-item v-if="loggedIn" index="/notification/userComment" class="block">
<router-link :to="{ path: '/notification/userComment' }">
<el-icon>
<Bell /> </el-icon
>消息
<el-icon> <Bell /> </el-icon>消息
</router-link>
</el-menu-item>
<el-menu-item index="cms.igeekfan.cn/" class="block">
<a href="https://cms.igeekfan.cn/" target="_blank">
<el-icon>
<Van /> </el-icon
>CMS
<el-icon> <Van /> </el-icon>CMS
</a>
</el-menu-item>
<div class="flex-grow" />
Expand Down Expand Up @@ -78,7 +70,6 @@
<el-dropdown-item command="/subscribe" v-if="loggedIn">关注 </el-dropdown-item>
<el-dropdown-item command="/tag/subscribe/all">标签</el-dropdown-item>
<el-dropdown-item command="/notification/userComment" v-if="loggedIn">消息 </el-dropdown-item>
<el-dropdown-item command="vvlog-vue2">VUE2 旧版本</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
Expand Down Expand Up @@ -138,8 +129,6 @@ export default {
return '标签'
case '/notification/userComment':
return '消息'
case 'vvlog-vue2':
return 'VUE2 旧版本'
default:
return '首页'
}
Expand Down
63 changes: 23 additions & 40 deletions src/view/layout/base-layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
<div class="headerWrapper">
<el-header class="main-header">
<div class="header-container">
<el-menu :default-active="activeIndex" mode="horizontal" class="header-menu-desktop" :ellipsis="false"
@select="handleSelect">
<el-menu
:default-active="activeIndex"
mode="horizontal"
class="header-menu-desktop"
:ellipsis="false"
@select="handleSelect"
>
<el-menu-item index="/index" class="block">
<router-link :to="{ path: '/index' }">
<i class="el-icon-help"></i>
Expand All @@ -15,44 +20,22 @@
</el-menu-item>
<el-menu-item v-if="loggedIn" index="/subscribe" class="block">
<router-link :to="{ path: '/subscribe' }">
<el-icon>
<ScaleToOriginal />
</el-icon>关注
<el-icon> <ScaleToOriginal /> </el-icon>关注
</router-link>
</el-menu-item>
<el-menu-item index="/tag/subscribe/all" class="block">
<router-link :to="{ path: '/tag/subscribe/all' }">
<el-icon>
<CopyDocument />
</el-icon>标签
<el-icon> <CopyDocument /> </el-icon>标签
</router-link>
</el-menu-item>
<el-menu-item v-if="loggedIn" index="/notification/userComment" class="block">
<router-link :to="{ path: '/notification/userComment' }">
<el-icon>
<Bell />
</el-icon>消息
<el-icon> <Bell /> </el-icon>消息
</router-link>
</el-menu-item>
<el-menu-item index="vvlog-vue2.igeekfan.cn/" class="block">
<a href="https://vvlog-vue2.igeekfan.cn/" target="_blank">
<el-icon>
<Van />
</el-icon>VUE2 旧版本
</a>
</el-menu-item>
<el-menu-item index="cms.igeekfan.cn/" class="block">
<a href="https://cms.igeekfan.cn/" target="_blank">
<el-icon>
<Van />
</el-icon>CMS
</a>
</el-menu-item>
<el-menu-item index="cms-vue2.igeekfan.cn/" class="block">
<a href="https://cms-vue2.igeekfan.cn/" target="_blank">
<el-icon>
<Van />
</el-icon>CMS VUE2
<el-icon> <Van /> </el-icon>CMS
</a>
</el-menu-item>
<div class="flex-grow" />
Expand All @@ -66,8 +49,13 @@
<current-user class="current-user"></current-user>
</el-menu-item>
</el-menu>
<el-menu :default-active="activeIndex" mode="horizontal" :ellipsis="false" @select="handleSelect"
class="header-menu-mobile">
<el-menu
:default-active="activeIndex"
mode="horizontal"
:ellipsis="false"
@select="handleSelect"
class="header-menu-mobile"
>
<el-menu-item index="index">
<el-dropdown size="large" class="header-dropdown" @command="handleCommand">
<span class="el-dropdown-link">
Expand All @@ -79,12 +67,9 @@
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="/index">首页</el-dropdown-item>
<el-dropdown-item command="/subscribe" v-if="loggedIn">关注
</el-dropdown-item>
<el-dropdown-item command="/subscribe" v-if="loggedIn">关注 </el-dropdown-item>
<el-dropdown-item command="/tag/subscribe/all">标签</el-dropdown-item>
<el-dropdown-item command="/notification/userComment" v-if="loggedIn">消息
</el-dropdown-item>
<el-dropdown-item command="vvlog-vue2">VUE2 旧版本</el-dropdown-item>
<el-dropdown-item command="/notification/userComment" v-if="loggedIn">消息 </el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
Expand Down Expand Up @@ -144,8 +129,6 @@ export default {
return '标签'
case '/notification/userComment':
return '消息'
case 'vvlog-vue2':
return 'VUE2 旧版本'
default:
return '首页'
}
Expand Down Expand Up @@ -185,8 +168,8 @@ export default {
window.open('https://vvlog-vue2.igeekfan.cn/')
return
}
this.$router.push(command);
}
this.$router.push(command)
},
},
}
</script>
Expand Down Expand Up @@ -254,7 +237,7 @@ export default {
@media screen and (max-width: 768px) {
.header-menu-desktop {
display: none
display: none;
}
.header-menu-mobile {
Expand Down

0 comments on commit 3961921

Please sign in to comment.