|
|
@ -6,8 +6,8 @@ export interface SettingModelType { |
|
|
namespace: 'settings'; |
|
|
namespace: 'settings'; |
|
|
state: DefaultSettings; |
|
|
state: DefaultSettings; |
|
|
reducers: { |
|
|
reducers: { |
|
|
getSetting: Reducer<any>; |
|
|
getSetting: Reducer<DefaultSettings>; |
|
|
changeSetting: Reducer<any>; |
|
|
changeSetting: Reducer<DefaultSettings>; |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
let lessNodesAppended: boolean; |
|
|
let lessNodesAppended: boolean; |
|
|
@ -72,7 +72,7 @@ const updateTheme: (primaryColor?: string) => void = primaryColor => { |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
const updateColorWeak: (colorWeak: string) => void = colorWeak => { |
|
|
const updateColorWeak: (colorWeak: boolean) => void = colorWeak => { |
|
|
const root = document.getElementById('root'); |
|
|
const root = document.getElementById('root'); |
|
|
if (root) { |
|
|
if (root) { |
|
|
root.className = colorWeak ? 'colorWeak' : ''; |
|
|
root.className = colorWeak ? 'colorWeak' : ''; |
|
|
@ -83,8 +83,8 @@ const SettingModel: SettingModelType = { |
|
|
namespace: 'settings', |
|
|
namespace: 'settings', |
|
|
state: defaultSettings, |
|
|
state: defaultSettings, |
|
|
reducers: { |
|
|
reducers: { |
|
|
getSetting(state) { |
|
|
getSetting(state = defaultSettings) { |
|
|
const setting: any = {}; |
|
|
const setting: Partial<DefaultSettings> = {}; |
|
|
const urlParams = new URL(window.location.href); |
|
|
const urlParams = new URL(window.location.href); |
|
|
Object.keys(state).forEach(key => { |
|
|
Object.keys(state).forEach(key => { |
|
|
if (urlParams.searchParams.has(key)) { |
|
|
if (urlParams.searchParams.has(key)) { |
|
|
@ -97,13 +97,13 @@ const SettingModel: SettingModelType = { |
|
|
if (state.primaryColor !== primaryColor) { |
|
|
if (state.primaryColor !== primaryColor) { |
|
|
updateTheme(primaryColor); |
|
|
updateTheme(primaryColor); |
|
|
} |
|
|
} |
|
|
updateColorWeak(colorWeak); |
|
|
updateColorWeak(!!colorWeak); |
|
|
return { |
|
|
return { |
|
|
...state, |
|
|
...state, |
|
|
...setting, |
|
|
...setting, |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
changeSetting(state, { payload }) { |
|
|
changeSetting(state = defaultSettings, { payload }) { |
|
|
const urlParams = new URL(window.location.href); |
|
|
const urlParams = new URL(window.location.href); |
|
|
Object.keys(defaultSettings).forEach(key => { |
|
|
Object.keys(defaultSettings).forEach(key => { |
|
|
if (urlParams.searchParams.has(key)) { |
|
|
if (urlParams.searchParams.has(key)) { |
|
|
|