-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
76 lines (71 loc) · 1.75 KB
/
index.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
import App from './src/index.js';
import mockData from './mock/mock.data';
import mockContextData from './mock/mock.data.context';
const app = new App('log-visual-app', {
useTimestamp: true,
useWrapLines: false,
useContext: true,
maxHeight: 600,
// search: '2052475',
});
const dataSource = mockData.response.data;
// 数组类型
app.setLoading(true);
setTimeout(() => {
app.setState(
[
{
logs: dataSource.result[0].values.slice(0, 100),
stream: dataSource.result[0].stream,
},
{
logs: dataSource.result[0].values.slice(101, 200),
stream: dataSource.result[0].stream,
},
{
logs: dataSource.result[0].values.slice(201, 300),
stream: dataSource.result[0].stream,
},
]
);
app.setLoading(false);
}, 500)
// 对象类型
setTimeout(() => {
console.info('第二次渲染');
app.setState(
{
logs: dataSource.result[0].values,
stream: dataSource.result[0].stream,
},
)
}, 5000);
// setTimeout(() => {
// console.info('第三次渲染');
// app.setState(
// {
// logs: dataSource.result[0].values,
// stream: dataSource.result[0].stream,
// },
// )
// }, 10000);
app.onFilter(function (pubs) {
console.info(pubs);
});
app.regRenderContext(function (render, { log, stream }) {
// 模拟请求上下文
app.setLoading(true);
setTimeout(() => {
console.info(log, stream);
render(mockContextData.prevs, mockContextData.nexts);
app.setLoading(false);
}, 1000);
});
app.regRenderMoreContext(function (render) {
app.setLoading(true);
setTimeout(() => {
render([...mockContextData.prevs, ...mockContextData.nexts], mockContextData.nexts);
app.setLoading(false);
}, 1000);
});
// app.search('2052475');