Skip to content

Commit 4a89849

Browse files
committed
调试
1 parent 1936926 commit 4a89849

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

src/layouts/BaseLayout.astro

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,27 +65,6 @@ const { description, keywords, title, canonical, ogType } = Astro.props;
6565
</html>
6666

6767
<script>
68-
import { ToastMessageEvent } from "../utils/types";
69-
70-
const welcome = () => {
71-
// 获取完整的来源 URL
72-
let referrer = document.referrer;
73-
console.log("欢迎,referrer:", referrer);
74-
if (!referrer) {
75-
return;
76-
}
77-
let url = new URL(referrer);
78-
console.log("来源域名:", url.hostname);
79-
document.dispatchEvent(
80-
new ToastMessageEvent(
81-
"welcomeEvent",
82-
"welcome",
83-
`欢迎来自${url.hostname}的访客`
84-
)
85-
);
86-
};
87-
window.onload = welcome;
88-
8968
const menu = document.getElementById("menu");
9069
if (menu instanceof HTMLElement) {
9170
let lastScrollTop = 0;

src/pages/index.astro

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,29 @@ import BaseLayout from "../layouts/BaseLayout.astro";
1818
</div>
1919
</BaseLayout>
2020

21+
<script>
22+
import { ToastMessageEvent } from "../utils/types";
23+
24+
const welcome = () => {
25+
// 获取完整的来源 URL
26+
let referrer = document.referrer;
27+
console.log("欢迎,referrer:", referrer);
28+
if (!referrer) {
29+
return;
30+
}
31+
let url = new URL(referrer);
32+
console.log("来源域名:", url.hostname);
33+
document.dispatchEvent(
34+
new ToastMessageEvent(
35+
"welcomeEvent",
36+
"welcome",
37+
`欢迎来自${url.hostname}的访客`
38+
)
39+
);
40+
};
41+
window.onload = welcome;
42+
</script>
43+
2144
<style>
2245
.content-wrapper {
2346
padding: 0 1.5rem;

0 commit comments

Comments
 (0)