48 lines
1.5 KiB
Swift
48 lines
1.5 KiB
Swift
/*
|
|
* This file is part of the SDWebImage package.
|
|
* (c) DreamPiggy <lizhuoli1126@126.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
import Cocoa
|
|
import SwiftUI
|
|
import SDWebImage
|
|
import SDWebImageWebPCoder
|
|
import SDWebImageSVGCoder
|
|
import SDWebImagePDFCoder
|
|
|
|
@NSApplicationMain
|
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
|
var window: NSWindow!
|
|
|
|
|
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
|
// Create the SwiftUI view that provides the window contents.
|
|
let contentView = ContentView()
|
|
|
|
// Create the window and set the content view.
|
|
window = NSWindow(
|
|
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
|
|
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
|
|
backing: .buffered, defer: false)
|
|
window.center()
|
|
window.setFrameAutosaveName("Main Window")
|
|
window.contentView = NSHostingView(rootView: contentView)
|
|
window.makeKeyAndOrderFront(nil)
|
|
// Add WebP/SVG/PDF support
|
|
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
|
|
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
|
|
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
|
|
}
|
|
|
|
func applicationWillTerminate(_ aNotification: Notification) {
|
|
// Insert code here to tear down your application
|
|
}
|
|
|
|
|
|
}
|
|
|