Skip to content

Commit f68cac1

Browse files
committed
refactor: 增加点击逻辑
1 parent 2da994b commit f68cac1

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
RenderFragment RenderVote =>
2121
@<div>
2222
<p style="font-weight: bold;">我正在参加 Gitee 2025 最受欢迎的开源软件投票活动,快来给我投票吧!</p>
23-
<div style="display: flex; justify-content: space-around;"><a href="https://gitee.com/activity/2025opensource?ident=I6MYBB" target="_blank" style="font-weight: bold;">必须投一票</a> <a href="https://gitee.com/activity/2025opensource?ident=I6MYBB" target="_blank" class="text-muted" title="老六你居然不投票">我知道了</a></div>
23+
<div style="display: flex; justify-content: space-around;" id="bb-gitee-vote">
24+
<a href="https://gitee.com/activity/2025opensource?ident=I6MYBB" target="_blank" style="font-weight: bold; padding: 3px 12px; border: 1px solid var(--bs-primary); border-radius: var(--bs-border-radius);">必须投一票</a>
25+
<a href="https://gitee.com/activity/2025opensource?ident=I6MYBB" target="_blank" class="text-muted" style="padding: 3px 12px;" title="老六你居然不投票">我知道了</a>
26+
</div>
2427
</div>;
2528
}
Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getTheme, setTheme } from "../../_content/BootstrapBlazor/modules/utility.js"
2+
import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js"
23

34
function initTheme() {
45
const currentTheme = getTheme();
@@ -7,12 +8,34 @@ function initTheme() {
78

89
export function doTask(invoke) {
910
initTheme();
10-
const handler = setTimeout(() => {
11+
12+
const v = localStorage.getItem('bb-gitee-vote');
13+
if (v) {
14+
try {
15+
const differ = new Date().getTime() - v;
16+
if (differ < 86400000) {
17+
return;
18+
}
19+
}
20+
catch {
21+
localStorage.removeItem('bb-gitee-vote');
22+
}
23+
}
24+
const handler = setTimeout(async () => {
1125
clearTimeout(handler);
12-
invoke.invokeMethodAsync("ShowVoteToast");
26+
await invoke.invokeMethodAsync("ShowVoteToast");
1327
}, 1000);
28+
29+
EventHandler.on(document, 'click', '#bb-gitee-vote', e => {
30+
const toast = e.delegateTarget.closest('.toast');
31+
if (toast) {
32+
toast.classList.remove('show');
33+
34+
localStorage.setItem('bb-gitee-vote', new Date().getTime());
35+
}
36+
});
1437
}
1538

1639
export function dispose() {
17-
40+
EventHandler.off(document, 'click', '#bb-gitee-vote');
1841
}

0 commit comments

Comments
 (0)