|
|
@@ -134,6 +134,7 @@ interface GeneratedObjectLiteralInterface_1 {
|
|
|
@Preview
|
|
|
@Component
|
|
|
export struct LocalMusic {
|
|
|
+ themeMode: number=0;
|
|
|
@State titleName: string = '首页'
|
|
|
@State textStr: string = ''
|
|
|
// static readonly STR_MUSIC_VIDEO: string = 'Audios';
|
|
|
@@ -170,13 +171,13 @@ export struct LocalMusic {
|
|
|
@State isShowHistory:boolean = true //是否显示最近播放
|
|
|
@State isCustomizeBg: boolean = false //自定义背景界面
|
|
|
@State customizeBgPath: string | undefined = '';
|
|
|
- @State isDarkMode: boolean = AppStorage.get<number>('currentColorMode')===ConfigurationConstant.ColorMode.COLOR_MODE_DARK
|
|
|
+ @State isDarkMode: boolean = false
|
|
|
@StorageProp('currentColorMode') @Watch('onColorModeChange') currentMode: number =
|
|
|
ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT;
|
|
|
|
|
|
|
|
|
onColorModeChange() {
|
|
|
- this.isDarkMode=AppStorage.get<number>('currentColorMode')===ConfigurationConstant.ColorMode.COLOR_MODE_DARK
|
|
|
+ // this.isDarkMode=colorMode===ConfigurationConstant.ColorMode.COLOR_MODE_DARK
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -448,6 +449,28 @@ export struct LocalMusic {
|
|
|
|
|
|
});
|
|
|
this.isCoverRectangle = PreferencesUtil.getBooleanSync(SettingPage.IS_COVER_RECTANGLE, false)
|
|
|
+
|
|
|
+
|
|
|
+ // 读取 themeMode 并同步 currentColorMode
|
|
|
+ this.themeMode = PreferencesUtil.getNumberSync(SettingPage.THEME_MODE, 0)
|
|
|
+ this.applyThemeMode(this.themeMode)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ applyThemeMode(mode: number) {
|
|
|
+ let colorMode = ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET
|
|
|
+ if (mode === 1) {
|
|
|
+ colorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT
|
|
|
+ } else if (mode === 2) {
|
|
|
+ colorMode = ConfigurationConstant.ColorMode.COLOR_MODE_DARK
|
|
|
+ }
|
|
|
+ AppStorage.setOrCreate('currentColorMode', colorMode)
|
|
|
+ AppStorage.setOrCreate('isDarkMode', colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK)
|
|
|
+ PreferencesUtil.putSync(SettingPage.THEME_MODE, mode)
|
|
|
+ AppStorage.setOrCreate('themeMode', mode)
|
|
|
+ // 只有强制浅色/深色时才主动设置
|
|
|
+ const context = getContext(this) as common.UIAbilityContext
|
|
|
+ context.getApplicationContext().setColorMode(colorMode)
|
|
|
}
|
|
|
|
|
|
doChangeSetting(){
|