mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: fix #117
This commit is contained in:
parent
b5a9884448
commit
b9b6e133d0
@ -4,6 +4,8 @@ import android.content.Intent
|
|||||||
import com.tencent.mmkv.MMKV
|
import com.tencent.mmkv.MMKV
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
import moe.fuqiuluo.shamrock.tools.GlobalJson5
|
import moe.fuqiuluo.shamrock.tools.GlobalJson5
|
||||||
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
|
import moe.fuqiuluo.shamrock.utils.MMKVFetcher
|
||||||
import mqq.app.MobileQQ
|
import mqq.app.MobileQQ
|
||||||
@ -15,10 +17,14 @@ internal object ShamrockConfig {
|
|||||||
if (it.exists()) it.delete()
|
if (it.exists()) it.delete()
|
||||||
it.mkdirs()
|
it.mkdirs()
|
||||||
}
|
}
|
||||||
private val Config: ServiceConfig by lazy {
|
private val Config = kotlin.runCatching {
|
||||||
GlobalJson5.decodeFromString(ConfigDir.resolve("config.json").also {
|
GlobalJson5.decodeFromString<ServiceConfig>(ConfigDir.resolve("config.json").also {
|
||||||
if (!it.exists()) it.writeText("{}")
|
if (!it.exists()) it.writeText("{}")
|
||||||
}.readText())
|
}.readText())
|
||||||
|
}.onFailure {
|
||||||
|
LogCenter.log("您的配置文件出现错误: ${it.stackTraceToString()}", Level.ERROR)
|
||||||
|
}.getOrElse {
|
||||||
|
ServiceConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun isInit(): Boolean {
|
fun isInit(): Boolean {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user