import ComposeApp
import SwiftUI
import os

@main
struct iOSApp: App {
    
    var body: some Scene {
        let test1:String="111";
        WindowGroup {
            ContentView().onAppear(){

                NotificationCenter.default.addObserver(
                    forName: NSNotification.Name("set_os_signal"),
                    object: nil,
                    queue: .main
                ) { note in
                    if let dic = note.object as? NSDictionary {
                        let text = dic.object(forKey: "text") as! String
                        print("set_os_signal: \(text)")
                       // let staticText = StaticString(stringLiteral: text as String)
                        let isBeginNumber = dic.object(forKey: "isBegin") as! NSNumber
                        print("set_os_signal: \(isBeginNumber.boolValue)")
                        let signalId = dic.object(forKey: "id") as! NSString
                        let signpostID = OSSignpostID(log: .default, object: signalId)
                        print("set_os_signal: \(signalId)")

                        if isBeginNumber.boolValue == true {
                            os_signpost(.begin, log: .default, name: "开始", signpostID: signpostID)
                        } else {
                            // ✅ 结束事件
                            os_signpost(.end, log: .default, name: "结束", signpostID: signpostID)
                        }
                    }
                }

            }
                .ignoresSafeArea()
                .background(Color.clear)  // 确保整个背景透明
        }
        
    }


}
