|
@@ -17,13 +17,19 @@ const defaultTab: State[0] = {key: '-1', url: '/main', label: '首页'};
|
|
|
|
|
|
function reducer(state: State, action: Action): State {
|
|
|
const {type} = action;
|
|
|
- const {key, dispatch} = tabStore.getState();
|
|
|
+ const {key, dispatch: update} = tabStore.getState();
|
|
|
+
|
|
|
+ // 防止react devtool报错
|
|
|
+ function dispatch(key: string) {
|
|
|
+ Promise.resolve().then(() => update(key));
|
|
|
+ }
|
|
|
|
|
|
switch (type) {
|
|
|
case 'ADD': {
|
|
|
const {payload} = action;
|
|
|
-
|
|
|
- dispatch(payload.key);
|
|
|
+ setTimeout(function () {
|
|
|
+ dispatch(payload.key);
|
|
|
+ }, 0);
|
|
|
|
|
|
const exist = state.find(val => val.key === payload.key);
|
|
|
if (exist) {
|