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