Skip to content

Commit 6897f9c

Browse files
authored
Merge pull request #113 from nini22P/dev
v1.8.1
2 parents 00616ef + 158f5b2 commit 6897f9c

File tree

17 files changed

+321
-123
lines changed

17 files changed

+321
-123
lines changed

package-lock.json

Lines changed: 87 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@react-spring/web": "^9.7.3",
2424
"@use-gesture/react": "^10.3.1",
2525
"buffer": "^6.0.3",
26+
"color": "^4.2.3",
2627
"extract-colors": "^4.0.6",
2728
"idb-keyval": "^6.2.1",
2829
"music-metadata-browser": "^2.5.10",
@@ -39,6 +40,7 @@
3940
"@lingui/swc-plugin": "^4.0.8",
4041
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
4142
"@swc/core": "^1.5.29",
43+
"@types/color": "^3.0.6",
4244
"@types/extract-colors": "^1.1.4",
4345
"@types/node": "^20.14.2",
4446
"@types/react": "^18.3.3",
@@ -67,4 +69,4 @@
6769
"webpack-merge": "^5.10.0",
6870
"workbox-webpack-plugin": "^7.1.0"
6971
}
70-
}
72+
}

src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const App = () => {
103103
width: '100%',
104104
height: '100%',
105105
overflowY: 'auto',
106+
backgroundColor: `${customTheme.palette.background.paper}99`
106107
}}>
107108
{needLogin ? <LogIn /> : <Outlet />}
108109
</Paper>

