选择图片分享功能
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
struct Album: Codable {
|
||||
let album_id: String
|
||||
let name: String
|
||||
let authors: [String]
|
||||
let actors: [String]
|
||||
let tags: [String]
|
||||
let image_urls: [String]
|
||||
let nums: [Int]
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case album_id, name, authors, actors, tags
|
||||
case image_urls = "image_urls"
|
||||
case nums
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// 共用的数据模型
|
||||
struct AlbumItem: Codable, Identifiable {
|
||||
let album_id: String
|
||||
let title: String
|
||||
|
||||
var id: String { album_id }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import Foundation
|
||||
|
||||
// 配置类:统一管理API地址、常量等
|
||||
final class Config {
|
||||
// 单例实例,确保全局唯一
|
||||
static let shared = Config()
|
||||
|
||||
// 服务器主机地址(HOST)
|
||||
private let host = "http://jm.rbq.college"
|
||||
|
||||
// 私有初始化方法,防止外部创建实例
|
||||
private init() {}
|
||||
|
||||
// 拼接完整的API地址
|
||||
func apiURL(path: String) -> String {
|
||||
// 处理path开头的斜杠,确保拼接正确
|
||||
let formattedPath = path.starts(with: "/") ? path : "/\(path)"
|
||||
return "\(host)\(formattedPath)"
|
||||
}
|
||||
|
||||
// 常用API路径常量(可选,进一步简化调用)
|
||||
struct Path {
|
||||
static let search = "search/" // 搜索接口
|
||||
static let albumDetail = "album/" // 漫画详情接口
|
||||
static let rankings = "rankings/" // 排行榜接口(如果有)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user