@ -3,7 +3,7 @@
<!-- 头部导航菜单 -- >
< div class = "headerMenu" v-if ="show_menu" >
< a -menu v -model :selectedKeys ="current" mode = "horizontal" :items ="items" style = "border-bottom: none;"
@ click = "menuClick" @ select = "menuSelect" / >
@ click = "menuClick" @ select = "menuSelect" / >
< a -input -search v -model :value ="value" placeholder = "search" style = "width: 200px" @search ="onSearch" / >
< / div >
< div class = "author" v-if ="show_author" > < / div >
@ -121,12 +121,12 @@
< / Simplebar >
< / template >
< script lang = "ts" setup >
import { h , reactive , ref , nextTick } from 'vue' ;
import { h , reactive , ref , nextTick } from 'vue' ;
import { MenuProps } from 'ant-design-vue/es/menu' ;
import { HomeOutlined , HighlightOutlined , ProfileOutlined , CameraOutlined , UsergroupDeleteOutlined , DownCircleOutlined } from '@ant-design/icons-vue' ;
import { MusicLined , EmailLined , QQLined , WechatLined , GravatarLined , GitHubLined } from "@/assets"
import Typed from 'typed.js' ;
import { onMounted , watch } from 'vue' ;
import { onMounted , watch } from 'vue' ;
import type { CSSProperties } from 'vue' ;
import { CaretRightOutlined } from '@ant-design/icons-vue' ;
import 'APlayer/dist/APlayer.min.css' ;
@ -143,7 +143,7 @@ const activeKey = ref(['']);
const text = ` A dog is a type of domesticated animal.Known for its loyalty and faithfulness,it can be found as a welcome guest in many households across the world. ` ;
const customStyle =
'background: #F5F5F5;border-radius: 4px;margin-bottom: 12px;border: 0;overflow: hidden' ;
const scrollbar = ref < Element | null > ( null ) ;
const scrollbar = ref < Element | null > ( null ) ;
onMounted ( ( ) => {
/ / 定 义 h o m e 页 的 博 客 标 题 名
new Typed ( '.author' , {
@ -316,8 +316,8 @@ onMounted(() => {
const show_menu = ref ( false ) ;
const show_carousel = ref ( true ) ;
const show_author = ref ( true )
const mainCss = reactive ( {
marginTop : "0px"
const mainCss = reactive ( {
marginTop : "0px"
} )
const items = ref < MenuProps [ ' items ' ] > ( [
@ -376,7 +376,7 @@ const items = ref<MenuProps['items']>([
const handleScrollEnabled = ref ( true ) ;
/ / 定 义 滚 动 条 滚 到 一 半 显 示 导 航 菜 单
const handleScroll = ( ) => {
if ( ! handleScrollEnabled . value ) return ;
if ( ! handleScrollEnabled . value ) return ;
if ( scrollbar . value ) {
const scrollOffset = scrollbar . value . scrollTop ;
const halfViewportHeight = scrollbar . value . clientHeight / 2 ;
@ -385,23 +385,21 @@ const handleScroll = () => {
} ;
const menuClick = ( { item } : { item : any } ) => {
handleScrollEnabled . value = false
if ( scrollbar . value ) {
}
if ( item . url == "/" || item . url == "/home" ) {
handleScrollEnabled . value = true
show_carousel . value = true
} else {
show_menu . value = true
show_carousel . value = false
scrollbar . value ! . scrollTop = 0
mainCss . marginTop = "48px"
/ / l o c a l S t o r a g e . s e t I t e m ( ' s h o w _ m e n u ' , ' t r u e ' ) ;
/ / l o c a l S t o r a g e . s e t I t e m ( ' s h o w _ c a r o u s e l ' , ' f a l s e ' ) ;
/ / l o c a l S t o r a g e . s e t I t e m ( ' s c r o l l P o s i t i o n ' , ' 0 ' ) ;
/ / l o c a l S t o r a g e . s e t I t e m ( ' m a i n C s s _ m a r g i n T o p ' , ' 4 8 p x ' ) ;
}
router . push ( item . url )
/ / h a n d l e S c r o l l E n a b l e d . v a l u e = f a l s e ;
/ / i f ( s c r o l l b a r . v a l u e ) {
/ / s c r o l l b a r . v a l u e . s c r o l l T o p = 0 ;
/ / }
/ / i f ( i t e m . u r l = = = ' / ' | | i t e m . u r l = = = ' / h o m e ' ) {
/ / h a n d l e S c r o l l E n a b l e d . v a l u e = t r u e ;
/ / s h o w _ c a r o u s e l . v a l u e = t r u e ;
/ / } e l s e {
/ / s h o w _ m e n u . v a l u e = t r u e ;
/ / s h o w _ c a r o u s e l . v a l u e = f a l s e ;
/ / m a i n C s s . m a r g i n T o p = ' 4 8 p x ' ;
/ / }
router . push ( item . url ) ;
}
const current = ref < string [ ] > ( [ 'mail' ] ) ;
@ -411,13 +409,14 @@ const downScroll = () => {
if ( scrollbar . value ) {
const scrollTop = scrollbar . value . scrollTop ;
const viewportHeight = scrollbar . value . clientHeight ;
const scrollDistance = viewportHeight - scrollTop - 48 ;
const scrollDistance = viewportHeight - scrollTop - 48 ;
setTimeout ( ( ) => {
scrollbar . value ! . scrollBy ( { top : scrollDistance , behavior : 'smooth' } ) ;
} , 300 ) ;
}
} ;
/ / 定 义 文 章
/ / c o n s t a r t i c l e s = r e a c t i v e ( {
/ / i m g : " " ,
@ -437,6 +436,35 @@ const img = ref("https://os.alipayobjects.com/rmsportal/QBnOOoLaAfKPirc.png")
const gravatarClick = ( ) => {
window . open ( "https://www.baidu.com" )
}
const updateCarouselVisibility = ( routeName ) => {
handleScrollEnabled . value = false ;
if ( scrollbar . value ) {
scrollbar . value . scrollTop = 0 ;
}
if ( routeName === 'home' ) {
handleScrollEnabled . value = true ;
show_carousel . value = true ;
} else {
show_menu . value = true ;
show_carousel . value = false ;
mainCss . marginTop = '48px' ;
}
} ;
/ / 监 控 路 由 变 化
watch (
( ) => route . name ,
( newRouteName ) => {
updateCarouselVisibility ( newRouteName ) ;
} ,
{ immediate : true }
) ;
router . beforeEach ( ( to , from , next ) => {
updateCarouselVisibility ( to . name ) ;
next ( ) ;
} ) ;
< / script >
< style scoped >
. headerMenu {
@ -488,10 +516,11 @@ const gravatarClick = () => {
}
}
. carousel img {
. carousel img {
height : 100 vh ;
width : 100 vw ;
}
. anchorDown {
position : absolute ;
bottom : 100 px ;