UNPKG

1.47 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 const initialState = (() => {
46 if (__CLIENT__) return window.__REDUX_STATE__
47 if (__SERVER__) return {}
48})()
49
50//
51
52/**
53 * @type {Array}
54 */
55export const middlewares = [
56 thunk,
57 routerMiddleware(history),
58]