Skip to content

Commit d44fe75

Browse files
docs: update README for v1.2.4 release
1 parent 7a0a686 commit d44fe75

8 files changed

Lines changed: 71 additions & 25 deletions

File tree

README.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ class MyViewModel: ViewModel() {
3838

3939
**注:此库是对Compose中使用其他框架(比如 Preference、MMKV、DataStore 等)的封装,不是一个单独的数据保存框架**。您可以参考[此链接](https://juejin.cn/post/7144750071156834312)以了解它的设计思想。
4040

41-
<img src="screenshot.png" alt="Example" style="zoom: 15%;" />
41+
在线预览:<https://funnysaltyfish.github.io/ComposeDataSaver/>
42+
43+
点击下方任意截图即可打开在线预览:
44+
45+
| 预览 1 | 预览 2 | 预览 3 |
46+
| --- | --- | --- |
47+
| <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/CN_1.jpg" alt="中文界面预览 1" width="240" /></a> | <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/CN_2.jpg" alt="中文界面预览 2" width="240" /></a> | <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/CN_3.jpg" alt="中文界面预览 3" width="240" /></a> |
4248

4349
您可以点击 [这里下载demo体验](demo.apk)(Debug 包,相较于 release 包较卡顿)
4450

@@ -60,7 +66,7 @@ dependencyResolutionManagement {
6066

6167
```bash
6268
dependencies {
63-
implementation "io.github.funnysaltyfish:data-saver-core:1.2.3"
69+
implementation "io.github.funnysaltyfish:data-saver-core:1.2.4"
6470
}
6571
```
6672

@@ -69,6 +75,8 @@ dependencies {
6975
## 示例代码
7076
以下介绍的示例代码均可在 [这里](composeApp/src/commonMain/kotlin/com/funny/data_saver/ui/ExampleComposables.kt) 查看具体实现
7177

78+
示例应用采用分组布局,并内置了日志侧边栏,方便直接查看读写日志与状态变化。
79+
7280
## 配置
7381

7482
项目使用 `DataSaverInterface` 的实现类来保存数据,因此**您需要先提供一个此类对象。**
@@ -93,7 +101,7 @@ CompositionLocalProvider(LocalDataSaver provides dataSaverPreferences){
93101

94102
```bash
95103
// if you want to use mmkv
96-
implementation "io.github.funnysaltyfish:data-saver-mmkv:1.2.3"
104+
implementation "io.github.funnysaltyfish:data-saver-mmkv:1.2.4"
97105
implementation 'com.tencent:mmkv:1.2.14'
98106
```
99107
@@ -121,7 +129,7 @@ CompositionLocalProvider(LocalDataSaver provides dataSaverMMKV){
121129
122130
```bash
123131
// if you want to use DataStore
124-
implementation "io.github.funnysaltyfish:data-saver-data-store-preferences:1.2.3"
132+
implementation "io.github.funnysaltyfish:data-saver-data-store-preferences:1.2.4"
125133
def data_store_version = "1.0.0"
126134
implementation "androidx.datastore:datastore:$data_store_version"
127135
implementation "androidx.datastore:datastore-preferences:$data_store_version"
@@ -398,19 +406,36 @@ open class SavePolicy {
398406
}
399407
```
400408
401-
### 设置库参数
409+
### 日志设置
402410
403-
目前,库提供了一些可以设置的参数,它们位于`DataSaverConfig`
411+
目前,库提供了分级日志配置,它们位于 `DataSaverConfig` 下:
404412
405-
```Kotlin
406-
/**
407-
* 1. DEBUG: 是否输出库的调试信息
408-
*/
413+
```kotlin
409414
object DataSaverConfig {
410-
var DEBUG = true
415+
var logLevel: DataSaverLogLevel = DataSaverLogLevel.INFO
411416
}
412417
```
413418
419+
可用级别如下:
420+
421+
```kotlin
422+
enum class DataSaverLogLevel {
423+
NONE,
424+
ERROR,
425+
WARNING,
426+
INFO,
427+
DEBUG,
428+
VERBOSE
429+
}
430+
```
431+
432+
默认级别为 `INFO`。在默认配置下,读取、恢复、写入、移除以及外部数据变更等关键日志都可直接看到。
433+
434+
> 注意:
435+
>
436+
> 1. `DataSaverLogger` 已移除,如果您之前直接使用它,请改为直接调用 `Log`
437+
> 2. `DataSaverConfig.DEBUG` 仍保留兼容入口,但后续推荐使用 `DataSaverConfig.logLevel`
438+
414439
### 异步保存
415440
416441
v1.1.0 对 `DataSaverInterface` 新增了 `suspend fun saveDataAsync` ,用于异步保存。默认情况下,它等同于 `saveData`。对于支持协程的框架(如`DataStore`),使用此实现有助于充分利用协程优势(默认给出的`DataStorePreference`就是如此)。

README_en.md

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ class MyViewModel: ViewModel() {
3737

3838
**Note: This library is a wrapper for using other frameworks (such as Preference, MMKV, DataStore, etc.) in Compose, not a standalone data storage framework**. You can refer to [this link](https://juejin.cn/post/7144750071156834312) to understand its design concepts.
3939

40-
<img src="screenshot.png" alt="Example" style="zoom: 15%;" />
40+
Online preview: <https://funnysaltyfish.github.io/ComposeDataSaver/>
41+
42+
Click any screenshot to view the online preview.
43+
44+
| Preview 1 | Preview 2 | Preview 3 |
45+
| --- | --- | --- |
46+
| <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/EN_1.jpg" alt="English UI Preview 1" width="240" /></a> | <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/EN_2.jpg" alt="English UI Preview 2" width="240" /></a> | <a href="https://funnysaltyfish.github.io/ComposeDataSaver/"><img src="screenshots/EN_3.jpg" alt="English UI Preview 3" width="240" /></a> |
4147

4248
You can click [here to download the demo for experience](demo.apk) (Debug package, may be slower compared to the release package)
4349

@@ -59,14 +65,16 @@ Include in project `build.gradle`
5965

6066
```bash
6167
dependencies {
62-
implementation "io.github.funnysaltyfish:data-saver-core:1.2.3"
68+
implementation "io.github.funnysaltyfish:data-saver-core:1.2.4"
6369
}
6470
```
6571
> Note: Starting from v1.2.0, the repository has been migrated to Compose Multiplatform and released to Maven Central. The Group Id has also been changed. When upgrading from versions before v1.2.0, please remember to make the necessary changes.
6672
6773
## Sample Code
6874
The sample codes described below can be viewed in detail [here](composeApp/src/commonMain/kotlin/com/funny/data_saver/ui/ExampleComposables.kt).
6975

76+
The demo app uses a grouped layout and includes a log sidebar, so you can inspect read/write logs and state changes more easily.
77+
7078
## Configuration
7179

7280
The project uses an implementation class of `DataSaverInterface` to save data, so **you need to provide an object of this class first.**
@@ -91,11 +99,7 @@ Additionally, we also provide simple implementations based on [MMKV](https://git
9199

92100
```bash
93101
// If you want to use MMKV
94-
The following:
95-
96-
```bash
97-
// If you want to use MMKV
98-
implementation "io.github.funnysaltyfish:data-saver-mmkv:1.2.3"
102+
implementation "io.github.funnysaltyfish:data-saver-mmkv:1.2.4"
99103
implementation 'com.tencent:mmkv:1.2.14'
100104
```
101105

@@ -123,7 +127,7 @@ CompositionLocalProvider(LocalDataSaver provides dataSaverMMKV){
123127

124128
```bash
125129
// if you want to use DataStore
126-
implementation "io.github.funnysaltyfish:data-saver-data-store-preferences:1.2.3"
130+
implementation "io.github.funnysaltyfish:data-saver-data-store-preferences:1.2.4"
127131
def data_store_version = "1.0.0"
128132
implementation "androidx.datastore:datastore:$data_store_version"
129133
implementation "androidx.datastore:datastore-preferences:$data_store_version"
@@ -389,19 +393,36 @@ open class SavePolicy {
389393
}
390394
```
391395
392-
### Setting Library Parameters
396+
### Logging Configuration
393397
394-
Currently, the library provides some parameters that can be set under `DataSaverConfig`.
398+
The library now provides leveled logging configuration under `DataSaverConfig`:
395399
396400
```kotlin
397-
/**
398-
* 1. DEBUG: Whether to output debug information of the library
399-
*/
400401
object DataSaverConfig {
401-
var DEBUG = true
402+
var logLevel: DataSaverLogLevel = DataSaverLogLevel.INFO
402403
}
403404
```
404405
406+
Available levels:
407+
408+
```kotlin
409+
enum class DataSaverLogLevel {
410+
NONE,
411+
ERROR,
412+
WARNING,
413+
INFO,
414+
DEBUG,
415+
VERBOSE
416+
}
417+
```
418+
419+
The default level is `INFO`. With the default configuration, important logs such as read, restore, write, remove, and external data change events are visible out of the box.
420+
421+
> Note:
422+
>
423+
> 1. `DataSaverLogger` has been removed. If you referenced it directly before, migrate to `Log`
424+
> 2. `DataSaverConfig.DEBUG` is still kept as a compatibility entry point, but `DataSaverConfig.logLevel` is now the recommended API
425+
405426
### Asynchronous Saving
406427
407428
In version 1.1.0, `suspend fun saveDataAsync` was added to `DataSaverInterface` for asynchronous saving. By default, it is equivalent to `saveData`. For frameworks that support coroutines (such as `DataStore`), using this implementation helps to fully leverage the advantages of coroutines (the default `DataStorePreference` does this).

screenshots/CN_1.jpg

477 KB
Loading

screenshots/CN_2.jpg

445 KB
Loading

screenshots/CN_3.jpg

777 KB
Loading

screenshots/EN_1.jpg

463 KB
Loading

screenshots/EN_2.jpg

516 KB
Loading

screenshots/EN_3.jpg

523 KB
Loading

0 commit comments

Comments
 (0)