优化代码

This commit is contained in:
lyswhut 2023-03-30 09:09:34 +08:00
parent b481d0367f
commit b5201495f1
8 changed files with 15 additions and 20 deletions

View File

@ -160,7 +160,7 @@ export const getOnlineOtherSourceMusicUrl = async({ musicInfos, quality, onToggl
if (retryedSource.includes(musicInfo.source)) continue
retryedSource.push(musicInfo.source)
if (!assertApiSupport(musicInfo.source)) continue
itemQuality = quality ?? getPlayQuality(settingState.setting['player.highQuality'], musicInfo)
itemQuality = quality ?? getPlayQuality(settingState.setting['player.isPlayHighQuality'], musicInfo)
if (!musicInfo.meta._qualitys[itemQuality]) continue
console.log('try toggle to: ', musicInfo.source, musicInfo.name, musicInfo.singer, musicInfo.interval)
@ -205,7 +205,7 @@ export const handleGetOnlineMusicUrl = async({ musicInfo, quality, onToggleSourc
isFromCache: boolean
}> => {
// console.log(musicInfo.source)
const targetQuality = quality ?? getPlayQuality(settingState.setting['player.highQuality'], musicInfo)
const targetQuality = quality ?? getPlayQuality(settingState.setting['player.isPlayHighQuality'], musicInfo)
let reqPromise
try {

View File

@ -67,7 +67,7 @@ const getMusicPlayUrl = async(musicInfo: LX.Music.MusicInfo | LX.Download.ListIt
// this.musicInfo.url = await getMusicPlayUrl(targetSong, type)
setStatusText(global.i18n.t('player__geting_url'))
// const type = getPlayType(settingState.setting['player.highQuality'], musicInfo)
// const type = getPlayType(settingState.setting['player.isPlayHighQuality'], musicInfo)
return getMusicUrl({
musicInfo,

View File

@ -106,8 +106,8 @@ export class StateEvent extends Event {
this.emit('componentIdsUpdated', ids)
}
navActiveIdUpdated(index: CommonState['navActiveId']) {
this.emit('navActiveIdUpdated', index)
navActiveIdUpdated(id: CommonState['navActiveId']) {
this.emit('navActiveIdUpdated', id)
}
sourceNamesUpdated(names: CommonState['sourceNames']) {

View File

@ -5,23 +5,22 @@ import { Icon } from '@/components/common/Icon'
import { pop } from '@/navigation'
// import { AppColors } from '@/theme'
import StatusBar from '@/components/common/StatusBar'
import { useComponentIds } from '@/store/common/hook'
import { useI18n } from '@/lang'
import { createStyle } from '@/utils/tools'
import Text from '@/components/common/Text'
import { HEADER_HEIGHT as _HEADER_HEIGHT } from '@/config/constant'
import { scaleSizeH } from '@/utils/pixelRatio'
import commonState from '@/store/common/state'
const HEADER_HEIGHT = scaleSizeH(_HEADER_HEIGHT)
export default memo(({ musicInfo }: {
musicInfo: LX.Music.MusicInfo
}) => {
const componentIds = useComponentIds()
const t = useI18n()
const back = () => {
void pop(componentIds.comment as string)
void pop(commonState.componentIds.comment as string)
}
return (

View File

@ -31,7 +31,7 @@ export default () => {
// setWidth(getWindowSise().width * 0.82)
global.app_event.on('homeNavPagerChanged', handleFixDrawer)
global.state_event.on('navActiveIdUpdated', handleFixDrawer)
global.app_event.on('changeLoveListVisible', changeVisible)
// 就放旋转屏幕后的宽度没有更新的问题
@ -43,7 +43,7 @@ export default () => {
// })
return () => {
global.app_event.off('homeNavPagerChanged', handleFixDrawer)
global.state_event.off('navActiveIdUpdated', handleFixDrawer)
global.app_event.off('changeLoveListVisible', changeVisible)
// changeEvent.remove()
}

View File

@ -27,12 +27,12 @@ export default () => {
drawer.current?.closeDrawer()
}
global.app_event.on('homeNavPagerChanged', handleFixDrawer)
global.state_event.on('navActiveIdUpdated', handleFixDrawer)
global.app_event.on('showSonglistTagList', handleShow)
global.app_event.on('hideSonglistTagList', handleHide)
return () => {
global.app_event.off('homeNavPagerChanged', handleFixDrawer)
global.state_event.off('navActiveIdUpdated', handleFixDrawer)
global.app_event.off('showSonglistTagList', handleShow)
global.app_event.off('hideSonglistTagList', handleHide)
}

View File

@ -1,14 +1,12 @@
import React from 'react'
import Btn from './Btn'
import { useComponentIds } from '@/store/common/hook'
import { navigations } from '@/navigation'
import commonState from '@/store/common/state'
export default () => {
const componentIds = useComponentIds()
const handleShowCommentScreen = () => {
navigations.pushCommentScreen(componentIds.playDetail as string)
navigations.pushCommentScreen(commonState.componentIds.playDetail as string)
}
return <Btn icon="comment" onPress={handleShowCommentScreen} />

View File

@ -1,14 +1,12 @@
import React from 'react'
import Btn from './Btn'
import { useComponentIds } from '@/store/common/hook'
import { navigations } from '@/navigation'
import commonState from '@/store/common/state'
export default () => {
const componentIds = useComponentIds()
const handleShowCommentScreen = () => {
navigations.pushCommentScreen(componentIds.playDetail as string)
navigations.pushCommentScreen(commonState.componentIds.playDetail as string)
}
return <Btn icon="comment" onPress={handleShowCommentScreen} />