mirror of
https://github.com/gedoor/legado.git
synced 2024-07-17 00:58:29 +08:00
优化
This commit is contained in:
parent
555e15d534
commit
76fa03e518
@ -8,6 +8,7 @@ import io.legado.app.data.entities.Cookie
|
||||
import io.legado.app.help.CacheManager
|
||||
import io.legado.app.help.http.api.CookieManager
|
||||
import io.legado.app.utils.NetworkUtils
|
||||
import io.legado.app.utils.removeCookie
|
||||
|
||||
object CookieStore : CookieManager {
|
||||
|
||||
@ -61,7 +62,7 @@ object CookieStore : CookieManager {
|
||||
val domain = NetworkUtils.getSubDomain(url)
|
||||
appDb.cookieDao.delete(domain)
|
||||
CacheManager.deleteMemory("${domain}_cookie")
|
||||
android.webkit.CookieManager.getInstance().removeAllCookies(null)
|
||||
android.webkit.CookieManager.getInstance().removeCookie(domain)
|
||||
}
|
||||
|
||||
override fun cookieToMap(cookie: String): MutableMap<String, String> {
|
||||
|
@ -0,0 +1,22 @@
|
||||
package io.legado.app.utils
|
||||
|
||||
import android.webkit.CookieManager
|
||||
|
||||
|
||||
@Suppress("unused")
|
||||
fun CookieManager.removeCookie(domain: String) {
|
||||
val cm = CookieManager.getInstance()
|
||||
val urls = arrayOf(
|
||||
"http://$domain",
|
||||
"https://$domain"
|
||||
)
|
||||
urls.forEach { url ->
|
||||
val cookieGlob = cm.getCookie(url)
|
||||
cookieGlob.split(";").forEach {
|
||||
val cookieName = it.substringBefore("=")
|
||||
if (cookieName.isEmpty()) {
|
||||
cm.setCookie(url, "$cookieName=; Expires=Wed, 31 Dec 2000 23:59:59 GMT")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user