mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-04 06:42:09 +08:00
修复自动切换主题问题
This commit is contained in:
parent
23a7795743
commit
c7ee043ba2
4
index.js
4
index.js
@ -19,7 +19,7 @@ import { init as initMusicTools } from '@/utils/music'
|
||||
import { init as initLyric, toggleTranslation } from '@/utils/lyric'
|
||||
import { showLyric, onPositionChange } from '@/utils/lyricDesktop'
|
||||
import { init as initI18n, supportedLngs } from '@/plugins/i18n'
|
||||
import { deviceLanguage, getPlayInfo, toast, onAppearanceChange, getIsSupportedAutoTheme } from '@/utils/tools'
|
||||
import { deviceLanguage, getPlayInfo, toast, onAppearanceChange, getIsSupportedAutoTheme, getAppearance } from '@/utils/tools'
|
||||
import { LIST_ID_PLAY_TEMP } from '@/config/constant'
|
||||
import { connect, SYNC_CODE } from '@/plugins/sync'
|
||||
|
||||
@ -127,6 +127,8 @@ const init = () => {
|
||||
|
||||
initNavigation(() => {
|
||||
init().then(() => {
|
||||
if (getIsSupportedAutoTheme()) store.dispatch(commonAction.setSystemColor(getAppearance()))
|
||||
|
||||
return navigations.pushHomeScreen().then(() => {
|
||||
SplashScreen.hide()
|
||||
if (store.getState().common.setting.isAgreePact) {
|
||||
|
@ -377,18 +377,25 @@ export const shareMusic = (shareType, downloadFileName, musicInfo) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const getAppearance = () => {
|
||||
return Appearance.getColorScheme()
|
||||
}
|
||||
|
||||
export const onAppearanceChange = callback => {
|
||||
callback(Appearance.getColorScheme())
|
||||
return Appearance.addChangeListener(({ colorScheme }) => {
|
||||
callback(colorScheme)
|
||||
})
|
||||
}
|
||||
|
||||
let isSupportedAutoTheme = null
|
||||
export const getIsSupportedAutoTheme = () => {
|
||||
if (isSupportedAutoTheme == null) {
|
||||
const osVerNum = parseInt(osVer)
|
||||
return isAndroid
|
||||
isSupportedAutoTheme = isAndroid
|
||||
? osVerNum >= 10
|
||||
: osVerNum >= 13
|
||||
}
|
||||
return isSupportedAutoTheme
|
||||
}
|
||||
|
||||
export {
|
||||
|
Loading…
x
Reference in New Issue
Block a user