Merge pull request #737 from Celeter/master

优化
pull/743/head 3.20.121618
kunfei 5 years ago committed by GitHub
commit b7cd5bd176
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      .github/workflows/legado.yml
  2. 7
      app/src/main/java/io/legado/app/constant/AppConst.kt
  3. 10
      app/src/main/java/io/legado/app/help/JsExtensions.kt
  4. 2
      app/src/main/java/io/legado/app/model/webBook/BookInfo.kt
  5. 4
      app/src/main/java/io/legado/app/model/webBook/BookList.kt

@ -28,7 +28,7 @@ jobs:
# 蓝奏云里的文件夹名(需手动在蓝奏云创建) # 蓝奏云里的文件夹名(需手动在蓝奏云创建)
LANZOU_FOLDER: '阅读3测试版' LANZOU_FOLDER: '阅读3测试版'
# 是否上传到artifact # 是否上传到artifact
UPLOAD_ARTIFACT: 'true' UPLOAD_ARTIFACT: 'false'
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: set up JDK 1.8 - name: set up JDK 1.8
@ -57,7 +57,7 @@ jobs:
echo "开始进行release构建" echo "开始进行release构建"
chmod +x gradlew chmod +x gradlew
./gradlew assembleAppRelease ./gradlew assembleAppRelease
- name: upload apk - name: Upload App To Artifact
if: ${{ env.UPLOAD_ARTIFACT != 'false' }} if: ${{ env.UPLOAD_ARTIFACT != 'false' }}
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
@ -83,7 +83,7 @@ jobs:
f.write(res.content) f.write(res.content)
env: env:
FILEPATH: ${{ github.workspace }}/.github/lzy.py FILEPATH: ${{ github.workspace }}/.github/lzy.py
- name: Upload App - name: Upload App To Lanzou
if: ${{ env.LANZOU_PSD }} if: ${{ env.LANZOU_PSD }}
run: python $GITHUB_WORKSPACE/.github/lzy.py run: python $GITHUB_WORKSPACE/.github/lzy.py
env: env:

@ -36,9 +36,8 @@ object AppConst {
val keyboardToolChars: List<String> by lazy { val keyboardToolChars: List<String> by lazy {
arrayListOf( arrayListOf(
"", "@", "&", "|", "%", "/", "\\", ":", "[", "]", "{", "}", "<", ">", "", "@css:", "<js></js>", "{{}}", "&&", "%%", "||", "//", "$.", "@", "class", "id", "href",
"$", "#", "!", ".", "+", "-", "*", "=", "href", "src", "textNodes", "xpath", "json", "textNodes", "ownText", "all", "html", "[", "]", "<", ">","#", "!", ".", "+", "-", "*", "="
"css", "id", "class", "tag"
) )
} }
@ -69,4 +68,4 @@ object AppConst {
) )
val sysElevation = App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt() val sysElevation = App.INSTANCE.resources.getDimension(R.dimen.design_appbar_elevation).toInt()
} }

