Мелкий рефакторинг

This commit is contained in:
Book Pauk
2020-11-05 15:43:15 +07:00
parent 471de104bc
commit 546f4556f6

View File

@@ -44,7 +44,7 @@
@focus="selectAllOnFocus" @keydown="bookUrlKeyDown" @focus="selectAllOnFocus" @keydown="bookUrlKeyDown"
> >
<template v-slot:prepend> <template v-slot:prepend>
<q-btn class="q-mr-xs" round dense color="blue" icon="la la-home" @click="goToLink(selectedLink, true)" size="12px"> <q-btn class="q-mr-xs" round dense color="blue" icon="la la-home" @click="goToLink(selectedLink)" size="12px">
<q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Вернуться на стартовую страницу</q-tooltip> <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">Вернуться на стартовую страницу</q-tooltip>
</q-btn> </q-btn>
<q-btn round dense color="blue" icon="la la-angle-double-down" @click="openBookUrlInFrame" size="12px" :disabled="!bookUrl"> <q-btn round dense color="blue" icon="la la-angle-double-down" @click="openBookUrlInFrame" size="12px" :disabled="!bookUrl">
@@ -215,14 +215,15 @@ class ExternalLibs extends Vue {
openFullscreen = false; openFullscreen = false;
created() { created() {
this.oldStartLink = '';
this.$root.addKeyHook(this.keyHook); this.$root.addKeyHook(this.keyHook);
document.addEventListener('fullscreenchange', () => { document.addEventListener('fullscreenchange', () => {
this.fullScreenActive = (document.fullscreenElement !== null); this.fullScreenActive = (document.fullscreenElement !== null);
}); });
this.debouncedGoToLink = _.debounce((link, force) => { this.debouncedGoToLink = _.debounce((link) => {
this.goToLink(link, force); this.goToLink(link);
}, 100, {'maxWait':200}); }, 100, {'maxWait':200});
//this.commit = this.$store.commit; //this.commit = this.$store.commit;
//this.commit('reader/setLibs', rstore.libsDefaults); //this.commit('reader/setLibs', rstore.libsDefaults);
@@ -419,11 +420,14 @@ class ExternalLibs extends Vue {
this.commitLibs(libs); this.commitLibs(libs);
} }
this.debouncedGoToLink(this.selectedLink, force); if (force || this.oldStartLink != libs.startLink) {
this.oldStartLink = libs.startLink;
this.debouncedGoToLink(this.selectedLink);
}
} else { } else {
this.rootLink = ''; this.rootLink = '';
this.selectedLink = ''; this.selectedLink = '';
this.debouncedGoToLink(this.selectedLink, true); this.debouncedGoToLink(this.selectedLink);
} }
} }
@@ -466,11 +470,11 @@ class ExternalLibs extends Vue {
openBookUrlInFrame() { openBookUrlInFrame() {
if (this.bookUrl) { if (this.bookUrl) {
this.goToLink(lu.addProtocol(this.bookUrl), true); this.goToLink(lu.addProtocol(this.bookUrl));
} }
} }
goToLink(link, force) { goToLink(link) {
if (!this.ready || !link) if (!this.ready || !link)
return; return;
@@ -479,9 +483,7 @@ class ExternalLibs extends Vue {
return; return;
} }
const newLink = this.makeProxySubst(link); this.frameSrc = this.makeProxySubst(link);
if (force || newLink != this.frameSrc) {
this.frameSrc = newLink;
this.frameVisible = false; this.frameVisible = false;
this.$nextTick(() => { this.$nextTick(() => {
@@ -492,7 +494,6 @@ class ExternalLibs extends Vue {
}); });
}); });
} }
}
getCommentByLink(list, link) { getCommentByLink(list, link) {
const item = lu.getListItemByLink(list, link); const item = lu.getListItemByLink(list, link);
@@ -685,7 +686,7 @@ class ExternalLibs extends Vue {
this.submitUrl(); this.submitUrl();
} else { } else {
if (this.bookUrl) if (this.bookUrl)
this.goToLink(this.bookUrl, true); this.goToLink(this.bookUrl);
} }
event.preventDefault(); event.preventDefault();
} }