ProfileStorage class

订阅配置档案的持久化存取(MMKV 元数据 + 文件系统配置体)。

元数据(Profile)存 MMKV(cs_profile 实例),sing-box 配置 JSON 写 profiles/ 目录下的文件;两者以 Profile.id 关联。

Constructors

ProfileStorage()
单例工厂构造器。
factory

Properties

generateProfileId → int
生成新的档案 ID(自增)。
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addProfile(Profile profile, SingBox singBox) → Future<void>
新增档案:配置 JSON 写文件、元数据入 MMKV;首个档案自动选中。
clear() → void
清空全部档案元数据(不动配置文件)。
deleteProfile(int id) → void
删除档案(元数据与配置文件一并删除),选中项自动顺延。
getProfile(int id) → Profile?
按 ID 读取档案元数据;不存在返回 null。
getProfileIds() → List<int>
全部档案 ID。
getProfilePath(int id) → Future<String>
取档案配置文件的完整路径(目录不存在则创建)。
getProfiles() → List<Profile>
全部档案,按用户排序值(order)升序。
getSelectedProfile() → Profile?
当前选中的档案;从未选择过时返回 null。
getStorageDirectory() → Future<Directory>
配置存储根目录:Android 取应用文档目录,Windows 取应用缓存目录。
getUsingConfig() → Future<File>
当前生效配置文件的路径(未设置时用存储根目录下的缺省文件名)。
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setSelectedProfile(int profileId) → bool
设为当前选中的档案。
setUsingConfig(String path) → void
记录当前生效配置所在目录。
sort(List<Profile> profiles) → void
按传入顺序重写各档案的 order。
toString() → String
A string representation of this object.
inherited
updateProfile(Profile profile) → void
更新档案元数据。

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

instance → ProfileStorage
单例实例。
no setter
storage → KeyValueStorage
底层键值存储;缺省惰性初始化为 MMKV。
no setter

Static Methods

mockInit() → void
仅用于单元测试, 用 MemoryStorage 代替默认的 MmkvStorage