增加好物的页面

This commit is contained in:
浪子 2024-06-05 16:50:26 +08:00
parent 12ee26cdfe
commit e8f4e79009
2 changed files with 23 additions and 11 deletions

View File

@ -3,6 +3,8 @@
移植自 `bigfa `大大的 `hugo-theme-farallon` 原汁原味,可以直接使用 原主题的CSS 移植自 `bigfa `大大的 `hugo-theme-farallon` 原汁原味,可以直接使用 原主题的CSS
精简部分 JS. 精简部分 JS.
- 2024.6.5
新增了好物的页面 还是通过memos来获取
- 2024.6.4 v0.5.1 - 2024.6.4 v0.5.1

View File

@ -7,20 +7,32 @@
if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?> if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php $this->need('header.php'); ?> <?php $this->need('header.php'); ?>
<div class="site--main site--main__gears"> <div class="site--main site--main__gears">
<header class="archive--header">
<h1 class="post--single__title"><?php $this->title() ?></h1> <h1 class="post--single__title"><?php $this->title() ?></h1>
<h2 class="post--single__subtitle"><?php $this->content(); ?></h2> <h2 class="post--single__subtitle"><?php $this->content(); ?></h2>
<div class="good--list"> </header>
<div id=goods></div> <div id=goods class="good--list"></div>
</div>
</div> </div>
<style>
.img40 {
height: 137px;
width: auto;
}
</style>
<?php
// 检查是否存在自定义字段 'memos' 和 'memosID'
$memos = $this->fields->memos ? $this->fields->memos : 'https://memos.imsun.org';
$memosID = $this->fields->memosID ? $this->fields->memosID : '1';
$memostag = $this->fields->memostag ? $this->fields->memostag : '好物';
?>
<script> <script>
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
memoGoods(); memoGoods();
}); });
function memoGoods(e) { function memoGoods(e) {
let t = e || 12; let t = e || 12;
var n = "https://memos.imsun.org", var n = "<?php echo $memos; ?>",
s = n + "/api/v1/memo?creatorId=1&limit=" + t + "&tag=好物"; s = n + "/api/v1/memo?creatorId=<?php echo $memosID; ?>&limit=" + t + "&tag=<?php echo $memostag; ?>";
let i = 1; let i = 1;
const o = /\n/; const o = /\n/;
fetch(s).then(e => e.json()).then(e => { fetch(s).then(e => e.json()).then(e => {
@ -39,10 +51,9 @@ function memoGoods(e) {
+ h + + h +
'" target="_blank"><img src="' '" target="_blank"><img src="'
+ i + + i +
'"></a></div><div class="good--name"><div class="brand">' '" class="img40"></a></div><div class="good--name"><div class="brand">'
+ d + '<br>' + u + + d + '·' + m +'</div>'
'</div>' + u +
+ m +
'</div></div>'; '</div></div>';
} }
let f = document.querySelector("#goods"); let f = document.querySelector("#goods");
@ -50,5 +61,4 @@ function memoGoods(e) {
}); });
} }
</script> </script>
<?php $this->need('footer.php'); ?> <?php $this->need('footer.php'); ?>