mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Improve cards display when not logged in
This commit is contained in:
parent
8c4fedc731
commit
65d58d709a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -2,7 +2,7 @@
|
||||
"index.min.html": "94B83D9EBB9005C1286A7E0759A7683932F8DADA20D07E5E9D8FF867B04D4B95",
|
||||
"watchlater-expire-warnings.min.js": "99282802EF8EB87F199BDE88240E1F196CD85C77516E8D5466EB6F1939B908DD",
|
||||
"comment.min.css": "CEDA2E6733E294A608812309FA6629045ABBC55A55C7677B6B60F019C0B62CAB",
|
||||
"video-card.vue.min.js": "340436CDE3B102F467F671411D4373E0DBF59C5A72867D18BDF45BA6C66156C2",
|
||||
"video-card.vue.min.js": "9EBC38E9F9CD6BDE3CC031BB88F6447EB29E7D8A2E7C32159D7BDC6CFD956D74",
|
||||
"i18n.min.js": "7FCB933FD43C05A152B672D4BD721F3ECEBA6AD29648379947DAAFC403907B38",
|
||||
"comment.min.js": "64F7B6951861C25799C48BB1ABCF2A73F79BCBBFC1E9D3BD45EC1F16F94F6451",
|
||||
"v-checkbox.vue.min.js": "A23C35D5627009A29FD396A024442A19E37DEE70674BF3CE0FA377D781ED2231",
|
||||
@ -46,7 +46,7 @@
|
||||
"expand-description.min.css": "58C7710A50521B80F7D872BDC4C652610D84C4FABC6874BA66DA37B4F8759224",
|
||||
"dark-schedule.min.js": "853C446547603F4F0425F19F09F73335C9EC451A790C1C07E5E5B88A09E9B453",
|
||||
"frame-playback.min.html": "4089BD1D954155EA91D39C33E22D7585A87C3F8A9B4A6BA4CE5D97B51763C971",
|
||||
"video-list.vue.min.js": "7232862B2837C12DC41E93AD66E5384BAEECC3FFC98147FA24EC0F36C871BF8F",
|
||||
"video-list.vue.min.js": "14CE7CA7C1A890247F2AB3D2A084833563033D88C80B649A2871ACB204845D6F",
|
||||
"style.min.css": "27223BD1ABBB5D8E529B13C009B5099F53F75B26AA713E4C660C205C1121495B",
|
||||
"remove-top-mask.min.js": "A15C1EC10D2E1A61845B1ADAE51860553F96427059E10443B1E53FAF48F45304",
|
||||
"hide-recommend-live.min.js": "C85A3478FFE38AF91A5369F278F23C5B501BE385A451962F222680E81B86CC05",
|
||||
@ -54,7 +54,7 @@
|
||||
"default-video-speed.min.js": "34E3D2BC8BD5BBC2534EDE6D7B02DE6D5F4A01879641A9E128B4C24124759D77",
|
||||
"custom-navbar.min.css": "A7BF1FCF6A7004991640C8505DD31D700A263ACC26AADF01B7EFF3F9D46FD13C",
|
||||
"frame-playback.min.js": "57B34757FD03B9164B27DB48A1D6F4E3633086C27CD1E3246FCEDDCD7768F05E",
|
||||
"feeds-apis.min.js": "ED1FFDEBC22680C5089F9D30CF667535FB99881C96A969DB47BC70BF095A99E8",
|
||||
"feeds-apis.min.js": "E6727C1FEBCCFF7FBBD199F36842E0A2D272CCCF0725C51711D53AFF526811ED",
|
||||
"favorites-redirect.min.js": "70D6ECCE0402AA76387D2A3288C1148C60CC88D5378B7A2BDC813F3F78E4EE84",
|
||||
"aria2-rpc-profiles.vue.min.js": "CBF3D159566A694BC543EAB5B9E743A13B571743EBDDB8C558AE036483E3AF5A",
|
||||
"clear-cache.min.js": "9AB1536D8278DA681831A589AD1414425BF206B36AE109FB4EC1E8A685BB2A9F",
|
||||
@ -172,7 +172,7 @@
|
||||
"auto-draw.min.js": "AE72CF2623DF2D15AD4AF82D125FFAF7EF5B1E6B36D9E9AC646AC98AA6AA8698",
|
||||
"simplify-liveroom.min.css": "543EB84B02069274B26B83A837042DD51A787F7BCE9339998473E8B524D91B02",
|
||||
"about.min.html": "E44CC2091973A839E5A533B397EF8C78DD573DAB9AF0C4D19E63748DCB9450DB",
|
||||
"trending-videos.min.js": "FB1507281A70FADBFC51B2BD5A94F765868F380673B5A1ECE19E4E333A383625",
|
||||
"trending-videos.min.js": "CBD579F9C07B5B612B50C1522F05CD8B49AE9E1F47BB95896FE91BB032656FB1",
|
||||
"full-activity-content.min.js": "64BCC18A73078AFDA8FF52EF3593E241E3C58856ED5681C5116CFB0AE1334196",
|
||||
"notify-new-version.min.js": "B657B4A67D791FC413E1DBF2BBC59A79EE453582F44F17BF9157D927891BAE96",
|
||||
"blackboard.min.js": "8BB9CCDE72302AE7DE39D66F9231EFB82BA27DDA799BA4AAAC06F6DE802661BF",
|
||||
|
||||
BIN
min/bundle.zip
BIN
min/bundle.zip
Binary file not shown.
2
min/feeds-apis.min.js
vendored
2
min/feeds-apis.min.js
vendored
@ -1 +1 @@
|
||||
(()=>{return(e,t)=>{const a={repost:{id:1,name:"转发"},textWithImages:{id:2,name:"图文"},text:{id:4,name:"文字"},video:{id:8,name:"视频"},miniVideo:{id:16,name:"小视频"},column:{id:64,name:"专栏"},audio:{id:256,name:"音频"},bangumi:{id:512,name:"番剧"},share:{id:2048,name:"分享"}};class i extends EventTarget{constructor(){super(...arguments);this.cards=[]}addEventListener(e,t,a){super.addEventListener(e,t,a)}removeEventListener(e,t,a){super.removeEventListener(e,t,a)}async addCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){if(e.querySelector(".skeleton")!==null){const t=Observer.childList(e,()=>{if(e.querySelector(".skeleton")===null){t.stop();this.addCard(e)}})}else{const t=await this.parseCard(e);this.cards.push(t);const a=new CustomEvent("addCard",{detail:t});this.dispatchEvent(a)}}}async removeCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){const t=(await this.parseCard(e)).id;const a=this.cards.findIndex(e=>e.id===t);const i=this.cards[a];this.cards.splice(a,1);const n=new CustomEvent("removeCard",{detail:i});this.dispatchEvent(n)}}async parseCard(e){const t=async t=>{const a=await SpinQuery.condition(()=>e.querySelector(t),e=>e!==null);if(a===null){console.warn(e,t);return""}return a.innerText};const i=async e=>{const a=parseInt(await t(e));if(isNaN(a)){return 0}return a};const n=(()=>{if(e.querySelector(".repost")){return a.repost}if(e.querySelector(".imagesbox")){return a.textWithImages}if(e.querySelector(".video-container")){return a.video}if(e.querySelector(".bangumi-container")){return a.bangumi}if(e.querySelector(".article-container")){return a.column}if(e.querySelector(".music-container")){return a.audio}if(e.querySelector(".h5share-container")){return a.share}if(e.querySelector(".vc-ctnr")){return a.miniVideo}return a.text})();const r={id:e.getAttribute("data-did"),username:await t(".main-content .user-name"),text:await t(".card-content .text.description,.video-container .title,.bangumi-container .title"),reposts:await i(".button-bar .single-button:nth-child(1) .text-offset"),comments:await i(".button-bar .single-button:nth-child(2) .text-offset"),likes:await i(".button-bar .single-button:nth-child(3) .text-offset"),element:e,type:n};e.setAttribute("data-type",n.id.toString());return r}async startWatching(){const e=await SpinQuery.select(".card-list .content");if(!e){return false}const t=[...e.querySelectorAll(".content>.card")];t.forEach(e=>this.addCard(e));Observer.childList(e,e=>{e.forEach(e=>{e.addedNodes.forEach(e=>this.addCard(e));e.removedNodes.forEach(e=>this.removeCard(e))})});return true}}const n=new i;const r=async(e="video")=>{const a=await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=${e==="video"?8:512}`);if(a.code!==0){throw new Error(a.message)}if(e==="video"){const{getWatchlaterList:e}=await t.importAsync("watchlater-api");const i=await e();return a.data.cards.map(e=>{const t=JSON.parse(e.card);const a=_.get(e,"display.topic_info.topic_details",[]).map(e=>{return{id:e.topic_id,name:e.topic_name}});return{id:e.desc.dynamic_id_str,aid:t.aid,title:t.title,upID:e.desc.user_profile.info.uid,upName:e.desc.user_profile.info.uname,upFaceUrl:e.desc.user_profile.info.face,coverUrl:t.pic,description:t.desc,timestamp:e.timestamp,time:new Date(e.timestamp*1e3),topics:a,dynamic:t.dynamic,like:formatCount(e.desc.like),duration:t.duration,durationText:formatDuration(t.duration,0),playCount:formatCount(t.stat.view),danmakuCount:formatCount(t.stat.danmaku),watchlater:i.includes(t.aid)}})}else if(e==="bangumi"){return a.data.cards.map(e=>{const t=JSON.parse(e.card);return{id:e.desc.dynamic_id_str,aid:t.aid,epID:t.episode_id,title:t.new_desc,upName:t.apiSeasonInfo.title,upFaceUrl:t.apiSeasonInfo.cover,coverUrl:t.cover,description:"",timestamp:e.timestamp,time:new Date(e.timestamp*1e3),like:formatCount(e.desc.like),durationText:"",playCount:formatCount(t.play_count),danmakuCount:formatCount(t.bullet_count),watchlater:false}})}else{return[]}};return{export:{feedsCardsManager:n,feedsCardTypes:a,getVideoFeeds:r}}}})();
|
||||
(()=>{return(e,t)=>{const a={repost:{id:1,name:"转发"},textWithImages:{id:2,name:"图文"},text:{id:4,name:"文字"},video:{id:8,name:"视频"},miniVideo:{id:16,name:"小视频"},column:{id:64,name:"专栏"},audio:{id:256,name:"音频"},bangumi:{id:512,name:"番剧"},share:{id:2048,name:"分享"}};class i extends EventTarget{constructor(){super(...arguments);this.cards=[]}addEventListener(e,t,a){super.addEventListener(e,t,a)}removeEventListener(e,t,a){super.removeEventListener(e,t,a)}async addCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){if(e.querySelector(".skeleton")!==null){const t=Observer.childList(e,()=>{if(e.querySelector(".skeleton")===null){t.stop();this.addCard(e)}})}else{const t=await this.parseCard(e);this.cards.push(t);const a=new CustomEvent("addCard",{detail:t});this.dispatchEvent(a)}}}async removeCard(e){if(e instanceof HTMLElement&&e.classList.contains("card")){const t=(await this.parseCard(e)).id;const a=this.cards.findIndex(e=>e.id===t);const i=this.cards[a];this.cards.splice(a,1);const n=new CustomEvent("removeCard",{detail:i});this.dispatchEvent(n)}}async parseCard(e){const t=async t=>{const a=await SpinQuery.condition(()=>e.querySelector(t),e=>e!==null);if(a===null){console.warn(e,t);return""}return a.innerText};const i=async e=>{const a=parseInt(await t(e));if(isNaN(a)){return 0}return a};const n=(()=>{if(e.querySelector(".repost")){return a.repost}if(e.querySelector(".imagesbox")){return a.textWithImages}if(e.querySelector(".video-container")){return a.video}if(e.querySelector(".bangumi-container")){return a.bangumi}if(e.querySelector(".article-container")){return a.column}if(e.querySelector(".music-container")){return a.audio}if(e.querySelector(".h5share-container")){return a.share}if(e.querySelector(".vc-ctnr")){return a.miniVideo}return a.text})();const r={id:e.getAttribute("data-did"),username:await t(".main-content .user-name"),text:await t(".card-content .text.description,.video-container .title,.bangumi-container .title"),reposts:await i(".button-bar .single-button:nth-child(1) .text-offset"),comments:await i(".button-bar .single-button:nth-child(2) .text-offset"),likes:await i(".button-bar .single-button:nth-child(3) .text-offset"),element:e,type:n};e.setAttribute("data-type",n.id.toString());return r}async startWatching(){const e=await SpinQuery.select(".card-list .content");if(!e){return false}const t=[...e.querySelectorAll(".content>.card")];t.forEach(e=>this.addCard(e));Observer.childList(e,e=>{e.forEach(e=>{e.addedNodes.forEach(e=>this.addCard(e));e.removedNodes.forEach(e=>this.removeCard(e))})});return true}}const n=new i;const r=async(e="video")=>{if(!getUID()){return[]}const a=await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=${e==="video"?8:512}`);if(a.code!==0){throw new Error(a.message)}if(e==="video"){const{getWatchlaterList:e}=await t.importAsync("watchlater-api");const i=await e();return a.data.cards.map(e=>{const t=JSON.parse(e.card);const a=_.get(e,"display.topic_info.topic_details",[]).map(e=>{return{id:e.topic_id,name:e.topic_name}});return{id:e.desc.dynamic_id_str,aid:t.aid,title:t.title,upID:e.desc.user_profile.info.uid,upName:e.desc.user_profile.info.uname,upFaceUrl:e.desc.user_profile.info.face,coverUrl:t.pic,description:t.desc,timestamp:e.timestamp,time:new Date(e.timestamp*1e3),topics:a,dynamic:t.dynamic,like:formatCount(e.desc.like),duration:t.duration,durationText:formatDuration(t.duration,0),playCount:formatCount(t.stat.view),danmakuCount:formatCount(t.stat.danmaku),watchlater:i.includes(t.aid)}})}else if(e==="bangumi"){return a.data.cards.map(e=>{const t=JSON.parse(e.card);return{id:e.desc.dynamic_id_str,aid:t.aid,epID:t.episode_id,title:t.new_desc,upName:t.apiSeasonInfo.title,upFaceUrl:t.apiSeasonInfo.cover,coverUrl:t.cover,description:"",timestamp:e.timestamp,time:new Date(e.timestamp*1e3),like:formatCount(e.desc.like),durationText:"",playCount:formatCount(t.play_count),danmakuCount:formatCount(t.bullet_count),watchlater:false}})}else{return[]}};return{export:{feedsCardsManager:n,feedsCardTypes:a,getVideoFeeds:r}}}})();
|
||||
2
min/trending-videos.min.js
vendored
2
min/trending-videos.min.js
vendored
@ -1 +1 @@
|
||||
(()=>{return(t,a)=>{const i=async(t,i)=>{const e=await Ajax.getJsonWithCredentials(`https://api.bilibili.com/x/web-interface/ranking/index?day=${t}`);if(i===undefined){const{getWatchlaterList:t}=await a.importAsync("watchlater-api");i=await t()}if(e.code!==0){throw new Error(e.message)}return e.data.map(a=>({id:a.aid+"-"+t,aid:parseInt(a.aid),title:a.title,upID:a.mid,upName:a.author,coverUrl:a.pic.replace("http://","https://"),description:a.description,durationText:a.duration,playCount:formatCount(a.play),coins:formatCount(a.coins),favorites:formatCount(a.favorites),watchlater:i.includes(parseInt(a.aid))}))};return{export:{getTrendingVideos:i}}}})();
|
||||
(()=>{return(t,a)=>{const i=async(t,i)=>{const e=await Ajax.getJsonWithCredentials(`https://api.bilibili.com/x/web-interface/ranking/index?day=${t}`);if(getUID()&&i===undefined){const{getWatchlaterList:t}=await a.importAsync("watchlater-api");i=await t()}if(e.code!==0){throw new Error(e.message)}return e.data.map(a=>({id:a.aid+"-"+t,aid:parseInt(a.aid),title:a.title,upID:a.mid,upName:a.author,coverUrl:a.pic.replace("http://","https://"),description:a.description,durationText:a.duration,playCount:formatCount(a.play),coins:formatCount(a.coins),favorites:formatCount(a.favorites),watchlater:i?i.includes(parseInt(a.aid)):null}))};return{export:{getTrendingVideos:i}}}})();
|
||||
2
min/video-card.vue.min.js
vendored
2
min/video-card.vue.min.js
vendored
File diff suppressed because one or more lines are too long
2
min/video-list.vue.min.js
vendored
2
min/video-list.vue.min.js
vendored
@ -1 +1 @@
|
||||
(()=>{return(i,a)=>{const t=`<div class=video-list><div class=loading v-if=loading><i class="mdi mdi-18px mdi-loading mdi-spin"></i>加载中...</div><div class=cards :class="{'show-rank': showRank}"v-else-if=cards.length><video-card v-for="card of cards":key=card.id :data=card></video-card></div><div class=empty v-else>空空如也哦 = ̄ω ̄=</div></div>`;a.applyStyleFromText(`.minimal-home .video-list .empty,.minimal-home .video-list .loading{height:48px;display:flex;align-items:center;justify-content:center;font-size:11pt;color:#707070}.minimal-home .video-list .empty .mdi,.minimal-home .video-list .loading .mdi{margin-right:8px}body.dark .minimal-home .video-list .empty,body.dark .minimal-home .video-list .loading{color:#eee}.minimal-home .video-list .cards{display:flex;flex-wrap:wrap;align-items:flex-end}.minimal-home .video-list .cards.show-rank .video-card:nth-child(1),.minimal-home .video-list .cards.show-rank .video-card:nth-child(17),.minimal-home .video-list .cards.show-rank .video-card:nth-child(9){margin-top:48px}.minimal-home .video-list .cards.show-rank .video-card:nth-child(1)::before,.minimal-home .video-list .cards.show-rank .video-card:nth-child(17)::before,.minimal-home .video-list .cards.show-rank .video-card:nth-child(9)::before{position:absolute;top:-42px;left:0;font-size:14pt;font-weight:700}.minimal-home .video-list .cards.show-rank .video-card:nth-child(1)::before{content:"今日"}.minimal-home .video-list .cards.show-rank .video-card:nth-child(9)::before{content:"三日"}.minimal-home .video-list .cards.show-rank .video-card:nth-child(17)::before{content:"一周"}`,"video-list-style");return{export:Object.assign({template:t},{components:{VideoCard:()=>a.importAsync("video-card.vue")},props:["showRank"],data(){return{cards:[],loading:true}},methods:{async getRankList(){const{getTrendingVideos:i}=await a.importAsync("trending-videos");const{getWatchlaterList:t}=await a.importAsync("watchlater-api");const e=await t();const o=async a=>{const t=await i(a,e);this.cards.push(...t)};await Promise.all([1,3,7].map(o))},async getActivityVideos(){const i=await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=8`);const{getWatchlaterList:t}=await a.importAsync("watchlater-api");const e=await t();if(i.code!==0){throw new Error(i.message)}this.cards=i.data.cards.map(i=>{const a=JSON.parse(i.card);const t=_.get(i,"display.topic_info.topic_details",[]).map(i=>{return{id:i.topic_id,name:i.topic_name}});return{id:i.desc.dynamic_id_str,aid:a.aid,title:a.title,upID:i.desc.user_profile.info.uid,upName:i.desc.user_profile.info.uname,upFaceUrl:i.desc.user_profile.info.face,coverUrl:a.pic,description:a.desc,timestamp:i.timestamp,time:new Date(i.timestamp*1e3),topics:t,dynamic:a.dynamic,like:formatCount(i.desc.like),duration:a.duration,durationText:formatDuration(a.duration,0),playCount:formatCount(a.stat.view),danmakuCount:formatCount(a.stat.danmaku),watchlater:e.includes(a.aid)}})}},async mounted(){try{if(this.showRank){await this.getRankList()}else{await this.getActivityVideos()}}catch(i){Toast.error(i.message,this.showRank?"热门视频":"视频动态",3e3)}finally{this.loading=false}}})}}})();
|
||||
(()=>{return(i,e)=>{const t=`<div class=video-list><div class=loading v-if=loading><i class="mdi mdi-18px mdi-loading mdi-spin"></i>加载中...</div><div class=cards :class="{'show-rank': showRank}"v-else-if=cards.length><video-card v-for="card of cards":key=card.id :data=card></video-card></div><div class=empty v-else>空空如也哦 = ̄ω ̄=</div></div>`;e.applyStyleFromText(`.minimal-home .video-list .empty,.minimal-home .video-list .loading{height:48px;display:flex;align-items:center;justify-content:center;font-size:11pt;color:#707070}.minimal-home .video-list .empty .mdi,.minimal-home .video-list .loading .mdi{margin-right:8px}body.dark .minimal-home .video-list .empty,body.dark .minimal-home .video-list .loading{color:#eee}.minimal-home .video-list .cards{display:flex;flex-wrap:wrap;align-items:flex-end}.minimal-home .video-list .cards.show-rank .video-card:nth-child(1),.minimal-home .video-list .cards.show-rank .video-card:nth-child(17),.minimal-home .video-list .cards.show-rank .video-card:nth-child(9){margin-top:48px}.minimal-home .video-list .cards.show-rank .video-card:nth-child(1)::before,.minimal-home .video-list .cards.show-rank .video-card:nth-child(17)::before,.minimal-home .video-list .cards.show-rank .video-card:nth-child(9)::before{position:absolute;top:-42px;left:0;font-size:14pt;font-weight:700}.minimal-home .video-list .cards.show-rank .video-card:nth-child(1)::before{content:"今日"}.minimal-home .video-list .cards.show-rank .video-card:nth-child(9)::before{content:"三日"}.minimal-home .video-list .cards.show-rank .video-card:nth-child(17)::before{content:"一周"}`,"video-list-style");return{export:Object.assign({template:t},{components:{VideoCard:()=>e.importAsync("video-card.vue")},props:["showRank"],data(){return{cards:[],loading:true}},methods:{async getRankList(){const{getTrendingVideos:i}=await e.importAsync("trending-videos");let t=undefined;if(getUID()){const{getWatchlaterList:i}=await e.importAsync("watchlater-api");t=await i()}const a=async e=>{const a=await i(e,t);this.cards.push(...a)};await Promise.all([1,3,7].map(a))},async getActivityVideos(){const i=await Ajax.getJsonWithCredentials(`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=8`);let t=undefined;if(getUID()){const{getWatchlaterList:i}=await e.importAsync("watchlater-api");t=await i()}if(i.code!==0){throw new Error(i.message)}this.cards=i.data.cards.map(i=>{const e=JSON.parse(i.card);const a=_.get(i,"display.topic_info.topic_details",[]).map(i=>{return{id:i.topic_id,name:i.topic_name}});return{id:i.desc.dynamic_id_str,aid:e.aid,title:e.title,upID:i.desc.user_profile.info.uid,upName:i.desc.user_profile.info.uname,upFaceUrl:i.desc.user_profile.info.face,coverUrl:e.pic,description:e.desc,timestamp:i.timestamp,time:new Date(i.timestamp*1e3),topics:a,dynamic:e.dynamic,like:formatCount(i.desc.like),duration:e.duration,durationText:formatDuration(e.duration,0),playCount:formatCount(e.stat.view),danmakuCount:formatCount(e.stat.danmaku),watchlater:t?t.includes(e.aid):undefined}})}},async mounted(){try{if(this.showRank){await this.getRankList()}else{await this.getActivityVideos()}}catch(i){Toast.error(i.message,this.showRank?"热门视频":"视频动态",3e3)}finally{this.loading=false}}})}}})();
|
||||
@ -173,6 +173,9 @@ class FeedsCardsManager extends EventTarget {
|
||||
export const feedsCardsManager = new FeedsCardsManager()
|
||||
|
||||
export const getVideoFeeds = async (type: 'video' | 'bangumi' = 'video'): Promise<VideoCardInfo[]> => {
|
||||
if (!getUID()) {
|
||||
return []
|
||||
}
|
||||
const json = await Ajax.getJsonWithCredentials(
|
||||
`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=${type === 'video' ? 8 : 512}`
|
||||
)
|
||||
|
||||
@ -26,10 +26,13 @@ export default {
|
||||
methods: {
|
||||
async getRankList() {
|
||||
const { getTrendingVideos } = await import('../trending-videos')
|
||||
const { getWatchlaterList } = await import(
|
||||
'../../../video/watchlater-api'
|
||||
)
|
||||
const watchlaterList = await getWatchlaterList()
|
||||
let watchlaterList: number[] | undefined = undefined
|
||||
if (getUID()) {
|
||||
const { getWatchlaterList } = await import(
|
||||
'../../../video/watchlater-api'
|
||||
)
|
||||
watchlaterList = await getWatchlaterList()
|
||||
}
|
||||
const getRankListByDays = async (days: number) => {
|
||||
const cards = await getTrendingVideos(days, watchlaterList)
|
||||
this.cards.push(...cards)
|
||||
@ -40,10 +43,13 @@ export default {
|
||||
const json = await Ajax.getJsonWithCredentials(
|
||||
`https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${getUID()}&type_list=8`
|
||||
)
|
||||
const { getWatchlaterList } = await import(
|
||||
'../../../video/watchlater-api'
|
||||
)
|
||||
const watchlaterList = await getWatchlaterList()
|
||||
let watchlaterList: number[] | undefined = undefined
|
||||
if (getUID()) {
|
||||
const { getWatchlaterList } = await import(
|
||||
'../../../video/watchlater-api'
|
||||
)
|
||||
watchlaterList = await getWatchlaterList()
|
||||
}
|
||||
if (json.code !== 0) {
|
||||
throw new Error(json.message)
|
||||
}
|
||||
@ -76,7 +82,7 @@ export default {
|
||||
durationText: formatDuration(card.duration, 0),
|
||||
playCount: formatCount(card.stat.view),
|
||||
danmakuCount: formatCount(card.stat.danmaku),
|
||||
watchlater: watchlaterList.includes(card.aid)
|
||||
watchlater: watchlaterList ? watchlaterList.includes(card.aid) : undefined,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@ -3,7 +3,7 @@ export const getTrendingVideos = async (days: number, watchlaterList?: number[])
|
||||
const json = await Ajax.getJsonWithCredentials(
|
||||
`https://api.bilibili.com/x/web-interface/ranking/index?day=${days}`
|
||||
)
|
||||
if (watchlaterList === undefined) {
|
||||
if (getUID() && watchlaterList === undefined) {
|
||||
const { getWatchlaterList } = await import(
|
||||
'../../video/watchlater-api'
|
||||
)
|
||||
@ -25,7 +25,7 @@ export const getTrendingVideos = async (days: number, watchlaterList?: number[])
|
||||
playCount: formatCount(card.play),
|
||||
coins: formatCount(card.coins),
|
||||
favorites: formatCount(card.favorites),
|
||||
watchlater: watchlaterList!.includes(parseInt(card.aid))
|
||||
watchlater: watchlaterList ? watchlaterList.includes(parseInt(card.aid)) : null
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
@ -23,5 +23,5 @@ export interface VideoCardInfo {
|
||||
id: number
|
||||
name: string
|
||||
}[]
|
||||
watchlater: boolean
|
||||
watchlater?: boolean
|
||||
}
|
||||
@ -8,7 +8,7 @@
|
||||
<div class="cover-container">
|
||||
<dpi-img class="cover" :src="coverUrl" :size="{height: 120, width: 200}"></dpi-img>
|
||||
<div v-if="durationText" class="duration">{{durationText}}</div>
|
||||
<div v-if="durationText" class="watchlater" @click.stop.prevent="toggleWatchlater()">
|
||||
<div v-if="durationText && watchlater !== null && watchlater !== undefined" class="watchlater" @click.stop.prevent="toggleWatchlater()">
|
||||
<i class="mdi" :class="{'mdi-clock-outline': !watchlater, 'mdi-check-circle': watchlater}"></i>
|
||||
{{watchlater ? '已添加' : '稍后再看'}}
|
||||
</div>
|
||||
@ -217,6 +217,7 @@ export default {
|
||||
color: white;
|
||||
border-radius: 14px;
|
||||
height: 24px;
|
||||
box-sizing: border-box;
|
||||
.mdi {
|
||||
font-size: 12pt;
|
||||
line-height: 1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user