(
key: SystemConfigKey,
defaultValue: WithAsyncValue<Exclude<T, undefined>>
)
| 129 | } |
| 130 | |
| 131 | private async transferSyncToLocal<T>( |
| 132 | key: SystemConfigKey, |
| 133 | defaultValue: WithAsyncValue<Exclude<T, undefined>> |
| 134 | ): Promise<T> { |
| 135 | const syncVal = await this.syncStorage.get(key); |
| 136 | if (syncVal === undefined) { |
| 137 | this.cache.set(key, undefined); |
| 138 | return this.resolveDefault<T>(defaultValue); |
| 139 | } |
| 140 | // 迁移到 local storage 并从 sync 中删除 |
| 141 | await this.syncStorage.remove(key); // 先删除 |
| 142 | await this.localStorage.set(key, syncVal); // 删除成功后储回本地 |
| 143 | this.cache.set(key, syncVal); |
| 144 | return syncVal as T; |
| 145 | } |
| 146 | |
| 147 | private _get<T extends string | number | boolean | object>( |
| 148 | key: SystemConfigKey, |
no test coverage detected