From 0f49d5f017e36d583e8e8835d924f13f3791eb07 Mon Sep 17 00:00:00 2001 From: JiXieShi Date: Tue, 7 May 2024 21:46:06 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20img=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/bilibili.go | 5 +++-- themes/blog/album.html | 1 - themes/blog/talk.html | 23 +++++++++++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) 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 += `
${item.text}` for (const id of item.ids) { await fetch(`/api/bilibili?bvid=${id}`).then(res => res.json()).then(data => { - console.log(data) html += ` ' } - if (musics) musics.forEach(item => { content += `` }) + if (musics) musics.forEach(item => { + content += `` + }) if (videos) videos.forEach(item => { content += `
` }) - 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 += `
Leonus${item.date}
${item.content}
` }) document.getElementById('talk').innerHTML = html - imgStatus.watch('.talk-img', () => { waterfall('#talk') }) + imgStatus.watch('.talk-img', () => { + waterfall('#talk') + }) })