Add: Added architecture selection, for more update logs, please see Update-log.md.

This commit is contained in:
X1a0He
2024-11-06 10:09:16 +08:00
parent 665fb4b7ff
commit bcac77f1c1
14 changed files with 318 additions and 85 deletions

View File

@@ -189,7 +189,7 @@
MACOSX_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -247,6 +247,7 @@
MACOSX_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
};

View File

@@ -31,7 +31,7 @@
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"

View File

@@ -4,13 +4,35 @@ import SwiftUI
struct Adobe_DownloaderApp: App {
@StateObject private var networkManager = NetworkManager()
@State private var showBackupAlert = false
@State private var showTipsSheet = false
@State private var showLanguagePicker = false
@AppStorage("useDefaultLanguage") private var useDefaultLanguage: Bool = true
@AppStorage("defaultLanguage") private var defaultLanguage: String = "ALL"
@AppStorage("downloadAppleSilicon") private var downloadAppleSilicon: Bool = true
@AppStorage("confirmRedownload") private var confirmRedownload: Bool = true
init() {
if UserDefaults.standard.object(forKey: "useDefaultLanguage") == nil {
UserDefaults.standard.set(true, forKey: "useDefaultLanguage")
let isFirstRun = UserDefaults.standard.object(forKey: "downloadAppleSilicon") == nil ||
UserDefaults.standard.object(forKey: "useDefaultLanguage") == nil
UserDefaults.standard.set(isFirstRun, forKey: "isFirstLaunch")
if UserDefaults.standard.object(forKey: "downloadAppleSilicon") == nil {
UserDefaults.standard.set(AppStatics.isAppleSilicon, forKey: "downloadAppleSilicon")
}
if UserDefaults.standard.object(forKey: "useDefaultLanguage") == nil {
let systemLanguage = Locale.current.identifier
let matchedLanguage = AppStatics.supportedLanguages.first {
systemLanguage.hasPrefix($0.code.prefix(2))
}?.code ?? "ALL"
UserDefaults.standard.set(true, forKey: "useDefaultLanguage")
UserDefaults.standard.set(matchedLanguage, forKey: "defaultLanguage")
}
if UserDefaults.standard.object(forKey: "useDefaultDirectory") == nil {
UserDefaults.standard.set(true, forKey: "useDefaultDirectory")
UserDefaults.standard.set(false, forKey: "useDefaultDirectory")
}
}
@@ -24,6 +46,11 @@ struct Adobe_DownloaderApp: App {
if ModifySetup.checkSetupBackup() {
showBackupAlert = true
}
if UserDefaults.standard.bool(forKey: "isFirstLaunch") {
showTipsSheet = true
UserDefaults.standard.removeObject(forKey: "isFirstLaunch")
}
}
.alert("Setup未备份提示", isPresented: $showBackupAlert) {
Button("OK") {
@@ -37,12 +64,80 @@ struct Adobe_DownloaderApp: App {
} message: {
Text("检测到Setup文件尚未备份如果你需要安装程序则Setup必须被处理点击确定后你需要输入密码Adobe Downloader将自动处理并备份为Setup.original")
}
.sheet(isPresented: $showTipsSheet) {
VStack(spacing: 20) {
Text("Adobe Downloader 已为你默认设定如下值")
.font(.headline)
VStack(spacing: 12) {
HStack {
Toggle("使用默认语言", isOn: $useDefaultLanguage)
.padding(.leading, 5)
Spacer()
Text(getLanguageName(code: defaultLanguage))
.foregroundColor(.secondary)
Button("选择") {
showLanguagePicker = true
}
.padding(.trailing, 5)
.buttonStyle(.borderless)
}
Divider()
HStack {
Toggle("重新下载时需要确认", isOn: $confirmRedownload)
.padding(.leading, 5)
Spacer()
}
Divider()
HStack {
Toggle("下载 Apple Silicon 架构", isOn: $downloadAppleSilicon)
.padding(.leading, 5)
Spacer()
Text("当前架构: \(AppStatics.cpuArchitecture)")
.foregroundColor(.secondary)
.lineLimit(1)
.truncationMode(.middle)
}
.onChange(of: downloadAppleSilicon) { _, newValue in
networkManager.updateAllowedPlatform(useAppleSilicon: newValue)
}
}
.padding()
.background(Color(NSColor.controlBackgroundColor))
.cornerRadius(8)
Text("你可以在设置中随时更改以上选项")
.font(.headline)
Button("确定") {
showTipsSheet = false
}
.buttonStyle(.borderedProminent)
}
.padding()
.frame(width: 500)
.sheet(isPresented: $showLanguagePicker) {
LanguagePickerView(languages: AppStatics.supportedLanguages) { language in
defaultLanguage = language
showLanguagePicker = false
}
}
}
}
.windowStyle(.hiddenTitleBar)
.windowResizability(.contentSize)
Settings {
AboutView()
.environmentObject(networkManager)
}
}
private func getLanguageName(code: String) -> String {
AppStatics.supportedLanguages.first { $0.code == code }?.name ?? code
}
}

View File

@@ -31,11 +31,23 @@ struct AppStatics {
("ALL", "所有语言")
]
static func isValidLanguageCode(_ code: String) -> Bool {
return supportedLanguages.contains { $0.code == code }
}
static let cpuArchitecture: String = {
#if arch(arm64)
return "Apple Silicon"
#elseif arch(x86_64)
return "Intel"
#else
return "Unknown Architecture"
#endif
}()
static func getLanguageName(for code: String) -> String? {
return supportedLanguages.first { $0.code == code }?.name
}
static let isAppleSilicon: Bool = {
#if arch(arm64)
return true
#elseif arch(x86_64)
return false
#else
return false
#endif
}()
}

