fix: support comment tags coloring in dark mode. closes #880 (#897)

* fix: bilibili comment theme color

* cleanup

* fix: spinner bg color

* refactor: adjust theme color timer logic

* fix: comment tags still show a light color when page is first loaded

* chore: remove unused import in useDark.ts

---------

Co-authored-by: Hakadao <a578457889743@gmail.com>
This commit is contained in:
star knight
2024-07-14 23:57:00 +08:00
committed by GitHub
parent 3e5fa7a805
commit 3312d809fa
3 changed files with 48 additions and 0 deletions

14
src/utils/timer.ts Normal file
View File

@@ -0,0 +1,14 @@
export function executeTimes(fn: () => void | Promise<void>, times: number, interval: number = 1000) {
let count = 0
let timer: NodeJS.Timeout
// eslint-disable-next-line prefer-const
timer = setInterval(async () => {
await fn()
count++
if (count >= times) {
clearInterval(timer)
}
}, interval)
return timer
}