src/components/CommonList/CommonList.tsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ const CommonList = (
4646
const [dialogOpen, setDialogOpen] = useState(false)
4747
const [selectIndex, setSelectIndex] = useState<number | null>(null)
4848
const [selectIndexArray, setSelectIndexArray] = useState<number[]>([])
49+
4950
const isSelectMode = selectIndexArray.length > 0
51+
const shuffleDisplay = listData.filter(item => item.fileType === 'audio' || item.fileType === 'video').length > 0
52+
const playAllDisplay = shuffleDisplay || listData.filter(item => item.fileType === 'folder' && /^(disc|disk)\s*\d+$/.test(item.fileName.toLocaleLowerCase())).length > 0
5053

5154
const addSelectIndex = (index: number) => { setSelectIndexArray([...selectIndexArray, index].sort()) }
5255

@@ -222,24 +225,24 @@ const CommonList = (
222225
const scroll = scrollRef.current
223226
const fab = fabRef.current
224227
if (fab && isSelectMode) {
225-
fab.style.visibility = 'visible'
228+
fab.style.transform = 'translateY(0)'
226229
} else if (scroll && fab && !isSelectMode) {
227230
const onWheel = (e: WheelEvent) => {
228231
if (e.deltaY > 0)
229-
fab.style.visibility = 'hidden'
232+
fab.style.transform = 'translateY(200%)'
230233
else
231-
fab.style.visibility = 'visible'
234+
fab.style.transform = 'translateY(0)'
232235
}
233236
const onTouchStart = (e: TouchEvent) => {
234237
touchStartYRef.current = (e.touches[0].clientY)
235238
}
236239
const onTouchMove = (e: TouchEvent) => {
237240
if (e.touches[0].clientY > touchStartYRef.current) {
238-
fab.style.visibility = 'visible'
241+
fab.style.transform = 'translateY(0)'
239242
touchStartYRef.current = (e.touches[0].clientY)
240243
}
241244
else {
242-
fab.style.visibility = 'hidden'
245+
fab.style.transform = 'translateY(200%)'
243246
touchStartYRef.current = (e.touches[0].clientY)
244247
}
245248

@@ -256,7 +259,7 @@ const CommonList = (
256259
}, [isSelectMode])
257260

258261
return (
259-
<Box sx={{ height: '100%', width: '100%', position: 'relative' }} >
262+
<Box sx={{ height: '100%', width: '100%', position: 'relative', overflow: 'hidden' }} >
260263

261264
{/* 文件列表 */}
262265
<Grid container sx={{ flexDirection: 'column', flexWrap: 'nowrap', height: '100%' }}>
@@ -344,6 +347,7 @@ const CommonList = (
344347
justifyContent: 'center',
345348
alignItems: 'center',
346349
gap: '0.5rem',
350+
transition: 'all 0.2s ease-out',
347351
}}
348352
>
349353
{
@@ -355,13 +359,19 @@ const CommonList = (
355359
{
356360
(listType !== 'playQueue') && !isSelectMode && !disableFAB &&
357361
<>
358-
<Fab size='small' onClick={handleClickShuffleAll}>
359-
<ShuffleRoundedIcon />
360-
</Fab>
361-
<Fab variant='extended' color='primary' onClick={handleClickPlayAll}>
362-
<PlayArrowRoundedIcon />
363-
<span style={{ marginLeft: '0.5rem' }}>{t`Play all`}</span>
364-
</Fab>
362+
{
363+
shuffleDisplay &&
364+
<Fab size='small' onClick={handleClickShuffleAll}>
365+
<ShuffleRoundedIcon />
366+
</Fab>
367+
}
368+
{
369+
playAllDisplay &&
370+
<Fab variant='extended' color='primary' onClick={handleClickPlayAll}>
371+
<PlayArrowRoundedIcon />
372+
<span style={{ marginLeft: '0.5rem' }}>{t`Play all`}</span>
373+
</Fab>
374+
}
365375
</>
366376
}
367377

src/data/licenses.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ export const licenses = [
6262
'link': 'https://github.com/feross/buffer',
6363
'author': 'Feross Aboukhadijeh feross@feross.org https://feross.org'
6464
},
65+
{
66+
'name': 'color',
67+
'licenseType': 'MIT',
68+
'link': 'https://github.com/Qix-/color',
69+
'author': 'Josh Junon'
70+
},
6571
{
6672
'name': 'extract-colors',
6773
'licenseType': 'GPL-3.0',

src/hooks/ui/useCustomTheme.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useMediaQuery } from '@mui/material'
44
import createTheme from '@mui/material/styles/createTheme'
55
import { extractColors } from 'extract-colors'
66
import { useMemo } from 'react'
7-
7+
import Color from 'color'
88
const useCustomTheme = () => {
99
const [
1010
coverColor,
@@ -42,13 +42,10 @@ const useCustomTheme = () => {
4242
useMemo(
4343
async () => {
4444
if (cover !== './cover.svg') {
45-
const colors = await extractColors(cover)
46-
const lightColors = colors.filter(color => color.lightness < 0.7)
47-
const darkColors = colors.filter(color => color.lightness > 0.5)
48-
if (prefersDarkMode && darkColors.length > 0)
49-
updateCoverColor(darkColors[0].hex)
50-
else if (!prefersDarkMode && lightColors.length > 0)
51-
updateCoverColor(lightColors[0].hex)
45+
const color = (await extractColors(cover))[0]
46+
const lightColor = Color(color.hex).lightness(50).hex()
47+
const darkColor = Color(color.hex).lightness(75).hex()
48+
updateCoverColor(prefersDarkMode ? darkColor : lightColor)
5249
}
5350
},
5451
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -176,6 +173,12 @@ const useCustomTheme = () => {
176173
paper: {
177174
border: `${prefersDarkMode ? '#f7f7f722' : '#3b3b3b22'} solid 1px`,
178175
boxShadow: `5px 5px 10px 0px ${prefersDarkMode ? '#f7f7f722' : '#3b3b3b22'}`,
176+
},
177+
root: {
178+
' .MuiBackdrop-root': {
179+
background: `${prefersDarkMode ? '#121212' : '#ffffff'}33`,
180+
backdropFilter: 'blur(0.5px)',
181+
},
179182
}
180183
}
181184
},

src/hooks/ui/useThemeColor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const useThemeColor = () => {
3333
themeColorLight.content = customTheme.palette.background.default
3434
themeColorDark.content = customTheme.palette.background.default
3535
}
36-
else if (audioViewIsShow && audioViewTheme === 'classic' || videoViewIsShow) {
36+
else if (audioViewIsShow && audioViewTheme === 'classic') {
3737
themeColorLight.content = '#1e1e1e'
3838
themeColorDark.content = '#1e1e1e'
3939
}

src/index.css

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ html {
2323
-webkit-text-size-adjust: 100%;
2424
text-size-adjust: 100%;
2525
font-family: Roboto, Helvetica, Arial, sans-serif;
26+
--custom-titlebar-height: 32px;
27+
--titlebar-height: env(titlebar-area-height, var(--custom-titlebar-height));
28+
--titlebar-center-safe-width: calc((50dvw - (100dvw - env(titlebar-area-x) - env(titlebar-area-width))) * 2)
2629
}
2730

2831
:root[data-theme="light"] {
@@ -50,13 +53,7 @@ a {
5053
}
5154

5255
.pt-titlebar-area-height {
53-
padding-top: 0 !important;
54-
}
55-
56-
@media (display-mode: window-controls-overlay) {
57-
.pt-titlebar-area-height {
58-
padding-top: env(titlebar-area-height, 32) !important;
59-
}
56+
padding-top: env(titlebar-area-height, 0) !important;
6057
}
6158

6259
.show-scrollbar::-webkit-scrollbar-thumb {

src/pages/Files/Files.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,31 @@ const Files = () => {
140140
updateVideoViewIsShow(true)
141141
}
142142
}
143+
144+
if (!currentFile) {
145+
const discs = listData.filter(item => item.fileName.toLocaleLowerCase().includes('disc'))
146+
if (discs.length > 0) {
147+
Promise.all(discs.map(item => getFilesData(account, pathConvert(item.filePath)).then(res => remoteItemToFile(res))))
148+
.then(files => {
149+
const list = files
150+
.flat()
151+
.filter((item) => item.fileType === 'audio' || item.fileType === 'video')
152+
.map((item, _index) => ({ ...item, index: _index }))
153+
154+
if (list.length > 0) {
155+
if (shuffle) {
156+
updateShuffle(false)
157+
}
158+
updatePlayQueue(list)
159+
updateCurrentIndex(0)
160+
updatePlayStatu('playing')
161+
if (list[0].fileType === 'video') {
162+
updateVideoViewIsShow(true)
163+
}
164+
}
165+
})
166+
}
167+
}
143168
}
144169
}
145170

0 commit comments

Comments
 (0)