Skip to content

Commit

Permalink
feat: adjust notice banner
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Apr 9, 2023
1 parent e2baef5 commit 182db7c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/pages/notes/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,24 @@ const NoteView: React.FC<{ id: string }> = memo((props) => {
}).format(secretDate)
: ''
useEffect(() => {
console.log(
'sc',
+secretDate,
+new Date(),
secretDate,
+secretDate - +new Date(),
)

let timer: any
if (isSecret) {
const timeout = +secretDate - +new Date()
// https://stackoverflow.com/questions/3468607/why-does-settimeout-break-for-large-millisecond-delay-values
const MAX_TIMEOUT = (2 ^ 31) - 1
if (isSecret && timeout && timeout < MAX_TIMEOUT) {
timer = setTimeout(() => {
message.info('刷新以查看解锁的文章', 10e3)
}, +secretDate - +new Date())
}, timeout)
}

return () => {
clearTimeout(timer)
}
Expand Down Expand Up @@ -215,9 +227,9 @@ const NoteView: React.FC<{ id: string }> = memo((props) => {
})}
<NoteLayout title={title} date={note.created} tips={tips} id={note.id}>
{isSecret && !isLogged ? (
<p className="text-center my-8">
<Banner type="warning" className="mt-4">
这篇文章暂时没有公开呢,将会在 {dateFormat} 解锁,再等等哦
</p>
</Banner>
) : (
<ImageSizeMetaContext.Provider value={imageSizeProviderValue}>
{isSecret && (
Expand Down

0 comments on commit 182db7c

Please sign in to comment.