Explorar el Código

备份:快捷键 字典 服务器 默认webDav账号

Xwite hace 3 años
padre
commit
3a448a2595

+ 4 - 0
app/src/main/java/io/legado/app/help/storage/Backup.kt

@@ -45,6 +45,8 @@ object Backup {
             "txtTocRule.json",
             "httpTTS.json",
             "keyboardAssists.json",
+            "dictRule.json",
+            "servers.json",
             DirectLinkUpload.ruleFileName,
             ReadBookConfig.configFileName,
             ReadBookConfig.shareConfigFileName,
@@ -86,6 +88,8 @@ object Backup {
             writeListToJson(appDb.txtTocRuleDao.all, "txtTocRule.json", backupPath)
             writeListToJson(appDb.httpTTSDao.all, "httpTTS.json", backupPath)
             writeListToJson(appDb.keyboardAssistsDao.all, "keyboardAssists.json", backupPath)
+            writeListToJson(appDb.dictRuleDao.all, "dictRule.json", backupPath)
+            writeListToJson(appDb.serverDao.all, "servers.json", backupPath)
             ensureActive()
             GSON.toJson(ReadBookConfig.configList).let {
                 FileUtils.createFileIfNotExist(backupPath + File.separator + ReadBookConfig.configFileName)

+ 4 - 4
app/src/main/java/io/legado/app/help/storage/BackupConfig.kt

@@ -45,10 +45,10 @@ object BackupConfig {
         PreferKey.backupPath,
         PreferKey.defaultBookTreeUri,
         PreferKey.webDavDeviceName,
-        PreferKey.webDavUrl,
-        PreferKey.webDavDir,
-        PreferKey.webDavAccount,
-        PreferKey.webDavPassword,
+       // PreferKey.webDavUrl,
+       // PreferKey.webDavDir,
+       // PreferKey.webDavAccount,
+       // PreferKey.webDavPassword,
         PreferKey.launcherIcon,
         PreferKey.bitmapCacheSize,
         PreferKey.webServiceWakeLock,

+ 9 - 0
app/src/main/java/io/legado/app/help/storage/Restore.kt

@@ -112,6 +112,15 @@ object Restore {
             fileToListT<HttpTTS>(path, "httpTTS.json")?.let {
                 appDb.httpTTSDao.insert(*it.toTypedArray())
             }
+            fileToListT<DictRule>(path, "dictRule.json")?.let {
+                appDb.dictRuleDao.insert(*it.toTypedArray())
+            }
+            fileToListT<Server>(path, "servers.json")?.let {
+                appDb.serverDao.insert(*it.toTypedArray())
+            }
+            fileToListT<KeyboardAssists>(path, "keyboardAssists.json")?.let {
+                appDb.keyboardAssistsDao.insert(*it.toTypedArray())
+            }
             fileToListT<ReadRecord>(path, "readRecord.json")?.let {
                 it.forEach { readRecord ->
                     //判断是不是本机记录

+ 4 - 10
app/src/main/java/io/legado/app/utils/NetworkUtils.kt

@@ -110,20 +110,14 @@ object NetworkUtils {
      * 获取绝对地址
      */
     fun getAbsoluteURL(baseURL: String?, relativePath: String): String {
-        if (baseURL.isNullOrEmpty()) return relativePath
-        if (relativePath.isAbsUrl()) return relativePath
-        if (relativePath.isDataUrl()) return relativePath
-        if (relativePath.startsWith("javascript")) return ""
-        var relativeUrl = relativePath
+        if (baseURL.isNullOrEmpty()) return relativePath.trim()
+        var absoluteUrl: URL? = null
         try {
-            val absoluteUrl = URL(baseURL.substringBefore(","))
-            val parseUrl = URL(absoluteUrl, relativePath)
-            relativeUrl = parseUrl.toString()
-            return relativeUrl
+            absoluteUrl = URL(baseURL.substringBefore(","))
         } catch (e: Exception) {
             e.printOnDebug()
         }
-        return relativeUrl
+        return getAbsoluteURL(absoluteUrl, relativePath)
     }
 
     /**