UNPKG

1.43 kBJavaScriptView Raw
1import { routerReducer, routerMiddleware } from 'react-router-redux'
2import thunk from 'redux-thunk'
3import {
4 reducer as realtimeLocationReducer,
5 REALTIME_LOCATION_REDUCER_NAME,
6} from './realtime-location'
7import { SERVER_REDUCER_NAME, serverReducer } from '../ReactApp/server/redux'
8import {
9 reducerLocaleId as i18nReducerLocaleId,
10 // reducerLocales as i18nReducerLocales,
11} from '../i18n/redux'
12import isI18nEnabled from '../i18n/is-enabled'
13// import history from "__KOOT_CLIENT_REQUIRE_HISTORY__"
14import history from "./history"
15// const getHistory = () => {
16// if (__SPA__) {
17// return require('react-router/lib/hashHistory')
18// }
19// return require('react-router/lib/browserHistory')
20// }
21
22//
23
24/**
25 * @type {Array}
26 */
27export const reducers = {
28 // 路由状态扩展
29 'routing': routerReducer,
30 // 目的:新页面请求处理完成后再改变URL
31 [REALTIME_LOCATION_REDUCER_NAME]: realtimeLocationReducer,
32 // 对应服务器生成的store
33 [SERVER_REDUCER_NAME]: serverReducer,
34}
35if (isI18nEnabled()) {
36 reducers.localeId = i18nReducerLocaleId
37 // reducers.locales = i18nReducerLocales
38}
39
40//
41
42/**
43 * @type {Object}
44 */
45export let initialState = {}
46if (__CLIENT__) initialState = window.__REDUX_STATE__
47
48//
49
50/**
51 * @type {Array}
52 */
53export const middlewares = [
54 thunk,
55 routerMiddleware(history),
56]