Quellcode durchsuchen

【功能】下载主题THM

xingcheng02 vor 1 Jahr
Ursprung
Commit
265b4ddf32

+ 1 - 1
XCTheme/Classes/Impl/XCThemeManager.swift

@@ -18,7 +18,7 @@ public class XCThemeManager: NSObject {
     
     public static let shared = XCThemeManager()
     
-    public private(set) var selectedTheme: XCThemeSpec? {
+    public var selectedTheme: XCThemeSpec? {
         didSet {
             self.forceThemeInterfaceStyleForWindows()
             var needRemovals = [PrepareThemeBlock]()

+ 7 - 1
XCTheme/Classes/Impl/XCThemeService.m

@@ -96,6 +96,12 @@
     NSString *downloadTHMPath = [rootPath stringByAppendingFormat:@"/ThemeResources/%@.thm", themeId];
     NSString *extractPath = [rootPath stringByAppendingFormat:@"/ThemeResources/%@", themeId];
     self.downloadBlock(themeId, downloadTHMPath, ^(BOOL success, NSString * _Nonnull reason) {
+        if (!success) {
+            if (completion) {
+                completion(NO, reason, nil);
+            }
+            return;
+        }
         BOOL extractSuccess = [SSZipArchive unzipFileAtPath:downloadTHMPath toDestination:extractPath uniqueId:nil];
         [NSFileManager.defaultManager removeItemAtPath:downloadTHMPath error:nil];
         if (!extractSuccess) {
@@ -128,7 +134,7 @@
 }
 
 - (void)applyTheme:(XCThemeSpecModel *)localSpec {
-    
+    XCThemeManager.shared.selectedTheme = localSpec.wrappedObject;
 }
 
 @end