mirror of
https://github.com/ikun0014/lx-music-mobile.git
synced 2025-07-04 16:08:54 +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 { init as initLyric, toggleTranslation } from '@/utils/lyric'
|
||||||
import { showLyric, onPositionChange } from '@/utils/lyricDesktop'
|
import { showLyric, onPositionChange } from '@/utils/lyricDesktop'
|
||||||
import { init as initI18n, supportedLngs } from '@/plugins/i18n'
|
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 { LIST_ID_PLAY_TEMP } from '@/config/constant'
|
||||||
import { connect, SYNC_CODE } from '@/plugins/sync'
|
import { connect, SYNC_CODE } from '@/plugins/sync'
|
||||||
|
|
||||||
@ -127,6 +127,8 @@ const init = () => {
|
|||||||
|
|
||||||
initNavigation(() => {
|
initNavigation(() => {
|
||||||
init().then(() => {
|
init().then(() => {
|
||||||
|
if (getIsSupportedAutoTheme()) store.dispatch(commonAction.setSystemColor(getAppearance()))
|
||||||
|
|
||||||
return navigations.pushHomeScreen().then(() => {
|
return navigations.pushHomeScreen().then(() => {
|
||||||
SplashScreen.hide()
|
SplashScreen.hide()
|
||||||
if (store.getState().common.setting.isAgreePact) {
|
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 => {
|
export const onAppearanceChange = callback => {
|
||||||
callback(Appearance.getColorScheme())
|
|
||||||
return Appearance.addChangeListener(({ colorScheme }) => {
|
return Appearance.addChangeListener(({ colorScheme }) => {
|
||||||
callback(colorScheme)
|
callback(colorScheme)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let isSupportedAutoTheme = null
|
||||||
export const getIsSupportedAutoTheme = () => {
|
export const getIsSupportedAutoTheme = () => {
|
||||||
|
if (isSupportedAutoTheme == null) {
|
||||||
const osVerNum = parseInt(osVer)
|
const osVerNum = parseInt(osVer)
|
||||||
return isAndroid
|
isSupportedAutoTheme = isAndroid
|
||||||
? osVerNum >= 10
|
? osVerNum >= 10
|
||||||
: osVerNum >= 13
|
: osVerNum >= 13
|
||||||
|
}
|
||||||
|
return isSupportedAutoTheme
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user