/
App.js
156 lines (152 loc) · 4.25 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import React, { Component } from 'react';
import Markdown from './components/Markdown';
import GithubCorner from './components/GithubCorner';
import DocumentStr from './doc.md';
import GithubShields from './components/GithubShields';
import Button from './components/Button';
import Footer from './components/Footer';
import styles from './styles/index.less';
import './styles/reset.less';
import Notify from '../src/main';
import notifyImg from './assets/iNotify.png';
import mp4 from './assets/msg.mp4';
import mp3 from './assets/msg.mp3';
import wav from './assets/msg.wav';
export default class App extends Component {
constructor() {
super();
this.state = {
button: [
{
label: '弹出框',
onClick: () => {
this.iN.notify({
title: '欢迎使用iNotify',
body: '你正在打开 iNotify 官网!',
});
},
},
{
label: '播放声音',
onClick: () => {
this.iN.player();
},
},
{
label: '停止播放声音',
onClick: () => {
this.iN.stopPlay();
},
},
{
label: '清除标题闪烁',
onClick: () => {
this.iN.setTitle();
},
},
{
label: '播放闪烁动画',
onClick: () => {
this.iN.setTitle(true);
},
},
{
label: '闪烁标题提示',
onClick: () => {
this.iN.setTitle('新消息');
},
},
{
label: '消息数',
onClick: () => {
const num = Math.floor(Math.random() * 10) || 2;
this.iN.faviconClear().setFavicon(num + 1);
},
},
{
label: '清空消息数',
onClick: () => {
this.iN.faviconClear();
},
},
{
label: 'Favicon 字体颜色',
onClick: () => {
this.iN.setFaviconColor('#0043ff');
},
},
{
label: 'Favicon 背景颜色',
onClick: () => {
this.iN.setFaviconColor('#f5ff00').setFaviconBackgroundColor('red');
},
},
],
};
}
componentDidMount() {
this.iN = new Notify({
effect: 'flash',
interval: 500,
message: '有消息拉!2',
audio: {
file: [mp4, mp3, wav],
},
notification: {
title: '通知!',
body: '您来了一条新消息',
},
});
this.iN.setTitle('新标题')
.notify({
title: '欢迎使用iNotify',
body: '你正在打开 iNotify 官网!',
})
.player();
}
render() {
const { button } = this.state;
return (
<div className={styles.wapper}>
<GithubCorner url="https://github.com/jaywcjlove/iNotify" />
<div className={styles.panel}>
<h1>
iNotify
</h1>
<div className={styles.button}>
{button.map((item, key) => {
return (
<Button key={key} onClick={item.onClick}>
{item.label}
</Button>
);
})}
</div>
<img src={notifyImg} alt="iNotify" />
</div>
<Markdown source={DocumentStr} />
<GithubShields
source={[
{
href: 'https://github.com/jaywcjlove/iNotify/stargazers',
img: 'https://img.shields.io/github/stars/jaywcjlove/iNotify.svg?style=social',
},
{
href: 'https://github.com/jaywcjlove/iNotify/network',
img: 'https://img.shields.io/github/forks/jaywcjlove/iNotify.svg?style=social',
},
{
href: 'https://github.com/jaywcjlove/iNotify/watchers',
img: 'https://img.shields.io/github/watchers/jaywcjlove/iNotify.svg?style=social&label=Watch',
},
{
href: 'https://github.com/jaywcjlove/followers',
img: 'https://img.shields.io/github/followers/jaywcjlove.svg?style=social',
},
]}
/>
<Footer name="Kenny Wong" href="http://jaywcjlove.github.io" year="2015-present" />
</div>
);
}
}