Skip to content

Commit

Permalink
docs: 使用文档
Browse files Browse the repository at this point in the history
  • Loading branch information
liangjingkanji committed Aug 4, 2023
1 parent 05c3164 commit 1da20e5
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 79 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
| setDebug | 是否输出网络日志, 和`LogRecordInterceptor`互不影响 |
| setSSLCertificate | 配置Https证书 |
| trustSSLCertificate | 信任所有Https证书 |
| setConverter | [配置数据转换器](customizer-converter.md), 将网络返回的数据转换成你想要的数据结构 |
| setConverter | [配置数据转换器](converter-customize.md), 将网络返回的数据转换成你想要的数据结构 |
| setRequestInterceptor | [配置请求拦截器](interceptor.md), 适用于添加全局请求头/参数 |
| setErrorHandler | [配置全局错误处理](error-global.md) |
| setDialogFactory | [配置全局对话框](auto-dialog.md) |
Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 8 additions & 9 deletions docs/converter.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Net支持请求返回的数据类型取决于你自己的转换器实现(即理论上支持返回任何对象):
Net支持请求返回的数据类型取决于你自己的转换器实现

# Get<任何对象>("path").await()

如果不自定义转换器默认支持返回以下数据类型
默认转换器支持返回以下数据类型

| 函数 | 描述 |
|-|-|
| String | 字符串 |
| ByteArray | 字节数组 |
| ByteString | 内部定义的一种字符串对象 |
| ByteString | 更多功能的字符串对象 |
| File | 文件对象, 这种情况其实应当称为[下载文件](download-file.md) |
| Response | 最基础的, 包含全部响应信息的对象(响应体/响应头/请求信息等) |
| Response | 所有响应信息(响应体/响应头/请求信息等) |

使用示例

Expand All @@ -20,10 +20,9 @@ scopeNetLife {
}
```

??? summary "
默认使用的是: [NetConverter.DEFAULT](https://github.com/liangjingkanji/Net/blob/master/net/src/main/java/com/drake/net/convert/NetConverter.kt)"
```kotlin
interface NetConverter {
??? example "转换器实现非常简单"
```kotlin title="NetConverter.kt" linenums="1"
interface NetConverter {

@Throws(Throwable::class)
fun <R> onConvert(succeed: Type, response: Response): R?
Expand All @@ -48,4 +47,4 @@ interface NetConverter {
}
```

假设这里没有你需要的数据类型请[自定义转换器](/converter/#_3)(例如返回JsonProtocol)
假设不支持你需要的数据类型, 例如JSON/ProtoBuf/Bitmap等请[自定义转换器](/converter/#_3)
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/error-default.md → docs/error.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Net具备完善的错误处理机制, 能捕获大部分网络请求或者异步

如果捕获到错误默认会执行以下操作

- `Logcat`中会输出详细的异常堆栈信息, 如果想要输出更详细内容请阅读[自定义异常](error-exception.md)
- `Logcat`中会输出详细的异常堆栈信息, 如果想要输出更详细内容请阅读[自定义异常](error-throws.md)
- `Toast`吐司错误异常信息, 如果想要自定义或者国际化错误文本请阅读[自定义错误提示](error-tip.md)

<br>
Expand Down
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ scopeNetLife {
}
```

详细查看[转换器](customizer-converter.md), 非以上类型要求[自定义转换器](customizer-converter.md)
详细查看[转换器](converter.md), 非以上类型要求[自定义转换器](converter-customize.md)

---
[下载Apk](https://github.com/liangjingkanji/Net/releases/latest/download/net-sample.apk){ .md-button }
[下载源码](https://github.com/liangjingkanji/Net.git){ .md-button }
[示例代码](https://github.com/liangjingkanji/Net/tree/master/sample/src/main/java/com/drake/net/sample/ui/fragment){ .md-button }
[项目实战](https://github.com/liangjingkanji/Net/tree/master/sample/src/main/java/com/drake/net/sample/ui/fragment){ .md-button }
59 changes: 0 additions & 59 deletions docs/read-cache.md

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion docs/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
- 修复未知的TypeToken访问权限问题

## 3.0.6
- 所有Json解析框架都可以解析`List<UserModel>`等嵌套泛型数据结构: [特殊结构解析](convert-special.md)
- 所有Json解析框架都可以解析`List<UserModel>`等嵌套泛型数据结构

## 3.0.5
- 修复Path编码问题
Expand Down
12 changes: 6 additions & 6 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ nav:
- 全局配置: config.md
- 请求结果:
- 转换器: converter.md
- 自定义转换器: customizer-converter.md
- 自定义结构解析: convert-special.md
- 自定义转换器: converter-customize.md
- 自定义结构解析: converter-struct.md
- Kotlin-Serialization: kotlin-serialization.md
- 数据类生成插件: model-generate.md
- 自动化:
- 自动加载框: auto-dialog.md
- 自动缺省页: auto-state.md
- 自动下拉刷新: auto-refresh.md
- 自动分页加载: auto-page.md
- 自动分页加载: auto-pull.md
- 切换线程: thread.md
- ViewModel: view-model.md
- 异常追踪: exception-track.md
- 异常追踪: track.md
- 错误处理:
- 默认错误处理: error-default.md
- 默认错误处理: error.md
- 单例错误捕获: error-single.md
- 全局错误捕获: error-global.md
- 自定义错误提示: error-tip.md
- 自定义异常抛出: error-exception.md
- 自定义异常抛出: error-throws.md
- OkHttpClient: okhttp-client.md
- 拦截器: interceptor.md
- Https证书: https.md
Expand Down
2 changes: 1 addition & 1 deletion sample/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Add project specific ProGuard rules here.
# You can control the setKalle of applied configuration files using the
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
Expand Down

0 comments on commit 1da20e5

Please sign in to comment.