main
parent
6b7adcb07a
commit
1a99e53158
|
@ -99,7 +99,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.zone_imgbox a {
|
.zone_imgbox a {
|
||||||
display: block;
|
display: block;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
|
@ -141,7 +140,17 @@
|
||||||
|
|
||||||
.limit {
|
.limit {
|
||||||
transition: all .3s ease-in-out;
|
transition: all .3s ease-in-out;
|
||||||
color: rgba(76, 73, 72, 0.6)
|
color: rgba(76, 73, 72, 0.6);
|
||||||
|
display: none;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.limit button {
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 9pt;
|
||||||
|
background: var(--primary, #673ab7);
|
||||||
|
border: 1px solid lightgrey;
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-theme=dark] .limit {
|
[data-theme=dark] .limit {
|
||||||
|
@ -175,13 +184,14 @@
|
||||||
font-size: 14px
|
font-size: 14px
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.downloadBtn {
|
.downloadBtn {
|
||||||
display: flex;
|
display: flex;
|
||||||
background: var(--primary, #673ab7);
|
background: var(--primary, #673ab7);
|
||||||
color: white;
|
color: white;
|
||||||
padding: 6px 22px;
|
padding: 4px 8px;
|
||||||
margin: 8px 0;
|
margin: 2px 0;
|
||||||
border-radius: 7px;
|
border-radius: 5px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 12pt;
|
font-size: 12pt;
|
||||||
border: none;
|
border: none;
|
||||||
|
@ -198,6 +208,7 @@
|
||||||
<a>加载中...</a>
|
<a>加载中...</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class='limit'><button onclick='loadMemo(-1)'>上一页</button> <button onclick='loadMemo(1)'>下一页</button></div>
|
||||||
<script>
|
<script>
|
||||||
function Format(item) {
|
function Format(item) {
|
||||||
let date = getTime(new Date(item.createdTs * 1000).toString()),
|
let date = getTime(new Date(item.createdTs * 1000).toString()),
|
||||||
|
@ -206,10 +217,10 @@
|
||||||
name = item.name,
|
name = item.name,
|
||||||
codes = content.match(/```(.*)```/igs);
|
codes = content.match(/```(.*)```/igs);
|
||||||
content = content.replace(/#(.*?)\s/g, '').replace(/{.*}/g, '').replace(/\!\[(.*?)\]\((.*?)\)/g, '').replace(/```(.*)```/igs, '')
|
content = content.replace(/#(.*?)\s/g, '').replace(/{.*}/g, '').replace(/\!\[(.*?)\]\((.*?)\)/g, '').replace(/```(.*)```/igs, '')
|
||||||
let text =`<a href="{{ .Data.url }}/m/${name}">原文地址</a>`;
|
let text = `<a href="{{ .Data.url }}/m/${name}">原文地址</a>`;
|
||||||
if (codes) codes.forEach(item => {
|
if (codes) codes.forEach(item => {
|
||||||
content += `<div style="display: flex;"><a type="button" class="downloadBtn" href="legado://import/auto?src=${window.location.origin}/api/memos?id=${id}">一键导入</a>`
|
content += `<div style="display: flex;"><a type="button" class="downloadBtn" href="legado://import/auto?src=${window.location.origin}/api/memos?id=${id}">一键导入</a>`
|
||||||
content += `<a type="button" class="downloadBtn" href="${window.location.origin}/api/memos?id=${id}">下载文件</a></div>`
|
content += ` <a type="button" class="downloadBtn" href="${window.location.origin}/api/memos?id=${id}">下载文件</a></div>`
|
||||||
// content += marked(item);
|
// content += marked(item);
|
||||||
})
|
})
|
||||||
return {content, date, text}
|
return {content, date, text}
|
||||||
|
@ -237,21 +248,39 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch('{{ .Data.url }}/api/v1/memo?creatorId={{ .Data.user }}&tag={{ .Data.tag }}').then(res => res.json()).then(data => {
|
var offset = 0;
|
||||||
let items = [], html = ''
|
let limit =30;
|
||||||
data.forEach(item => {
|
function loadMemo(p) {
|
||||||
items.push(Format(item))
|
offset += p*limit;
|
||||||
})
|
if (offset < 1) {
|
||||||
if (items.length == 30) document.querySelector('.limit').style.display = 'block'
|
offset = 0;
|
||||||
items.forEach(item => {
|
}
|
||||||
html += '<div class="talk_item"><div class="talk_meta">';
|
fetch('{{ .Data.url }}/api/v1/memo?creatorId={{ .Data.user }}&tag={{ .Data.tag }}&limit='+limit+'&offset=' + offset)
|
||||||
html += "<img class=\"no-lightbox no-lazyload avatar\" src=\"https://q1.qlogo.cn/g?b=qq&nk={{ .Data.qq }}&s=5\">";
|
.then(res => res.json())
|
||||||
html += `<div class="info"><span class="talk_nick">{{ .Data.author }}</span><span class="talk_date">${item.date}</span>`;
|
.then(data => {
|
||||||
html += `</div></div><div class="talk_content">${item.content}</div>${item.text}</div>`;
|
let items = [], html = '';
|
||||||
})
|
data.forEach(item => {
|
||||||
document.getElementById('talk').innerHTML = html;
|
items.push(Format(item));
|
||||||
waterfall('#talk');
|
});
|
||||||
})
|
if (items.length === limit) {
|
||||||
|
document.querySelector('.limit').style.display = 'flex';
|
||||||
|
}
|
||||||
|
items.forEach(item => {
|
||||||
|
html += '<div class="talk_item"><div class="talk_meta">';
|
||||||
|
html += "<img class=\"no-lightbox no-lazyload avatar\" src=\"https://q1.qlogo.cn/g?b=qq&nk={{ .Data.qq }}&s=5\">";
|
||||||
|
html += `<div class="info"><span class="talk_nick">{{ .Data.author }}</span><span class="talk_date">${item.date}</span>`;
|
||||||
|
html += `</div></div><div class="talk_content">${item.content}</div>${item.text}</div>`;
|
||||||
|
});
|
||||||
|
if(items.length!==0){
|
||||||
|
document.getElementById('talk').innerHTML = '';
|
||||||
|
document.getElementById('talk').insertAdjacentHTML('afterbegin', html);
|
||||||
|
waterfall('#talk');
|
||||||
|
}else {
|
||||||
|
document.getElementById('talk').innerHTML = '<span>无数据</span>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
loadMemo(0);
|
||||||
</script>
|
</script>
|
||||||
<script src="/public/js/prism.js"></script>
|
<script src="/public/js/prism.js"></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