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

This commit is contained in:
Book Pauk
2022-04-14 17:13:38 +07:00
parent c20aa089fa
commit 7c73c74730
2 changed files with 50 additions and 2 deletions

View File

@@ -393,6 +393,23 @@ class Reader {
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
async loadWallpapers() {
const wallpaperDataLength = await wallpaperStorage.getLength();
@@ -1117,7 +1134,9 @@ class Reader {
} catch (e) {
progress.hide(); this.progressActive = false;
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 {
this.checkNewVersionAvailable();
}

View File

@@ -68,6 +68,26 @@
</q-btn>
</template>
</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>
</template>
@@ -95,6 +115,7 @@ class ReaderDialogs {
whatsNewVisible = false;
whatsNewContent = '';
donationVisible = false;
urlHelpVisible = false;
created() {
this.commit = this.$store.commit;
@@ -135,6 +156,14 @@ class ReaderDialogs {
}
}
async showUrlHelp() {
this.urlHelpVisible = true;
}
loadBufferClick() {
this.urlHelpVisible = false;
}
donationDialogDisable() {
this.donationVisible = false;
if (this.showDonationDialog2020) {
@@ -191,7 +220,7 @@ class ReaderDialogs {
}
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 false;
}