From 88128163f23e05e23ba20ff4ad85d8a28f1106aa Mon Sep 17 00:00:00 2001 From: AnemoFlower Date: Tue, 20 Jan 2026 18:38:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=95=B0=E6=8D=AE=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E4=B8=8E=20MessageBoxManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PCL.Mac/App/AppRouter.swift | 3 +-- PCL.Mac/App/MessageBoxManager.swift | 23 +++++++++++++++++++++++ PCL.Mac/Models/MessageBox.swift | 22 ++++++++++++++++++++++ 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 PCL.Mac/App/MessageBoxManager.swift create mode 100644 PCL.Mac/Models/MessageBox.swift 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 + } +}