UNPKG

2.09 kBJavaScriptView Raw
1/* global
2 __KOOT_STORE__:false,
3 __KOOT_HISTORY__:false,
4 __KOOT_LOCALEID__:false,
5*/
6
7/**
8 * 手动创建 Redux Store 时需要的相关对象
9 * @type {Object}
10 */
11import * as reduxForCreateStore from './React/redux'
12export { reduxForCreateStore }
13
14/**
15 * 通用的高阶组件/方法的装饰器
16 * @type {Function}
17 */
18export { default as extend } from "__KOOT_HOC_EXTEND__"
19
20// 其他全局变量
21export const getLocaleId = () => {
22 if (__CLIENT__)
23 return window.__KOOT_LOCALEID__ || ''
24 if (__SERVER__) {
25 if (__DEV__)
26 return global.__KOOT_LOCALEID__
27 if (typeof __KOOT_LOCALEID__ === 'undefined')
28 return ''
29 return __KOOT_LOCALEID__ || ''
30 }
31}
32export const resetLocaleId = () => localeId = getLocaleId()
33export let localeId = (() => getLocaleId())()
34
35export const getStore = () => {
36 if (__CLIENT__)
37 return window.__KOOT_STORE__
38 if (__SERVER__) {
39 if (__DEV__)
40 return global.__KOOT_STORE__
41 if (typeof __KOOT_STORE__ === 'undefined')
42 return ''
43 return __KOOT_STORE__
44 }
45}
46export const resetStore = () => store = getStore()
47export let store = (() => getStore())()
48
49export const getHistory = () => {
50 if (__CLIENT__)
51 return window.__KOOT_HISTORY__
52 if (__SERVER__) {
53 if (__DEV__)
54 return global.__KOOT_HISTORY__
55 if (typeof __KOOT_HISTORY__ === 'undefined')
56 return ''
57 return __KOOT_HISTORY__
58 }
59}
60export const resetHistory = () => history = getHistory()
61export let history = (() => getHistory())()
62
63if (__DEV__) {
64 global.__KOOT_SSR_SET__ = v => {
65 global.__KOOT_SSR__ = v
66 }
67 global.__KOOT_SSR_SET_LOCALEID__ = v => {
68 global.__KOOT_LOCALEID__ = v
69 localeId = v
70 }
71 global.__KOOT_SSR_SET_STORE__ = v => {
72 global.__KOOT_STORE__ = v
73 store = v
74 }
75 global.__KOOT_SSR_SET_HISTORY__ = v => {
76 global.__KOOT_HISTORY__ = v
77 history = v
78 }
79}