This commit is contained in:
1 parent
de44e8d946
commit
de081a5e33
4 files changed
+39
-2
No files matched your search
@@ -17,7 +17,8 @@ export const load: LayoutServerLoad = async ({ platform }) => {
|
||||
title: 'BlogFlare',
|
||||
description: 'A high-performance blog powered by Cloudflare D1, R2, and KV.',
|
||||
avatar_enabled: 'true',
|
||||
avatar_url: ''
|
||||
avatar_url: '',
|
||||
launch_date: ''
|
||||
};
|
||||
|
||||
if (db) {
|
||||
|
||||
@@ -7,6 +7,18 @@
|
||||
import { page } from '$app/stores';
|
||||
|
||||
let scrolled = $state(false);
|
||||
let uptimeText = $state('');
|
||||
|
||||
function calcUptime(launchDate: string): string {
|
||||
if (!launchDate) return '';
|
||||
const start = new Date(launchDate).getTime();
|
||||
const diff = Date.now() - start;
|
||||
if (diff < 0) return '';
|
||||
const days = Math.floor(diff / 86400000);
|
||||
const hours = Math.floor((diff % 86400000) / 3600000);
|
||||
const minutes = Math.floor((diff % 3600000) / 60000);
|
||||
return `${days} 天 ${hours} 小时 ${minutes} 分钟`;
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
const handleScroll = () => {
|
||||
@@ -14,8 +26,16 @@
|
||||
};
|
||||
window.addEventListener('scroll', handleScroll);
|
||||
|
||||
// 初始化建站时长
|
||||
const launchDate = $page.data.site?.launch_date || '';
|
||||
uptimeText = calcUptime(launchDate);
|
||||
const timer = setInterval(() => {
|
||||
uptimeText = calcUptime(launchDate);
|
||||
}, 60000);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('scroll', handleScroll);
|
||||
clearInterval(timer);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -96,7 +116,9 @@
|
||||
© {new Date().getFullYear()}
|
||||
<span class="brand">{$page.data.site?.title || 'BlogFlare'}</span>
|
||||
</p>
|
||||
<p>感谢陪伴:<span id="uptime"></span></p>
|
||||
{#if uptimeText}
|
||||
<p>感谢陪伴:{uptimeText}</p>
|
||||
{/if}
|
||||
</section>
|
||||
<section>
|
||||
<p>
|
||||
|
||||
@@ -42,6 +42,10 @@ export const actions: Actions = {
|
||||
{
|
||||
key: 'r2.public_domain',
|
||||
value: data.get('r2_public_domain')?.toString() || 'https://assets.yourdomain.com'
|
||||
},
|
||||
{
|
||||
key: 'site.launch_date',
|
||||
value: data.get('site_launch_date')?.toString() || ''
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -85,6 +85,16 @@
|
||||
/>
|
||||
<small class="form-hint">请确保不要以斜杠 / 结尾</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="site_launch_date">建站日期</label>
|
||||
<input
|
||||
type="date"
|
||||
id="site_launch_date"
|
||||
name="site_launch_date"
|
||||
value={data.settings['site.launch_date'] || ''}
|
||||
/>
|
||||
<small class="form-hint">用于在底栏显示"感谢陪伴 X 天 X 小时"</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
|
||||
Reference in new issue
Block a user