Fix img加载
parent
47f42fe2b0
commit
0f49d5f017
|
@ -200,13 +200,14 @@ func GetVideoData(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, "无法解析视频数据", http.StatusInternalServerError)
|
http.Error(w, "无法解析视频数据", http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
imageurl := "https://images.weserv.nl/?url="
|
||||||
info := &VideoInfo{
|
info := &VideoInfo{
|
||||||
Owner: video.Data.Owner.Name,
|
Owner: video.Data.Owner.Name,
|
||||||
Face: video.Data.Owner.Face,
|
Face: imageurl + video.Data.Owner.Face,
|
||||||
Title: video.Data.Title,
|
Title: video.Data.Title,
|
||||||
Desc: video.Data.Desc,
|
Desc: video.Data.Desc,
|
||||||
Duration: secondsToTimeString(video.Data.Duration),
|
Duration: secondsToTimeString(video.Data.Duration),
|
||||||
Pic: video.Data.Pic,
|
Pic: imageurl + video.Data.Pic,
|
||||||
Coin: video.Data.Stat.Coin,
|
Coin: video.Data.Stat.Coin,
|
||||||
Danmaku: video.Data.Stat.Danmaku,
|
Danmaku: video.Data.Stat.Danmaku,
|
||||||
Favorite: video.Data.Stat.Favorite,
|
Favorite: video.Data.Stat.Favorite,
|
||||||
|
|
|
@ -249,7 +249,6 @@
|
||||||
html += `<div class="bilibili_item"><span>${item.text}</span>`
|
html += `<div class="bilibili_item"><span>${item.text}</span>`
|
||||||
for (const id of item.ids) {
|
for (const id of item.ids) {
|
||||||
await fetch(`/api/bilibili?bvid=${id}`).then(res => res.json()).then(data => {
|
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}">
|
html += `<a href="https://www.bilibili.com/video/${id}/" class="bilibili_box" id="${id}">
|
||||||
<div class="bilibili_cover">
|
<div class="bilibili_cover">
|
||||||
<img src="https://s1.hdslb.com/bfs/static/player/img/play.svg" class="play_icon no-lazyload">
|
<img src="https://s1.hdslb.com/bfs/static/player/img/play.svg" class="play_icon no-lazyload">
|
||||||
|
|
|
@ -213,7 +213,9 @@
|
||||||
imgs = content.match(/!\[.*\]\(.*?\)/g),
|
imgs = content.match(/!\[.*\]\(.*?\)/g),
|
||||||
musics = content.match(/{\s*music\s*(.*)\s*}/g),
|
musics = content.match(/{\s*music\s*(.*)\s*}/g),
|
||||||
videos = content.match(/{\s*bilibili\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 (item.resourceList.length) {
|
||||||
if (!imgs) imgs = []
|
if (!imgs) imgs = []
|
||||||
item.resourceList.forEach(t => {
|
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>`)
|
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>'
|
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 => {
|
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>`
|
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) {
|
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 now = new Date()
|
||||||
var yesterday = new Date(now.getTime() - (1000 * 60 * 60 * 24)).toLocaleDateString()
|
var yesterday = new Date(now.getTime() - (1000 * 60 * 60 * 24)).toLocaleDateString()
|
||||||
var twoDaysAgo = new Date(now.getTime() - 2 * (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]
|
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 => {
|
fetch('{{ .Data.url }}/api/v1/memo?creatorId={{ .Data.user }}&tag={{ .Data.tag }}&limit=30').then(res => res.json()).then(data => {
|
||||||
let items = [], html = ''
|
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'
|
if (items.length == 30) document.querySelector('.limit').style.display = 'block'
|
||||||
items.forEach(item => {
|
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>`
|
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
|
document.getElementById('talk').innerHTML = html
|
||||||
imgStatus.watch('.talk-img', () => { waterfall('#talk') })
|
imgStatus.watch('.talk-img', () => {
|
||||||
|
waterfall('#talk')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<script defer src="https://cdn.jsdelivr.net/gh/jkjoy/14e/js/waterfall.min.js"></script>
|
<script defer src="https://cdn.jsdelivr.net/gh/jkjoy/14e/js/waterfall.min.js"></script>
|
||||||
|
|
Loading…
Reference in New Issue