From 186297bf058d8e5fb27f5eebd5843c00f45db622 Mon Sep 17 00:00:00 2001 From: X1a0He Date: Fri, 8 Nov 2024 14:48:40 +0800 Subject: [PATCH] Fix: Fixed the issue that when launching the program for the first time, the default directory is Downloads, which causes a download error message. --- Adobe Downloader.xcodeproj/project.pbxproj | 8 ++++---- Adobe Downloader/Adobe DownloaderApp.swift | 10 +++++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Adobe Downloader.xcodeproj/project.pbxproj b/Adobe Downloader.xcodeproj/project.pbxproj index e963fc7..48ecd0f 100644 --- a/Adobe Downloader.xcodeproj/project.pbxproj +++ b/Adobe Downloader.xcodeproj/project.pbxproj @@ -286,7 +286,7 @@ CODE_SIGN_ENTITLEMENTS = "Adobe Downloader/Adobe Downloader.entitlements"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Adobe Downloader/Preview Content\""; DEVELOPMENT_TEAM = ""; @@ -300,7 +300,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0.1; + MARKETING_VERSION = 1.0.2; PRODUCT_BUNDLE_IDENTIFIER = "com.x1a0he.macOS.Adobe-Downloader"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; @@ -318,7 +318,7 @@ "CODE_SIGN_IDENTITY[sdk=macosx*]" = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 101; + CURRENT_PROJECT_VERSION = 102; DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"Adobe Downloader/Preview Content\""; DEVELOPMENT_TEAM = ""; @@ -332,7 +332,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 13.0; - MARKETING_VERSION = 1.0.1; + MARKETING_VERSION = 1.0.2; PRODUCT_BUNDLE_IDENTIFIER = "com.x1a0he.macOS.Adobe-Downloader"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/Adobe Downloader/Adobe DownloaderApp.swift b/Adobe Downloader/Adobe DownloaderApp.swift index 8b4390b..7186bac 100644 --- a/Adobe Downloader/Adobe DownloaderApp.swift +++ b/Adobe Downloader/Adobe DownloaderApp.swift @@ -14,7 +14,7 @@ struct Adobe_DownloaderApp: App { @AppStorage("downloadAppleSilicon") private var downloadAppleSilicon: Bool = true @AppStorage("confirmRedownload") private var confirmRedownload: Bool = true @AppStorage("useDefaultDirectory") private var useDefaultDirectory: Bool = true - @AppStorage("defaultDirectory") private var defaultDirectory: String = "Downloads" + @AppStorage("defaultDirectory") private var defaultDirectory: String = "" private let updaterController: SPUStandardUpdaterController init() { @@ -40,8 +40,12 @@ struct Adobe_DownloaderApp: App { } if UserDefaults.standard.object(forKey: "useDefaultDirectory") == nil { - UserDefaults.standard.set(true, forKey: "useDefaultDirectory") - UserDefaults.standard.set("Downloads", forKey: "defaultDirectory") + if let downloadsURL = FileManager.default.urls(for: .downloadsDirectory, in: .userDomainMask).first { + print(downloadsURL.path) + defaultDirectory = downloadsURL.path + UserDefaults.standard.set(true, forKey: "useDefaultDirectory") + UserDefaults.standard.set(downloadsURL.path, forKey: "defaultDirectory") + } } }