feat: 添加云盘与消息中心功能

This commit is contained in:
2026-07-09 22:37:43 +08:00
parent 8e356973bd
commit f20ec7f06c
91 changed files with 5437 additions and 89 deletions

View File

@ -0,0 +1,62 @@
//
// CloudDriveFormatter.swift
// suixinkan
//
import Foundation
import UIKit
///
enum CloudDriveFormatter {
///
static func typeName(_ type: Int) -> String {
switch type {
case 1:
"视频"
case 2:
"图片"
case 99:
"文件夹"
default:
"文件"
}
}
///
static func fileDescription(_ file: CloudFile) -> String {
if file.isFolder {
return "\(file.childNum) 个项目"
}
return "\(typeName(file.type)) \(fileSize(file.fileSize))"
}
///
static func fileSize(_ bytes: Int64) -> String {
guard bytes > 0 else { return "0B" }
let units = ["B", "KB", "MB", "GB", "TB"]
var value = Double(bytes)
var index = 0
while value >= 1024, index < units.count - 1 {
value /= 1024
index += 1
}
if index == 0 {
return "\(Int(value))\(units[index])"
}
return String(format: "%.1f%@", value, units[index])
}
/// URL
static func fileExtension(_ value: String) -> String {
let ext = URL(string: value)?.pathExtension ?? URL(fileURLWithPath: value).pathExtension
return ext.isEmpty ? typeName(0) : ext.uppercased()
}
}
/// Android 访
enum CloudDriveAsset {
/// 使
static func image(named name: String, fallbackSystemName: String) -> UIImage? {
UIImage(named: name)?.withRenderingMode(.alwaysOriginal) ?? UIImage(systemName: fallbackSystemName)
}
}