Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 0c0d06d

Browse files
authored
fix(SoftwareManager): missing handle Adobe software directory structure (#21)
1 parent dba45c1 commit 0c0d06d

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

InjectGUI/Backend/InjectConfiguration.swift

+38-3
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,43 @@ class InjectConfiguration: ObservableObject {
329329
guard let conf = remoteConf else {
330330
return false
331331
}
332-
let package = conf.appList.first { $0.packageName.allStrings.contains(package) }
333-
guard package != nil else {
332+
let packageDetail = conf.appList.first { $0.packageName.allStrings.contains(package) }
333+
guard packageDetail != nil else {
334+
// 这种情况适用于软件存在,但是 Bundle ID 改变了,而导致无法注入
335+
// 这部分纯纯的为了兼容好目前的 config.json
336+
// FIXME: 未来会移除,因为这种情况不应该存在. 应该在 packageName 中使用数组来支持多个 Bundle ID,而不是单个字符串
337+
let localPackageInfo = softwareManager.appListCache[package]
338+
if localPackageInfo != nil {
339+
let app = conf.appList.first { $0.appBaseLocate == localPackageInfo?.path.replacingOccurrences(of: "/Contents", with: "") }
340+
if app != nil {
341+
print("[*] Found \(package) in local cache, try to add to supported list...")
342+
let newApp = AppList(
343+
packageName: .string(package),
344+
appBaseLocate: app?.appBaseLocate,
345+
bridgeFile: app?.bridgeFile,
346+
injectFile: app?.injectFile,
347+
needCopyToAppDir: app?.needCopyToAppDir,
348+
noSignTarget: app?.noSignTarget,
349+
autoHandleHelper: app?.autoHandleHelper,
350+
helperFile: app?.helperFile,
351+
tccutil: app?.tccutil,
352+
forQiuChenly: app?.forQiuChenly,
353+
onlysh: app?.onlysh,
354+
extraShell: app?.extraShell,
355+
smExtra: app?.smExtra,
356+
componentApp: app?.componentApp,
357+
deepSignApp: app?.deepSignApp,
358+
noDeep: app?.noDeep,
359+
entitlements: app?.entitlements,
360+
useOptool: app?.useOptool,
361+
autoHandleSetapp: app?.autoHandleSetapp,
362+
keygen: app?.keygen
363+
)
364+
remoteConf!.appList.append(newApp)
365+
print("[*] Added \(package) to supported list.")
366+
return true
367+
}
368+
}
334369
return false
335370
}
336371
return true
@@ -354,7 +389,7 @@ struct InjectConfigurationModel: Codable, Equatable {
354389
let project, author: String
355390
let version: Double
356391
let basePublicConfig: BasePublicConfig
357-
let appList: [AppList]
392+
var appList: [AppList]
358393

359394
enum CodingKeys: String, CodingKey {
360395
case project

InjectGUI/Backend/SoftwareManager.swift

+14-2
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,20 @@ class SoftwareManager: ObservableObject {
119119
for appPath in appPaths {
120120
let fullPath = "\(directory)/\(appPath)"
121121
let infoPlistPath = "\(fullPath)/Contents/Info.plist"
122-
if let appInfo = loadAppInfo(from: infoPlistPath) {
123-
newAppListCache[appInfo.identifier] = appInfo
122+
// MARK: - 针对 Adobe 系列软件的特殊处理
123+
if appPath.hasPrefix("Adobe") {
124+
let adobeAppPaths = try? fileManager.contentsOfDirectory(atPath: fullPath)
125+
for adobeAppPath in adobeAppPaths ?? [] { // Adobe 系列软件的子目录
126+
let adobeFullPath = "\(fullPath)/\(adobeAppPath)"
127+
let adobeInfoPlistPath = "\(adobeFullPath)/Contents/Info.plist"
128+
if let appInfo = loadAppInfo(from: adobeInfoPlistPath) {
129+
newAppListCache[appInfo.identifier] = appInfo
130+
}
131+
}
132+
} else {
133+
if let appInfo = loadAppInfo(from: infoPlistPath) {
134+
newAppListCache[appInfo.identifier] = appInfo
135+
}
124136
}
125137
}
126138
}

InjectGUI/View/AppDetailView.swift

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ struct AppDetailView: View {
3535
if getAppDetailFromSoftwareManager != nil {
3636
self.appDetail = SoftwareManager.shared.appListCache[appId]!
3737
} else {
38+
print("[*] Can't find app detail in SoftwareManager, it's a abnormal situation, please report to developer. appId: \(appId)")
3839
self.appDetail = AppDetail(name: appInjectConfDetail?.packageName.allStrings.first ?? "", identifier: appInjectConfDetail?.packageName.allStrings.first ?? "", version: "", path: "", executable: "", icon: NSImage())
3940
}
4041
// self._appDetail = State(wrappedValue: SoftwareManager.shared.appListCache[appId] ?? AppDetail(name: "", identifier: "", version: "", path: "", icon: NSImage()))

0 commit comments

Comments
 (0)