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

Commit

Permalink
fix(SoftwareManager): missing handle Adobe software directory structu…
Browse files Browse the repository at this point in the history
…re (#21)
  • Loading branch information
wibus-wee authored Aug 22, 2024
1 parent dba45c1 commit 0c0d06d
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
41 changes: 38 additions & 3 deletions InjectGUI/Backend/InjectConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,43 @@ class InjectConfiguration: ObservableObject {
guard let conf = remoteConf else {
return false
}
let package = conf.appList.first { $0.packageName.allStrings.contains(package) }
guard package != nil else {
let packageDetail = conf.appList.first { $0.packageName.allStrings.contains(package) }
guard packageDetail != nil else {
// 这种情况适用于软件存在,但是 Bundle ID 改变了,而导致无法注入
// 这部分纯纯的为了兼容好目前的 config.json
// FIXME: 未来会移除,因为这种情况不应该存在. 应该在 packageName 中使用数组来支持多个 Bundle ID,而不是单个字符串
let localPackageInfo = softwareManager.appListCache[package]
if localPackageInfo != nil {
let app = conf.appList.first { $0.appBaseLocate == localPackageInfo?.path.replacingOccurrences(of: "/Contents", with: "") }
if app != nil {
print("[*] Found \(package) in local cache, try to add to supported list...")
let newApp = AppList(
packageName: .string(package),
appBaseLocate: app?.appBaseLocate,
bridgeFile: app?.bridgeFile,
injectFile: app?.injectFile,
needCopyToAppDir: app?.needCopyToAppDir,
noSignTarget: app?.noSignTarget,
autoHandleHelper: app?.autoHandleHelper,
helperFile: app?.helperFile,
tccutil: app?.tccutil,
forQiuChenly: app?.forQiuChenly,
onlysh: app?.onlysh,
extraShell: app?.extraShell,
smExtra: app?.smExtra,
componentApp: app?.componentApp,
deepSignApp: app?.deepSignApp,
noDeep: app?.noDeep,
entitlements: app?.entitlements,
useOptool: app?.useOptool,
autoHandleSetapp: app?.autoHandleSetapp,
keygen: app?.keygen
)
remoteConf!.appList.append(newApp)
print("[*] Added \(package) to supported list.")
return true
}
}
return false
}
return true
Expand All @@ -354,7 +389,7 @@ struct InjectConfigurationModel: Codable, Equatable {
let project, author: String
let version: Double
let basePublicConfig: BasePublicConfig
let appList: [AppList]
var appList: [AppList]

enum CodingKeys: String, CodingKey {
case project
Expand Down
16 changes: 14 additions & 2 deletions InjectGUI/Backend/SoftwareManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,20 @@ class SoftwareManager: ObservableObject {
for appPath in appPaths {
let fullPath = "\(directory)/\(appPath)"
let infoPlistPath = "\(fullPath)/Contents/Info.plist"
if let appInfo = loadAppInfo(from: infoPlistPath) {
newAppListCache[appInfo.identifier] = appInfo
// MARK: - 针对 Adobe 系列软件的特殊处理
if appPath.hasPrefix("Adobe") {
let adobeAppPaths = try? fileManager.contentsOfDirectory(atPath: fullPath)
for adobeAppPath in adobeAppPaths ?? [] { // Adobe 系列软件的子目录
let adobeFullPath = "\(fullPath)/\(adobeAppPath)"
let adobeInfoPlistPath = "\(adobeFullPath)/Contents/Info.plist"
if let appInfo = loadAppInfo(from: adobeInfoPlistPath) {
newAppListCache[appInfo.identifier] = appInfo
}
}
} else {
if let appInfo = loadAppInfo(from: infoPlistPath) {
newAppListCache[appInfo.identifier] = appInfo
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions InjectGUI/View/AppDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct AppDetailView: View {
if getAppDetailFromSoftwareManager != nil {
self.appDetail = SoftwareManager.shared.appListCache[appId]!
} else {
print("[*] Can't find app detail in SoftwareManager, it's a abnormal situation, please report to developer. appId: \(appId)")
self.appDetail = AppDetail(name: appInjectConfDetail?.packageName.allStrings.first ?? "", identifier: appInjectConfDetail?.packageName.allStrings.first ?? "", version: "", path: "", executable: "", icon: NSImage())
}
// self._appDetail = State(wrappedValue: SoftwareManager.shared.appListCache[appId] ?? AppDetail(name: "", identifier: "", version: "", path: "", icon: NSImage()))
Expand Down

0 comments on commit 0c0d06d

Please sign in to comment.