diff --git a/api/bilibili.go b/api/bilibili.go index 00cde31..0624b87 100644 --- a/api/bilibili.go +++ b/api/bilibili.go @@ -200,13 +200,14 @@ func GetVideoData(w http.ResponseWriter, r *http.Request) { http.Error(w, "无法解析视频数据", http.StatusInternalServerError) return } + imageurl := "https://images.weserv.nl/?url=" info := &VideoInfo{ Owner: video.Data.Owner.Name, - Face: video.Data.Owner.Face, + Face: imageurl + video.Data.Owner.Face, Title: video.Data.Title, Desc: video.Data.Desc, Duration: secondsToTimeString(video.Data.Duration), - Pic: video.Data.Pic, + Pic: imageurl + video.Data.Pic, Coin: video.Data.Stat.Coin, Danmaku: video.Data.Stat.Danmaku, Favorite: video.Data.Stat.Favorite, diff --git a/themes/blog/album.html b/themes/blog/album.html index 53a005a..7b9aaab 100644 --- a/themes/blog/album.html +++ b/themes/blog/album.html @@ -249,7 +249,6 @@ html += `<div class="bilibili_item"><span>${item.text}</span>` for (const id of item.ids) { await fetch(`/api/bilibili?bvid=${id}`).then(res => res.json()).then(data => { - console.log(data) html += `<a href="https://www.bilibili.com/video/${id}/" class="bilibili_box" id="${id}"> <div class="bilibili_cover"> <img src="https://s1.hdslb.com/bfs/static/player/img/play.svg" class="play_icon no-lazyload"> diff --git a/themes/blog/talk.html b/themes/blog/talk.html index 4ecd888..8d3a1e5 100644 --- a/themes/blog/talk.html +++ b/themes/blog/talk.html @@ -213,7 +213,9 @@ imgs = content.match(/!\[.*\]\(.*?\)/g), musics = content.match(/{\s*music\s*(.*)\s*}/g), videos = content.match(/{\s*bilibili\s*(.*)\s*}/g); - if (imgs) imgs = imgs.map(item => { return item.replace(/!\[.*\]\((.*?)\)/, '$1') }) + if (imgs) imgs = imgs.map(item => { + return item.replace(/!\[.*\]\((.*?)\)/, '$1') + }) if (item.resourceList.length) { if (!imgs) imgs = [] item.resourceList.forEach(t => { @@ -229,14 +231,18 @@ imgs.forEach(e => content += `<a href="${e}" data-fancybox="gallery" class="fancybox" data-thumb="${e}"><img class="no-lazyload talk-img" src="${e}"></a>`) content += '</div>' } - if (musics) musics.forEach(item => { content += `<meting-js auto="${item.replace(/{\s*music\s*(.*)\s*}/, '$1')}" theme="var(--leonus-main)" preload="metadata"></meting-js>` }) + if (musics) musics.forEach(item => { + content += `<meting-js auto="${item.replace(/{\s*music\s*(.*)\s*}/, '$1')}" theme="var(--leonus-main)" preload="metadata"></meting-js>` + }) if (videos) videos.forEach(item => { content += `<div style="position: relative; padding: 30% 45%;margin-top: 10px;margin-bottom: 10px"><iframe style="position: absolute; width: 100%; height: 100%; left: 0; top: 0;" src="//player.bilibili.com/player.html?autoplay=0&bvid=${item.replace(/{\s*bilibili\s*(.*)\s*}/, '$1').replace(/.*video\/([^\/]*).*/, '$1')}" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"></iframe></div>` }) - return { content, date, text } + return {content, date, text} } function getTime(time) { - var nol = function (h) { return h > 9 ? h : '0' + h } + var nol = function (h) { + return h > 9 ? h : '0' + h + } var now = new Date() var yesterday = new Date(now.getTime() - (1000 * 60 * 60 * 24)).toLocaleDateString() var twoDaysAgo = new Date(now.getTime() - 2 * (1000 * 60 * 60 * 24)).toLocaleDateString() @@ -254,15 +260,20 @@ else return ls[0] + '年' + ls[1] + '月' + ls[2] + '日 ' + ls[3] + ':' + ls[4] } } + fetch('{{ .Data.url }}/api/v1/memo?creatorId={{ .Data.user }}&tag={{ .Data.tag }}&limit=30').then(res => res.json()).then(data => { let items = [], html = '' - data.forEach(item => { items.push(Format(item)) }) + data.forEach(item => { + items.push(Format(item)) + }) if (items.length == 30) document.querySelector('.limit').style.display = 'block' items.forEach(item => { html += `<div class="talk_item"><div class="talk_meta"><img class="no-lightbox no-lazyload avatar" src="https://q1.qlogo.cn/g?b=qq&nk={{ .Data.qq }}&s=5"><div class="info"><span class="talk_nick">Leonus</span><span class="talk_date">${item.date}</span></div><a href="javascript:;" class="goComment" onclick="goComment('${item.text}')"><span class="icon"><i class="fa-solid fa-message fa-fw"></i></span></a></div><div class="talk_content">${item.content}</div></div>` }) document.getElementById('talk').innerHTML = html - imgStatus.watch('.talk-img', () => { waterfall('#talk') }) + imgStatus.watch('.talk-img', () => { + waterfall('#talk') + }) }) </script> <script defer src="https://cdn.jsdelivr.net/gh/jkjoy/14e/js/waterfall.min.js"></script>