Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

kunfei 3 лет назад
Родитель
Сommit
921bad3eca

+ 1 - 1
app/build.gradle

@@ -214,7 +214,7 @@ dependencies {
     //网络
     //网络
     implementation('com.squareup.okhttp3:okhttp:4.11.0')
     implementation('com.squareup.okhttp3:okhttp:4.11.0')
     appImplementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
     appImplementation(fileTree(dir: 'cronetlib', include: ['*.jar', '*.aar']))
-    appImplementation 'com.google.protobuf:protobuf-javalite:3.23.0'
+    appImplementation 'com.google.protobuf:protobuf-javalite:3.23.1'
 
 
     //Glide
     //Glide
     def glideVersion = "4.15.1"
     def glideVersion = "4.15.1"

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
app/src/main/assets/web/vue/assets/BookChapter-41769cd4.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
app/src/main/assets/web/vue/assets/BookShelf-8954be5f.js


+ 1 - 1
app/src/main/assets/web/vue/assets/config-f501cff0.js → app/src/main/assets/web/vue/assets/config-272d962d.js

@@ -1 +1 @@
-import{A as f,u as i}from"./index-a856ee26.js";import"./vendor-b9134af1.js";f.getReadConfig().then(e=>{var t=e.data.data;if(t){const a=i();let o=JSON.parse(t),s=a.config;o=Object.assign(s,o),a.setConfig(o)}});
+import{A as f,u as i}from"./index-8ff7a1b1.js";import"./vendor-b9134af1.js";f.getReadConfig().then(e=>{var t=e.data.data;if(t){const a=i();let o=JSON.parse(t),s=a.config;o=Object.assign(s,o),a.setConfig(o)}});

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
app/src/main/assets/web/vue/assets/index-38115393.css


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
app/src/main/assets/web/vue/assets/index-8ff7a1b1.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
app/src/main/assets/web/vue/assets/index-a856ee26.js


Разница между файлами не показана из-за своего большого размера
+ 0 - 0
app/src/main/assets/web/vue/assets/loading-bde9ba73.js


+ 2 - 2
app/src/main/assets/web/vue/index.html

@@ -4,10 +4,10 @@
         <meta charset="UTF-8" />
         <meta charset="UTF-8" />
         <link rel="icon" href="./favicon.ico" />
         <link rel="icon" href="./favicon.ico" />
     <meta name="viewport" content="width=device-width,initial-scale=1.0" />
     <meta name="viewport" content="width=device-width,initial-scale=1.0" />
-      <script type="module" crossorigin src="./assets/index-a856ee26.js"></script>
+      <script type="module" crossorigin src="./assets/index-8ff7a1b1.js"></script>
       <link rel="modulepreload" crossorigin href="./assets/vendor-b9134af1.js">
       <link rel="modulepreload" crossorigin href="./assets/vendor-b9134af1.js">
       <link rel="stylesheet" href="./assets/vendor-5578283d.css">
       <link rel="stylesheet" href="./assets/vendor-5578283d.css">
-      <link rel="stylesheet" href="./assets/index-f0744ec1.css">
+      <link rel="stylesheet" href="./assets/index-38115393.css">
     </head>
     </head>
 
 
     <body>
     <body>

+ 22 - 3
app/src/main/java/io/legado/app/ui/book/read/page/provider/ChapterProvider.kt

@@ -182,7 +182,7 @@ object ChapterProvider {
                     }
                     }
                     durY = setTypeImage(
                     durY = setTypeImage(
                         book, matcher.group(1)!!,
                         book, matcher.group(1)!!,
-                        absStartX, durY, textPages, book.getImageStyle()
+                        absStartX, durY, textPages, stringBuilder, book.getImageStyle()
                     )
                     )
                     start = matcher.end()
                     start = matcher.end()
                 }
                 }