View File

@@ -6,11 +6,6 @@ struct ContentView: View {
@State private var errorMessage: String?
@State private var showDownloadManager = false
@State private var searchText = ""
@AppStorage("useDefaultLanguage") private var useDefaultLanguage = true
@AppStorage("useDefaultDirectory") private var useDefaultDirectory = true
@AppStorage("defaultLanguage") private var defaultLanguage: String = "zh_CN"
@AppStorage("defaultDirectory") private var defaultDirectory: String = ""
@State private var showLanguagePicker = false
private var filteredProducts: [Sap] {
let products = networkManager.saps.values
@@ -27,6 +22,10 @@ struct ContentView: View {
}
}
private func openSettings() {
NSApp.sendAction(Selector(("showSettingsWindow:")), to: nil, from: nil)
}
var body: some View {
VStack(spacing: 0) {
HStack() {
@@ -35,17 +34,17 @@ struct ContentView: View {
.fontWeight(.bold)
.fixedSize()
SettingsView(
useDefaultLanguage: $useDefaultLanguage,
useDefaultDirectory: $useDefaultDirectory,
onSelectLanguage: selectLanguage,
onSelectDirectory: selectDirectory
)
.frame(maxWidth: .infinity)
Spacer()
HStack(spacing: 8) {
SearchField(text: $searchText)
.frame(maxWidth: 200)
SettingsLink {
Image(systemName: "gearshape")
.imageScale(.medium)
}
.buttonStyle(.borderless)
Button(action: refreshData) {
Image(systemName: "arrow.clockwise")
@@ -74,7 +73,8 @@ struct ContentView: View {
)
}
}
.padding(.horizontal, 12)
.padding(.horizontal)
.padding(.vertical, 8)
.background(Color(NSColor.windowBackgroundColor))
ZStack {
@@ -113,7 +113,6 @@ struct ContentView: View {
.buttonStyle(.borderedProminent)
.controlSize(.large)
}
.padding()
.frame(maxWidth: .infinity, maxHeight: .infinity)
case .success:
@@ -139,12 +138,6 @@ struct ContentView: View {
}
}
}
.sheet(isPresented: $showLanguagePicker) {
LanguagePickerView(languages: AppStatics.supportedLanguages) { language in
defaultLanguage = language
showLanguagePicker = false
}
}
.sheet(isPresented: $showDownloadManager) {
DownloadManagerView()
.environmentObject(networkManager)
@@ -168,23 +161,6 @@ struct ContentView: View {
}
}
}
private func selectLanguage() {
showLanguagePicker = true
}
private func selectDirectory() {
let panel = NSOpenPanel()
panel.title = "选择默认下载目录"
panel.canCreateDirectories = true
panel.canChooseDirectories = true
panel.canChooseFiles = false
if panel.runModal() == .OK {
defaultDirectory = panel.url?.path ?? ""
useDefaultDirectory = false
}
}
}
struct SearchField: View {

View File

@@ -10,7 +10,7 @@ class NetworkManager: ObservableObject {
@Published var isConnected = false
@Published var saps: [String: Sap] = [:]
@Published var cdn: String = ""
@Published var allowedPlatform = ["macuniversal", "macarm64", "osx10-64", "osx10"]
@Published var allowedPlatform: [String]
@Published var sapCodes: [SapCodes] = []
@Published var loadingState: LoadingState = .idle
@Published var downloadTasks: [NewDownloadTask] = []
@@ -33,6 +33,9 @@ class NetworkManager: ObservableObject {
}
init() {
let useAppleSilicon = UserDefaults.standard.bool(forKey: "downloadAppleSilicon")
self.allowedPlatform = useAppleSilicon ? ["macuniversal", "macarm64"] : ["macuniversal", "osx10-64"]
self.downloadUtils = DownloadUtils(networkManager: self, cancelTracker: cancelTracker)
setupNetworkMonitoring()
}
@@ -259,7 +262,7 @@ class NetworkManager: ObservableObject {
guard let url = URL(string: NetworkConstants.applicationJsonURL) else {
throw NetworkError.invalidURL(NetworkConstants.applicationJsonURL)
}
var request = URLRequest(url: url)
request.httpMethod = "GET"
@@ -292,7 +295,7 @@ class NetworkManager: ObservableObject {
URLQueryItem(name: "_type", value: "xml"),
URLQueryItem(name: "channel", value: "ccm"),
URLQueryItem(name: "channel", value: "sti"),
URLQueryItem(name: "platform", value: "osx10-64,osx10,macarm64,macuniversal"),
URLQueryItem(name: "platform", value: allowedPlatform.joined(separator: ",")),
URLQueryItem(name: "productType", value: "Desktop")
]
@@ -349,13 +352,14 @@ class NetworkManager: ObservableObject {
func isVersionDownloaded(sap: Sap, version: String, language: String) -> URL? {
let platform = sap.versions[version]?.apPlatform ?? "unknown"
var fileName = ""
if(sap.sapCode=="APRO"){
if(sap.sapCode=="APRO") {
fileName = "Install \(sap.sapCode)_\(version)_\(platform).dmg"
} else {
fileName = "Install \(sap.sapCode)_\(version)-\(language)-\(platform).app"
}
if !defaultDirectory.isEmpty {
let useDefaultDirectory = UserDefaults.standard.bool(forKey: "useDefaultDirectory")
if useDefaultDirectory && !defaultDirectory.isEmpty {
let defaultPath = URL(fileURLWithPath: defaultDirectory)
.appendingPathComponent(fileName)
if FileManager.default.fileExists(atPath: defaultPath.path) {
@@ -363,16 +367,16 @@ class NetworkManager: ObservableObject {
}
}
if let task = downloadTasks.first(where: {
$0.sapCode == sap.sapCode &&
$0.version == version &&
$0.language == language
if let task = downloadTasks.first(where: {
$0.sapCode == sap.sapCode &&
$0.version == version &&
$0.language == language
}) {
if FileManager.default.fileExists(atPath: task.directory.path) {
return task.directory
}
}
return nil
}
@@ -402,4 +406,8 @@ class NetworkManager: ObservableObject {
await fetchProducts()
}
}
func updateAllowedPlatform(useAppleSilicon: Bool) {
allowedPlatform = useAppleSilicon ? ["macuniversal", "macarm64"] : ["macuniversal", "osx10-64"]
}
}

View File

@@ -724,7 +724,7 @@ class DownloadUtils {
if !FileManager.default.fileExists(atPath: productDir.path) {
try FileManager.default.createDirectory(at: productDir, withIntermediateDirectories: true)
}
print("product.sapCode: \(product.sapCode), product.buildGuid: \(product.buildGuid)")
let jsonString = try await getApplicationInfo(buildGuid: product.buildGuid)
let jsonURL = productDir.appendingPathComponent("application.json")
try jsonString.write(to: jsonURL, atomically: true, encoding: .utf8)

View File

@@ -15,7 +15,6 @@ class XHXMLParser {
static func parseProductsXML(xmlData: Data) throws -> ParseResult {
let xml = try XMLDocument(data: xmlData)
let allowedPlatforms = Set(["osx10-64", "osx10", "macuniversal", "macarm64"])
guard let cdn = try xml.nodes(forXPath: "//channels/channel/cdn/secure").first?.stringValue else {
throw ParserError.missingCDN
}
@@ -60,6 +59,13 @@ class XHXMLParser {
var baseVersion = languageSet.attribute(forName: "baseVersion")?.stringValue ?? ""
var buildGuid = languageSet.attribute(forName: "buildGuid")?.stringValue ?? ""
let appPlatform = platform.attribute(forName: "id")?.stringValue ?? ""
if let existingVersion = products[sap]?.versions[productVersion] {
if existingVersion.apPlatform == "macuniversal" {
break
}
}
let dependencies = try languageSet.nodes(forXPath: "dependencies/dependency").compactMap { node -> Sap.Versions.Dependencies? in
guard let element = node as? XMLElement,
let sapCode = try element.nodes(forXPath: "sapCode").first?.stringValue,
@@ -69,11 +75,6 @@ class XHXMLParser {
return Sap.Versions.Dependencies(sapCode: sapCode, version: version)
}
if let existingVersion = products[sap]?.versions[productVersion],
allowedPlatforms.contains(existingVersion.apPlatform) {
break
}
if sap == "APRO" {
baseVersion = productVersion
let buildNodes = try xml.nodes(forXPath: "//builds/build")
@@ -91,7 +92,7 @@ class XHXMLParser {
buildGuid = try languageSet.nodes(forXPath: "urls/manifestURL").first?.stringValue ?? ""
}
if !buildGuid.isEmpty && allowedPlatforms.contains(appPlatform) {
if !buildGuid.isEmpty {
let version = Sap.Versions(
sapCode: sap,
baseVersion: baseVersion,

View File

@@ -24,12 +24,14 @@ struct AboutView: View {
}
struct GeneralSettingsView: View {
@AppStorage("defaultLanguage") private var defaultLanguage: String = "zh_CN"
@AppStorage("defaultLanguage") private var defaultLanguage: String = "ALL"
@AppStorage("defaultDirectory") private var defaultDirectory: String = ""
@AppStorage("useDefaultLanguage") private var useDefaultLanguage: Bool = true
@AppStorage("useDefaultDirectory") private var useDefaultDirectory: Bool = true
@AppStorage("confirmRedownload") private var confirmRedownload: Bool = true
@AppStorage("downloadAppleSilicon") private var downloadAppleSilicon: Bool = true
@State private var showLanguagePicker = false
@EnvironmentObject private var networkManager: NetworkManager
var body: some View {
Form {
@@ -45,7 +47,6 @@ struct GeneralSettingsView: View {
showLanguagePicker = true
}
.padding(.trailing, 5)
.buttonStyle(.borderless)
}
Divider()
@@ -62,7 +63,6 @@ struct GeneralSettingsView: View {
selectDirectory()
}
.padding(.trailing, 5)
.buttonStyle(.borderless)
}
Divider()
@@ -72,6 +72,19 @@ struct GeneralSettingsView: View {
.padding(.leading, 5)
Spacer()
}
Divider()
HStack {
Toggle("下载 Apple Silicon 架构", isOn: $downloadAppleSilicon)
.padding(.leading, 5)
Spacer()
Text("当前架构: \(AppStatics.cpuArchitecture)")
.foregroundColor(.secondary)
.lineLimit(1)
.truncationMode(.middle)
}
.onChange(of: downloadAppleSilicon) { _, newValue in
networkManager.updateAllowedPlatform(useAppleSilicon: newValue)
}
}
.padding(.vertical, 4)
}
@@ -84,6 +97,9 @@ struct GeneralSettingsView: View {
showLanguagePicker = false
}
}
.onAppear {
networkManager.updateAllowedPlatform(useAppleSilicon: downloadAppleSilicon)
}
}
private func getLanguageName(code: String) -> String {
@@ -91,7 +107,7 @@ struct GeneralSettingsView: View {
}
private func formatPath(_ path: String) -> String {
if path.isEmpty { return "未设置" }
if path.isEmpty { return String(localized: "未设置") }
return URL(fileURLWithPath: path).lastPathComponent
}
@@ -124,6 +140,10 @@ struct AboutAppView: View {
.font(.subheadline)
.foregroundColor(.secondary)
Link("Contect @X1a0He",
destination: URL(string: "https://t.me/X1a0He")!)
.font(.caption)
.foregroundColor(.blue)
Link("Github: Adobe Downloader",
destination: URL(string: "https://github.com/X1a0He/Adobe-Downloader")!)
.font(.caption)
@@ -149,5 +169,7 @@ struct AboutAppView: View {
}
#Preview {
AboutView()
let networkManager = NetworkManager()
return AboutView()
.environmentObject(networkManager)
}

View File

@@ -47,7 +47,7 @@ struct SettingsView: View {
.toggleStyle(.checkbox)
.fixedSize()
Text(formatPath(defaultDirectory.isEmpty ? "未设置" : defaultDirectory))
Text(formatPath(defaultDirectory.isEmpty ? String(localized: "未设置") : defaultDirectory))
.foregroundColor(.secondary)
.lineLimit(1)
.frame(alignment: .leading)
@@ -67,7 +67,7 @@ struct SettingsView: View {
}
private func formatPath(_ path: String) -> String {
if path.isEmpty || path == "未设置" { return "未设置" }
if path.isEmpty { return String(localized: "未设置") }
let url = URL(fileURLWithPath: path)
return url.lastPathComponent
}

View File

@@ -9,6 +9,7 @@ struct VersionPickerView: View {
@EnvironmentObject private var networkManager: NetworkManager
@Environment(\.dismiss) private var dismiss
@AppStorage("defaultLanguage") private var defaultLanguage: String = "zh_CN"
@AppStorage("downloadAppleSilicon") private var downloadAppleSilicon: Bool = true
@State private var expandedVersions: Set<String> = []
let sap: Sap
@@ -16,17 +17,24 @@ struct VersionPickerView: View {
var body: some View {
VStack(spacing: 0) {
HStack {
Text("\(sap.displayName)")
.font(.headline)
Text("选择版本")
.foregroundColor(.secondary)
Spacer()
Button("取消") {
dismiss()
VStack {
HStack {
Text("\(sap.displayName)")
.font(.headline)
Text("选择版本")
.foregroundColor(.secondary)
Spacer()
Button("取消") {
dismiss()
}
}
.padding(.bottom, 5)
Text("🔔 即将下载 \(downloadAppleSilicon ? "Apple Silicon" : "Intel") (\(networkManager.allowedPlatform.joined(separator: ", "))) 版本 🔔")
.font(.caption)
.frame(maxWidth: .infinity, alignment: .leading)
}
.padding()
.padding(.horizontal)
.padding(.top)
.background(Color(NSColor.windowBackgroundColor))
ScrollView(showsIndicators: false) {

View File

@@ -59,6 +59,16 @@
},
"|" : {
},
"🔔 即将下载 %@ (%@) 版本 🔔" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "🔔 To be downloaded %1$@ (%2$@) version 🔔"
}
}
}
},
"About" : {
"localizations" : {
@@ -72,9 +82,22 @@
},
"Adobe Downloader" : {
},
"Adobe Downloader 已为你默认设定如下值" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Adobe Downloader has set the following default values for you"
}
}
}
},
"By X1a0He. ❤️ Love from China. ❤️" : {
},
"Contect @X1a0He" : {
},
"General" : {
"localizations" : {
@@ -124,6 +147,16 @@
}
}
},
"下载 Apple Silicon 架构" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Download Apple Silicon"
}
}
}
},
"下载中" : {
"localizations" : {
"en" : {
@@ -197,6 +230,16 @@
}
}
},
"你可以在设置中随时更改以上选项" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "You can change the above options at any time in the settings"
}
}
}
},
"使用现有程序" : {
"localizations" : {
"en" : {
@@ -408,6 +451,16 @@
}
}
},
"当前架构: %@" : {
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Current Architecture: %@"
}
}
}
},
"搜索应用" : {
"localizations" : {
"en" : {
@@ -479,6 +532,23 @@
}
}
},
"未设置" : {
"comment" : "Default directory not set",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Not Set"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "未设置"
}
}
}
},
"检测到Setup文件尚未备份如果你需要安装程序则Setup必须被处理点击确定后你需要输入密码Adobe Downloader将自动处理并备份为Setup.original" : {
"localizations" : {
"en" : {

View File

@@ -6,7 +6,7 @@
**🍎Only for macOS 14+.**
> **If you like Adobe Downloader, or it helps you, please Star🌟 it.** \
> **If you like Adobe Downloader, or it helps you, please Star🌟 it.**
>
> 1. Before proceeding with the installation, make sure you have
installed [Adobe Creative Cloud](https://creativecloud.adobe.com/apps/download/creative-cloud)
@@ -18,6 +18,28 @@
the [adobe-packager](https://github.com/Drovosek01/adobe-packager)
> 4. ⚠️⚠️⚠️**All Adobe apps in Adobe Downloader are from official Adobe channels and are not cracked versions.**
## 📔Latest Log
- For historical update logs, please go to [Update Log](update-log.md)
- 2024-11-06 10:00 Update Log
```markdown
1. Added default configuration settings and prompts when the program is started for the first time
2. Added optional architecture downloads, please select in settings
3. Fixed the problem of version detection error (only checks whether the file exists, not whether it is complete)
4. Removed the language selection and directory selection on the main interface and moved them to settings
5. Added architecture prompts on the version selection page
====================
1. 增加程序首次启动时的默认配置设定与提示
2. 增加可选架构下载,请在设置中进行选择
3. 修复了版本已存在检测错误的问题 (仅检测文件是否存在,并不会检测是否完整)
4. 移除主界面的语言选择和目录选择,移动到了设置中
5. 版本选择页面增加架构提示
```
### Language friendly
- [x] Chinese

View File

@@ -1,5 +1,23 @@
# Change Log
- 2024-11-06 10:00 更新日志
```markdown
1. 增加程序首次启动时的默认配置设定与提示
2. 增加可选架构下载,请在设置中进行选择
3. 修复了版本已存在检测错误的问题 \(仅检测文件是否存在,并不会检测是否完整\)
4. 移除主界面的语言选择和目录选择,移动到了设置中
5. 版本选择页面增加架构提示
====================
1. Added default configuration settings and prompts when the program is started for the first time
2. Added optional architecture downloads, please select in settings
3. Fixed the problem of version detection error \(only checks whether the file exists, not whether it is complete\)
4. Removed the language selection and directory selection on the main interface and moved them to settings
5. Added architecture prompts on the version selection page
```
- 2024-11-05 21:15 更新日志
```markdown