diff --git a/src/stores/setting.ts b/src/stores/setting.ts
index 0665273a..c2e0fe38 100644
--- a/src/stores/setting.ts
+++ b/src/stores/setting.ts
@@ -86,6 +86,7 @@ interface SettingState {
dynamicCover: boolean;
useKeepAlive: boolean;
excludeKeywords: string[];
+ showDefaultLocalPath: boolean;
}
export const useSettingStore = defineStore("setting", {
@@ -148,6 +149,7 @@ export const useSettingStore = defineStore("setting", {
excludeKeywords: keywords, // 排除歌词关键字
// 本地
localFilesPath: [],
+ showDefaultLocalPath: true, // 显示默认本地路径
localSeparators: ["/", "&"],
showLocalCover: true,
// 下载
diff --git a/src/utils/helper.ts b/src/utils/helper.ts
index af11d34f..3b8002bb 100644
--- a/src/utils/helper.ts
+++ b/src/utils/helper.ts
@@ -273,9 +273,11 @@ export const changeLocalPath = async (delIndex?: number) => {
// 检查是否为子文件夹
const defaultMusicPath = await window.electron.ipcRenderer.invoke("get-default-dir", "music");
const allPath = [defaultMusicPath, ...settingStore.localFilesPath];
- const isSubfolder = allPath.some((existingPath) => {
- return selectedDir.startsWith(existingPath);
- });
+ const isSubfolder = await window.electron.ipcRenderer.invoke(
+ "check-if-subfolder",
+ allPath,
+ selectedDir,
+ );
if (!isSubfolder) {
settingStore.localFilesPath.push(selectedDir);
} else {
diff --git a/src/views/Local/layout.vue b/src/views/Local/layout.vue
index 218838dd..f38d06e9 100644
--- a/src/views/Local/layout.vue
+++ b/src/views/Local/layout.vue
@@ -106,7 +106,14 @@
-
+
+
+
+
@@ -176,7 +183,10 @@ const listData = computed(() => {
// 获取音乐文件夹
const getMusicFolder = async (): Promise => {
defaultMusicPath.value = await window.electron.ipcRenderer.invoke("get-default-dir", "music");
- return [defaultMusicPath.value, ...settingStore.localFilesPath];
+ return [
+ settingStore.showDefaultLocalPath ? defaultMusicPath.value : "",
+ ...settingStore.localFilesPath,
+ ];
};
// 全部音乐大小
@@ -262,7 +272,7 @@ localEventBus.on(() => getAllLocalMusic());
// 本地目录变化
watch(
- () => settingStore.localFilesPath,
+ () => [settingStore.localFilesPath, settingStore.showDefaultLocalPath],
async () => await getAllLocalMusic(),
{ deep: true },
);
diff --git a/tsconfig.node.json b/tsconfig.node.json
index fdc9aef8..60c28b27 100644
--- a/tsconfig.node.json
+++ b/tsconfig.node.json
@@ -10,7 +10,7 @@
"electron/main/index.d.ts",
"electron/preload/index.d.ts",
"electron/preload/index.ts"
- ],
+, "dist/lastfm.ts" ],
"compilerOptions": {
"composite": true,
"types": ["electron-vite/node"]
diff --git a/tsconfig.web.json b/tsconfig.web.json
index 89023010..b574c63f 100644
--- a/tsconfig.web.json
+++ b/tsconfig.web.json
@@ -6,7 +6,7 @@
"src/**/*.vue",
"electron/main/index.d.ts",
"electron/preload/index.d.ts"
- ],
+, "dist/lastfm.ts" ],
"compilerOptions": {
"composite": true,
"maxNodeModuleJsDepth": 2,