@@ -7,11 +7,17 @@ import { File, Picture, Id3v2Settings } from "node-taglib-sharp";
77import { ipcLog } from "../logger" ;
88import { download } from "electron-dl" ;
99import FastGlob from "fast-glob" ;
10+ import { Options as GlobOptions } from "fast-glob/out/settings" ;
1011
1112/**
1213 * 文件相关 IPC
1314 */
1415const initFileIpc = ( ) : void => {
16+ const globOpt = ( cwd ?: string ) : GlobOptions => ( {
17+ cwd,
18+ caseSensitiveMatch : false
19+ } ) ;
20+
1521 // 默认文件夹
1622 ipcMain . handle (
1723 "get-default-dir" ,
@@ -27,7 +33,7 @@ const initFileIpc = (): void => {
2733 const filePath = resolve ( dirPath ) . replace ( / \\ / g, "/" ) ;
2834 console . info ( `📂 Fetching music files from: ${ filePath } ` ) ;
2935 // 查找指定目录下的所有音乐文件
30- const musicFiles = await FastGlob ( "**/*.{mp3,wav,flac,aac,webm}" , { cwd : filePath } ) ;
36+ const musicFiles = await FastGlob ( "**/*.{mp3,wav,flac,aac,webm}" , globOpt ( filePath ) ) ;
3137 // 解析元信息
3238 const metadataPromises = musicFiles . map ( async ( file ) => {
3339 const filePath = join ( dirPath , file ) ;
@@ -207,7 +213,7 @@ const initFileIpc = (): void => {
207213 try {
208214 // 查找 ttml
209215 if ( ! result . ttml ) {
210- const ttmlFiles = await FastGlob ( patterns . ttml , { cwd : dir } ) ;
216+ const ttmlFiles = await FastGlob ( patterns . ttml , globOpt ( dir ) ) ;
211217 if ( ttmlFiles . length > 0 ) {
212218 const filePath = join ( dir , ttmlFiles [ 0 ] ) ;
213219 await access ( filePath ) ;
@@ -217,7 +223,7 @@ const initFileIpc = (): void => {
217223
218224 // 查找 lrc
219225 if ( ! result . lrc ) {
220- const lrcFiles = await FastGlob ( patterns . lrc , { cwd : dir } ) ;
226+ const lrcFiles = await FastGlob ( patterns . lrc , globOpt ( dir ) ) ;
221227 if ( lrcFiles . length > 0 ) {
222228 const filePath = join ( dir , lrcFiles [ 0 ] ) ;
223229 await access ( filePath ) ;
0 commit comments