mirror of
https://github.com/easychen/pushdeer.git
synced 2024-11-14 14:29:23 +08:00
2136883536
支持微信登录, 支持同时绑定微信和苹果账号; 解决markdown标题文字显示不全的问题; markdown中的链接支持内嵌浏览器打开; 增加是否使用内置浏览器的设置项; 改名输入框, 失去焦点的时候也保存;
47 lines
1.5 KiB
Swift
47 lines
1.5 KiB
Swift
//
|
|
// PushDeerApp.swift
|
|
// PushDeer
|
|
//
|
|
// Created by HEXT on 2021/12/25.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
@main
|
|
struct PushDeerApp: App {
|
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
let store = AppState.shared
|
|
let persistenceController = PersistenceController.shared
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
ContentView()
|
|
.onOpenURL(perform: { url in
|
|
print(#function, url)
|
|
#if !targetEnvironment(macCatalyst) && !APPCLIP && !SELFHOSTED
|
|
WXApi.handleOpen(url, delegate: WXDelegate.shared)
|
|
#endif
|
|
})
|
|
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb, perform: { userActivity in
|
|
print(#function, userActivity.webpageURL as Any)
|
|
#if !targetEnvironment(macCatalyst) && !APPCLIP && !SELFHOSTED
|
|
WXApi.handleOpenUniversalLink(userActivity, delegate: WXDelegate.shared)
|
|
#endif
|
|
})
|
|
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
|
|
// 后台进入前台后, 清空未读消息角标
|
|
UIApplication.shared.applicationIconBadgeNumber = 0
|
|
// 后台进入前台后, 刷新本地消息列表
|
|
if !AppState.shared.token.isEmpty {
|
|
Task {
|
|
let messageItems = try await HttpRequest.getMessages().messages
|
|
try MessageModel.saveAndUpdate(messageItems: messageItems)
|
|
}
|
|
}
|
|
}
|
|
.environmentObject(store)
|
|
.environment(\.managedObjectContext, persistenceController.container.viewContext)
|
|
}
|
|
}
|
|
}
|