fix ios & macos

This commit is contained in:
nyne
2024-10-27 20:42:20 +08:00
parent 3cea340f97
commit 99449bb3d1
3 changed files with 13 additions and 13 deletions

View File

@@ -34,25 +34,25 @@ class AppDelegate: FlutterAppDelegate {
}
}
func getDirectoryPath() {
func getDirectoryPath() {
let openPanel = NSOpenPanel()
openPanel.canChooseDirectories = true
openPanel.canChooseFiles = false
openPanel.allowsMultipleSelection = false
openPanel.begin { (result) in
if result == .OK {
self.directoryPath = openPanel.urls.first
if !self.directoryPath?.startAccessingSecurityScopedResource() ?? false {
self.flutterResult?(nil)
return
if result == .OK {
self.directoryPath = openPanel.urls.first
if let directoryPath = self.directoryPath, !directoryPath.startAccessingSecurityScopedResource() {
self.flutterResult?(nil)
return
}
self.flutterResult?(self.directoryPath?.path)
} else {
self.flutterResult?(nil)
}
self.flutterResult?(self.directoryPath?.path)
} else {
self.flutterResult?(nil)
}
}
}
}
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true