import { createContext, Component, FunctionComponent } from "react"; import { Emitter } from "@Model/Emitter"; /** * 主题模式 */ enum Themes { light = 1, dark = 2 } class Setting extends Emitter< Setting & {change: keyof Setting} > { /** * 主题 */ public themes: Themes = Themes.light; /** * 设置参数 */ public setProps
(key: P, value: Setting[P]) {
this[key] = value as any;
this.emit("change", key);
this.emit(key as any, value as any);
}
}
interface IMixinSettingProps {
setting?: Setting;
}
const SettingContext = createContext