Files
real-e-party-iOS/YuMi/E-P/Moments/Services/EPMomentAPISwiftHelper.swift
edwinQQQ f84044425f feat: 添加优化版本的 Localizable.strings 清理工具
主要变更:
1. 新增 clean_localizable_optimized.py 脚本,用于清理 Localizable.strings 文件,只保留使用的 key,并移除多余空行。
2. 优化了清理逻辑,支持多语言版本的处理,提升了文件的整洁性和可维护性。
3. 生成清理报告,显示保留和删除的 key 数量及删除率。

此更新旨在提高本地化文件的管理效率,减少冗余内容。
2025-10-17 15:38:34 +08:00

97 lines
3.3 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Created by AI on 2025-10-11.
import Foundation
@objc class EPMomentAPISwiftHelper: NSObject {
@objc func fetchLatestMomentsWithNextID(
_ nextID: String,
completion: @escaping ([MomentsInfoModel], String) -> Void,
failure: @escaping (Int, String) -> Void
) {
let pageSize = "20"
let types = "0,2"
NSLog("[EPMomentAPISwiftHelper] 🔄 开始请求动态列表nextID=\(nextID.isEmpty ? "(首页)" : nextID)")
Api.momentsLatestList({ (data, code, msg) in
NSLog("[EPMomentAPISwiftHelper] 📥 收到响应code=\(code)")
if code == 200, let dict = data?.data as? NSDictionary {
NSLog("[EPMomentAPISwiftHelper] 📦 开始解析数据字典")
if let listInfo = MomentsListInfoModel.mj_object(withKeyValues: dict) {
let dynamicList = listInfo.dynamicList
let nextDynamicId = listInfo.nextDynamicId
NSLog("[EPMomentAPISwiftHelper] ✅ 解析成功dynamicList.count=\(dynamicList.count), nextDynamicId=\(nextDynamicId)")
completion(dynamicList, nextDynamicId)
} else {
NSLog("[EPMomentAPISwiftHelper] ⚠️ 解析失败,返回空数组")
completion([], "")
}
} else {
NSLog("[EPMomentAPISwiftHelper] ❌ 请求失败code=\(code), msg=\(msg ?? "无错误信息")")
failure(Int(code), msg ?? YMLocalizedString("error.request_failed"))
}
}, dynamicId: nextID, pageSize: pageSize, types: types)
}
@objc func publishMoment(
type: String,
content: String,
resList: [[String: Any]],
completion: @escaping () -> Void,
failure: @escaping (Int, String) -> Void
) {
guard let uid = AccountInfoStorage.instance().getUid() else {
failure(-1, YMLocalizedString("error.not_logged_in"))
return
}
// NOTE: XPMonentsPublishViewController
Api.momentsPublish({ (data, code, msg) in
if code == 200 {
completion()
} else {
failure(Int(code), msg ?? YMLocalizedString("error.publish_failed"))
}
}, uid: uid, type: type, worldId: "", content: content, resList: resList)
}
@objc func likeMoment(
dynamicId: String,
isLike: Bool,
likedUid: String,
worldId: Int,
completion: @escaping () -> Void,
failure: @escaping (Int, String) -> Void
) {
guard let uid = AccountInfoStorage.instance().getUid() else {
failure(-1, YMLocalizedString("error.not_logged_in"))
return
}
let status = isLike ? "1" : "0"
let worldIdStr = String(format: "%ld", worldId)
Api.momentsLike({ (data, code, msg) in
if code == 200 {
completion()
} else {
failure(Int(code), msg ?? YMLocalizedString("error.like_failed"))
}
}, dynamicId: dynamicId, uid: uid, status: status, likedUid: likedUid, worldId: worldIdStr)
}
}