-
Notifications
You must be signed in to change notification settings - Fork 9
/
App.tsx
41 lines (39 loc) · 1.29 KB
/
App.tsx
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
import {alert, confirm, toast} from 'amis';
import copy from 'copy-to-clipboard';
// import {Provider} from 'mobx-react';
import React from 'react';
import RootRoute from './route/index';
import {Provider, MainStore} from './store/index';
import {fetcher, isCancel} from './utils/fetcher';
import 'amis/scss/helper.scss';
function initializeStore() {
const store = ((window as any).store = MainStore.create(
{},
{
fetcher,
isCancel,
notify: (type: 'success' | 'error' | 'info', msg: string) => {
toast[type]
? toast[type](msg, type === 'error' ? '系统错误' : '系统消息')
: console.warn('[Notify]', type, msg);
console.log('[notify]', type, msg);
},
alert,
confirm,
copy: (contents: string, options: any = {}) => {
const ret = copy(contents, options);
ret && (!options || options.shutup !== true) && toast.info('内容已拷贝到剪切板');
return ret;
}
}
));
return store;
}
export default function (): JSX.Element {
const store = initializeStore();
return (
<Provider value={store}>
<RootRoute />
</Provider>
);
}