Skip to content

Commit 5fdd568

Browse files
committed
check if it is wechat environment
1 parent 2276759 commit 5fdd568

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

public/favourite/index.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ body {
1818
--box-size: 3.6rem;
1919
}
2020

21+
body {
22+
color: var(--global-color);
23+
}
24+
2125
.h2-title,
2226
.text {
2327
background: linear-gradient(45deg, #ff6b6b, #feca57, #ff9ff3);
@@ -128,4 +132,20 @@ dialog {
128132
dialog::backdrop {
129133
-webkit-backdrop-filter: blur(5px);
130134
backdrop-filter: blur(5px);
135+
}
136+
137+
.wechat {
138+
display: flex;
139+
padding: 6rem;
140+
flex-direction: column;
141+
align-items: center;
142+
}
143+
144+
.decoration-line {
145+
cursor: pointer;
146+
color: var(--global-color);
147+
text-decoration-line: underline;
148+
text-decoration-thickness: 0.2rem;
149+
text-decoration-color: var(--global-color);
150+
text-underline-offset: 0.5rem;
131151
}

public/favourite/index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const MS_IN_A_YEAR = MS_IN_A_DAY * 365
66

77
const meettingTime = Date.parse("2024-06-22T23:39:00.000Z")
88
const birthdayTime = +new Date("2024-11-20")
9+
const userAgent = navigator.userAgent.toLowerCase()
910

1011
function getDiffTime({ start, end }) {
1112
const diff = end - start
@@ -55,7 +56,18 @@ function handleTimeElement(element) {
5556
}
5657
}
5758

59+
5860
document.addEventListener('DOMContentLoaded', () => {
61+
62+
if (userAgent.includes('micromessenger')) {
63+
document.body.innerHTML = `
64+
<div class="wechat text">
65+
<span>请使用浏览器打开该网页</span>
66+
<span class="decoration-line">https://www.fwqaq.us/public/favourite/index.html</span>
67+
</div>
68+
`
69+
}
70+
5971
const meettingFunction = handleTimeElement(document.getElementById('meetting'))
6072
const birthdayFunction = handleTimeElement(document.getElementById('birthday'))
6173

0 commit comments

Comments
 (0)