@@ -232,13 +232,17 @@ object ChapterProvider {
         x: Int,
         x: Int,
         y: Float,
         y: Float,
         textPages: ArrayList<TextPage>,
         textPages: ArrayList<TextPage>,
+        stringBuilder: StringBuilder,
         imageStyle: String?,
         imageStyle: String?,
     ): Float {
     ): Float {
         var durY = y
         var durY = y
         val size = ImageProvider.getImageSize(book, src, ReadBook.bookSource)
         val size = ImageProvider.getImageSize(book, src, ReadBook.bookSource)
         if (size.width > 0 && size.height > 0) {
         if (size.width > 0 && size.height > 0) {
             if (durY > visibleHeight) {
             if (durY > visibleHeight) {
-                textPages.last().height = durY
+                val textPage = textPages.last()
+                textPage.height = durY
+                textPage.text = stringBuilder.toString()
+                stringBuilder.clear()
                 textPages.add(TextPage())
                 textPages.add(TextPage())
                 durY = 0f
                 durY = 0f
             }
             }
@@ -249,6 +253,7 @@ object ChapterProvider {
                     width = visibleWidth
                     width = visibleWidth
                     height = size.height * visibleWidth / size.width
                     height = size.height * visibleWidth / size.width
                 }
                 }
+
                 else -> {
                 else -> {
                     if (size.width > visibleWidth) {
                     if (size.width > visibleWidth) {
                         height = size.height * visibleWidth / size.width
                         height = size.height * visibleWidth / size.width
@@ -259,7 +264,10 @@ object ChapterProvider {
                         height = visibleHeight
                         height = visibleHeight
                     }
                     }
                     if (durY + height > visibleHeight) {
                     if (durY + height > visibleHeight) {
-                        textPages.last().height = durY
+                        val textPage = textPages.last()
+                        textPage.height = durY
+                        textPage.text = stringBuilder.toString()
+                        stringBuilder.clear()
                         textPages.add(TextPage())
                         textPages.add(TextPage())
                         durY = 0f
                         durY = 0f
                     }
                     }
@@ -326,8 +334,10 @@ object ChapterProvider {
                     y - textLayoutHeight
                     y - textLayoutHeight
                 }
                 }
             }
             }
+
             isTitle && textPages.size == 1 && textPages.last().lines.isEmpty() ->
             isTitle && textPages.size == 1 && textPages.last().lines.isEmpty() ->
                 y + titleTopSpacing
                 y + titleTopSpacing
+
             else -> y
             else -> y
         }
         }
         for (lineIndex in 0 until layout.lineCount) {
         for (lineIndex in 0 until layout.lineCount) {
@@ -363,6 +373,7 @@ object ChapterProvider {
                         textPaint, desiredWidth, srcList
                         textPaint, desiredWidth, srcList
                     )
                     )
                 }
                 }
+
                 lineIndex == layout.lineCount - 1 -> {
                 lineIndex == layout.lineCount - 1 -> {
                     //最后一行
                     //最后一行
                     textLine.text = words
                     textLine.text = words
@@ -381,6 +392,7 @@ object ChapterProvider {
                         startX, !isTitle && lineIndex == 0, srcList
                         startX, !isTitle && lineIndex == 0, srcList
                     )
                     )
                 }
                 }
