添加印度尼西亚
This commit is contained in:
@@ -742,99 +742,99 @@ static NSString * const kKBSkinMetadataThemeKey = @"theme_json";
|
||||
NSString *skinsRoot = [baseRoot stringByAppendingPathComponent:@"Skins"];
|
||||
NSString *skinRoot = [skinsRoot stringByAppendingPathComponent:skinId];
|
||||
NSString *iconsDir = [skinRoot stringByAppendingPathComponent:@"icons"];
|
||||
|
||||
// 每次切换语言都强制重新解压,确保获取最新的皮肤资源
|
||||
NSLog(@"[SkinBridge] Force reinstall skin: %@", skinId);
|
||||
[fm removeItemAtPath:skinRoot error:nil];
|
||||
[fm createDirectoryAtPath:iconsDir
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:NULL];
|
||||
BOOL isDir = NO;
|
||||
BOOL hasIconsDir = [fm fileExistsAtPath:iconsDir isDirectory:&isDir] && isDir;
|
||||
NSArray *contents = hasIconsDir ? [fm contentsOfDirectoryAtPath:iconsDir error:NULL] : nil;
|
||||
BOOL hasCachedAssets = (contents.count > 0);
|
||||
NSString *bgPath = [skinRoot stringByAppendingPathComponent:@"background.png"];
|
||||
|
||||
NSString *fileName = zipName;
|
||||
if ([fileName hasPrefix:@"bundle://"]) {
|
||||
fileName = [fileName substringFromIndex:[@"bundle://" length]];
|
||||
}
|
||||
NSString *dir = [fileName stringByDeletingLastPathComponent];
|
||||
NSString *last = fileName.lastPathComponent;
|
||||
NSString *ext = last.pathExtension;
|
||||
NSString *base = last;
|
||||
if (ext.length == 0) {
|
||||
ext = @"zip";
|
||||
} else {
|
||||
base = [last stringByDeletingPathExtension];
|
||||
}
|
||||
|
||||
if (!hasCachedAssets) {
|
||||
NSString *fileName = zipName;
|
||||
if ([fileName hasPrefix:@"bundle://"]) {
|
||||
fileName = [fileName substringFromIndex:[@"bundle://" length]];
|
||||
}
|
||||
NSString *dir = [fileName stringByDeletingLastPathComponent];
|
||||
NSString *last = fileName.lastPathComponent;
|
||||
NSString *ext = last.pathExtension;
|
||||
NSString *base = last;
|
||||
if (ext.length == 0) {
|
||||
ext = @"zip";
|
||||
} else {
|
||||
base = [last stringByDeletingPathExtension];
|
||||
NSString *zipPath = nil;
|
||||
if (dir.length > 0) {
|
||||
zipPath = [bundle pathForResource:base ofType:ext inDirectory:dir];
|
||||
} else {
|
||||
zipPath = [bundle pathForResource:base ofType:ext];
|
||||
}
|
||||
|
||||
if (zipPath.length == 0) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:KBSkinBridgeErrorDomain
|
||||
code:KBSkinBridgeErrorZipMissing
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"Zip resource not found"}];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSString *zipPath = nil;
|
||||
if (dir.length > 0) {
|
||||
zipPath = [bundle pathForResource:base ofType:ext inDirectory:dir];
|
||||
} else {
|
||||
zipPath = [bundle pathForResource:base ofType:ext];
|
||||
}
|
||||
if (zipPath.length == 0) {
|
||||
if (error) {
|
||||
*error = [NSError errorWithDomain:KBSkinBridgeErrorDomain
|
||||
code:KBSkinBridgeErrorZipMissing
|
||||
userInfo:@{NSLocalizedDescriptionKey: @"Zip resource not found"}];
|
||||
}
|
||||
return NO;
|
||||
NSError *unzipError = nil;
|
||||
BOOL unzipOK = [SSZipArchive unzipFileAtPath:zipPath
|
||||
toDestination:skinRoot
|
||||
overwrite:YES
|
||||
password:nil
|
||||
error:&unzipError];
|
||||
if (!unzipOK || unzipError) {
|
||||
if (error) {
|
||||
*error = unzipError ?: [NSError errorWithDomain:KBSkinBridgeErrorDomain
|
||||
code:KBSkinBridgeErrorUnzipFailed
|
||||
userInfo:nil];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *unzipError = nil;
|
||||
BOOL ok = [SSZipArchive unzipFileAtPath:zipPath
|
||||
toDestination:skinRoot
|
||||
overwrite:YES
|
||||
password:nil
|
||||
error:&unzipError];
|
||||
if (!ok || unzipError) {
|
||||
if (error) {
|
||||
*error = unzipError ?: [NSError errorWithDomain:KBSkinBridgeErrorDomain
|
||||
code:KBSkinBridgeErrorUnzipFailed
|
||||
userInfo:nil];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
BOOL isDir2 = NO;
|
||||
NSArray *iconsContent = [fm contentsOfDirectoryAtPath:iconsDir error:NULL];
|
||||
BOOL iconsValid = ([fm fileExistsAtPath:iconsDir isDirectory:&isDir2] && isDir2 && iconsContent.count > 0);
|
||||
if (!iconsValid) {
|
||||
NSArray<NSString *> *subItems = [fm contentsOfDirectoryAtPath:skinRoot error:NULL];
|
||||
for (NSString *subName in subItems) {
|
||||
if ([subName isEqualToString:@"icons"] || [subName isEqualToString:@"__MACOSX"]) continue;
|
||||
NSString *nestedRoot = [skinRoot stringByAppendingPathComponent:subName];
|
||||
BOOL isDirNested = NO;
|
||||
if (![fm fileExistsAtPath:nestedRoot isDirectory:&isDirNested] || !isDirNested) continue;
|
||||
|
||||
BOOL isDir2 = NO;
|
||||
NSArray *iconsContent = [fm contentsOfDirectoryAtPath:iconsDir error:NULL];
|
||||
BOOL iconsValid = ([fm fileExistsAtPath:iconsDir isDirectory:&isDir2] && isDir2 && iconsContent.count > 0);
|
||||
if (!iconsValid) {
|
||||
NSArray<NSString *> *subItems = [fm contentsOfDirectoryAtPath:skinRoot error:NULL];
|
||||
for (NSString *subName in subItems) {
|
||||
if ([subName isEqualToString:@"icons"] || [subName isEqualToString:@"__MACOSX"]) continue;
|
||||
NSString *nestedRoot = [skinRoot stringByAppendingPathComponent:subName];
|
||||
BOOL isDirNested = NO;
|
||||
if (![fm fileExistsAtPath:nestedRoot isDirectory:&isDirNested] || !isDirNested) continue;
|
||||
|
||||
NSString *nestedIcons = [nestedRoot stringByAppendingPathComponent:@"icons"];
|
||||
BOOL isDirNestedIcons = NO;
|
||||
if ([fm fileExistsAtPath:nestedIcons isDirectory:&isDirNestedIcons] && isDirNestedIcons) {
|
||||
NSArray *nestedFiles = [fm contentsOfDirectoryAtPath:nestedIcons error:NULL];
|
||||
if (nestedFiles.count > 0) {
|
||||
[fm createDirectoryAtPath:iconsDir
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:NULL];
|
||||
for (NSString *fn in nestedFiles) {
|
||||
NSString *from = [nestedIcons stringByAppendingPathComponent:fn];
|
||||
NSString *to = [iconsDir stringByAppendingPathComponent:fn];
|
||||
[fm removeItemAtPath:to error:nil];
|
||||
[fm moveItemAtPath:from toPath:to error:nil];
|
||||
}
|
||||
NSString *nestedIcons = [nestedRoot stringByAppendingPathComponent:@"icons"];
|
||||
BOOL isDirNestedIcons = NO;
|
||||
if ([fm fileExistsAtPath:nestedIcons isDirectory:&isDirNestedIcons] && isDirNestedIcons) {
|
||||
NSArray *nestedFiles = [fm contentsOfDirectoryAtPath:nestedIcons error:NULL];
|
||||
if (nestedFiles.count > 0) {
|
||||
[fm createDirectoryAtPath:iconsDir
|
||||
withIntermediateDirectories:YES
|
||||
attributes:nil
|
||||
error:NULL];
|
||||
for (NSString *fn in nestedFiles) {
|
||||
NSString *from = [nestedIcons stringByAppendingPathComponent:fn];
|
||||
NSString *to = [iconsDir stringByAppendingPathComponent:fn];
|
||||
[fm removeItemAtPath:to error:nil];
|
||||
[fm moveItemAtPath:from toPath:to error:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSString *nestedBg = [nestedRoot stringByAppendingPathComponent:@"background.png"];
|
||||
if ([fm fileExistsAtPath:nestedBg]) {
|
||||
[fm removeItemAtPath:bgPath error:nil];
|
||||
[fm moveItemAtPath:nestedBg toPath:bgPath error:nil];
|
||||
}
|
||||
NSString *nestedBg = [nestedRoot stringByAppendingPathComponent:@"background.png"];
|
||||
if ([fm fileExistsAtPath:nestedBg]) {
|
||||
NSString *bgPath = [skinRoot stringByAppendingPathComponent:@"background.png"];
|
||||
[fm removeItemAtPath:bgPath error:nil];
|
||||
[fm moveItemAtPath:nestedBg toPath:bgPath error:nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NSString *bgPath = [skinRoot stringByAppendingPathComponent:@"background.png"];
|
||||
NSDictionary *shortNames = payload[kKBSkinPendingIconShortKey];
|
||||
if (![shortNames isKindOfClass:NSDictionary.class] || shortNames.count == 0) {
|
||||
NSString *currentLanguageCode = [[NSUserDefaults standardUserDefaults]
|
||||
|
||||
Reference in New Issue
Block a user