From 0d41171e9db82b36108514f0d00d0e3dc8459535 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 21 Jul 2019 12:15:33 +0700 Subject: [PATCH 1/3] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D1=82=D0=B7=D1=8B=D0=B2=D1=87=D0=B8=D0=B2?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B8=20=D0=BF=D1=80=D0=BE=D0=B3=D1=80=D0=B5?= =?UTF-8?q?=D1=81=D1=81=D0=B1=D0=B0=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/share/bookManager.js | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/client/components/Reader/share/bookManager.js b/client/components/Reader/share/bookManager.js index 9d2932af..294bd624 100644 --- a/client/components/Reader/share/bookManager.js +++ b/client/components/Reader/share/bookManager.js @@ -143,7 +143,6 @@ class BookManager { } } - async deflateWithProgress(data, callback) { const chunkSize = 128*1024; const deflator = new utils.pako.Deflate({level: 5}); @@ -178,6 +177,40 @@ class BookManager { return deflator.result; } + async inflateWithProgress(data, callback) { + const chunkSize = 64*1024; + const inflator = new utils.pako.Inflate({to: 'string'}); + + let chunkTotal = 1 + Math.floor(data.length/chunkSize); + let chunkNum = 0; + let perc = 0; + let prevPerc = 0; + + for (var i = 0; i < data.length; i += chunkSize) { + if ((i + chunkSize) >= data.length) { + inflator.push(data.subarray(i, i + chunkSize), true); + } else { + inflator.push(data.subarray(i, i + chunkSize), false); + } + chunkNum++; + + perc = Math.round(chunkNum/chunkTotal*100); + if (perc != prevPerc) { + callback(perc); + await utils.sleep(1); + prevPerc = perc; + } + } + + if (inflator.err) { + throw new Error(inflator.msg); + } + + callback(100); + + return inflator.result; + } + async addBook(newBook, callback) { if (!this.books) await this.init(); @@ -239,12 +272,18 @@ class BookManager { if (result && !result.parsed) { let data = await bmDataStore.getItem(`bmData-${meta.key}`); - callback(10); + callback(5); await utils.sleep(10); + let cb = (perc) => { + const p = 5 + Math.round(15*perc/100); + callback(p); + }; + if (result.dataCompressed) { try { - data = utils.pako.inflate(data, {to: 'string'}); + //data = utils.pako.inflate(data, {to: 'string'}); + data = await this.inflateWithProgress(data, cb); } catch (e) { this.delBook(meta); throw e; @@ -252,7 +291,7 @@ class BookManager { } callback(20); - const cb = (perc) => { + cb = (perc) => { const p = 20 + Math.round(80*perc/100); callback(p); }; From 9af055ec54d1ba02c64d298d71f75b6ad2282fe5 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 21 Jul 2019 14:39:06 +0700 Subject: [PATCH 2/3] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=D1=80=D1=8F=D0=B4=D0=BA=D0=B0=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D0=BA=D0=BE=D0=BC?= =?UTF-8?q?=D0=BF=D0=BE=D0=BD=D0=B5=D0=BD=D1=82=D0=BE=D0=B2=20=D0=B8=20?= =?UTF-8?q?=D1=81=D0=BE=D0=BF=D1=83=D1=82=D1=81=D1=82=D0=B2=D1=83=D1=8E?= =?UTF-8?q?=D1=89=D0=B8=D1=85=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 --- client/components/App.vue | 22 ++++++++++------- .../Reader/ProgressPage/ProgressPage.vue | 2 +- client/components/Reader/Reader.vue | 6 ++++- .../Reader/SettingsPage/SettingsPage.vue | 6 ++--- client/main.js | 2 +- client/router.js | 12 ++++++---- client/share/utils.js | 24 +++++++++++++++++++ 7 files changed, 55 insertions(+), 19 deletions(-) diff --git a/client/components/App.vue b/client/components/App.vue index a568a3a9..514aaaf6 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -47,14 +47,12 @@ //----------------------------------------------------------------------------- import Vue from 'vue'; import Component from 'vue-class-component'; +import * as utils from '../share/utils'; export default @Component({ watch: { - rootRoute: function() { - this.setAppTitle(); - this.redirectIfNeeded(); - }, mode: function() { + this.setAppTitle(); this.redirectIfNeeded(); } }, @@ -123,6 +121,9 @@ class App extends Vue { }); } }); + + this.setAppTitle(); + this.redirectIfNeeded(); } toggleCollapse() { @@ -201,15 +202,18 @@ class App extends Vue { } redirectIfNeeded() { - if ((this.mode == 'reader' || this.mode == 'omnireader') && (this.rootRoute != '/reader')) { + if ((this.mode == 'reader' || this.mode == 'omnireader') && (!this.isReaderActive)) { //старый url const search = window.location.search.substr(1); - const url = search.split('url=')[1] || ''; + const s = search.split('url='); + const url = s[1] || ''; + const q = utils.parseQuery(s[0] || ''); if (url) { - window.location = `/#/reader?url=${url}`; - } else { - this.$router.replace('/reader'); + q.url = decodeURIComponent(url); } + + window.history.replaceState({}, '', '/'); + this.$router.replace({ path: '/reader', query: q }); } //yandex-метрика для omnireader diff --git a/client/components/Reader/ProgressPage/ProgressPage.vue b/client/components/Reader/ProgressPage/ProgressPage.vue index 7d1e9cb1..0ac1a0bc 100644 --- a/client/components/Reader/ProgressPage/ProgressPage.vue +++ b/client/components/Reader/ProgressPage/ProgressPage.vue @@ -94,6 +94,6 @@ class ProgressPage extends Vue { diff --git a/client/components/Reader/Reader.vue b/client/components/Reader/Reader.vue index b0caaf99..184e3c7d 100644 --- a/client/components/Reader/Reader.vue +++ b/client/components/Reader/Reader.vue @@ -1036,7 +1036,7 @@ class Reader extends Vue { overflow-x: auto; overflow-y: hidden; } - + .header { display: flex; justify-content: space-between; @@ -1064,6 +1064,10 @@ class Reader extends Vue { box-shadow: 3px 3px 5px black; } +.tool-button + .tool-button { + margin: 0 2px 0 2px; +} + .tool-button:hover { background-color: white; } diff --git a/client/components/Reader/SettingsPage/SettingsPage.vue b/client/components/Reader/SettingsPage/SettingsPage.vue index ec20e6f8..be2b07b6 100644 --- a/client/components/Reader/SettingsPage/SettingsPage.vue +++ b/client/components/Reader/SettingsPage/SettingsPage.vue @@ -871,9 +871,9 @@ class SettingsPage extends Vue { } .el-form-item { - padding: 0; - margin: 0; - margin-bottom: 5px; + padding: 0 !important; + margin: 0 !important; + margin-bottom: 5px !important; } .color-picked { diff --git a/client/main.js b/client/main.js index a30075e7..435575c4 100644 --- a/client/main.js +++ b/client/main.js @@ -1,10 +1,10 @@ import Vue from 'vue'; -import App from './components/App.vue'; import router from './router'; import store from './store'; import './element'; +import App from './components/App.vue'; //Vue.config.productionTip = false; new Vue({ diff --git a/client/router.js b/client/router.js index 99efcd06..512e0db4 100644 --- a/client/router.js +++ b/client/router.js @@ -2,21 +2,25 @@ import Vue from 'vue'; import VueRouter from 'vue-router'; import _ from 'lodash'; -import App from './components/App.vue'; +//немедленная загрузка +import CardIndex from './components/CardIndex/CardIndex.vue'; +//const CardIndex = () => import('./components/CardIndex/CardIndex.vue'); -const CardIndex = () => import('./components/CardIndex/CardIndex.vue'); const Search = () => import('./components/CardIndex/Search/Search.vue'); const Card = () => import('./components/CardIndex/Card/Card.vue'); const Book = () => import('./components/CardIndex/Book/Book.vue'); const History = () => import('./components/CardIndex/History/History.vue'); -const Reader = () => import('./components/Reader/Reader.vue'); +//немедленная загрузка +//const Reader = () => import('./components/Reader/Reader.vue'); +import Reader from './components/Reader/Reader.vue'; + //const Forum = () => import('./components/Forum/Forum.vue'); const Income = () => import('./components/Income/Income.vue'); const Sources = () => import('./components/Sources/Sources.vue'); const Settings = () => import('./components/Settings/Settings.vue'); const Help = () => import('./components/Help/Help.vue'); -const NotFound404 = () => import('./components/NotFound404/NotFound404.vue'); +//const NotFound404 = () => import('./components/NotFound404/NotFound404.vue'); const myRoutes = [ ['/', null, null, '/cardindex'], diff --git a/client/share/utils.js b/client/share/utils.js index 1469fbc1..c97aaf99 100644 --- a/client/share/utils.js +++ b/client/share/utils.js @@ -166,3 +166,27 @@ export function applyObjDiff(obj, diff, isAddChanged) { return result; } + +export function parseQuery(str) { + if (typeof str != 'string' || str.length == 0) + return {}; + let s = str.split('&'); + let s_length = s.length; + let bit, query = {}, first, second; + + for (let i = 0; i < s_length; i++) { + bit = s[i].split('='); + first = decodeURIComponent(bit[0]); + if (first.length == 0) + continue; + second = decodeURIComponent(bit[1]); + if (typeof query[first] == 'undefined') + query[first] = second; + else + if (query[first] instanceof Array) + query[first].push(second); + else + query[first] = [query[first], second]; + } + return query; +} \ No newline at end of file From a28d4c2f1c80e787bd099a977608e8aa17ac423d Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 21 Jul 2019 14:42:54 +0700 Subject: [PATCH 3/3] =?UTF-8?q?=D0=92=D0=B5=D1=80=D1=81=D0=B8=D1=8F=200.6.?= =?UTF-8?q?10?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Reader/versionHistory.js | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/components/Reader/versionHistory.js b/client/components/Reader/versionHistory.js index 795b2786..37e39480 100644 --- a/client/components/Reader/versionHistory.js +++ b/client/components/Reader/versionHistory.js @@ -1,4 +1,15 @@ export const versionHistory = [ +{ + showUntil: '2019-07-20', + header: '0.6.10 (2019-07-21)', + content: +` +
    +
  • исправления багов
  • +
+` +}, + { showUntil: '2019-06-22', header: '0.6.9 (2019-06-23)', diff --git a/package.json b/package.json index a4011faf..41aa96f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Liberama", - "version": "0.6.9", + "version": "0.6.10", "engines": { "node": ">=10.0.0" },