@@ -279,9 +279,9 @@ public struct FLTabSettings {
279279 ]
280280 }
281281
282- private static func defaultBlueskySecondaryItems( accountKey: FLMicroBlogKey ) -> [ FLTabItem ] {
282+ private static func defaultBlueskySecondaryItems( accountKey _ : FLMicroBlogKey ) -> [ FLTabItem ] {
283283 [
284- // FLAllListTabItem(
284+ // FLAllListTabItem(
285285// metaData: FLTabMetaData(
286286// title: .localized(.list),
287287// icon: .mixed(.list, userKey: accountKey)
@@ -1174,11 +1174,11 @@ public struct FLProfileMediaTabItem: FLTabItem {
11741174// - AppBar统一存储数据结构
11751175// AppBar项目配置结构
11761176public struct AppBarItemConfig : Codable {
1177- public let key : String // 项目唯一标识
1178- public let type : AppBarItemType // 项目类型
1179- public let addedTime : Date // 添加时间
1180- public var metadata : [ String : String ] // 元数据
1181-
1177+ public let key : String // 项目唯一标识
1178+ public let type : AppBarItemType // 项目类型
1179+ public let addedTime : Date // 添加时间
1180+ public var metadata : [ String : String ] // 元数据
1181+
11821182 public init ( key: String , type: AppBarItemType , addedTime: Date = Date ( ) , metadata: [ String : String ] = [ : ] ) {
11831183 self . key = key
11841184 self . type = type
@@ -1189,36 +1189,36 @@ public struct AppBarItemConfig: Codable {
11891189
11901190// 项目类型枚举
11911191public enum AppBarItemType : String , Codable {
1192- case main // 主标签
1193- case secondary // 次要标签
1194- case list // 固定列表
1195- case feed // 固定Feed
1192+ case main // 主标签
1193+ case secondary // 次要标签
1194+ case list // 固定列表
1195+ case feed // 固定Feed
11961196}
11971197
11981198// 平台配置结构
11991199public struct PlatformAppBarConfig : Codable {
12001200 public var enabledItems : [ AppBarItemConfig ]
1201- public let version : Int = 1 // 添加版本字段便于未来扩展
1202-
1201+ public let version : Int = 1 // 添加版本字段便于未来扩展
1202+
12031203 public init ( enabledItems: [ AppBarItemConfig ] = [ ] ) {
12041204 self . enabledItems = enabledItems
12051205 }
12061206}
12071207
12081208// 扩展FLTabSettingsStorage添加AppBar配置相关方法
1209- extension FLTabSettingsStorage {
1209+ public extension FLTabSettingsStorage {
12101210 // 存储键名前缀
1211- private static let appBarConfigKeyPrefix = " appbar_config_3_ "
1212-
1211+ private static let appBarConfigKeyPrefix = " appbar_config_4_ "
1212+
12131213 // 获取AppBar配置存储键
12141214 private func appBarConfigKey( for platformType: PlatformType , accountKey: MicroBlogKey ) -> String {
12151215 let platformString = platformType. name
12161216 let accountString = accountKey. id
12171217 return " \( Self . appBarConfigKeyPrefix) \( platformString) _ \( accountString) "
12181218 }
1219-
1219+
12201220 // 保存AppBar配置
1221- public func saveAppBarConfig( _ config: PlatformAppBarConfig , for platformType: PlatformType , accountKey: MicroBlogKey ) {
1221+ func saveAppBarConfig( _ config: PlatformAppBarConfig , for platformType: PlatformType , accountKey: MicroBlogKey ) {
12221222 let key = appBarConfigKey ( for: platformType, accountKey: accountKey)
12231223 do {
12241224 let data = try JSONEncoder ( ) . encode ( config)
@@ -1227,90 +1227,90 @@ extension FLTabSettingsStorage {
12271227 NSLog ( " 保存AppBar配置失败: \( error. localizedDescription) " )
12281228 }
12291229 }
1230-
1230+
12311231 // 读取AppBar配置
1232- public func loadAppBarConfig( for platformType: PlatformType , accountKey: MicroBlogKey ) -> PlatformAppBarConfig ? {
1232+ func loadAppBarConfig( for platformType: PlatformType , accountKey: MicroBlogKey ) -> PlatformAppBarConfig ? {
12331233 let key = appBarConfigKey ( for: platformType, accountKey: accountKey)
12341234 guard let data = userDefaults. data ( forKey: key) else { return nil }
1235-
1235+
12361236 do {
12371237 return try JSONDecoder ( ) . decode ( PlatformAppBarConfig . self, from: data)
12381238 } catch {
12391239 NSLog ( " 加载AppBar配置失败: \( error. localizedDescription) " )
12401240 return nil
12411241 }
12421242 }
1243-
1243+
12441244 // 清除AppBar配置
1245- public func clearAppBarConfig( for platformType: PlatformType , accountKey: MicroBlogKey ) {
1245+ func clearAppBarConfig( for platformType: PlatformType , accountKey: MicroBlogKey ) {
12461246 let key = appBarConfigKey ( for: platformType, accountKey: accountKey)
12471247 userDefaults. removeObject ( forKey: key)
12481248 }
12491249}
12501250
12511251// 扩展FLTabSettingsManager添加AppBar配置相关方法
1252- extension FLTabSettingsManager {
1252+ public extension FLTabSettingsManager {
12531253 // 保存AppBar配置
1254- public func saveAppBarConfig( _ config: PlatformAppBarConfig , for user: UiUserV2 ) {
1254+ func saveAppBarConfig( _ config: PlatformAppBarConfig , for user: UiUserV2 ) {
12551255 storage. saveAppBarConfig ( config, for: user. platformType, accountKey: user. key)
12561256 }
1257-
1257+
12581258 // 读取AppBar配置
1259- public func getAppBarConfig( for user: UiUserV2 ) -> PlatformAppBarConfig {
1260- return storage. loadAppBarConfig ( for: user. platformType, accountKey: user. key) ?? PlatformAppBarConfig ( )
1259+ func getAppBarConfig( for user: UiUserV2 ) -> PlatformAppBarConfig {
1260+ storage. loadAppBarConfig ( for: user. platformType, accountKey: user. key) ?? PlatformAppBarConfig ( )
12611261 }
1262-
1262+
12631263 // 将FLTabItem转换为AppBarItemConfig
1264- public func convertTabToConfig( _ tab: FLTabItem , type: AppBarItemType , addedTime: Date = Date ( ) ) -> AppBarItemConfig {
1264+ func convertTabToConfig( _ tab: FLTabItem , type: AppBarItemType , addedTime: Date = Date ( ) ) -> AppBarItemConfig {
12651265 var metadata : [ String : String ] = [ : ]
1266-
1266+
12671267 // 添加标题元数据
12681268 switch tab. metaData. title {
12691269 case let . text( text) :
12701270 metadata [ " title " ] = text
12711271 case let . localized( key) :
12721272 metadata [ " title " ] = NSLocalizedString ( key, comment: " " )
12731273 }
1274-
1274+
12751275 return AppBarItemConfig (
12761276 key: tab. key,
12771277 type: type,
12781278 addedTime: addedTime,
12791279 metadata: metadata
12801280 )
12811281 }
1282-
1282+
12831283 // 将AppBarItemConfig转换回FLTabItem数组
1284- public func convertConfigToTabs( _ config: PlatformAppBarConfig , for user: UiUserV2 , accountType: AccountType ) -> [ FLTabItem ] {
1284+ func convertConfigToTabs( _ config: PlatformAppBarConfig , for user: UiUserV2 , accountType: AccountType ) -> [ FLTabItem ] {
12851285 // 获取默认标签以便查找
12861286 let defaultItems = FLTabSettings . defaultSecondary ( user: user)
12871287 let mainItems = FLTabSettings . defaultPrimary ( user: user)
12881288 let allDefaultItems = mainItems + defaultItems
1289-
1289+
12901290 // 按添加时间排序
12911291 let sortedItems = config. enabledItems. sorted { $0. addedTime < $1. addedTime }
1292-
1292+
12931293 // 转换为FLTabItem
12941294 var result : [ FLTabItem ] = [ ]
1295-
1295+
12961296 for item in sortedItems {
12971297 // 首先尝试从默认项中查找
12981298 if let tab = allDefaultItems. first ( where: { $0. key == item. key } ) {
12991299 result. append ( tab)
13001300 continue
13011301 }
1302-
1302+
13031303 // 特殊处理列表和Feed标签
13041304 if item. type == . list, let components = item. key. split ( separator: " _ " ) . last {
13051305 let listId = String ( components)
13061306 let title = item. metadata [ " title " ] ?? " List "
1307-
1307+
13081308 let listTab = FLListTimelineTabItem (
13091309 metaData: FLTabMetaData (
13101310 title: . text( title) ,
13111311 icon: . material( . list)
13121312 ) ,
1313- account: accountType, // 使用传入的accountType
1313+ account: accountType, // 使用传入的accountType
13141314 listKey: listId
13151315 )
13161316 result. append ( listTab)
@@ -1319,32 +1319,32 @@ extension FLTabSettingsManager {
13191319 if user. platformType == . bluesky {
13201320 let feedId = String ( components)
13211321 let title = item. metadata [ " title " ] ?? " Feed "
1322-
1322+
13231323 let feedTab = FLBlueskyFeedTabItem (
13241324 metaData: FLTabMetaData (
13251325 title: . text( title) ,
13261326 icon: . material( . feeds)
13271327 ) ,
1328- account: accountType, // 使用传入的accountType
1328+ account: accountType, // 使用传入的accountType
13291329 feedKey: feedId
13301330 )
13311331 result. append ( feedTab)
13321332 }
13331333 }
13341334 }
1335-
1335+
13361336 // 确保至少有主页标签
13371337 if result. isEmpty, let homeItem = mainItems. first {
13381338 result. append ( homeItem)
13391339 }
1340-
1340+
13411341 return result
13421342 }
1343-
1343+
13441344 // 创建默认配置
1345- public func createDefaultAppBarConfig( for user: UiUserV2 ) -> PlatformAppBarConfig {
1345+ func createDefaultAppBarConfig( for user: UiUserV2 ) -> PlatformAppBarConfig {
13461346 var items : [ AppBarItemConfig ] = [ ]
1347-
1347+
13481348 // 添加主标签,使用1970年确保始终排在最前
13491349 if let homeItem = FLTabSettings . defaultPrimary ( user: user) . first {
13501350 items. append ( convertTabToConfig (
@@ -1353,7 +1353,7 @@ extension FLTabSettingsManager {
13531353 addedTime: Date ( timeIntervalSince1970: 0 )
13541354 ) )
13551355 }
1356-
1356+
13571357 // 添加默认次要标签
13581358 let secondaryItems = FLTabSettings . defaultSecondary ( user: user) . prefix ( 3 )
13591359 for (index, item) in secondaryItems. enumerated ( ) {
@@ -1363,12 +1363,12 @@ extension FLTabSettingsManager {
13631363 addedTime: Date ( ) . addingTimeInterval ( Double ( index) * 60 )
13641364 ) )
13651365 }
1366-
1366+
13671367 return PlatformAppBarConfig ( enabledItems: items)
13681368 }
1369-
1369+
13701370 // 重置为默认AppBar配置
1371- public func resetToDefaultAppBarConfig( for user: UiUserV2 ) {
1371+ func resetToDefaultAppBarConfig( for user: UiUserV2 ) {
13721372 let defaultConfig = createDefaultAppBarConfig ( for: user)
13731373 saveAppBarConfig ( defaultConfig, for: user)
13741374 }
0 commit comments