From d9634a134c07d1994d8652deeeb4d7012f75e4de Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 3 Nov 2020 00:35:44 +0700 Subject: [PATCH 01/22] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20caniuse=20-lite?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8f925929..441deb1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,12 +36,6 @@ "pkg-up": "^2.0.0" } }, - "caniuse-lite": { - "version": "1.0.30001062", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001062.tgz", - "integrity": "sha512-ei9ZqeOnN7edDrb24QfJ0OZicpEbsWxv7WusOiQGz/f2SfvBgHHbOEwBJ8HKGVSyx8Z6ndPjxzR6m0NQq+0bfw==", - "dev": true - }, "electron-to-chromium": { "version": "1.3.446", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.446.tgz", @@ -321,12 +315,6 @@ "pkg-up": "^2.0.0" } }, - "caniuse-lite": { - "version": "1.0.30001062", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001062.tgz", - "integrity": "sha512-ei9ZqeOnN7edDrb24QfJ0OZicpEbsWxv7WusOiQGz/f2SfvBgHHbOEwBJ8HKGVSyx8Z6ndPjxzR6m0NQq+0bfw==", - "dev": true - }, "electron-to-chromium": { "version": "1.3.446", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.446.tgz", @@ -1603,12 +1591,6 @@ "pkg-up": "^2.0.0" } }, - "caniuse-lite": { - "version": "1.0.30001062", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001062.tgz", - "integrity": "sha512-ei9ZqeOnN7edDrb24QfJ0OZicpEbsWxv7WusOiQGz/f2SfvBgHHbOEwBJ8HKGVSyx8Z6ndPjxzR6m0NQq+0bfw==", - "dev": true - }, "electron-to-chromium": { "version": "1.3.446", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.446.tgz", @@ -4017,9 +3999,9 @@ } }, "caniuse-lite": { - "version": "1.0.30000989", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000989.tgz", - "integrity": "sha512-vrMcvSuMz16YY6GSVZ0dWDTJP8jqk3iFQ/Aq5iqblPwxSVVZI+zxDyTX0VPqtQsDnfdrBDcsmhgTEOh5R8Lbpw==", + "version": "1.0.30001154", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001154.tgz", + "integrity": "sha512-y9DvdSti8NnYB9Be92ddMZQrcOe04kcQtcxtBx4NkB04+qZ+JUWotnXBJTmxlKudhxNTQ3RRknMwNU2YQl/Org==", "dev": true }, "caseless": { @@ -4759,12 +4741,6 @@ "pkg-up": "^2.0.0" } }, - "caniuse-lite": { - "version": "1.0.30001062", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001062.tgz", - "integrity": "sha512-ei9ZqeOnN7edDrb24QfJ0OZicpEbsWxv7WusOiQGz/f2SfvBgHHbOEwBJ8HKGVSyx8Z6ndPjxzR6m0NQq+0bfw==", - "dev": true - }, "electron-to-chromium": { "version": "1.3.446", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.446.tgz", From 7f36d55320367411d3e250b8ba103bc11715b248 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 3 Nov 2020 14:41:32 +0700 Subject: [PATCH 02/22] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B0=D1=8F=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/App.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/App.vue b/client/components/App.vue index 51d135e4..70ae5c23 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -248,7 +248,7 @@ body, html, #app { } .dborder { - border: 2px solid yellow !important; + border: 2px solid magenta !important; } .icon-rotate { From 7e4c938dfde7b98e1db4924f998b61a95245915e Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 3 Nov 2020 14:42:02 +0700 Subject: [PATCH 03/22] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=20=D0=BD=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C=D1=88?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=B1=D0=B0=D0=B3=20=D0=BE=D1=82=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BE=D0=BA=D0=BD?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/share/Window.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/components/share/Window.vue b/client/components/share/Window.vue index 98c816cc..7180a6c4 100644 --- a/client/components/share/Window.vue +++ b/client/components/share/Window.vue @@ -32,6 +32,9 @@ export default @Component({ class Window extends Vue { init() { this.$nextTick(() => { + this.$refs.main.style.top = 0; + this.$refs.main.style.left = 0; + this.$refs.windowBox.style.height = this.height; this.$refs.windowBox.style.width = this.width; if (this.maxWidth) @@ -124,7 +127,6 @@ class Window extends Vue { .main { background-color: transparent !important; z-index: 50; - overflow: hidden; } .xyfit { From ba6bf8c09144d984f1a809e5191ad376275f25e4 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 3 Nov 2020 17:03:57 +0700 Subject: [PATCH 04/22] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20BookmarkSettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookmarkSettings/BookmarkSettings.vue | 89 +++++++++++++++++++ .../components/ExternalLibs/ExternalLibs.vue | 3 +- client/quasar.js | 2 + 3 files changed, 92 insertions(+), 2 deletions(-) diff --git a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue index 97653dd7..0924bf42 100644 --- a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue +++ b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue @@ -4,6 +4,51 @@ Настроить закладки +
+
+ + Открыть выбранную закладку + + + + + Опции + +
+ +
+
+ + Редактировать закладку + + + Добавить закладку + + + Удалить закладку + + + Переместить вверх + + + Переместить вниз + +
+ +
+ +
+
+
@@ -29,6 +74,11 @@ export default @Component({ } }) class BookmarkSettings extends BookmarkSettingsProps { + search = ''; + selected = ''; + ticked = []; + expanded = []; + created() { } @@ -39,6 +89,30 @@ class BookmarkSettings extends BookmarkSettingsProps { this.$refs.window.init(); } + get nodes() { + const result = []; + + let i = 0; + this.libs.groups.forEach(group => { + const g = {label: group.r, key: `${i}`, children: []}; + let j = 0; + group.list.forEach(link => { + g.children.push({label: (link.c ? link.c + ' ': '') + link.l, key: `${i}-${j}`}); + }); + + result.push(g); + i++; + }); + + return result; + } + + openSelected() { + } + + openOptions() { + } + close() { this.$emit('close'); } @@ -56,4 +130,19 @@ class BookmarkSettings extends BookmarkSettingsProps { diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index 19611658..92829d49 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -23,7 +23,7 @@ Добавить закладку - + Настроить закладки @@ -621,7 +621,6 @@ class ExternalLibs extends Vue { } return false; } - } //----------------------------------------------------------------------------- diff --git a/client/quasar.js b/client/quasar.js index 05526c9b..2567ca54 100644 --- a/client/quasar.js +++ b/client/quasar.js @@ -31,6 +31,7 @@ import {QColor} from 'quasar/src/components/color'; import {QPopupProxy} from 'quasar/src/components/popup-proxy'; import {QDialog} from 'quasar/src/components/dialog'; import {QChip} from 'quasar/src/components/chip'; +import {QTree} from 'quasar/src/components/tree'; const components = { //QLayout, @@ -57,6 +58,7 @@ const components = { QPopupProxy, QDialog, QChip, + QTree }; //directives From 607f2ff4071f6d404023a32aa8918a89601c90b1 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 3 Nov 2020 22:24:32 +0700 Subject: [PATCH 05/22] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20BookmarkSettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookmarkSettings/BookmarkSettings.vue | 45 ++++++++-- .../components/ExternalLibs/ExternalLibs.vue | 83 ++++++------------- client/components/ExternalLibs/linkUtils.js | 38 +++++++++ 3 files changed, 100 insertions(+), 66 deletions(-) create mode 100644 client/components/ExternalLibs/linkUtils.js diff --git a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue index 0924bf42..90ca0dc6 100644 --- a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue +++ b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue @@ -6,10 +6,13 @@
- + Открыть выбранную закладку - + + Опции @@ -39,13 +42,19 @@ + :filter="search" + no-nodes-label="Закладок пока нет" + no-results-label="Ничего не найдено" + > + +
@@ -58,6 +67,8 @@ import Vue from 'vue'; import Component from 'vue-class-component'; import Window from '../../share/Window.vue'; +import * as lu from '../linkUtils'; + const BookmarkSettingsProps = Vue.extend({ props: { libs: Object, @@ -92,12 +103,23 @@ class BookmarkSettings extends BookmarkSettingsProps { get nodes() { const result = []; + this.expanded = []; let i = 0; this.libs.groups.forEach(group => { - const g = {label: group.r, key: `${i}`, children: []}; + const rkey = `${i}`; + const g = {label: group.r, key: rkey, children: []}; let j = 0; group.list.forEach(link => { - g.children.push({label: (link.c ? link.c + ' ': '') + link.l, key: `${i}-${j}`}); + const key = `${i}-${j}`; + g.children.push({ + label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l), + key + }); + if (link.l == this.libs.startLink && this.expanded.indexOf(rkey) < 0) { + this.expanded.push(rkey); + } + + j++; }); result.push(g); @@ -107,6 +129,11 @@ class BookmarkSettings extends BookmarkSettingsProps { return result; } + resetSearch() { + this.search = ''; + this.$refs.search.focus(); + } + openSelected() { } @@ -145,4 +172,8 @@ class BookmarkSettings extends BookmarkSettingsProps { .tree { padding: 10px; } + +.selected { + text-shadow: 0 0 20px yellow, 0 0 15px yellow, 0 0 10px yellow, 0 0 10px yellow, 0 0 5px yellow; +} diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index 92829d49..2439aaf5 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -28,7 +28,7 @@
@@ -113,6 +113,7 @@ import BookmarkSettings from './BookmarkSettings/BookmarkSettings.vue'; import rstore from '../../store/modules/reader'; import * as utils from '../../share/utils'; +import * as lu from './linkUtils'; const proxySubst = { 'http://flibusta.is': 'http://b.liberama.top:23480', @@ -286,8 +287,8 @@ class ExternalLibs extends Vue { loadLibs() { const libs = this.libs; - this.startLink = (libs.comment ? libs.comment + ' ': '') + this.removeProtocol(libs.startLink); - this.rootLink = this.getOrigin(libs.startLink); + this.startLink = (libs.comment ? libs.comment + ' ': '') + lu.removeProtocol(libs.startLink); + this.rootLink = lu.getOrigin(libs.startLink); this.updateSelectedLink(); } @@ -304,10 +305,14 @@ class ExternalLibs extends Vue { return result; } + get rootLinkWithoutProtocol() { + return lu.removeProtocol(this.rootLink); + } + updateSelectedLink() { if (!this.ready) return; - const index = this.getRootIndexByUrl(this.libs.groups, this.rootLink); + const index = lu.getRootIndexByUrl(this.libs.groups, this.rootLink); if (index >= 0) this.selectedLink = this.libs.groups[index].s; } @@ -315,7 +320,7 @@ class ExternalLibs extends Vue { updateStartLink() { if (!this.ready) return; - const index = this.getRootIndexByUrl(this.libs.groups, this.rootLink); + const index = lu.getRootIndexByUrl(this.libs.groups, this.rootLink); if (index >= 0) { let libs = _.cloneDeep(this.libs); libs.groups[index].s = this.selectedLink; @@ -332,7 +337,7 @@ class ExternalLibs extends Vue { return result; this.libs.groups.forEach(group => { - result.push({label: this.removeProtocol(group.r), value: group.r}); + result.push({label: lu.removeProtocol(group.r), value: group.r}); }); return result; @@ -342,7 +347,7 @@ class ExternalLibs extends Vue { let result = []; rstore.libsDefaults.groups.forEach(group => { - result.push({label: this.removeProtocol(group.r), value: group.r}); + result.push({label: lu.removeProtocol(group.r), value: group.r}); }); return result; @@ -353,10 +358,10 @@ class ExternalLibs extends Vue { if (!this.ready) return result; - const index = this.getRootIndexByUrl(this.libs.groups, this.rootLink); + const index = lu.getRootIndexByUrl(this.libs.groups, this.rootLink); if (index >= 0) { this.libs.groups[index].list.forEach(link => { - result.push({label: (link.c ? link.c + ' ': '') + this.removeOrigin(link.l), value: link.l}); + result.push({label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l), value: link.l}); }); } @@ -365,7 +370,7 @@ class ExternalLibs extends Vue { openBookUrlInFrame() { if (this.bookUrl) { - this.goToLink(this.addProtocol(this.bookUrl)); + this.goToLink(lu.addProtocol(this.bookUrl)); } } @@ -383,48 +388,8 @@ class ExternalLibs extends Vue { }); } - addProtocol(url) { - if ((url.indexOf('http://') != 0) && (url.indexOf('https://') != 0)) - return 'http://' + url; - return url; - } - - removeProtocol(url) { - return url.replace(/(^\w+:|^)\/\//, ''); - } - - getOrigin(url) { - const parsed = new URL(url); - return parsed.origin; - } - - removeOrigin(url) { - const parsed = new URL(url); - const result = url.substring(parsed.origin.length); - return (result ? result : '/'); - } - - getRootIndexByUrl(groups, url) { - if (!this.ready) - return -1; - const origin = this.getOrigin(url); - for (let i = 0; i < groups.length; i++) { - if (groups[i].r == origin) - return i; - } - return -1; - } - - getListItemByLink(list, link) { - for (const item of list) { - if (item.l == link) - return item; - } - return null; - } - getCommentByLink(list, link) { - const item = this.getListItemByLink(list, link); + const item = lu.getListItemByLink(list, link); return (item ? item.c : ''); } @@ -457,7 +422,7 @@ class ExternalLibs extends Vue { submitUrl() { if (this.bookUrl) { this.sendMessage({type: 'submitUrl', data: { - url: this.makeProxySubst(this.addProtocol(this.bookUrl), true), + url: this.makeProxySubst(lu.addProtocol(this.bookUrl), true), force: true }}); this.bookUrl = ''; @@ -467,7 +432,7 @@ class ExternalLibs extends Vue { } addBookmark() { - this.bookmarkLink = (this.bookUrl ? this.makeProxySubst(this.addProtocol(this.bookUrl), true) : ''); + this.bookmarkLink = (this.bookUrl ? this.makeProxySubst(lu.addProtocol(this.bookUrl), true) : ''); this.bookmarkDesc = ''; this.addBookmarkVisible = true; this.$nextTick(() => { @@ -477,7 +442,7 @@ class ExternalLibs extends Vue { } updateBookmarkLink() { - const index = this.getRootIndexByUrl(rstore.libsDefaults.groups, this.defaultRootLink); + const index = lu.getRootIndexByUrl(rstore.libsDefaults.groups, this.defaultRootLink); if (index >= 0) { this.bookmarkLink = rstore.libsDefaults.groups[index].s; this.bookmarkDesc = this.getCommentByLink(rstore.libsDefaults.groups[index].list, this.bookmarkLink); @@ -509,10 +474,10 @@ class ExternalLibs extends Vue { if (!this.bookmarkLink) return; - const link = this.addProtocol(this.bookmarkLink); + const link = lu.addProtocol(this.bookmarkLink); let index = -1; try { - index = this.getRootIndexByUrl(this.libs.groups, link); + index = lu.getRootIndexByUrl(this.libs.groups, link); } catch (e) { await this.$root.stdDialog.alert('Неверный формат ссылки', 'Ошибка'); return; @@ -520,7 +485,7 @@ class ExternalLibs extends Vue { //есть группа в закладках if (index >= 0) { - const item = this.getListItemByLink(this.libs.groups[index].list, link); + const item = lu.getListItemByLink(this.libs.groups[index].list, link); if (!item || item.c != this.bookmarkDesc) { //добавляем @@ -543,9 +508,9 @@ class ExternalLibs extends Vue { } //добавляем сначала группу - libs.groups.push({r: this.getOrigin(link), s: link, list: []}); + libs.groups.push({r: lu.getOrigin(link), s: link, list: []}); - index = this.getRootIndexByUrl(libs.groups, link); + index = lu.getRootIndexByUrl(libs.groups, link); if (index >= 0) libs.groups[index].list.push({l: link, c: this.bookmarkDesc}); diff --git a/client/components/ExternalLibs/linkUtils.js b/client/components/ExternalLibs/linkUtils.js new file mode 100644 index 00000000..a837ac21 --- /dev/null +++ b/client/components/ExternalLibs/linkUtils.js @@ -0,0 +1,38 @@ +export function addProtocol(url) { + if ((url.indexOf('http://') != 0) && (url.indexOf('https://') != 0)) + return 'http://' + url; + return url; +} + +export function removeProtocol(url) { + return url.replace(/(^\w+:|^)\/\//, ''); +} + +export function getOrigin(url) { + const parsed = new URL(url); + return parsed.origin; +} + +export function removeOrigin(url) { + const parsed = new URL(url); + const result = url.substring(parsed.origin.length); + return (result ? result : '/'); +} + +export function getRootIndexByUrl(groups, url) { + const origin = this.getOrigin(url); + for (let i = 0; i < groups.length; i++) { + if (groups[i].r == origin) + return i; + } + return -1; +} + +export function getListItemByLink(list, link) { + for (const item of list) { + if (item.l == link) + return item; + } + return null; +} + From f69cc6f1b103b4b8c69f055a478f2834313e51f9 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 3 Nov 2020 23:04:06 +0700 Subject: [PATCH 06/22] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20BookmarkSettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookmarkSettings/BookmarkSettings.vue | 24 ++++++++++++++++--- .../components/ExternalLibs/ExternalLibs.vue | 12 ++++++++-- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue index 90ca0dc6..1eeb6f3d 100644 --- a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue +++ b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue @@ -103,11 +103,14 @@ class BookmarkSettings extends BookmarkSettingsProps { get nodes() { const result = []; - this.expanded = []; + const expanded = []; + this.links = {}; let i = 0; this.libs.groups.forEach(group => { const rkey = `${i}`; const g = {label: group.r, key: rkey, children: []}; + this.links[rkey] = group.r; + let j = 0; group.list.forEach(link => { const key = `${i}-${j}`; @@ -115,8 +118,10 @@ class BookmarkSettings extends BookmarkSettingsProps { label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l), key }); - if (link.l == this.libs.startLink && this.expanded.indexOf(rkey) < 0) { - this.expanded.push(rkey); + + this.links[key] = link.l; + if (link.l == this.libs.startLink && expanded.indexOf(rkey) < 0) { + expanded.push(rkey); } j++; @@ -126,6 +131,10 @@ class BookmarkSettings extends BookmarkSettingsProps { i++; }); + this.$nextTick(() => { + this.expanded = expanded; + }); + return result; } @@ -135,6 +144,15 @@ class BookmarkSettings extends BookmarkSettingsProps { } openSelected() { + if (!this.selected) + return; + if (this.selected.indexOf('-') < 0) {//rootLink + this.$emit('do-action', {action: 'setRootLink', data: this.links[this.selected]}); + } else {//selectedLink + this.$emit('do-action', {action: 'setSelectedLink', data: this.links[this.selected]}); + } + + //this.close(); } openOptions() { diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index 2439aaf5..463aa6a1 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -47,7 +47,7 @@ Вернуться на стартовую страницу - + Загрузить URL во фрейм @@ -97,7 +97,7 @@ - + @@ -292,6 +292,14 @@ class ExternalLibs extends Vue { this.updateSelectedLink(); } + doAction(event) { + switch (event.action) { + case 'setLibs': this.commitLibs(event.data); break; + case 'setRootLink': this.rootLink = event.data; this.rootLinkInput(); break; + case 'setSelectedLink': this.selectedLink = event.data; this.selectedLinkInput(); break; + } + } + get mode() { return this.$store.state.config.mode; } From d540cb91a95be16eb6c97f3195d67979312ef607 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 4 Nov 2020 14:41:11 +0700 Subject: [PATCH 07/22] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BF=D0=B0=D0=BA=D0=B5=D1=82=20vue-sanitize?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/main.js | 3 + package-lock.json | 143 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 3 files changed, 147 insertions(+) diff --git a/client/main.js b/client/main.js index 68785918..9398917a 100644 --- a/client/main.js +++ b/client/main.js @@ -4,6 +4,9 @@ import router from './router'; import store from './store'; import './quasar'; +import vueSanitize from 'vue-sanitize'; +Vue.use(vueSanitize); + import App from './components/App.vue'; //Vue.config.productionTip = false; Vue.prototype.$isMobileDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent); diff --git a/package-lock.json b/package-lock.json index 441deb1b..7060e684 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4355,6 +4355,11 @@ "simple-swizzle": "^0.2.2" } }, + "colorette": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz", + "integrity": "sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==" + }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", @@ -8672,6 +8677,11 @@ "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", "dev": true }, + "klona": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/klona/-/klona-2.0.4.tgz", + "integrity": "sha512-ZRbnvdg/NxqzC7L9Uyqzf4psi1OM4Cuc+sJAkQPjO6XkQIJTNbfK2Rsmbw8fx1p2mkZdp2FZYo2+LwXYY/uwIA==" + }, "last-call-webpack-plugin": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/last-call-webpack-plugin/-/last-call-webpack-plugin-3.0.0.tgz", @@ -8766,6 +8776,30 @@ "immediate": "~3.0.5" } }, + "line-column": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/line-column/-/line-column-1.0.2.tgz", + "integrity": "sha1-0lryk2tvSEkXKzEuR5LR2Ye8NKI=", + "requires": { + "isarray": "^1.0.0", + "isobject": "^2.0.0" + }, + "dependencies": { + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", + "requires": { + "isarray": "1.0.0" + } + } + } + }, "loader-runner": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.4.0.tgz", @@ -9348,6 +9382,11 @@ "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz", "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==" }, + "nanoid": { + "version": "3.1.16", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.16.tgz", + "integrity": "sha512-+AK8MN0WHji40lj8AEuwLOvLSbWYApQpre/aFJZD71r43wVRLrOYS4FmJOPQYon1TqB462RzrrxlfA74XRES8w==" + }, "nanomatch": { "version": "1.2.13", "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", @@ -9986,6 +10025,11 @@ "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", "dev": true }, + "parse-srcset": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/parse-srcset/-/parse-srcset-1.0.2.tgz", + "integrity": "sha1-8r0iH2zJcKk42IVWq8WJyqqiveE=" + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -13282,6 +13326,97 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "sanitize-html": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/sanitize-html/-/sanitize-html-2.1.1.tgz", + "integrity": "sha512-yb+I+K25cn6PzsRJb+kGdlOBC3SkvEwJrr/Xl+6YR42oDZDeu61yWeEMSEi0hCKlRSYlWWE4tUnF2Ds+c/M1Vg==", + "requires": { + "deepmerge": "^4.2.2", + "escape-string-regexp": "^4.0.0", + "htmlparser2": "^4.1.0", + "is-plain-object": "^5.0.0", + "klona": "^2.0.3", + "parse-srcset": "^1.0.2", + "postcss": "^8.0.2" + }, + "dependencies": { + "dom-serializer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.1.0.tgz", + "integrity": "sha512-ox7bvGXt2n+uLWtCRLybYx60IrOlWL/aCebWJk1T0d4m3y2tzf4U3ij9wBMUb6YJZpz06HCCYuyCDveE2xXmzQ==", + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^3.0.0", + "entities": "^2.0.0" + } + }, + "domelementtype": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.0.2.tgz", + "integrity": "sha512-wFwTwCVebUrMgGeAwRL/NhZtHAUyT9n9yg4IMDwf10+6iCMxSkVq9MGCVEH+QZWo1nNidy8kNvwmv4zWHDTqvA==" + }, + "domhandler": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-3.3.0.tgz", + "integrity": "sha512-J1C5rIANUbuYK+FuFL98650rihynUOEzRLxW+90bKZRWB6A1X1Tf82GxR1qAWLyfNPRvjqfip3Q5tdYlmAa9lA==", + "requires": { + "domelementtype": "^2.0.1" + } + }, + "domutils": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.4.2.tgz", + "integrity": "sha512-NKbgaM8ZJOecTZsIzW5gSuplsX2IWW2mIK7xVr8hTQF2v1CJWTmLZ1HOCh5sH+IzVPAGE5IucooOkvwBRAdowA==", + "requires": { + "dom-serializer": "^1.0.1", + "domelementtype": "^2.0.1", + "domhandler": "^3.3.0" + } + }, + "entities": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-2.1.0.tgz", + "integrity": "sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w==" + }, + "escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==" + }, + "htmlparser2": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-4.1.0.tgz", + "integrity": "sha512-4zDq1a1zhE4gQso/c5LP1OtrhYTncXNSpvJYtWJBtXAETPlMfi3IFNjGuQbYLuVY4ZR0QMqRVvo4Pdy9KLyP8Q==", + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^3.0.0", + "domutils": "^2.0.0", + "entities": "^2.0.0" + } + }, + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, + "postcss": { + "version": "8.1.4", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.1.4.tgz", + "integrity": "sha512-LfqcwgMq9LOd8pX7K2+r2HPitlIGC5p6PoZhVELlqhh2YGDVcXKpkCseqan73Hrdik6nBd2OvoDPUaP/oMj9hQ==", + "requires": { + "colorette": "^1.2.1", + "line-column": "^1.0.2", + "nanoid": "^3.1.15", + "source-map": "^0.6.1" + } + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + } + } + }, "sax": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", @@ -15169,6 +15304,14 @@ "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.1.6.tgz", "integrity": "sha512-GYhn2ynaZlysZMkFE5oCHRUTqE8BWs/a9YbKpNLi0i7xD6KG1EzDqpHQmv1F5gXjr8kL5iIVS8EOtRaVUEXTqA==" }, + "vue-sanitize": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/vue-sanitize/-/vue-sanitize-0.2.1.tgz", + "integrity": "sha512-MhrfAaAqIQ8JXWfdlhK6f+H2WnZ7KQwkOgLNeUyfACI2bq/3HPZ2zeUQDathnLdsXMXAa8pJehOgPYtlaG9Jew==", + "requires": { + "sanitize-html": "^2.1.1" + } + }, "vue-style-loader": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.2.tgz", diff --git a/package.json b/package.json index 35cb5950..9191413d 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "unbzip2-stream": "^1.3.3", "vue": "github:bookpauk/vue", "vue-router": "^3.1.6", + "vue-sanitize": "^0.2.1", "vuex": "^3.1.2", "vuex-persistedstate": "^2.7.1", "webdav": "^2.10.2", From fcf6639d38c42f63859327d16c818d42838ae648 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 4 Nov 2020 14:41:38 +0700 Subject: [PATCH 08/22] =?UTF-8?q?=D0=9D=D0=B5=D0=B1=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D1=88=D0=B8=D0=B5=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B8?= =?UTF-8?q?=20=D0=BA=D0=BB=D0=B0=D0=B2=D0=B8=D1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/share/StdDialog.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/components/share/StdDialog.vue b/client/components/share/StdDialog.vue index c10d5970..9bda6e51 100644 --- a/client/components/share/StdDialog.vue +++ b/client/components/share/StdDialog.vue @@ -144,6 +144,7 @@ class StdDialog extends Vue { this.inputValidator = null; this.inputValue = ''; this.error = ''; + this.showed = false; this.iconColor = 'text-warning'; if (opts && opts.color) { @@ -161,6 +162,7 @@ class StdDialog extends Vue { this.hideTrigger(); this.hideTrigger = null; } + this.showed = false; } onShow() { @@ -170,6 +172,7 @@ class StdDialog extends Vue { this.validate(this.inputValue); this.$refs.input.focus(); } + this.showed = true; } validate(value) { @@ -276,7 +279,7 @@ class StdDialog extends Vue { } keyHook(event) { - if (this.active) { + if (this.active && this.showed) { let handled = false; if (this.type == 'hotKey') { if (event.type == 'keydown') { From b2e0bcf99591671d54b58047b32289e8b8872f5b Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 4 Nov 2020 14:42:35 +0700 Subject: [PATCH 09/22] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B5=D0=B7=D0=BE=D0=BF=D0=B0=D1=81?= =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=81=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/SettingsPage/include/ProfilesTab.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/components/Reader/SettingsPage/include/ProfilesTab.inc b/client/components/Reader/SettingsPage/include/ProfilesTab.inc index b9e0a898..ad94f74a 100644 --- a/client/components/Reader/SettingsPage/include/ProfilesTab.inc +++ b/client/components/Reader/SettingsPage/include/ProfilesTab.inc @@ -22,7 +22,7 @@ From f8c496007902c5fc548e6362a10ddd928c5c2567 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 4 Nov 2020 14:43:06 +0700 Subject: [PATCH 10/22] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20BookmarkSettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookmarkSettings/BookmarkSettings.vue | 39 ++++++++--- .../components/ExternalLibs/ExternalLibs.vue | 65 ++++++++++++++----- 2 files changed, 79 insertions(+), 25 deletions(-) diff --git a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue index 1eeb6f3d..f327c254 100644 --- a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue +++ b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue @@ -21,7 +21,7 @@
- + Редактировать закладку @@ -72,6 +72,7 @@ import * as lu from '../linkUtils'; const BookmarkSettingsProps = Vue.extend({ props: { libs: Object, + addBookmarkVisible: Boolean, } }); @@ -91,6 +92,7 @@ class BookmarkSettings extends BookmarkSettingsProps { expanded = []; created() { + this.afterInit = true; } mounted() { @@ -109,7 +111,7 @@ class BookmarkSettings extends BookmarkSettingsProps { this.libs.groups.forEach(group => { const rkey = `${i}`; const g = {label: group.r, key: rkey, children: []}; - this.links[rkey] = group.r; + this.links[rkey] = {l: group.r, c: ''}; let j = 0; group.list.forEach(link => { @@ -119,7 +121,7 @@ class BookmarkSettings extends BookmarkSettingsProps { key }); - this.links[key] = link.l; + this.links[key] = link; if (link.l == this.libs.startLink && expanded.indexOf(rkey) < 0) { expanded.push(rkey); } @@ -131,9 +133,12 @@ class BookmarkSettings extends BookmarkSettingsProps { i++; }); - this.$nextTick(() => { - this.expanded = expanded; - }); + if (this.afterInit) { + this.$nextTick(() => { + this.expanded = expanded; + }); + this.afterInit = false; + } return result; } @@ -147,22 +152,36 @@ class BookmarkSettings extends BookmarkSettingsProps { if (!this.selected) return; if (this.selected.indexOf('-') < 0) {//rootLink - this.$emit('do-action', {action: 'setRootLink', data: this.links[this.selected]}); + this.$emit('do-action', {action: 'setRootLink', data: this.links[this.selected].l}); } else {//selectedLink - this.$emit('do-action', {action: 'setSelectedLink', data: this.links[this.selected]}); + this.$emit('do-action', {action: 'setSelectedLink', data: this.links[this.selected].l}); } - - //this.close(); + this.close(); } openOptions() { } + editBookmark() { + this.$emit('do-action', {action: 'editBookmark', data: {link: this.links[this.selected].l, desc: this.links[this.selected].c}}); + } + + addBookmark() { + this.$emit('do-action', {action: 'addBookmark'}); + } + + delBookmark() { + } + close() { + this.afterInit = false; this.$emit('close'); } keyHook(event) { + if (this.addBookmarkVisible) + return false; + if (event.type == 'keydown' && event.key == 'Escape') { this.close(); return true; diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index 463aa6a1..6648032a 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -68,7 +68,8 @@ @@ -97,7 +98,9 @@
- + + @@ -154,6 +157,7 @@ class ExternalLibs extends Vue { addBookmarkVisible = false; transparentLayoutVisible = false; + addBookmarkMode = ''; bookmarkLink = ''; bookmarkDesc = ''; defaultRootLink = ''; @@ -297,6 +301,8 @@ class ExternalLibs extends Vue { case 'setLibs': this.commitLibs(event.data); break; case 'setRootLink': this.rootLink = event.data; this.rootLinkInput(); break; case 'setSelectedLink': this.selectedLink = event.data; this.selectedLinkInput(); break; + case 'editBookmark': this.addBookmark('edit', event.data.link, event.data.desc); break; + case 'addBookmark': this.addBookmark('add'); break; } } @@ -439,9 +445,17 @@ class ExternalLibs extends Vue { } } - addBookmark() { - this.bookmarkLink = (this.bookUrl ? this.makeProxySubst(lu.addProtocol(this.bookUrl), true) : ''); - this.bookmarkDesc = ''; + addBookmark(mode = 'add', link = '', desc = '') { + + if (mode == 'edit') { + this.editBookmarkLink = this.bookmarkLink = link; + this.editBookmarkDesc = this.bookmarkDesc = desc; + } else { + this.bookmarkLink = (this.bookUrl ? this.makeProxySubst(lu.addProtocol(this.bookUrl), true) : ''); + this.bookmarkDesc = ''; + } + + this.addBookmarkMode = mode; this.addBookmarkVisible = true; this.$nextTick(() => { this.$refs.bookmarkLink.focus(); @@ -474,7 +488,6 @@ class ExternalLibs extends Vue { bookmarkDescKeyDown(event) { if (event.key == 'Enter') { this.okAddBookmark(); - event.preventDefault(); } } @@ -482,7 +495,7 @@ class ExternalLibs extends Vue { if (!this.bookmarkLink) return; - const link = lu.addProtocol(this.bookmarkLink); + const link = (this.addBookmarkMode == 'edit' ? lu.addProtocol(this.editBookmarkLink) : lu.addProtocol(this.bookmarkLink)); let index = -1; try { index = lu.getRootIndexByUrl(this.libs.groups, link); @@ -491,14 +504,25 @@ class ExternalLibs extends Vue { return; } + let libs = _.cloneDeep(this.libs); + + //добавление //есть группа в закладках if (index >= 0) { - const item = lu.getListItemByLink(this.libs.groups[index].list, link); - - if (!item || item.c != this.bookmarkDesc) { - //добавляем - let libs = _.cloneDeep(this.libs); + const item = lu.getListItemByLink(libs.groups[index].list, link); + //редактирование + if (item && this.addBookmarkMode == 'edit') { + if (item) { + //редактируем + item.l = link; + item.c = this.bookmarkDesc; + this.commitLibs(libs); + } else { + await this.$root.stdDialog.alert('Не удалось отредактировать закладку', 'Ошибка'); + } + } else if (!item) { + //добавляем if (libs.groups[index].list.length >= 100) { await this.$root.stdDialog.alert('Достигнут предел количества закладок для этого сайта', 'Ошибка'); return; @@ -506,10 +530,18 @@ class ExternalLibs extends Vue { libs.groups[index].list.push({l: link, c: this.bookmarkDesc}); this.commitLibs(libs); + } else if (item.c != this.bookmarkDesc) { + if (await this.$root.stdDialog.confirm(`Такая закладка уже существует с другим описанием
` + + `Заменить '${this.$sanitize(item.c)}' на '${this.$sanitize(this.bookmarkDesc)}'?`, ' ')) { + item.c = this.bookmarkDesc; + this.commitLibs(libs); + } else + return; + } else { + await this.$root.stdDialog.alert('Такая закладка уже существует', ' '); + return; } } else {//нет группы в закладках - let libs = _.cloneDeep(this.libs); - if (libs.groups.length >= 100) { await this.$root.stdDialog.alert('Достигнут предел количества различных сайтов в закладках', 'Ошибка'); return; @@ -573,10 +605,13 @@ class ExternalLibs extends Vue { keyHook(event) { if (this.$root.rootRoute() == '/external-libs') { + if (this.$root.stdDialog.active) + return false; + if (this.bookmarkSettingsActive && this.$refs.bookmarkSettings.keyHook(event)) return true; - if (this.$refs.dialogAddBookmark.active) + if (this.addBookmarkVisible) return false; if (event.type == 'keydown' && event.key == 'F4') { From 27412211a5f3283508335c9a78975afa7736c66c Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 4 Nov 2020 18:53:14 +0700 Subject: [PATCH 11/22] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20BookmarkSettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookmarkSettings/BookmarkSettings.vue | 77 +++++++++++++------ .../components/ExternalLibs/ExternalLibs.vue | 54 +++++++++---- client/components/ExternalLibs/linkUtils.js | 12 ++- 3 files changed, 103 insertions(+), 40 deletions(-) diff --git a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue index f327c254..4c8af4e5 100644 --- a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue +++ b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue @@ -14,27 +14,27 @@ - - Опции -
- - Редактировать закладку - Добавить закладку - - Удалить закладку + + Удалить отмеченные закладки - - Переместить вверх + + Редактировать закладку - - Переместить вниз + + Переместить отмеченные вверх + + + Переместить отмеченные вниз + + + Установить по умолчанию
@@ -65,9 +65,11 @@ //----------------------------------------------------------------------------- import Vue from 'vue'; import Component from 'vue-class-component'; -import Window from '../../share/Window.vue'; +import _ from 'lodash'; +import Window from '../../share/Window.vue'; import * as lu from '../linkUtils'; +import rstore from '../../../store/modules/reader'; const BookmarkSettingsProps = Vue.extend({ props: { @@ -107,15 +109,13 @@ class BookmarkSettings extends BookmarkSettingsProps { const expanded = []; this.links = {}; - let i = 0; this.libs.groups.forEach(group => { - const rkey = `${i}`; + const rkey = `r-${group.r}`; const g = {label: group.r, key: rkey, children: []}; this.links[rkey] = {l: group.r, c: ''}; - let j = 0; group.list.forEach(link => { - const key = `${i}-${j}`; + const key = link.l; g.children.push({ label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l), key @@ -126,11 +126,9 @@ class BookmarkSettings extends BookmarkSettingsProps { expanded.push(rkey); } - j++; }); result.push(g); - i++; }); if (this.afterInit) { @@ -151,7 +149,7 @@ class BookmarkSettings extends BookmarkSettingsProps { openSelected() { if (!this.selected) return; - if (this.selected.indexOf('-') < 0) {//rootLink + if (this.selected.indexOf('r-') === 0) {//rootLink this.$emit('do-action', {action: 'setRootLink', data: this.links[this.selected].l}); } else {//selectedLink this.$emit('do-action', {action: 'setSelectedLink', data: this.links[this.selected].l}); @@ -159,9 +157,6 @@ class BookmarkSettings extends BookmarkSettingsProps { this.close(); } - openOptions() { - } - editBookmark() { this.$emit('do-action', {action: 'editBookmark', data: {link: this.links[this.selected].l, desc: this.links[this.selected].c}}); } @@ -170,7 +165,41 @@ class BookmarkSettings extends BookmarkSettingsProps { this.$emit('do-action', {action: 'addBookmark'}); } - delBookmark() { + async delBookmark() { + const newLibs = _.cloneDeep(this.libs); + + if (await this.$root.stdDialog.confirm(`Подтвердите удаление ${this.ticked.length} закладок:`, ' ')) { + const ticked = new Set(this.ticked); + for (let i = newLibs.groups.length - 1; i >= 0; i--) { + const g = newLibs.groups[i]; + for (let j = g.list.length - 1; j >= 0; j--) { + if (ticked.has(g.list[j].l)) { + delete g.list[j]; + } + } + g.list = g.list.filter(v => v); + if (!g.list.length) + delete newLibs.groups[i]; + } + + newLibs.groups = newLibs.groups.filter(v => v); + this.ticked = []; + this.selected = ''; + this.$emit('do-action', {action: 'setLibs', data: newLibs}); + } + } + + moveBookmark() { + } + + async setDefaultBookmarks() { + const result = await this.$root.stdDialog.prompt(`Введите 'да' для сброса всех закладок в предустановленные значения:`, ' ', { + inputValidator: (str) => { if (str && str.toLowerCase() === 'да') return true; else return 'Удаление не подтверждено'; }, + }); + + if (result && result.value && result.value.toLowerCase() == 'да') { + this.$emit('do-action', {action: 'setLibs', data: _.cloneDeep(rstore.libsDefaults)}); + } } close() { diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index 6648032a..265e8981 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -51,6 +51,11 @@ Загрузить URL во фрейм + Открыть @@ -263,8 +268,6 @@ class ExternalLibs extends Vue { } else if (d.type == 'libs') { this.ready = true; this.libs = _.cloneDeep(d.data); - if (!this.frameSrc) - this.goToLink(this.libs.startLink); } else if (d.type == 'notify') { this.$root.notify.success(d.data, '', {position: 'bottom-right'}); } @@ -291,8 +294,9 @@ class ExternalLibs extends Vue { loadLibs() { const libs = this.libs; - this.startLink = (libs.comment ? libs.comment + ' ': '') + lu.removeProtocol(libs.startLink); + this.startLink = libs.startLink; this.rootLink = lu.getOrigin(libs.startLink); + this.updateSelectedLink(); } @@ -313,7 +317,7 @@ class ExternalLibs extends Vue { get header() { let result = (this.ready ? 'Библиотека' : 'Загрузка...'); if (this.ready && this.startLink) { - result += ` | ${this.startLink}`; + result += ` | ${(this.libs.comment ? this.libs.comment + ' ': '') + lu.removeProtocol(this.startLink)}`; } this.$root.$emit('set-app-title', result); return result; @@ -326,22 +330,37 @@ class ExternalLibs extends Vue { updateSelectedLink() { if (!this.ready) return; - const index = lu.getRootIndexByUrl(this.libs.groups, this.rootLink); + + const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.rootLink); if (index >= 0) this.selectedLink = this.libs.groups[index].s; + else + this.selectedLink = ''; } updateStartLink() { if (!this.ready) return; - const index = lu.getRootIndexByUrl(this.libs.groups, this.rootLink); + const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.rootLink); if (index >= 0) { let libs = _.cloneDeep(this.libs); - libs.groups[index].s = this.selectedLink; - libs.startLink = this.selectedLink; - libs.comment = this.getCommentByLink(libs.groups[index].list, this.selectedLink); - this.goToLink(this.selectedLink); - this.commitLibs(libs); + try { + if (lu.getOrigin(libs.groups[index].r) == lu.getOrigin(this.selectedLink)) { + libs.groups[index].s = this.selectedLink; + libs.startLink = this.selectedLink; + libs.comment = this.getCommentByLink(libs.groups[index].list, this.selectedLink); + this.goToLink(this.selectedLink); + this.commitLibs(libs); + } else { + console.error(`${lu.getOrigin(libs.groups[index].r)} != ${lu.getOrigin(this.selectedLink)}`); + } + } catch(e) { + console.log(e); + } + } else { + this.rootLink = ''; + this.startLink = ''; + this.frameVisible = false; } } @@ -372,7 +391,7 @@ class ExternalLibs extends Vue { if (!this.ready) return result; - const index = lu.getRootIndexByUrl(this.libs.groups, this.rootLink); + const index = lu.getSafeRootIndexByUrl(this.libs.groups, this.rootLink); if (index >= 0) { this.libs.groups[index].list.forEach(link => { result.push({label: (link.c ? link.c + ' ': '') + lu.removeOrigin(link.l), value: link.l}); @@ -389,7 +408,7 @@ class ExternalLibs extends Vue { } goToLink(link) { - if (!this.ready) + if (!this.ready || !link) return; this.frameSrc = this.makeProxySubst(link); @@ -464,7 +483,7 @@ class ExternalLibs extends Vue { } updateBookmarkLink() { - const index = lu.getRootIndexByUrl(rstore.libsDefaults.groups, this.defaultRootLink); + const index = lu.getSafeRootIndexByUrl(rstore.libsDefaults.groups, this.defaultRootLink); if (index >= 0) { this.bookmarkLink = rstore.libsDefaults.groups[index].s; this.bookmarkDesc = this.getCommentByLink(rstore.libsDefaults.groups[index].list, this.bookmarkLink); @@ -487,6 +506,8 @@ class ExternalLibs extends Vue { bookmarkDescKeyDown(event) { if (event.key == 'Enter') { + event.stopPropagation(); + event.preventDefault(); this.okAddBookmark(); } } @@ -550,7 +571,7 @@ class ExternalLibs extends Vue { //добавляем сначала группу libs.groups.push({r: lu.getOrigin(link), s: link, list: []}); - index = lu.getRootIndexByUrl(libs.groups, link); + index = lu.getSafeRootIndexByUrl(libs.groups, link); if (index >= 0) libs.groups[index].list.push({l: link, c: this.bookmarkDesc}); @@ -603,6 +624,9 @@ class ExternalLibs extends Vue { this.bookmarkSettingsActive = false; } + openOptions() { + } + keyHook(event) { if (this.$root.rootRoute() == '/external-libs') { if (this.$root.stdDialog.active) diff --git a/client/components/ExternalLibs/linkUtils.js b/client/components/ExternalLibs/linkUtils.js index a837ac21..395c9028 100644 --- a/client/components/ExternalLibs/linkUtils.js +++ b/client/components/ExternalLibs/linkUtils.js @@ -20,7 +20,7 @@ export function removeOrigin(url) { } export function getRootIndexByUrl(groups, url) { - const origin = this.getOrigin(url); + const origin = getOrigin(url); for (let i = 0; i < groups.length; i++) { if (groups[i].r == origin) return i; @@ -28,6 +28,16 @@ export function getRootIndexByUrl(groups, url) { return -1; } +export function getSafeRootIndexByUrl(groups, url) { + let index = -1; + try { + index = getRootIndexByUrl(groups, url); + } catch(e) { + // + } + return index; +} + export function getListItemByLink(list, link) { for (const item of list) { if (item.l == link) From 94b8f9fe1cfa4575e3e2af7b9065214182c2a28b Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 4 Nov 2020 19:06:11 +0700 Subject: [PATCH 12/22] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20BookmarkSettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExternalLibs/BookmarkSettings/BookmarkSettings.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue index 4c8af4e5..1dbdfba2 100644 --- a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue +++ b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue @@ -180,6 +180,11 @@ class BookmarkSettings extends BookmarkSettingsProps { g.list = g.list.filter(v => v); if (!g.list.length) delete newLibs.groups[i]; + else { + const item = lu.getListItemByLink(g.list, g.s); + if (!item) + g.s = g.list[0].l; + } } newLibs.groups = newLibs.groups.filter(v => v); From 1d8bd5686211f2de0af9f1c3948987d97b444a94 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 4 Nov 2020 22:23:39 +0700 Subject: [PATCH 13/22] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B1=D0=B0=D0=B3=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookmarkSettings/BookmarkSettings.vue | 2 +- client/components/ExternalLibs/ExternalLibs.vue | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue index 1dbdfba2..a1ff69cd 100644 --- a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue +++ b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue @@ -24,7 +24,7 @@ Удалить отмеченные закладки - + Редактировать закладку diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index 265e8981..e6a61511 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -294,8 +294,13 @@ class ExternalLibs extends Vue { loadLibs() { const libs = this.libs; - this.startLink = libs.startLink; - this.rootLink = lu.getOrigin(libs.startLink); + try { + this.startLink = libs.startLink; + this.rootLink = lu.getOrigin(libs.startLink); + } catch(e) { + this.startLink = ''; + this.rootLink = ''; + } this.updateSelectedLink(); } @@ -304,7 +309,11 @@ class ExternalLibs extends Vue { switch (event.action) { case 'setLibs': this.commitLibs(event.data); break; case 'setRootLink': this.rootLink = event.data; this.rootLinkInput(); break; - case 'setSelectedLink': this.selectedLink = event.data; this.selectedLinkInput(); break; + case 'setSelectedLink': + this.selectedLink = event.data; + this.rootLink = lu.getOrigin(this.selectedLink); + this.selectedLinkInput(); + break; case 'editBookmark': this.addBookmark('edit', event.data.link, event.data.desc); break; case 'addBookmark': this.addBookmark('add'); break; } @@ -552,7 +561,7 @@ class ExternalLibs extends Vue { libs.groups[index].list.push({l: link, c: this.bookmarkDesc}); this.commitLibs(libs); } else if (item.c != this.bookmarkDesc) { - if (await this.$root.stdDialog.confirm(`Такая закладка уже существует с другим описанием
` + + if (await this.$root.stdDialog.confirm(`Такая закладка уже существует с другим описанием.
` + `Заменить '${this.$sanitize(item.c)}' на '${this.$sanitize(this.bookmarkDesc)}'?`, ' ')) { item.c = this.bookmarkDesc; this.commitLibs(libs); From 14742ed4ad98e7e524c2e3a15f0cda7b9a9266b2 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Wed, 4 Nov 2020 22:56:28 +0700 Subject: [PATCH 14/22] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20BookmarkSettings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BookmarkSettings/BookmarkSettings.vue | 55 ++++++++++++++++++- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue index a1ff69cd..0094cd83 100644 --- a/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue +++ b/client/components/ExternalLibs/BookmarkSettings/BookmarkSettings.vue @@ -9,7 +9,7 @@ Открыть выбранную закладку - + @@ -194,7 +194,58 @@ class BookmarkSettings extends BookmarkSettingsProps { } } - moveBookmark() { + moveBookmark(down = false) { + const newLibs = _.cloneDeep(this.libs); + + const ticked = new Set(this.ticked); + let moved = false; + let prevFull = false; + if (!down) { + for (let i = 0; i < newLibs.groups.length; i++) { + const g = newLibs.groups[i]; + let count = 0; + for (let j = 0; j < g.list.length; j++) { + if (ticked.has(g.list[j].l)) { + if (j > 0 && !ticked.has(g.list[j - 1].l)) { + [g.list[j], g.list[j - 1]] = [g.list[j - 1], g.list[j]]; + moved = true; + } + count++; + } + } + + if (count == g.list.length && !prevFull && i > 0) { + const gs = newLibs.groups; + [gs[i], gs[i - 1]] = [gs[i - 1], gs[i]]; + moved = true; + } else + prevFull = (count == g.list.length); + } + } else { + for (let i = newLibs.groups.length - 1; i >= 0; i--) { + const g = newLibs.groups[i]; + let count = 0; + for (let j = g.list.length - 1; j >= 0; j--) { + if (ticked.has(g.list[j].l)) { + if (j < g.list.length - 1 && !ticked.has(g.list[j + 1].l)) { + [g.list[j], g.list[j + 1]] = [g.list[j + 1], g.list[j]]; + moved = true; + } + count++; + } + } + + if (count == g.list.length && !prevFull && i < newLibs.groups.length - 1) { + const gs = newLibs.groups; + [gs[i], gs[i + 1]] = [gs[i + 1], gs[i]]; + moved = true; + } else + prevFull = (count == g.list.length); + } + } + + if (moved) + this.$emit('do-action', {action: 'setLibs', data: newLibs}); } async setDefaultBookmarks() { From 4883b8a190597be03441b1e06fca535fa5c5d9bb Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 5 Nov 2020 03:21:54 +0700 Subject: [PATCH 15/22] =?UTF-8?q?=D0=A0=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B4=20ExternalLibs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ExternalLibs/ExternalLibs.vue | 64 +++++++++++++++---- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index e6a61511..b9ccf435 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -58,7 +58,7 @@ - Открыть + Открыть Открыть в читалке
@@ -139,14 +139,31 @@ export default @Component({ }, rootLink: function() { this.updateSelectedLink(); - this.updateStartLink(); }, selectedLink: function() { this.updateStartLink(); }, defaultRootLink: function() { this.updateBookmarkLink(); - } + }, + bookUrl: function(newValue) { + const value = lu.addProtocol(newValue); + const subst = this.makeProxySubst(value, true); + if (value != subst) { + this.$nextTick(() => { + this.bookUrl = subst; + }); + } + }, + bookmarkLink: function(newValue) { + const value = lu.addProtocol(newValue); + const subst = this.makeProxySubst(value, true); + if (value != subst) { + this.$nextTick(() => { + this.bookmarkLink = subst; + }); + } + }, } }) class ExternalLibs extends Vue { @@ -176,6 +193,8 @@ class ExternalLibs extends Vue { this.fullScreenActive = (document.fullscreenElement !== null); }); + this.commitInProgress = false; + //this.commit = this.$store.commit; //this.commit('reader/setLibs', rstore.libsDefaults); } @@ -266,6 +285,7 @@ class ExternalLibs extends Vue { case 'hello': this.sendMessage({type: 'mes', data: 'ready'}); break; } } else if (d.type == 'libs') { + this.commitInProgress = false; this.ready = true; this.libs = _.cloneDeep(d.data); } else if (d.type == 'notify') { @@ -289,7 +309,20 @@ class ExternalLibs extends Vue { } commitLibs(libs) { - this.sendMessage({type: 'libs', data: libs}); + (async() => { + let i = 0; + while (this.commitInProgress && i < 50) {//1 сек + await utils.sleep(20); + i++; + } + + if (!this.commitInProgress) { + this.commitInProgress = true; + this.sendMessage({type: 'libs', data: libs}); + } else { + throw new Error('Commit failed'); + } + })(); } loadLibs() { @@ -308,11 +341,17 @@ class ExternalLibs extends Vue { doAction(event) { switch (event.action) { case 'setLibs': this.commitLibs(event.data); break; - case 'setRootLink': this.rootLink = event.data; this.rootLinkInput(); break; + case 'setRootLink': this.rootLink = event.data; break; case 'setSelectedLink': - this.selectedLink = event.data; - this.rootLink = lu.getOrigin(this.selectedLink); - this.selectedLinkInput(); + this.rootLink = lu.getOrigin(event.data); + this.$nextTick(async() => { + let i = 0; + while (this.commitInProgress && i < 50) {//1 сек + await utils.sleep(20); + i++; + } + this.selectedLink = event.data; + }); break; case 'editBookmark': this.addBookmark('edit', event.data.link, event.data.desc); break; case 'addBookmark': this.addBookmark('add'); break; @@ -425,7 +464,8 @@ class ExternalLibs extends Vue { this.$nextTick(() => { this.frameVisible = true; this.$nextTick(() => { - this.$refs.frame.contentWindow.focus(); + if (this.$refs.frame) + this.$refs.frame.contentWindow.focus(); }); }); } @@ -439,7 +479,7 @@ class ExternalLibs extends Vue { for (const [key, value] of Object.entries(proxySubst)) { if (reverse && value == url.substring(0, value.length)) { return key + url.substring(value.length); - } else if (key == url.substring(0, key.length)) { + } else if (!reverse && key == url.substring(0, key.length)) { return value + url.substring(key.length); } } @@ -464,7 +504,7 @@ class ExternalLibs extends Vue { submitUrl() { if (this.bookUrl) { this.sendMessage({type: 'submitUrl', data: { - url: this.makeProxySubst(lu.addProtocol(this.bookUrl), true), + url: this.bookUrl, force: true }}); this.bookUrl = ''; @@ -479,7 +519,7 @@ class ExternalLibs extends Vue { this.editBookmarkLink = this.bookmarkLink = link; this.editBookmarkDesc = this.bookmarkDesc = desc; } else { - this.bookmarkLink = (this.bookUrl ? this.makeProxySubst(lu.addProtocol(this.bookUrl), true) : ''); + this.bookmarkLink = this.bookUrl; this.bookmarkDesc = ''; } From 6c0678ed6126d172d91cb3b97c7aa85523691a47 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 5 Nov 2020 14:08:15 +0700 Subject: [PATCH 16/22] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ExternalLibs/ExternalLibs.vue | 132 ++++++++---------- 1 file changed, 56 insertions(+), 76 deletions(-) diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index b9ccf435..27f48aab 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -44,7 +44,7 @@ @focus="selectAllOnFocus" @keydown="bookUrlKeyDown" > -
+
Открыть выбранную закладку @@ -17,8 +17,8 @@
-
- +
+ Добавить закладку @@ -36,20 +36,25 @@ Установить по умолчанию +
-
+
+
+ +
@@ -102,7 +102,27 @@ OK + + + + +
+ + + +
+ + +
+ @@ -158,6 +178,15 @@ export default @Component({ }); } }, + closeAfterSubmit: function(newValue) { + this.commitProp('closeAfterSubmit', newValue); + }, + openInFrameOnEnter: function(newValue) { + this.commitProp('openInFrameOnEnter', newValue); + }, + openFullscreen: function(newValue) { + this.commitProp('openFullscreen', newValue); + }, } }) class ExternalLibs extends Vue { @@ -169,9 +198,11 @@ class ExternalLibs extends Vue { bookUrl = ''; libs = {}; fullScreenActive = false; - addBookmarkVisible = false; transparentLayoutVisible = false; + addBookmarkVisible = false; + optionsVisible = false; + addBookmarkMode = ''; bookmarkLink = ''; bookmarkDesc = ''; @@ -179,6 +210,10 @@ class ExternalLibs extends Vue { bookmarkSettingsActive = false; + closeAfterSubmit = false; + openInFrameOnEnter = false; + openFullscreen = false; + created() { this.$root.addKeyHook(this.keyHook); @@ -305,10 +340,19 @@ class ExternalLibs extends Vue { this.sendMessage({type: 'libs', data: libs}); } + commitProp(prop, value) { + let libs = _.cloneDeep(this.libs); + libs[prop] = value; + this.commitLibs(libs); + } + loadLibs() { const libs = this.libs; this.selectedLink = libs.startLink; + this.closeAfterSubmit = libs.closeAfterSubmit || false; + this.openInFrameOnEnter = libs.openInFrameOnEnter || false; + this.openFullscreen = libs.openFullscreen || false; this.updateStartLink(); } @@ -488,7 +532,7 @@ class ExternalLibs extends Vue { force: true }}); this.bookUrl = ''; - if (this.libs.closeAfterSubmit) + if (this.closeAfterSubmit) this.close(); } } @@ -637,7 +681,12 @@ class ExternalLibs extends Vue { bookUrlKeyDown(event) { if (event.key == 'Enter') { - this.submitUrl(); + if (!this.openInFrameOnEnter) { + this.submitUrl(); + } else { + if (this.bookUrl) + this.goToLink(this.bookUrl, true); + } event.preventDefault(); } } @@ -653,9 +702,6 @@ class ExternalLibs extends Vue { this.bookmarkSettingsActive = false; } - openOptions() { - } - keyHook(event) { if (this.$root.rootRoute() == '/external-libs') { if (this.$root.stdDialog.active) @@ -664,7 +710,7 @@ class ExternalLibs extends Vue { if (this.bookmarkSettingsActive && this.$refs.bookmarkSettings.keyHook(event)) return true; - if (this.addBookmarkVisible) + if (this.addBookmarkVisible || this.optionsVisible) return false; if (event.type == 'keydown' && event.key == 'F4') { diff --git a/client/store/modules/reader.js b/client/store/modules/reader.js index a120851f..8933e6da 100644 --- a/client/store/modules/reader.js +++ b/client/store/modules/reader.js @@ -281,6 +281,8 @@ const libsDefaults = { startLink: 'http://flibusta.is', comment: 'Флибуста | Книжное братство', closeAfterSubmit: false, + openInFrameOnEnter: false, + openFullscreen: false, groups: [ {r: 'http://flibusta.is', s: 'http://flibusta.is', list: [ {l: 'http://flibusta.is', c: 'Флибуста | Книжное братство'}, From 546f4556f6084e4f9599b52693f08171166fb94a Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 5 Nov 2020 15:43:15 +0700 Subject: [PATCH 19/22] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B9=20?= =?UTF-8?q?=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD?= =?UTF-8?q?=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ExternalLibs/ExternalLibs.vue | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/client/components/ExternalLibs/ExternalLibs.vue b/client/components/ExternalLibs/ExternalLibs.vue index 369b3e76..d59ca769 100644 --- a/client/components/ExternalLibs/ExternalLibs.vue +++ b/client/components/ExternalLibs/ExternalLibs.vue @@ -44,7 +44,7 @@ @focus="selectAllOnFocus" @keydown="bookUrlKeyDown" >