fix: 快照 explicitNulls=true

This commit is contained in:
lisonge 2023-10-24 15:31:18 +08:00
parent 83677ea6cf
commit af113619fe
3 changed files with 10 additions and 2 deletions

View File

@ -32,7 +32,7 @@ data class NodeInfo(
quickFind: Boolean?,
): Boolean? {
// 如果父节点是无法查找的, 则所有子节点都是无法查找的
// 如果一个节点是可查找的, 则所有兄弟节点都是可查找的(如果满足条件)
// 如果一个节点是可查找的, 则所有兄弟节点及其祖先节点都是可查找的(如果满足条件)
return if (nodeInfo != null) {
val viewId = nodeInfo.viewIdResourceName
if (viewId != null && viewId.isNotEmpty()) { // id='' 不满足查找

View File

@ -112,7 +112,7 @@ object SnapshotExt {
val stream = File(getScreenshotPath(snapshot.id)).outputStream()
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream)
stream.close()
val text = Singleton.json.encodeToString(snapshot)
val text = Singleton.keepNullJson.encodeToString(snapshot)
File(getSnapshotPath(snapshot.id)).writeText(text)
DbSet.snapshotDao.insert(snapshot.toSnapshot())
}

View File

@ -20,6 +20,14 @@ object Singleton {
}
}
val keepNullJson by lazy {
Json {
isLenient = true
ignoreUnknownKeys = true
encodeDefaults = true
}
}
val client by lazy {
HttpClient(OkHttp) {
install(ContentNegotiation) {