From 154a6ca062ee21c7bd5946927ccdaa540d4748da Mon Sep 17 00:00:00 2001 From: lyswhut Date: Thu, 30 May 2024 12:53:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9E=84=E5=BB=BA=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-test.yml | 28 +++++++++++++++++++ package.json | 1 + .../MetadataEditModal/MetadataForm.tsx | 4 +-- .../common/ChoosePath/components/Header.tsx | 2 +- src/components/common/Popup.tsx | 2 +- src/plugins/storage.ts | 2 ++ .../Home/Views/Mylist/MusicList/index.tsx | 2 +- src/screens/Home/index.tsx | 2 +- src/screens/PlayDetail/Horizontal/Lyric.tsx | 8 +++--- src/screens/PlayDetail/Vertical/Lyric.tsx | 8 +++--- src/screens/PlayDetail/Vertical/Pic.tsx | 2 +- .../PlayDetail/components/PlayLine.tsx | 2 +- src/screens/SonglistDetail/MusicList.tsx | 2 +- src/utils/hooks/useAnimateColor.ts | 2 ++ src/utils/hooks/useAnimateNumber.ts | 3 ++ 15 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/build-test.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 000000000..0a11130ff --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,28 @@ +name: Run build test + +on: + pull_request: + branches: + - dev + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Check out git repository + uses: actions/checkout@v4 + + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install Dependencies + run: npm ci + + - name: Eslint check + run: npm run lint + + - name: Test Build + run: npm run build-test diff --git a/package.json b/package.json index 2eb264559..fb136942d 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "rd": "react-devtools", "menu": "adb shell input keyevent 82", "bundle-android": "react-native bundle --platform android --dev true --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res", + "build-test": "react-native bundle --platform android --dev true --entry-file index.js --bundle-output index.android.bundle --assets-dest res", "pack:android:debug": "./gradlew assembleDebug", "pack": "npm run pack:android", "pack:android": "cd android && gradlew.bat assembleRelease", diff --git a/src/components/MetadataEditModal/MetadataForm.tsx b/src/components/MetadataEditModal/MetadataForm.tsx index e912bd2a2..f90b20450 100644 --- a/src/components/MetadataEditModal/MetadataForm.tsx +++ b/src/components/MetadataEditModal/MetadataForm.tsx @@ -126,7 +126,7 @@ export default forwardRef((props, ref) => { }).finally(() => { matcheingPic.delete(path) }) - }, [data.albumName, data.name, data.singer, t]) + }, [data.albumName, data.interval, data.name, data.singer, isUnmounted, t]) const handleOnlineMatchLyric = useCallback(() => { let path = filePath.current if (matcheingLrc.has(path)) return @@ -164,7 +164,7 @@ export default forwardRef((props, ref) => { }).finally(() => { matcheingLrc.delete(path) }) - }, [data.albumName, data.name, data.singer, t]) + }, [data.albumName, data.interval, data.name, data.singer, isUnmounted, t]) const handleUpdatePic = useCallback((path: string) => { setData(data => { return { ...data, pic: path } diff --git a/src/components/common/ChoosePath/components/Header.tsx b/src/components/common/ChoosePath/components/Header.tsx index bcd3df48f..f93be8b9a 100644 --- a/src/components/common/ChoosePath/components/Header.tsx +++ b/src/components/common/ChoosePath/components/Header.tsx @@ -42,7 +42,7 @@ export default memo(({ }, []) useEffect(() => { checkExternalStoragePath() - }, []) + }, [checkExternalStoragePath]) const refresh = () => { void onRefreshDir(path) diff --git a/src/components/common/Popup.tsx b/src/components/common/Popup.tsx index 479271c4c..8d22cea66 100644 --- a/src/components/common/Popup.tsx +++ b/src/components/common/Popup.tsx @@ -166,7 +166,7 @@ export default forwardRef(({ }, ] as const } - }, [position]) + }, [position, statusBarHeight]) return ( diff --git a/src/plugins/storage.ts b/src/plugins/storage.ts index 91fa8851a..1fcf30ce3 100644 --- a/src/plugins/storage.ts +++ b/src/plugins/storage.ts @@ -24,6 +24,8 @@ const buildData = (key: string, value: any, datas: Array<[string, string]>) => { datas.push([key, partKeyArrPrefix + JSON.stringify(partKeys)]) } +// 1.4.0 之前的数据分片存储方式,存在key的内容与分隔符冲突的问题 +// 1.4.0 开始改用数组存储,不再使用分隔符的方式 const handleGetDataOld = async(partKeys: string): Promise => { const keys = partKeys.replace(partKeyPrefixRxp, '').split(keySplit) diff --git a/src/screens/Home/Views/Mylist/MusicList/index.tsx b/src/screens/Home/Views/Mylist/MusicList/index.tsx index 3afa505ee..c3d5ffa4b 100644 --- a/src/screens/Home/Views/Mylist/MusicList/index.tsx +++ b/src/screens/Home/Views/Mylist/MusicList/index.tsx @@ -87,7 +87,7 @@ export default () => { const handleScrollToInfo = useCallback((info: LX.Music.MusicInfo) => { listRef.current?.scrollToInfo(info) handleExitSearch() - }, []) + }, [handleExitSearch]) const onLayout = useCallback((e: LayoutChangeEvent) => { layoutHeightRef.current = e.nativeEvent.layout.height }, []) diff --git a/src/screens/Home/index.tsx b/src/screens/Home/index.tsx index 0180bbd21..43c2bdc73 100644 --- a/src/screens/Home/index.tsx +++ b/src/screens/Home/index.tsx @@ -23,7 +23,7 @@ export default ({ componentId }: Props) => { if (settingState.setting['player.startupPushPlayDetailScreen']) { navigations.pushPlayDetailScreen(componentId, true) } - }, []) + }, [componentId]) return ( diff --git a/src/screens/PlayDetail/Horizontal/Lyric.tsx b/src/screens/PlayDetail/Horizontal/Lyric.tsx index 60857f49c..eb9f47d45 100644 --- a/src/screens/PlayDetail/Horizontal/Lyric.tsx +++ b/src/screens/PlayDetail/Horizontal/Lyric.tsx @@ -101,7 +101,7 @@ export default () => { // }, [playMusicInfo]) // const imgWidth = useMemo(() => layout.width * 0.75, [layout.width]) - const handleScrollToActive = (index = lineRef.current.line) => { + const handleScrollToActive = useCallback((index = lineRef.current.line) => { if (index < 0) return if (flatListRef.current) { // console.log('handleScrollToActive', index) @@ -130,7 +130,7 @@ export default () => { } catch {} } } - } + }, [line]) const handleScroll = ({ nativeEvent }: NativeSyntheticEvent) => { scrollInfoRef.current = nativeEvent @@ -207,7 +207,7 @@ export default () => { }, 100) } }) - }, [lyricLines]) + }, [handleScrollToActive, lyricLines]) useEffect(() => { if (line < 0) return @@ -224,7 +224,7 @@ export default () => { delayScrollTimeout.current = null handleScrollToActive() }, 600) - }, [line]) + }, [handleScrollToActive, line]) useEffect(() => { requestAnimationFrame(() => { diff --git a/src/screens/PlayDetail/Vertical/Lyric.tsx b/src/screens/PlayDetail/Vertical/Lyric.tsx index 5358f28b4..27f9600c6 100644 --- a/src/screens/PlayDetail/Vertical/Lyric.tsx +++ b/src/screens/PlayDetail/Vertical/Lyric.tsx @@ -141,7 +141,7 @@ export default () => { // }, [playMusicInfo]) // const imgWidth = useMemo(() => layout.width * 0.75, [layout.width]) - const handleScrollToActive = (index = lineRef.current.line) => { + const handleScrollToActive = useCallback((index = lineRef.current.line) => { if (index < 0) return if (flatListRef.current) { // console.log('handleScrollToActive', index) @@ -170,7 +170,7 @@ export default () => { } catch {} } } - } + }, [line]) const handleScroll = ({ nativeEvent }: NativeSyntheticEvent) => { scrollInfoRef.current = nativeEvent @@ -247,7 +247,7 @@ export default () => { }, 100) } }) - }, [lyricLines]) + }, [handleScrollToActive, lyricLines]) useEffect(() => { if (line < 0) return @@ -264,7 +264,7 @@ export default () => { delayScrollTimeout.current = null handleScrollToActive() }, 600) - }, [line]) + }, [handleScrollToActive, line]) useEffect(() => { requestAnimationFrame(() => { diff --git a/src/screens/PlayDetail/Vertical/Pic.tsx b/src/screens/PlayDetail/Vertical/Pic.tsx index 4fbe21d48..2e5a593a5 100644 --- a/src/screens/PlayDetail/Vertical/Pic.tsx +++ b/src/screens/PlayDetail/Vertical/Pic.tsx @@ -35,7 +35,7 @@ export default ({ componentId }: { componentId: string }) => { height: imgWidth, borderRadius: 2, } - }, [winHeight, winWidth]) + }, [statusBarHeight, winHeight, winWidth]) return ( diff --git a/src/screens/PlayDetail/components/PlayLine.tsx b/src/screens/PlayDetail/components/PlayLine.tsx index 4fb454d5b..5d4d48f45 100644 --- a/src/screens/PlayDetail/components/PlayLine.tsx +++ b/src/screens/PlayDetail/components/PlayLine.tsx @@ -61,7 +61,7 @@ export default forwardRef(({ onPlayLine }, ref) => }) // setVisible() }, - }), []) + })) const handlePlayLine = () => { onPlayLine(time / 1000) diff --git a/src/screens/SonglistDetail/MusicList.tsx b/src/screens/SonglistDetail/MusicList.tsx index e404cb277..267898e45 100644 --- a/src/screens/SonglistDetail/MusicList.tsx +++ b/src/screens/SonglistDetail/MusicList.tsx @@ -67,7 +67,7 @@ export default forwardRef(({ componentId }, ref) }) } }, - }), []) + })) useEffect(() => { isUnmountedRef.current = false diff --git a/src/utils/hooks/useAnimateColor.ts b/src/utils/hooks/useAnimateColor.ts index 460a1a987..57422c4cf 100644 --- a/src/utils/hooks/useAnimateColor.ts +++ b/src/utils/hooks/useAnimateColor.ts @@ -5,6 +5,7 @@ import { Animated } from 'react-native' const ANIMATION_DURATION = 800 export const useAnimateColor = (color: string) => { + // eslint-disable-next-line react-hooks/exhaustive-deps const anim = useMemo(() => new Animated.Value(0), [color]) const [finished, setFinished] = useState(true) const currentColor = useRef(color) @@ -29,6 +30,7 @@ export const useAnimateColor = (color: string) => { requestAnimationFrame(() => { currentColor.current = nextColor }) + // eslint-disable-next-line react-hooks/exhaustive-deps }, [nextColor]) return [animColor, finished] as const diff --git a/src/utils/hooks/useAnimateNumber.ts b/src/utils/hooks/useAnimateNumber.ts index f07ea9b51..7b0bfd97d 100644 --- a/src/utils/hooks/useAnimateNumber.ts +++ b/src/utils/hooks/useAnimateNumber.ts @@ -5,6 +5,7 @@ import { Animated } from 'react-native' export const DEFAULT_DURATION = 800 export const useAnimateNumber = (val: number, duration = DEFAULT_DURATION, useNativeDriver = true) => { + // eslint-disable-next-line react-hooks/exhaustive-deps const anim = useMemo(() => new Animated.Value(0), [val]) const [finished, setFinished] = useState(true) const currentNumber = useRef(val) @@ -29,6 +30,7 @@ export const useAnimateNumber = (val: number, duration = DEFAULT_DURATION, useNa requestAnimationFrame(() => { currentNumber.current = nextNumber }) + // eslint-disable-next-line react-hooks/exhaustive-deps }, [nextNumber]) return [animNumber, finished] as const @@ -54,6 +56,7 @@ export const useAnimateOnecNumber = (val: number, toVal: number, duration = DEFA // currentNumber.current = nextNumber setFinished(true) }) + // eslint-disable-next-line react-hooks/exhaustive-deps }, []) return [animNumber, finished] as const