@ -54,10 +54,10 @@ interface JsExtensions {
} }
/** /**
* 实现文件下载,返回路径 * 实现16进制字符串转文件
*/ */
fun downloadFile(content: String, url: String): String { fun downloadFile(content: String, url: String): String {
val type = AnalyzeUrl(url).type ?: return "type为空,未下载" val type = AnalyzeUrl(url).type ?: return ""
val zipPath = FileUtils.getPath( val zipPath = FileUtils.getPath(
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), FileUtils.createFolderIfNotExist(FileUtils.getCachePath()),
"${MD5Utils.md5Encode16(url)}.${type}" "${MD5Utils.md5Encode16(url)}.${type}"
@ -76,6 +76,7 @@ interface JsExtensions {
* js实现压缩文件解压 * js实现压缩文件解压
*/ */
fun unzipFile(zipPath: String): String { fun unzipFile(zipPath: String): String {
if (zipPath.isEmpty()) return ""
val unzipPath = FileUtils.getPath( val unzipPath = FileUtils.getPath(
FileUtils.createFolderIfNotExist(FileUtils.getCachePath()), FileUtils.createFolderIfNotExist(FileUtils.getCachePath()),
FileUtils.getNameExcludeExtension(zipPath) FileUtils.getNameExcludeExtension(zipPath)
@ -92,6 +93,7 @@ interface JsExtensions {
* js实现文件夹内所有文件读取 * js实现文件夹内所有文件读取
*/ */
fun getTxtInFolder(unzipPath: String): String { fun getTxtInFolder(unzipPath: String): String {
if (unzipPath.isEmpty()) return ""
val unzipFolder = FileUtils.createFolderIfNotExist(unzipPath) val unzipFolder = FileUtils.createFolderIfNotExist(unzipPath)
val contents = StringBuilder() val contents = StringBuilder()
unzipFolder.listFiles().let { unzipFolder.listFiles().let {
@ -109,7 +111,7 @@ interface JsExtensions {
} }
/** /**
* js实现重定向拦截,不能删 * js实现重定向拦截,网络访问get
*/ */
fun get(urlStr: String, headers: Map<String, String>): Connection.Response { fun get(urlStr: String, headers: Map<String, String>): Connection.Response {
return Jsoup.connect(urlStr) return Jsoup.connect(urlStr)
@ -279,7 +281,7 @@ interface JsExtensions {
val oldCode = s.toInt() val oldCode = s.toInt()
if (font1.InLimit(s)) { if (font1.InLimit(s)) {
val code = font2.GetCodeByGlyf(font1.GetGlyfByCode(oldCode)) val code = font2.GetCodeByGlyf(font1.GetGlyfByCode(oldCode))
if(code != 0) contentArray[index] = code.toChar() if (code != 0) contentArray[index] = code.toChar()
} }
} }
return contentArray.joinToString("") return contentArray.joinToString("")

@ -70,7 +70,7 @@ object BookInfo {
analyzeRule.getString(infoRule.intro).let { analyzeRule.getString(infoRule.intro).let {
if (it.isNotEmpty()) book.intro = it.htmlFormat() if (it.isNotEmpty()) book.intro = it.htmlFormat()
} }
Debug.log(bookSource.bookSourceUrl, "${book.intro}", isHtml = true) Debug.log(bookSource.bookSourceUrl, "${book.intro}")
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接") Debug.log(bookSource.bookSourceUrl, "┌获取封面链接")
analyzeRule.getString(infoRule.coverUrl).let { analyzeRule.getString(infoRule.coverUrl).let {

@ -163,7 +163,7 @@ object BookList {
if (!scope.isActive) throw CancellationException() if (!scope.isActive) throw CancellationException()
Debug.log(bookSource.bookSourceUrl, "┌获取简介") Debug.log(bookSource.bookSourceUrl, "┌获取简介")
searchBook.intro = analyzeRule.getString(intro).htmlFormat() searchBook.intro = analyzeRule.getString(intro).htmlFormat()
Debug.log(bookSource.bookSourceUrl, "${searchBook.intro}", true) Debug.log(bookSource.bookSourceUrl, "${searchBook.intro}")
if (!scope.isActive) throw CancellationException() if (!scope.isActive) throw CancellationException()
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接") Debug.log(bookSource.bookSourceUrl, "┌获取封面链接")
searchBook.coverUrl = analyzeRule.getString(coverUrl, true) searchBook.coverUrl = analyzeRule.getString(coverUrl, true)
@ -223,7 +223,7 @@ object BookList {
if (!scope.isActive) throw CancellationException() if (!scope.isActive) throw CancellationException()
Debug.log(bookSource.bookSourceUrl, "┌获取简介", log) Debug.log(bookSource.bookSourceUrl, "┌获取简介", log)
searchBook.intro = analyzeRule.getString(ruleIntro).htmlFormat() searchBook.intro = analyzeRule.getString(ruleIntro).htmlFormat()
Debug.log(bookSource.bookSourceUrl, "${searchBook.intro}", log, true) Debug.log(bookSource.bookSourceUrl, "${searchBook.intro}", log)
if (!scope.isActive) throw CancellationException() if (!scope.isActive) throw CancellationException()
Debug.log(bookSource.bookSourceUrl, "┌获取封面链接", log) Debug.log(bookSource.bookSourceUrl, "┌获取封面链接", log)
analyzeRule.getString(ruleCoverUrl).let { analyzeRule.getString(ruleCoverUrl).let {

Loading…
Cancel
Save