mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
1 line
4.6 KiB
JavaScript
1 line
4.6 KiB
JavaScript
(()=>(e,t)=>{const s=`<div class=feeds><div class=header><div class=tabs><div class=title>动态</div><div class=tab v-for="tab in tabs":key=tab.type @click=changeTab(tab) :class="{active: currentTab === tab}"><div class=tab-name>{{tab.name}}</div></div></div><div class=grow></div><a class=online target=_blank href=https://www.bilibili.com/video/online.html>在线列表</a><div class=grow></div><div class=page><div class=prev-page @click=scroll(-1)><icon type=extended icon=left-arrow></icon></div><div class=next-page @click=scroll(1)><icon type=extended icon=right-arrow></icon></div></div><a class=more href=//t.bilibili.com/ target=_blank><icon type=home icon=activity></icon>全部动态</a></div><div class="contents edge-gradient"ref=contents @scroll=checkScrollPosition :class="{ 'is-bottom': isBottom }"><div class=card-wrapper v-for="card in feedCards":key=card.id><video-card :data=card orientation=vertical></video-card></div><div class=empty v-if="feedCards.length === 0">没有动态哦(´・_・\`)</div></div></div>`;t.applyStyleFromText(`.simple-home.snap .feeds .contents{scroll-snap-type:x mandatory}.simple-home .feeds{justify-self:start;display:flex;flex-direction:column}.simple-home .feeds .header,.simple-home .feeds .sub-header{grid-area:unset;margin-bottom:16px;padding:0 8px}.simple-home .feeds .header .page,.simple-home .feeds .sub-header .page{margin-right:8px;display:flex;align-items:center}.simple-home .feeds .header .page>*,.simple-home .feeds .sub-header .page>*{display:flex;align-items:center;justify-content:center;padding:4px;background-color:#8882;border-radius:50%;margin-left:8px;cursor:pointer}.simple-home .feeds .header .page>:hover,.simple-home .feeds .sub-header .page>:hover{background-color:#8884}.simple-home .feeds .header .page .prev-page .be-icon,.simple-home .feeds .sub-header .page .prev-page .be-icon{transform:translateX(-1px)}.simple-home .feeds .header .page .next-page .be-icon,.simple-home .feeds .sub-header .page .next-page .be-icon{transform:translateX(1px)}.simple-home .feeds .header .tab:nth-child(2),.simple-home .feeds .sub-header .tab:nth-child(2){margin-left:32px}.simple-home .feeds .header .grow,.simple-home .feeds .sub-header .grow{flex-grow:1}.simple-home .feeds .header .online,.simple-home .feeds .sub-header .online{padding:8px 16px;height:32px;border-radius:16px;background-color:#8882;color:inherit;font-size:12px;display:flex;align-items:center;box-sizing:border-box}.simple-home .feeds .contents{display:flex;overflow:auto;--card-width:200px;--card-height:250px;--card-count:4;width:calc((var(--card-width) + 16px) * var(--card-count));scrollbar-width:none!important;min-height:calc(var(--card-height) + 16px)}@media screen and (max-width:900px){.simple-home .feeds .contents{--card-count:3}}@media screen and (min-width:1100px){.simple-home .feeds .contents{--card-count:3}}@media screen and (min-width:1300px){.simple-home .feeds .contents{--card-count:4}}@media screen and (min-width:1550px){.simple-home .feeds .contents{--card-count:5}}@media screen and (min-width:1850px){.simple-home .feeds .contents{--card-count:6}}.simple-home .feeds .contents::-webkit-scrollbar{width:0!important;height:0!important}.simple-home .feeds .contents .card-wrapper{padding:0 8px;scroll-snap-align:start;flex-shrink:0}.simple-home .feeds .contents .empty{display:flex;align-items:center;justify-content:center;width:100%;font-size:16px}`,"simple-home-feeds-style");const i=[{name:"视频",type:"video",url:"https://t.bilibili.com/?tab=8"},{name:"番剧",type:"bangumi",url:"https://t.bilibili.com/?tab=512"}];return{export:Object.assign({template:s},{components:{VideoCard:()=>t.importAsync("video-card.vue"),Icon:()=>t.importAsync("icon.vue")},data(){return{online:"--",isBottom:false,tabs:i,currentTab:i[0],feedCards:[]}},watch:{currentTab(e){this.updateFeedCards(e)}},methods:{async updateFeedCards(e){const{getVideoFeeds:s}=await t.importAsync("feeds-apis");this.feedCards=await s(e.type)},changeTab(e){if(this.currentTab===e){open(e.url,"_blank")}else{this.currentTab=e}},scroll(e){const t=this.$refs.contents;const s=getComputedStyle(t);const i=parseFloat(s.getPropertyValue("--card-count"));const a=parseFloat(s.getPropertyValue("--card-width"));const o=16;const d=i*(a+o);t.scrollBy(e*d,0)},checkScrollPosition:_.debounce((function e(t){const s=t.target;this.isBottom=s.scrollWidth-s.scrollLeft===s.clientWidth}),200)},async mounted(){this.updateFeedCards(this.currentTab);let e;addSettingsListener("simpleHomeWheelScroll",(async s=>{if(s){const s=this.$refs.contents;const{enableHorizontalScroll:i}=await t.importAsync("horizontal-scroll");e=i(s)}else{e&&e()}}),true)}})}})(); |