This commit is contained in:
@ -1,23 +0,0 @@
|
||||
---
|
||||
import '../assets/style.css'
|
||||
|
||||
interface Props {
|
||||
title?: string
|
||||
}
|
||||
|
||||
const { title = '小帕的小窝' } = Astro.props
|
||||
---
|
||||
|
||||
<html lang="zh-hans">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta name="viewport" content="width=device-width" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>{title}</title>
|
||||
</head>
|
||||
<body>
|
||||
<slot />
|
||||
</body>
|
||||
</html>
|
||||
@ -1,55 +0,0 @@
|
||||
---
|
||||
/* 在博客翻新时期使用的占位 Layout,讲究的就是极简 */
|
||||
|
||||
import BaseLayout from '../components/BaseLayout.astro'
|
||||
|
||||
interface Props {
|
||||
title?: string
|
||||
}
|
||||
|
||||
const { title = '小帕的小窝' } = Astro.props
|
||||
---
|
||||
|
||||
<BaseLayout title={title}>
|
||||
<div class="main">
|
||||
<slot />
|
||||
</div>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
.main {
|
||||
font-family:
|
||||
'HarmonyOS Sans SC',
|
||||
'Noto Sans SC',
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
'Segoe UI',
|
||||
Roboto,
|
||||
Oxygen,
|
||||
Ubuntu,
|
||||
Cantarell,
|
||||
'Open Sans',
|
||||
'Helvetica Neue',
|
||||
sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
width: 100dvw;
|
||||
height: 100dvh;
|
||||
padding-inline: 40px;
|
||||
text-align: center;
|
||||
box-sizing: border-box;
|
||||
|
||||
& :global(a) {
|
||||
color: var(--color-link);
|
||||
text-decoration: none;
|
||||
|
||||
&:global(:hover),
|
||||
&:global(:focus) {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
48
src/components/MainpageButton.svelte
Normal file
48
src/components/MainpageButton.svelte
Normal file
@ -0,0 +1,48 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte'
|
||||
import { mainpageClick, mainpageGetClick } from '../lib/apis/legacy/mainpage'
|
||||
|
||||
let clicks = 0
|
||||
let clicksPending = 0
|
||||
|
||||
onMount(() => {
|
||||
// 先 fetch 一次
|
||||
mainpageGetClick().then((r) => {
|
||||
clicks = r.data
|
||||
})
|
||||
|
||||
// 添加计时器
|
||||
let _counter = 0
|
||||
let itv = setInterval(() => {
|
||||
_counter++
|
||||
if (clicksPending != 0 && _counter >= 2) {
|
||||
_counter = 0
|
||||
|
||||
let _clickPending = clicksPending
|
||||
clicks += clicksPending
|
||||
clicksPending = 0
|
||||
|
||||
mainpageClick(_clickPending).then((r) => {
|
||||
clicks = r.data
|
||||
})
|
||||
} else {
|
||||
if (_counter >= 60) {
|
||||
_counter = 0
|
||||
mainpageGetClick().then((r) => {
|
||||
clicks = r.data
|
||||
})
|
||||
}
|
||||
}
|
||||
}, 500)
|
||||
|
||||
return () => {
|
||||
clearInterval(itv)
|
||||
}
|
||||
})
|
||||
|
||||
async function click() {
|
||||
clicksPending += 1
|
||||
}
|
||||
</script>
|
||||
|
||||
<button onclick={click}>没用的按钮 | {clicks + clicksPending}</button>
|
||||
Reference in New Issue
Block a user