-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18c66a6
commit fca42b6
Showing
5 changed files
with
77 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { getStoreState } from '@redux/configureStore/helper'; | ||
import { SettingType } from '@redux/types/settings'; | ||
import _get from 'lodash/get'; | ||
|
||
/** | ||
* 获取用户设置 | ||
*/ | ||
export function getUserSettings<T extends SettingType>( | ||
field: string, | ||
defaultValue: T | ||
): T { | ||
const state = getStoreState(); | ||
|
||
return (_get(state, ['settings', 'user', field]) as T) ?? defaultValue; | ||
} | ||
|
||
/** | ||
* 获取系统设置 | ||
*/ | ||
export function getSystemSettings<T extends SettingType>( | ||
field: string, | ||
defaultValue: T | ||
): T { | ||
const state = getStoreState(); | ||
|
||
return (_get(state, ['settings', 'system', field]) as T) ?? defaultValue; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
import { DefaultSettings } from '@shared/project.config'; | ||
|
||
type NotificationType = 'granted' | 'denied' | 'default'; | ||
|
||
export interface ServerConfig { | ||
[name: string]: string | boolean | number | string[]; | ||
export type SettingType = string | boolean | number | string[]; | ||
|
||
interface CustomConfig { | ||
[name: string]: SettingType; | ||
} | ||
|
||
export type ServerConfig = CustomConfig; | ||
|
||
export interface SettingsState { | ||
user: any; | ||
system: any; | ||
user: DefaultSettings['user'] & CustomConfig; | ||
system: DefaultSettings['system'] & CustomConfig; | ||
notificationPermission: NotificationType; | ||
config: ServerConfig; // 服务端配置 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters