1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- //
- // AppDelegate.swift
- // TSLiveWallpaper
- //
- // Created by 100Years on 2024/12/19.i
- //
- import StoreKit
- import TSVideoKit
- import UIKit
- import Kingfisher
- @main
- class AppDelegate: UIResponder, UIApplicationDelegate {
- var window: UIWindow?
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
- window = UIWindow(frame: UIScreen.main.bounds)
- window?.backgroundColor = UIColor.black
- window?.makeKeyAndVisible()
- goToLoadVC()
- initBaseDatas()
- initPlatform()
- downloadNotifaction()
- return true
- }
- func goToTab() {
- window?.rootViewController = TSTabBarController()
- }
- func goToLoadVC() {
- _ = TSImageDataCenter.shared
- window?.rootViewController = TSLaunchVC()
-
- }
- func initBaseDatas() {
- var config = TSConfiguration.default
- config.configurePath = "http://p.100yearslater.com/live/config"
- TSVideoOperator.shared.loadWithConfiguration(config: config, needJs: false)
- if let videoId = UserDefaults.standard.string(forKey: "lastedVideoId"),
- !videoId.isEmpty,
- let lastVideo = TSVideoOperator.shared.dataManager.fetchVideo(videoId: videoId) {
- TSVideoOperator.shared.playerViewModel.currentVideo = lastVideo
- TSVideoOperator.shared.playerViewModel.currentVideos = TSVideoOperator.shared.dataManager.fetchCachedVideos()
- PlayerManager.shared.miniBar.updateVideoInfo(video: lastVideo, state: .pause)
- }
- if let loopMode = UserDefaults.standard.string(forKey: "lastedPlayMode") {
- let mMode = LoopMode(rawValue: loopMode) ?? .cyclic
- TSVideoOperator.shared.playerViewModel.loopMode = mMode
- }
- }
- @objc func recordData() {
- if UserDefaults.standard.value(forKey: "CachedTag") == nil {
- UserDefaults.standard.setValue("1", forKey: "CachedTag")
- SKStoreReviewController.requestReview()
- }
- }
- func downloadNotifaction() {
- NotificationCenter.default.addObserver(self, selector: #selector(recordData), name: kGroupDownloadFinishNotifactionName, object: nil)
- }
- func applicationDidBecomeActive(_ application: UIApplication) {
- }
- func applicationWillTerminate(_ application: UIApplication) {
- UserDefaults.standard.setValue(PlayerManager.shared.currentVideo?.videoId ?? "", forKey: "lastedVideoId")
- UserDefaults.standard.setValue(PlayerManager.shared.currentLoopMode.rawValue, forKey: "lastedPlayMode")
- }
- func applicationWillEnterForeground(_ application: UIApplication) {
-
- }
- }
- extension AppDelegate {
- func initPlatform() {
- dePrint("TSRMShared.aiListDB.listModels.count=\(TSRMShared.aiListDB.listModels.count)")
- TSColorConfigShared.naviMianTextColor = .white
-
- let cache = ImageCache(name: "permanent_image_cache")
- cache.diskStorage.config.expiration = .never // 永不过期
- cache.diskStorage.config.sizeLimit = 0 // 无大小限制
- KingfisherManager.shared.cache = cache
-
- }
- }
|