Răsfoiți Sursa

Добавлена подсказка при невалидном URL книги

Book Pauk 3 ani în urmă
părinte
comite
7c73c74730

+ 20 - 1
client/components/Reader/Reader.vue

@@ -393,6 +393,23 @@ class Reader {
         this.loadWallpapers();//no await
         this.loadWallpapers();//no await
     }
     }
 
 
+    showHelpOnErrorIfNeeded(errorMessage) {
+        //небольшая эвристика
+        let i = errorMessage.indexOf('http://');
+        if (i < 0)
+            i = errorMessage.indexOf('https://');
+
+        errorMessage = errorMessage.substring(i + 7);
+        const perCount = errorMessage.split('%').length - 1;
+
+        if (perCount > errorMessage.length/3.2) {
+            this.$refs.dialogs.showUrlHelp();
+            return true;
+        }
+
+        return false;
+    }
+
     //wallpaper css
     //wallpaper css
     async loadWallpapers() {
     async loadWallpapers() {
         const wallpaperDataLength = await wallpaperStorage.getLength();
         const wallpaperDataLength = await wallpaperStorage.getLength();
@@ -1117,7 +1134,9 @@ class Reader {
         } catch (e) {
         } catch (e) {
             progress.hide(); this.progressActive = false;
             progress.hide(); this.progressActive = false;
             this.loaderActive = true;
             this.loaderActive = true;
-            this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
+            if (!this.showHelpOnErrorIfNeeded(e.message)) {
+                this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
+            }
         } finally {
         } finally {
             this.checkNewVersionAvailable();
             this.checkNewVersionAvailable();
         }
         }

+ 30 - 1
client/components/Reader/ReaderDialogs/ReaderDialogs.vue

@@ -68,6 +68,26 @@
                 </q-btn>
                 </q-btn>
             </template>
             </template>
         </Dialog>
         </Dialog>
+
+        <Dialog ref="dialog3" v-model="urlHelpVisible">
+            <template #header>
+                Обнаружена невалидная ссылка в поле "URL книги".
+                <br>
+            </template>
+
+            <div style="word-break: normal">
+                Если вы хотите найти определенную книгу и открыть в читалке, добро пожаловать в
+                раздел "Сетевая библиотека" (кнопка <q-icon name="la la-sitemap" size="32px" />) на сайте
+                <a href="https://liberama.top" target="_blank">liberama.top</a>
+
+                <br><br>
+                Если же вы пытаетесь вставить текст в читалку из буфера обмена, пожалуйста воспользуйтесь кнопкой
+                <q-btn no-caps dense class="q-px-sm" color="primary" size="13px" @click="loadBufferClick">
+                    Из буфера обмена
+                </q-btn>
+                на странице загрузки.
+            </div>
+        </Dialog>
     </div>
     </div>
 </template>
 </template>
 
 
@@ -95,6 +115,7 @@ class ReaderDialogs {
     whatsNewVisible = false;
     whatsNewVisible = false;
     whatsNewContent = '';
     whatsNewContent = '';
     donationVisible = false;
     donationVisible = false;
+    urlHelpVisible = false;
 
 
     created() {
     created() {
         this.commit = this.$store.commit;
         this.commit = this.$store.commit;
@@ -135,6 +156,14 @@ class ReaderDialogs {
         }
         }
     }
     }
 
 
+    async showUrlHelp() {
+        this.urlHelpVisible = true;
+    }
+
+    loadBufferClick() {
+        this.urlHelpVisible = false;
+    }
+
     donationDialogDisable() {
     donationDialogDisable() {
         this.donationVisible = false;
         this.donationVisible = false;
         if (this.showDonationDialog2020) {
         if (this.showDonationDialog2020) {
@@ -191,7 +220,7 @@ class ReaderDialogs {
     }
     }
 
 
     keyHook() {
     keyHook() {
-        if (this.$refs.dialog1.active || this.$refs.dialog2.active)
+        if (this.$refs.dialog1.active || this.$refs.dialog2.active || this.$refs.dialog3.active)
             return true;
             return true;
         return false;
         return false;
     }
     }