1
0
Fork 0
tera-wallet/src/utils/dva.ts

36 lines
696 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* @Author: Tuisku
* @Date: 2018-12-03 10:27:38
* @LastEditors: Tuisku
* @LastEditTime: 2018-12-14 09:37:03
* @Description: dva帮助类此文件请勿修改
*/
import { create } from 'dva-core';
import createLoading from 'dva-loading';
let app;
let registered: boolean;
function createApp(opt) {
app = create(opt);
app.use(createLoading({}));
if (!registered) opt.models.forEach(model => app.model(model))
registered = true
app.start();
app.getStore = () => app._store;
app.use({
onError(err) {
console.log(err)
},
})
app.dispatch = app._store.dispatch;
return app;
}
export default {
createApp,
getDispatch() {
return app.dispatch;
}
}