-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
338af09
commit 350371d
Showing
10 changed files
with
160 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import tinycon from 'tinycon'; | ||
|
||
/** | ||
* 设置小红点 | ||
* @param num 小红点数 | ||
*/ | ||
let bubbleNum = 0; | ||
export function setBubble(num: number) { | ||
bubbleNum = num; | ||
if (num < 0) { | ||
num = 0; | ||
} | ||
tinycon.setBubble(num >= 100 ? 99 : num); | ||
} | ||
|
||
/** | ||
* 增加小红点数量 | ||
*/ | ||
export function incBubble() { | ||
setBubble(bubbleNum + 1); | ||
} | ||
|
||
const hiddenProperty = | ||
'hidden' in document | ||
? 'hidden' | ||
: 'webkitHidden' in document | ||
? 'webkitHidden' | ||
: 'mozHidden' in document | ||
? 'mozHidden' | ||
: null; | ||
const visibilityChangeEvent = hiddenProperty?.replace( | ||
/hidden/i, | ||
'visibilitychange' | ||
); | ||
const onVisibilityChange = function () { | ||
if (!document[hiddenProperty ?? '']) { | ||
// 显示标签页时清空 | ||
tinycon.setBubble(0); | ||
} else { | ||
// 隐藏标签页 | ||
} | ||
}; | ||
if (typeof visibilityChangeEvent === 'string') { | ||
document.addEventListener(visibilityChangeEvent, onVisibilityChange); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "./src", | ||
"esModuleInterop": true, | ||
"jsx": "react", | ||
"paths": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.