12-23-上传master

This commit is contained in:
xingsy
2020-12-23 11:14:35 +08:00
parent 9769f83bc8
commit b42e0c1ddd
553 changed files with 56506 additions and 0 deletions

37
src/models/setting.ts Normal file
View File

@ -0,0 +1,37 @@
import { Reducer } from 'umi';
import defaultSettings, { DefaultSettings } from '../../config/defaultSettings';
export interface SettingModelType {
namespace: 'settings';
state: DefaultSettings;
reducers: {
changeSetting: Reducer<DefaultSettings>;
};
}
const updateColorWeak: (colorWeak: boolean) => void = (colorWeak) => {
const root = document.getElementById('root');
if (root) {
root.className = colorWeak ? 'colorWeak' : '';
}
};
const SettingModel: SettingModelType = {
namespace: 'settings',
state: defaultSettings,
reducers: {
changeSetting(state = defaultSettings, { payload }) {
const { colorWeak, contentWidth } = payload;
if (state.contentWidth !== contentWidth && window.dispatchEvent) {
window.dispatchEvent(new Event('resize'));
}
updateColorWeak(!!colorWeak);
return {
...state,
...payload,
};
},
},
};
export default SettingModel;