diff --git a/PCL.Mac/App/AppRouter.swift b/PCL.Mac/App/AppRouter.swift index 66a3cd7..9e934d3 100644 --- a/PCL.Mac/App/AppRouter.swift +++ b/PCL.Mac/App/AppRouter.swift @@ -119,6 +119,5 @@ class AppRouter: ObservableObject { } } - private init() { - } + private init() {} } diff --git a/PCL.Mac/App/MessageBoxManager.swift b/PCL.Mac/App/MessageBoxManager.swift new file mode 100644 index 0000000..6a20804 --- /dev/null +++ b/PCL.Mac/App/MessageBoxManager.swift @@ -0,0 +1,23 @@ +// +// MessageBoxManager.swift +// PCL.Mac +// +// Created by 温迪 on 2026/1/20. +// + +import Foundation + +class MessageBoxManager: ObservableObject { + public static let shared: MessageBoxManager = .init() + @Published public private(set) var currentMessageBox: MessageBox? + + public func showText(title: String, body: String, level: MessageBox.Level = .info) { + currentMessageBox = .init(title: title, body: .text(text: body), level: level) + } + + public func close() { + currentMessageBox = nil + } + + private init() {} +} diff --git a/PCL.Mac/Models/MessageBox.swift b/PCL.Mac/Models/MessageBox.swift new file mode 100644 index 0000000..2268951 --- /dev/null +++ b/PCL.Mac/Models/MessageBox.swift @@ -0,0 +1,22 @@ +// +// MessageBox.swift +// PCL.Mac +// +// Created by 温迪 on 2026/1/20. +// + +import Foundation + +struct MessageBox { + public let title: String + public let body: Body + public let level: Level + + public enum Body { + case text(text: String) + } + + public enum Level { + case info, error + } +}