Skip to content

Commit

Permalink
improve search engine
Browse files Browse the repository at this point in the history
  • Loading branch information
underthestars-zhy committed Dec 21, 2022
1 parent 941ba0f commit d176357
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
29 changes: 2 additions & 27 deletions IconChanger.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
9017B5F8294DBBA9005709C6 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 9017B5F7294DBBA9005709C6 /* Sparkle */; };
9017B5FA294ED626005709C6 /* IconRes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9017B5F9294ED626005709C6 /* IconRes.swift */; };
9017B5FC294EDAB4005709C6 /* LocalImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9017B5FB294EDAB4005709C6 /* LocalImageView.swift */; };
9017B6162951B514005709C6 /* Sentry in Frameworks */ = {isa = PBXBuildFile; productRef = 9017B6152951B514005709C6 /* Sentry */; };
9017B6182951B514005709C6 /* Sentry-Dynamic in Frameworks */ = {isa = PBXBuildFile; productRef = 9017B6172951B514005709C6 /* Sentry-Dynamic */; };
9017B61E295282ED005709C6 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 9017B61D295282ED005709C6 /* LICENSE */; };
9053434F286B2A6800237F98 /* AutoUpdater.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9053434E286B2A6800237F98 /* AutoUpdater.swift */; };
90534352286C8BDA00237F98 /* fileicon in Resources */ = {isa = PBXBuildFile; fileRef = 90534351286C8BDA00237F98 /* fileicon */; };
Expand Down Expand Up @@ -82,11 +80,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
9017B6182951B514005709C6 /* Sentry-Dynamic in Frameworks */,
9017B5F8294DBBA9005709C6 /* Sparkle in Frameworks */,
9083CCE92867FDBD0093A1B2 /* SwiftyJSON in Frameworks */,
9083CCEC2867FDDD0093A1B2 /* LaunchPadManagerDBHelper in Frameworks */,
9017B6162951B514005709C6 /* Sentry in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -192,8 +188,6 @@
9083CCE82867FDBD0093A1B2 /* SwiftyJSON */,
9083CCEB2867FDDD0093A1B2 /* LaunchPadManagerDBHelper */,
9017B5F7294DBBA9005709C6 /* Sparkle */,
9017B6152951B514005709C6 /* Sentry */,
9017B6172951B514005709C6 /* Sentry-Dynamic */,
);
productName = IconChanger;
productReference = 900D1CE5281934C7007ABB12 /* IconChanger.app */;
Expand Down Expand Up @@ -227,7 +221,6 @@
9083CCE72867FDBD0093A1B2 /* XCRemoteSwiftPackageReference "SwiftyJSON" */,
9083CCEA2867FDDD0093A1B2 /* XCRemoteSwiftPackageReference "LaunchPadManagerDBHelper" */,
9017B5F6294DBBA9005709C6 /* XCRemoteSwiftPackageReference "Sparkle" */,
9017B6142951B514005709C6 /* XCRemoteSwiftPackageReference "sentry-cocoa" */,
);
productRefGroup = 900D1CE6281934C7007ABB12 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -425,7 +418,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.2.6;
PRODUCT_BUNDLE_IDENTIFIER = com.zhuhaoyu.IconChanger;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -458,7 +451,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.3;
MARKETING_VERSION = 1.3.0;
MARKETING_VERSION = 1.2.6;
PRODUCT_BUNDLE_IDENTIFIER = com.zhuhaoyu.IconChanger;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -499,14 +492,6 @@
minimumVersion = 2.3.0;
};
};
9017B6142951B514005709C6 /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/getsentry/sentry-cocoa.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 7.0.0;
};
};
9083CCE72867FDBD0093A1B2 /* XCRemoteSwiftPackageReference "SwiftyJSON" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SwiftyJSON/SwiftyJSON";
Expand All @@ -531,16 +516,6 @@
package = 9017B5F6294DBBA9005709C6 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
9017B6152951B514005709C6 /* Sentry */ = {
isa = XCSwiftPackageProductDependency;
package = 9017B6142951B514005709C6 /* XCRemoteSwiftPackageReference "sentry-cocoa" */;
productName = Sentry;
};
9017B6172951B514005709C6 /* Sentry-Dynamic */ = {
isa = XCSwiftPackageProductDependency;
package = 9017B6142951B514005709C6 /* XCRemoteSwiftPackageReference "sentry-cocoa" */;
productName = "Sentry-Dynamic";
};
9083CCE82867FDBD0093A1B2 /* SwiftyJSON */ = {
isa = XCSwiftPackageProductDependency;
package = 9083CCE72867FDBD0093A1B2 /* XCRemoteSwiftPackageReference "SwiftyJSON" */;
Expand Down
17 changes: 17 additions & 0 deletions IconChanger/AliasName.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ struct AliasName {
"语雀": "yuque",
"System Settings": "Settings",
"Readwise_iBooks": "Readwise",
"Adobe Photoshop (Beta)": "Photoshop",
"Adobe Bridge (Beta)": "Bridge",
"Adobe Illustrator (Beta)": "Illustrator",
"Adobe Illustrator 2023": "Illustrator",
]

static func getNames() -> [String: String] {
Expand Down Expand Up @@ -43,6 +47,19 @@ struct AliasName {

UserDefaults.standard.synchronize()
}

static func setEmpty(for raw: String) {
do {
if let data = UserDefaults.standard.data(forKey: "AliasName"), var names = try? JSONDecoder().decode([String : String].self, from: data) {
names[raw] = nil
UserDefaults.standard.set(try JSONEncoder().encode(names), forKey: "AliasName")
}
} catch {
print(error)
}

UserDefaults.standard.synchronize()
}
}

extension Dictionary {
Expand Down
8 changes: 7 additions & 1 deletion IconChanger/IconManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,23 @@ class IconManager: ObservableObject {

func getIcons(_ app: LaunchPadManagerDBHelper.AppInfo) async throws -> [IconRes] {
let appName = app.name
let urlName = AliasName.getNames(for: app.url.deletingPathExtension().lastPathComponent) ?? app.url.deletingPathExtension().lastPathComponent
let urlName = app.url.deletingPathExtension().lastPathComponent
let bundleName = try getAppBundleName(app)
let aliasName = AliasName.getNames(for: app.url.deletingPathExtension().lastPathComponent)

var res = [IconRes]()

res.append(contentsOf: try await MyQueryRequestController().sendRequest(appName))
res.append(contentsOf: try await MyQueryRequestController().sendRequest(urlName))

if let bundleName {
res.append(contentsOf: try await MyQueryRequestController().sendRequest(bundleName))
}

if let aliasName {
res.append(contentsOf: try await MyQueryRequestController().sendRequest(aliasName))
}

return Set(res).map { $0 }
}

Expand Down
2 changes: 2 additions & 0 deletions IconChanger/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class MyQueryRequestController {
*/
let query = qeuryMix(query)

print(query)

let sessionConfig = URLSessionConfiguration.default

/* Create session, and optionally set a URLSessionDelegate. */
Expand Down
2 changes: 1 addition & 1 deletion IconChanger/SetAliasNameView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct SetAliasNameView: View {
ToolbarItem(placement: .confirmationAction) {
Button("Finish") {
if text.isEmpty {
AliasName.setName(raw, for: raw)
AliasName.setEmpty(for: raw)
} else {
AliasName.setName(text, for: raw)
}
Expand Down

0 comments on commit d176357

Please sign in to comment.