From 57e57f3724688f18386d3f8ecf95fdd5d498c439 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 22 May 2021 16:20:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9B=E5=85=A5=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E8=AF=A6=E6=83=85=E6=AD=8C=E8=AF=8D=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E5=B1=8F=E5=B9=95=E5=B8=B8=E4=BA=AE=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E8=A2=AB=E5=8F=96=E6=B6=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 10 +--------- src/config/globalData.js | 2 ++ src/screens/PlayDetail/Portrait/Player/Lyric.js | 6 ------ src/screens/PlayDetail/Portrait/Player/index.js | 7 +++++++ src/store/modules/common/action.js | 15 +++++++++++---- src/utils/utils.js | 13 +++++++++++-- 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index b12394ffc..d471a6b8b 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,11 +1,3 @@ -### 新增 - -- 新增通过歌单链接打开歌单的功能 - -### 优化 - -- 切换到播放详情歌词界面时将阻止屏幕息屏 - ### 修复 -- 修复一个导致崩溃日志写入文件前会导致APP崩溃的莫名其妙问题 +- 修复进入播放详情歌词界面后的屏幕常亮不会被取消的问题 diff --git a/src/config/globalData.js b/src/config/globalData.js index 3a3bb1714..62e6c2b71 100644 --- a/src/config/globalData.js +++ b/src/config/globalData.js @@ -12,3 +12,5 @@ global.allList = null global.globalObj = null global.listScrollPosition = {} global.listSort = {} + +global.isScreenKeepAwake = false diff --git a/src/screens/PlayDetail/Portrait/Player/Lyric.js b/src/screens/PlayDetail/Portrait/Player/Lyric.js index 874adaf0e..b33535575 100644 --- a/src/screens/PlayDetail/Portrait/Player/Lyric.js +++ b/src/screens/PlayDetail/Portrait/Player/Lyric.js @@ -42,8 +42,6 @@ export default memo(() => { // const imgWidth = useMemo(() => layout.width * 0.75, [layout.width]) const handleScrollToActive = useCallback((index = lineRef.current) => { - screenkeepAwake() - if (scrollViewRef.current && linesRef.current.length) { scrollViewRef.current.scrollToIndex({ index, @@ -51,10 +49,6 @@ export default memo(() => { viewPosition: 0.4, }) } - - return () => { - screenUnkeepAwake() - } }, []) const handleScrollBeginDrag = () => { diff --git a/src/screens/PlayDetail/Portrait/Player/index.js b/src/screens/PlayDetail/Portrait/Player/index.js index 6339800c2..9475ee0d8 100644 --- a/src/screens/PlayDetail/Portrait/Player/index.js +++ b/src/screens/PlayDetail/Portrait/Player/index.js @@ -9,13 +9,20 @@ import { useGetter, useDispatch } from '@/store' import PagerView from 'react-native-pager-view' import Pic from './Pic' import Lyric from './Lyric' +import { screenkeepAwake, screenUnkeepAwake } from '@/utils/utils' +// global.iskeep = false export default memo(() => { const theme = useGetter('common', 'theme') const [pageIndex, setPageIndex] = useState(0) const onPageSelected = useCallback(({ nativeEvent }) => { setPageIndex(nativeEvent.position) + if (nativeEvent.position == 1) { + screenkeepAwake() + } else { + screenUnkeepAwake() + } }, []) const pic = useMemo(() => , []) diff --git a/src/store/modules/common/action.js b/src/store/modules/common/action.js index 8e66e6a59..4a5a9934a 100644 --- a/src/store/modules/common/action.js +++ b/src/store/modules/common/action.js @@ -9,6 +9,7 @@ import { compareVer } from '@/utils' // import { setMaxCache } from '@/plugins/player/utils' import { showVersionModal } from '@/navigation' import { VERSION_STATUS } from '@/config/constant' +import { screenUnkeepAwake } from '@/utils/utils' export const TYPES = { updateSetting: null, @@ -107,10 +108,16 @@ export const setComponentId = data => ({ type: TYPES.setComponentId, payload: data, }) -export const removeComponentId = id => ({ - type: TYPES.removeComponentId, - payload: id, -}) +export const removeComponentId = id => (dispatch, getState) => { + const { common } = getState() + if (common.componentIds.playDetail == id) { + screenUnkeepAwake() + } + dispatch({ + type: TYPES.removeComponentId, + payload: id, + }) +} export const setNavActiveIndex = index => ({ type: TYPES.setNavActiveIndex, diff --git a/src/utils/utils.js b/src/utils/utils.js index ce0ed97d6..de77fbd95 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -9,5 +9,14 @@ export const getSupportedAbis = UtilsModule.getSupportedAbis export const installApk = (filePath, fileProviderAuthority) => UtilsModule.installApk(filePath, fileProviderAuthority) -export const screenkeepAwake = UtilsModule.screenkeepAwake -export const screenUnkeepAwake = UtilsModule.screenUnkeepAwake +export const screenkeepAwake = () => { + if (global.isScreenKeepAwake) return + global.isScreenKeepAwake = true + UtilsModule.screenkeepAwake() +} +export const screenUnkeepAwake = () => { + // console.log('screenUnkeepAwake') + if (!global.isScreenKeepAwake) return + global.isScreenKeepAwake = false + UtilsModule.screenUnkeepAwake() +}