+
                 else -> {
                 else -> {
                     if (
                     if (
                         isTitle &&
                         isTitle &&
@@ -566,6 +578,7 @@ object ChapterProvider {
                     src = src
                     src = src
                 )
                 )
             }
             }
+
             isLineEnd && char == reviewChar -> {
             isLineEnd && char == reviewChar -> {
                 ReviewColumn(
                 ReviewColumn(
                     start = absStartX + xStart,
                     start = absStartX + xStart,
@@ -573,6 +586,7 @@ object ChapterProvider {
                     count = 100
                     count = 100
                 )
                 )
             }
             }
+
             else -> {
             else -> {
                 TextColumn(
                 TextColumn(
                     start = absStartX + xStart,
                     start = absStartX + xStart,
@@ -632,9 +646,11 @@ object ChapterProvider {
                             Typeface.Builder(it.fileDescriptor).build()
                             Typeface.Builder(it.fileDescriptor).build()
                         }
                         }
                 }
                 }
+
                 fontPath.isContentScheme() -> {
                 fontPath.isContentScheme() -> {
                     Typeface.createFromFile(RealPathUtil.getPath(appCtx, Uri.parse(fontPath)))
                     Typeface.createFromFile(RealPathUtil.getPath(appCtx, Uri.parse(fontPath)))
                 }
                 }
+
                 fontPath.isNotEmpty() -> Typeface.createFromFile(fontPath)
                 fontPath.isNotEmpty() -> Typeface.createFromFile(fontPath)
                 else -> when (AppConfig.systemTypefaces) {
                 else -> when (AppConfig.systemTypefaces) {
                     1 -> Typeface.SERIF
                     1 -> Typeface.SERIF
@@ -660,12 +676,14 @@ object ChapterProvider {
                 else
                 else
                     Pair(bold, bold)
                     Pair(bold, bold)
             }
             }
+
             2 -> {
             2 -> {
                 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
                 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
                     Pair(normal, Typeface.create(typeface, 300, false))
                     Pair(normal, Typeface.create(typeface, 300, false))
                 else
                 else
                     Pair(normal, normal)
                     Pair(normal, normal)
             }
             }
+
             else -> Pair(bold, normal)
             else -> Pair(bold, normal)
         }
         }
 
 
@@ -709,6 +727,7 @@ object ChapterProvider {
                 doublePage = (viewWidth > viewHeight)
                 doublePage = (viewWidth > viewHeight)
                         && ReadBook.pageAnim() != 3
                         && ReadBook.pageAnim() != 3
             }
             }
+
             "3" -> {
             "3" -> {
                 doublePage = (viewWidth > viewHeight || appCtx.isPad)
                 doublePage = (viewWidth > viewHeight || appCtx.isPad)
                         && ReadBook.pageAnim() != 3
                         && ReadBook.pageAnim() != 3

+ 1 - 1
build.gradle

@@ -7,7 +7,7 @@ buildscript {
         kotlin_version = '1.8.21'
         kotlin_version = '1.8.21'
         agp_version = '8.0.1'
         agp_version = '8.0.1'
         //exoplayer_version = '2.18.6'
         //exoplayer_version = '2.18.6'
-        media3_version = "1.0.1"
+        media3_version = "1.0.2"
         splitties_version = '3.0.0'
         splitties_version = '3.0.0'
         room_version = '2.5.1'
         room_version = '2.5.1'
     }
     }

+ 1 - 1
modules/web/package.json

@@ -33,7 +33,7 @@
     "eslint-plugin-vue": "^9.12.0",
     "eslint-plugin-vue": "^9.12.0",
     "prettier": "^2.8.8",
     "prettier": "^2.8.8",
     "sass": "^1.62.1",
     "sass": "^1.62.1",
-    "unplugin-auto-import": "^0.15.3",
+    "unplugin-auto-import": "^0.16.0",
     "unplugin-icons": "^0.16.1",
     "unplugin-icons": "^0.16.1",
     "unplugin-vue-components": "^0.24.1",
     "unplugin-vue-components": "^0.24.1",
     "vite": "^4.3.5"
     "vite": "^4.3.5"

+ 35 - 23
modules/web/scripts/sync.js

@@ -1,28 +1,40 @@
 import { URL } from "node:url";
 import { URL } from "node:url";
 import fs from "node:fs";
 import fs from "node:fs";
 
 
-const LEGADO_ASSETS_WEB_VUE_DIR = new URL("../../../app/src/main/assets/web/vue", import.meta.url)
-const VUE_DIST_DIR = new URL("../dist", import.meta.url)
+const LEGADO_ASSETS_WEB_VUE_DIR = new URL(
+  "../../../app/src/main/assets/web/vue",
+  import.meta.url
+);
+const VUE_DIST_DIR = new URL("../dist", import.meta.url);
 
 
-console.log("> delete", LEGADO_ASSETS_WEB_VUE_DIR.pathname)
+console.log("> delete", LEGADO_ASSETS_WEB_VUE_DIR.pathname);
 // 删除
 // 删除
-fs.rm(LEGADO_ASSETS_WEB_VUE_DIR, {
-  force: true,
-  recursive: true
-}, (error) => {
-  if (error) console.log(error);
-  console.log("> mkdir", LEGADO_ASSETS_WEB_VUE_DIR.pathname);
-  fs.mkdir(LEGADO_ASSETS_WEB_VUE_DIR, error => {
-    if (error) return console.error(error)
-    console.log("> cp dist files")
-    fs.cp(VUE_DIST_DIR, LEGADO_ASSETS_WEB_VUE_DIR, {
-      recursive: true
-    }, (error) => {
-      if (error) {
-        console.warn("> cp error, you may copy files yourshelf");
-        throw error;
-      }
-      console.log("> cp success")
-    })
-  })
-});
+fs.rm(
+  LEGADO_ASSETS_WEB_VUE_DIR,
+  {
+    force: true,
+    recursive: true,
+  },
+  (error) => {
+    if (error) console.log(error);
+    console.log("> mkdir", LEGADO_ASSETS_WEB_VUE_DIR.pathname);
+    fs.mkdir(LEGADO_ASSETS_WEB_VUE_DIR, (error) => {
+      if (error) return console.error(error);
+      console.log("> cp dist files");
+      fs.cp(
+        VUE_DIST_DIR,
+        LEGADO_ASSETS_WEB_VUE_DIR,
+        {
+          recursive: true,
+        },
+        (error) => {
+          if (error) {
+            console.warn("> cp error, you may copy files yourshelf");
+            throw error;
+          }
+          console.log("> cp success");
+        }
+      );
+    });
+  }
+);

+ 30 - 13
modules/web/src/components/ToolBar.vue

@@ -27,7 +27,7 @@
         </div>
         </div>
         <el-button
         <el-button
           :disabled="recordKeyDowning"
           :disabled="recordKeyDowning"
-          @click="bindHotKeys"
+          @click="saveHotKeys"
           :icon="CircleCheckFilled"
           :icon="CircleCheckFilled"
           >保存</el-button
           >保存</el-button
         >
         >
@@ -230,7 +230,13 @@ const stopRecordKeyDown = () => {
 watch(
 watch(
   hotkeysDialogVisible,
   hotkeysDialogVisible,
   (visibale) => {
   (visibale) => {
-    if (!visibale) return hotkeys.unbind("*");
+    if (!visibale) {
+      hotkeys.unbind("*");
+      readHotkeysConfig();
+      bindHotKeys();
+      return;
+    }
+    readHotkeysConfig();
     hotkeys.unbind();
     hotkeys.unbind();
     /**监听按键 */
     /**监听按键 */
     hotkeys("*", (event) => {
     hotkeys("*", (event) => {
@@ -257,39 +263,50 @@ const recordKeyDown = (index) => {
   recordKeyDownIndex.value = index;
   recordKeyDownIndex.value = index;
 };
 };
 
 
-const bindHotKeys = () => {
-  hotkeysDialogVisible.value = false;
+const saveHotKeys = () => {
   const hotKeysConfig = [];
   const hotKeysConfig = [];
+  buttons.value.forEach(({ hotKeys }) => {
+    hotKeysConfig.push(hotKeys);
+  });
+  saveHotkeysConfig(hotKeysConfig);
+  hotkeysDialogVisible.value = false;
+};
+
+const bindHotKeys = () => {
   buttons.value.forEach(({ hotKeys, action }) => {
   buttons.value.forEach(({ hotKeys, action }) => {
+    if (hotKeys.length == 0) return;
     hotkeys(hotKeys.join("+"), (event) => {
     hotkeys(hotKeys.join("+"), (event) => {
       event.preventDefault();
       event.preventDefault();
       action.call(null);
       action.call(null);
     });
     });
-    hotKeysConfig.push(hotKeys);
   });
   });
-  saveHotkeysConfig(hotKeysConfig);
 };
 };
-
 const saveHotkeysConfig = (config) => {
 const saveHotkeysConfig = (config) => {
   localStorage.setItem("legado_web_hotkeys", JSON.stringify(config));
   localStorage.setItem("legado_web_hotkeys", JSON.stringify(config));
 };
 };
 
 
-const readHotkeysConfig = () => {
+/**
+ * 读取快捷键配置
+ * @return 是否成功读取配置
+ */
+function readHotkeysConfig() {
   try {
   try {
     const config = JSON.parse(localStorage.getItem("legado_web_hotkeys"));
     const config = JSON.parse(localStorage.getItem("legado_web_hotkeys"));
-    if (!Array.isArray(config) || config.length == 0) return;
+    if (!Array.isArray(config) || config.length == 0) return false;
     buttons.value.forEach((button, index) => (button.hotKeys = config[index]));
     buttons.value.forEach((button, index) => (button.hotKeys = config[index]));
-    hotkeysDialogVisible.value = false;
-    bindHotKeys();
+    return true;
   } catch {
   } catch {
     ElMessage({ message: "快捷键配置错误", type: "error" });
     ElMessage({ message: "快捷键配置错误", type: "error" });
     localStorage.removeItem("legado_web_hotkeys");
     localStorage.removeItem("legado_web_hotkeys");
   }
   }
-};
+  return false;
+}
 
 
 onMounted(() => {
 onMounted(() => {
   /**读取热键配置 */
   /**读取热键配置 */
-  readHotkeysConfig();
+  if (readHotkeysConfig()) {
+    hotkeysDialogVisible.value = false;
+  }
 });
 });
 </script>
 </script>
 
 

+ 5 - 5
modules/web/src/config/bookSourceEditConfig.js

@@ -69,13 +69,13 @@ export default {
         title: "并发率",
         title: "并发率",
         id: "concurrentRate",
         id: "concurrentRate",
         type: "String",
         type: "String",
-        hint: "并发率",
+        hint: "并发率,如1000(访问间隔1000ms)或者1/1000(1000ms内访问1次)",
       },
       },
       {
       {
         title: "js库",
         title: "js库",
         id: "jsLib",
         id: "jsLib",
         type: "String",
         type: "String",
-        hint: "js库",
+        hint: "js库, 可填写js或者key-value object获取在线js文件",
       },
       },
       {
       {
         title: "请求头",
         title: "请求头",
@@ -105,7 +105,7 @@ export default {
         namespace: "ruleSearch",
         namespace: "ruleSearch",
         id: "checkKeyWord",
         id: "checkKeyWord",
         type: "String",
         type: "String",
-        hint: "校验关键字",
+        hint: "校验关键字,强烈建议填写",
       },
       },
       {
       {
         title: "列表规则",
         title: "列表规则",
@@ -179,7 +179,7 @@ export default {
         title: "发现地址",
         title: "发现地址",
         id: "exploreUrl",
         id: "exploreUrl",
         type: "String",
         type: "String",
-        hint: "内容能显示在发现菜单\n每行一条发现分类(网址域名可省略),例:\n名称1::网址(Url)1\n名称2::网址(Url)2\n...",
+        hint: "单个发现格式<name>::<url>或者{url:<url>,title:<name>,style:...};前者用换行符或者&&连接,后者放在数组内;可用js动态生成",
       },
       },
       {
       {
         title: "发现筛选",
         title: "发现筛选",
@@ -370,7 +370,7 @@ export default {
         namespace: "ruleToc",
         namespace: "ruleToc",
         id: "formatJs",
         id: "formatJs",
         type: "String",
         type: "String",
-        hint: "直接填写js, 提供index和tittle变量",
+        hint: "遍历去重后的章节列表的回调,提供index(章节序号从1开始)、title(章节标题)变量,额外提供gInt(初始值0),返回值作为新的标题",
       },
       },
       {
       {
         title: "卷名标识",
         title: "卷名标识",

Некоторые файлы не были показаны из-за большого количества измененных файлов