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',
|
title: 'BlogFlare',
|
||||||
description: 'A high-performance blog powered by Cloudflare D1, R2, and KV.',
|
description: 'A high-performance blog powered by Cloudflare D1, R2, and KV.',
|
||||||
avatar_enabled: 'true',
|
avatar_enabled: 'true',
|
||||||
avatar_url: ''
|
avatar_url: '',
|
||||||
|
launch_date: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
if (db) {
|
if (db) {
|
||||||
|
|||||||
@@ -7,6 +7,18 @@
|
|||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
|
|
||||||
let scrolled = $state(false);
|
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(() => {
|
onMount(() => {
|
||||||
const handleScroll = () => {
|
const handleScroll = () => {
|
||||||
@@ -14,8 +26,16 @@
|
|||||||
};
|
};
|
||||||
window.addEventListener('scroll', handleScroll);
|
window.addEventListener('scroll', handleScroll);
|
||||||
|
|
||||||
|
// 初始化建站时长
|
||||||
|
const launchDate = $page.data.site?.launch_date || '';
|
||||||
|
uptimeText = calcUptime(launchDate);
|
||||||
|
const timer = setInterval(() => {
|
||||||
|
uptimeText = calcUptime(launchDate);
|
||||||
|
}, 60000);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('scroll', handleScroll);
|
window.removeEventListener('scroll', handleScroll);
|
||||||
|
clearInterval(timer);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -96,7 +116,9 @@
|
|||||||
© {new Date().getFullYear()}
|
© {new Date().getFullYear()}
|
||||||
<span class="brand">{$page.data.site?.title || 'BlogFlare'}</span>
|
<span class="brand">{$page.data.site?.title || 'BlogFlare'}</span>
|
||||||
</p>
|
</p>
|
||||||
<p>感谢陪伴:<span id="uptime"></span></p>
|
{#if uptimeText}
|
||||||
|
<p>感谢陪伴:{uptimeText}</p>
|
||||||
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ export const actions: Actions = {
|
|||||||
{
|
{
|
||||||
key: 'r2.public_domain',
|
key: 'r2.public_domain',
|
||||||
value: data.get('r2_public_domain')?.toString() || 'https://assets.yourdomain.com'
|
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>
|
<small class="form-hint">请确保不要以斜杠 / 结尾</small>
|
||||||
</div>
|
</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>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
|
|||||||
Reference in new issue
Block a user