(props: SettingProps)
| 40 | }; |
| 41 | |
| 42 | function Setting(props: SettingProps) { |
| 43 | const { visible, onClose } = props; |
| 44 | |
| 45 | const action = useAction(); |
| 46 | const soundSwitch = useSelector((state: State) => state.status.soundSwitch); |
| 47 | const notificationSwitch = useSelector( |
| 48 | (state: State) => state.status.notificationSwitch, |
| 49 | ); |
| 50 | const voiceSwitch = useSelector((state: State) => state.status.voiceSwitch); |
| 51 | const selfVoiceSwitch = useSelector( |
| 52 | (state: State) => state.status.selfVoiceSwitch, |
| 53 | ); |
| 54 | const sound = useSelector((state: State) => state.status.sound); |
| 55 | const theme = useSelector((state: State) => state.status.theme); |
| 56 | const primaryColor = useSelector( |
| 57 | (state: State) => state.status.primaryColor, |
| 58 | ); |
| 59 | const primaryTextColor = useSelector( |
| 60 | (state: State) => state.status.primaryTextColor, |
| 61 | ); |
| 62 | const backgroundImage = useSelector( |
| 63 | (state: State) => state.status.backgroundImage, |
| 64 | ); |
| 65 | const aero = useSelector((state: State) => state.status.aero); |
| 66 | const userId = useSelector((state: State) => state.user?._id); |
| 67 | const tagColorMode = useSelector( |
| 68 | (state: State) => state.status.tagColorMode, |
| 69 | ); |
| 70 | const enableSearchExpression = useSelector( |
| 71 | (state: State) => state.status.enableSearchExpression, |
| 72 | ); |
| 73 | |
| 74 | const [backgroundLoading, toggleBackgroundLoading] = useState(false); |
| 75 | |
| 76 | function setTheme(themeName: string) { |
| 77 | action.setStatus('theme', themeName); |
| 78 | // @ts-ignore |
| 79 | const themeConfig = themes[themeName]; |
| 80 | if (themeConfig) { |
| 81 | action.setStatus('primaryColor', themeConfig.primaryColor); |
| 82 | action.setStatus('primaryTextColor', themeConfig.primaryTextColor); |
| 83 | action.setStatus('backgroundImage', themeConfig.backgroundImage); |
| 84 | action.setStatus('aero', themeConfig.aero); |
| 85 | setCssVariable( |
| 86 | themeConfig.primaryColor, |
| 87 | themeConfig.primaryTextColor, |
| 88 | ); |
| 89 | window.localStorage.removeItem(LocalStorageKey.PrimaryColor); |
| 90 | window.localStorage.removeItem(LocalStorageKey.PrimaryTextColor); |
| 91 | window.localStorage.removeItem(LocalStorageKey.BackgroundImage); |
| 92 | window.localStorage.removeItem(LocalStorageKey.Aero); |
| 93 | Message.success('已修改主题'); |
| 94 | } else { |
| 95 | window.localStorage.setItem( |
| 96 | LocalStorageKey.PrimaryColor, |
| 97 | primaryColor, |
| 98 | ); |
| 99 | window.localStorage.setItem( |
nothing calls this directly
no test coverage detected