Skip to content

Commit 182db7c

Browse files
committed
feat: adjust notice banner
Signed-off-by: Innei <tukon479@gmail.com>
1 parent e2baef5 commit 182db7c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/pages/notes/[id].tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,24 @@ const NoteView: React.FC<{ id: string }> = memo((props) => {
179179
}).format(secretDate)
180180
: ''
181181
useEffect(() => {
182+
console.log(
183+
'sc',
184+
+secretDate,
185+
+new Date(),
186+
secretDate,
187+
+secretDate - +new Date(),
188+
)
189+
182190
let timer: any
183-
if (isSecret) {
191+
const timeout = +secretDate - +new Date()
192+
// https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values
193+
const MAX_TIMEOUT = (2 ^ 31) - 1
194+
if (isSecret && timeout && timeout < MAX_TIMEOUT) {
184195
timer = setTimeout(() => {
185196
message.info('刷新以查看解锁的文章', 10e3)
186-
}, +secretDate - +new Date())
197+
}, timeout)
187198
}
199+
188200
return () => {
189201
clearTimeout(timer)
190202
}
@@ -215,9 +227,9 @@ const NoteView: React.FC<{ id: string }> = memo((props) => {
215227
})}
216228
<NoteLayout title={title} date={note.created} tips={tips} id={note.id}>
217229
{isSecret && !isLogged ? (
218-
<p className="text-center my-8">
230+
<Banner type="warning" className="mt-4">
219231
这篇文章暂时没有公开呢,将会在 {dateFormat} 解锁,再等等哦
220-
</p>
232+
</Banner>
221233
) : (
222234
<ImageSizeMetaContext.Provider value={imageSizeProviderValue}>
223235
{isSecret && (

0 commit comments

Comments
 (0)