1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-12 07:04:00 +00:00

feat: Add VS Code launch/task configurations and refactor app icon and resource management.

This commit is contained in:
Tw93
2025-12-15 14:00:27 +08:00
parent 46cebd7dbb
commit 4547f5819e
28 changed files with 111 additions and 35 deletions

19
app/Extensions.swift Normal file
View File

@@ -0,0 +1,19 @@
import AppKit
extension Bundle {
/// Loads an image from the bundle's resources by name.
///
/// This method attempts to load an image with the given name by trying
/// common image file extensions in order: PNG, JPG, and ICNS.
///
/// - Parameter name: The name of the image resource without extension.
/// - Returns: An NSImage if found, nil otherwise.
///
/// - Note: Supported formats: PNG, JPG, ICNS
func image(forResource name: String) -> NSImage? {
if let url = url(forResource: name, withExtension: "png") { return NSImage(contentsOf: url) }
if let url = url(forResource: name, withExtension: "jpg") { return NSImage(contentsOf: url) }
if let url = url(forResource: name, withExtension: "icns") { return NSImage(contentsOf: url) }
return nil
}
}