@ -1,5 +1,5 @@
< template >
< div class = "home-banner" : style = "{background:'url('+backgrounds[randomIndex]+') fixed center center',backgroundSize:'cover',OBackgroundSize:'cover',MozBackgroundSize:'cover'} ">
< div class = "home-banner" :style ="backgroundStyle ">
< div class = "banner-container" >
< div >
< el -avatar :size ="150" src = "https://file.peteralbus.com/assets/blog/imgs/blog_avatar.png" > < / e l - a v a t a r >
@ -103,6 +103,8 @@ import {ElMessage} from "element-plus";
import FriendLinks from "@/components/FriendLinks.vue"
import PersonalInfo from "@/components/PersonalInfo.vue"
import { fetchBlogList } from "@/services/blogApi" ;
import { fetchBackgroundList } from "@/services/backgroundApi" ;
import { HttpResult } from "@/services/httpConfig" ;
const blogList = ref ( [
{
@ -152,21 +154,38 @@ const copyQuotes=()=>{
ElMessage . success ( "复制成功!点击右键可换一句" )
}
const backgrounds = [
'https://file.peteralbus.com/assets/blog/static/background/background-lumine.jpg' ,
/ / ' h t t p s : / / f i l e . p e t e r a l b u s . c o m / a s s e t s / b l o g / s t a t i c / b a c k g r o u n d / b a c k g r o u n d - k a z u h a . j p g ' ,
/ / ' h t t p s : / / f i l e . p e t e r a l b u s . c o m / a s s e t s / b l o g / s t a t i c / b a c k g r o u n d / b a c k g r o u n d - b l u e e y e s . j p g ' ,
'https://file.peteralbus.com/assets/blog/static/background/background-girl1.jpg' ,
/ / ' h t t p s : / / f i l e . p e t e r a l b u s . c o m / a s s e t s / b l o g / s t a t i c / b a c k g r o u n d / b a c k g r o u n d - m o u n t a i n 1 . j p g ' ,
'https://file.peteralbus.com/assets/blog/static/background/background-nogamenolife.jpg' ,
/ / ' h t t p s : / / f i l e . p e t e r a l b u s . c o m / a s s e t s / b l o g / s t a t i c / b a c k g r o u n d / b a c k g r o u n d - a i 1 . j p g ' ,
/ / ' h t t p s : / / f i l e . p e t e r a l b u s . c o m / a s s e t s / b l o g / s t a t i c / b a c k g r o u n d / b a c k g r o u n d - a i 2 . j p g ' ,
'https://file.peteralbus.com/assets/blog/static/background/background_ygo_1_1440p.jpg' ,
'https://file.peteralbus.com/assets/blog/static/background/background_1440pba.jpg' ,
'https://file.peteralbus.com/assets/blog/static/background/background_1440psekiro.jpg' ,
]
const randomIndex = Math . floor ( Math . random ( ) * backgrounds . length )
const backgrounds = ref ( [
{
url : '' ,
description : '无'
}
] )
const getBackgrounds = ( ) => {
fetchBackgroundList ( ) . then ( ( res : HttpResult ) => {
backgrounds . value = [ ]
res . data . map ( ( item : any ) => {
if ( item . isShow ) {
backgrounds . value . push ( {
url : item . backgroundUrl ,
description : item . description
} )
}
} )
randomIndex . value = Math . floor ( Math . random ( ) * backgrounds . value . length )
} )
}
const backgroundStyle = computed ( ( ) => {
return {
backgroundImage : ` url( ${ backgrounds . value [ randomIndex . value ] . url } ) ` ,
backgroundSize : 'cover' ,
OBackgroundSize : 'cover' ,
MozBackgroundSize : 'cover'
}
} )
const randomIndex = ref ( Math . floor ( Math . random ( ) * backgrounds . value . length ) )
/ / c o n s t r a n d o m I n d e x = 4
const getBlogList = function ( ) {
@ -176,6 +195,7 @@ const getBlogList=function () {
}
onMounted ( ( ) => {
getBackgrounds ( )
getBlogList ( )
getQuotes ( )
} )
@ -191,7 +211,8 @@ const topBlogs=computed(()=>{
} )
const recentBlogs = computed ( function ( ) {
const recentBlogs = blogList . value . reverse ( ) ;
const blogListCopy = blogList . value ;
const recentBlogs = blogListCopy . reverse ( ) ;
return recentBlogs . slice ( 0 , 10 ) ;
} )