Reader.vue 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443
  1. <template>
  2. <div class="column no-wrap">
  3. <div v-show="toolBarActive" ref="header" class="header">
  4. <div ref="buttons" class="row justify-between no-wrap">
  5. <div>
  6. <button ref="loader" v-ripple class="tool-button" :class="buttonActiveClass('loader')" @click="buttonClick('loader')">
  7. <q-icon name="la la-arrow-left" size="32px" />
  8. <q-tooltip :delay="1500" anchor="bottom right" content-style="font-size: 80%">
  9. {{ rstore.readerActions['loader'] }}
  10. </q-tooltip>
  11. </button>
  12. <button ref="help" v-ripple class="tool-button" :class="buttonActiveClass('help')" @click="buttonClick('help')">
  13. <q-icon name="la la-question" size="32px" />
  14. <q-tooltip :delay="1500" anchor="bottom right" content-style="font-size: 80%">
  15. {{ rstore.readerActions['help'] }}
  16. </q-tooltip>
  17. </button>
  18. </div>
  19. <div>
  20. <button v-show="showToolButton['undoAction']" ref="undoAction" v-ripple class="tool-button" :class="buttonActiveClass('undoAction')" @click="buttonClick('undoAction')">
  21. <q-icon name="la la-angle-left" size="32px" />
  22. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  23. {{ rstore.readerActions['undoAction'] }}
  24. </q-tooltip>
  25. </button>
  26. <button v-show="showToolButton['redoAction']" ref="redoAction" v-ripple class="tool-button" :class="buttonActiveClass('redoAction')" @click="buttonClick('redoAction')">
  27. <q-icon name="la la-angle-right" size="32px" />
  28. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  29. {{ rstore.readerActions['redoAction'] }}
  30. </q-tooltip>
  31. </button>
  32. <div class="space"></div>
  33. <button v-show="showToolButton['fullScreen']" ref="fullScreen" v-ripple class="tool-button" :class="buttonActiveClass('fullScreen')" @click="buttonClick('fullScreen')">
  34. <q-icon :name="(fullScreenActive ? 'la la-compress-arrows-alt': 'la la-expand-arrows-alt')" size="32px" />
  35. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  36. {{ rstore.readerActions['fullScreen'] }}
  37. </q-tooltip>
  38. </button>
  39. <button v-show="showToolButton['scrolling']" ref="scrolling" v-ripple class="tool-button" :class="buttonActiveClass('scrolling')" @click="buttonClick('scrolling')">
  40. <q-icon name="la la-film" size="32px" />
  41. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  42. {{ rstore.readerActions['scrolling'] }}
  43. </q-tooltip>
  44. </button>
  45. <button v-show="showToolButton['setPosition']" ref="setPosition" v-ripple class="tool-button" :class="buttonActiveClass('setPosition')" @click="buttonClick('setPosition')">
  46. <q-icon name="la la-angle-double-right" size="32px" />
  47. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  48. {{ rstore.readerActions['setPosition'] }}
  49. </q-tooltip>
  50. </button>
  51. <button v-show="showToolButton['search']" ref="search" v-ripple class="tool-button" :class="buttonActiveClass('search')" @click="buttonClick('search')">
  52. <q-icon name="la la-search" size="32px" />
  53. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  54. {{ rstore.readerActions['search'] }}
  55. </q-tooltip>
  56. </button>
  57. <button v-show="showToolButton['copyText']" ref="copyText" v-ripple class="tool-button" :class="buttonActiveClass('copyText')" @click="buttonClick('copyText')">
  58. <q-icon name="la la-copy" size="32px" />
  59. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  60. {{ rstore.readerActions['copyText'] }}
  61. </q-tooltip>
  62. </button>
  63. <button v-show="showToolButton['convOptions']" ref="convOptions" v-ripple class="tool-button" :class="buttonActiveClass('convOptions')" @click="buttonClick('convOptions')">
  64. <q-icon name="la la-magic" size="32px" />
  65. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  66. {{ rstore.readerActions['convOptions'] }}
  67. </q-tooltip>
  68. </button>
  69. <button v-show="showToolButton['refresh']" ref="refresh" v-ripple class="tool-button" :class="buttonActiveClass('refresh')" @click="buttonClick('refresh')">
  70. <q-icon name="la la-sync" size="32px" :class="{clear: !showRefreshIcon}" />
  71. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  72. {{ rstore.readerActions['refresh'] }}
  73. </q-tooltip>
  74. </button>
  75. <div class="space"></div>
  76. <button v-show="showToolButton['contents']" ref="contents" v-ripple class="tool-button" :class="buttonActiveClass('contents')" @click="buttonClick('contents')">
  77. <q-icon name="la la-list" size="32px" />
  78. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  79. {{ rstore.readerActions['contents'] }}
  80. </q-tooltip>
  81. </button>
  82. <button v-show="mode == 'liberama.top' && showToolButton['libs']" ref="libs" v-ripple class="tool-button" :class="buttonActiveClass('libs')" @click="buttonClick('libs')">
  83. <q-icon name="la la-sitemap" size="32px" />
  84. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  85. {{ rstore.readerActions['libs'] }}
  86. </q-tooltip>
  87. </button>
  88. <button v-show="showToolButton['recentBooks']" ref="recentBooks" v-ripple class="tool-button" :class="buttonActiveClass('recentBooks')" @click="buttonClick('recentBooks')">
  89. <q-icon name="la la-book-open" size="32px" />
  90. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  91. {{ rstore.readerActions['recentBooks'] }}
  92. </q-tooltip>
  93. </button>
  94. </div>
  95. <div>
  96. <button v-show="showToolButton['offlineMode']" ref="offlineMode" v-ripple class="tool-button" :class="buttonActiveClass('offlineMode')" @click="buttonClick('offlineMode')">
  97. <q-icon name="la la-unlink" size="32px" />
  98. <q-tooltip :delay="1500" anchor="bottom middle" content-style="font-size: 80%">
  99. {{ rstore.readerActions['offlineMode'] }}
  100. </q-tooltip>
  101. </button>
  102. <button ref="settings" v-ripple class="tool-button" :class="buttonActiveClass('settings')" @click="buttonClick('settings')">
  103. <q-icon name="la la-cog" size="32px" />
  104. <q-tooltip :delay="1500" anchor="bottom left" content-style="font-size: 80%">
  105. {{ rstore.readerActions['settings'] }}
  106. </q-tooltip>
  107. </button>
  108. </div>
  109. </div>
  110. </div>
  111. <div class="main col row relative-position">
  112. <keep-alive>
  113. <component
  114. :is="activePage"
  115. ref="page"
  116. class="col"
  117. @load-book="loadBook"
  118. @load-file="loadFile"
  119. @book-pos-changed="bookPosChanged"
  120. @do-action="doAction"
  121. ></component>
  122. </keep-alive>
  123. <SetPositionPage v-if="setPositionActive" ref="setPositionPage" @set-position-toggle="setPositionToggle" @book-pos-changed="bookPosChanged"></SetPositionPage>
  124. <SearchPage
  125. v-show="searchActive"
  126. ref="searchPage"
  127. @do-action="doAction"
  128. @book-pos-changed="bookPosChanged"
  129. @start-text-search="startTextSearch"
  130. @stop-text-search="stopTextSearch"
  131. ></SearchPage>
  132. <CopyTextPage v-if="copyTextActive" ref="copyTextPage" @do-action="doAction"></CopyTextPage>
  133. <LibsPage v-show="hidden" ref="libsPage" @load-book="loadBook" @libs-close="libsClose" @do-action="doAction"></LibsPage>
  134. <RecentBooksPage v-show="recentBooksActive" ref="recentBooksPage" @load-book="loadBook" @recent-books-close="recentBooksClose"></RecentBooksPage>
  135. <SettingsPage v-show="settingsActive" ref="settingsPage" @do-action="doAction"></SettingsPage>
  136. <HelpPage v-if="helpActive" ref="helpPage" @do-action="doAction"></HelpPage>
  137. <ClickMapPage v-show="clickMapActive" ref="clickMapPage"></ClickMapPage>
  138. <ContentsPage v-show="contentsActive" ref="contentsPage" :book-pos="bookPos" :is-visible="contentsActive" @do-action="doAction" @book-pos-changed="bookPosChanged"></ContentsPage>
  139. <ServerStorage v-show="hidden" ref="serverStorage"></ServerStorage>
  140. <ReaderDialogs ref="dialogs" @donate-toggle="donateToggle" @version-history-toggle="versionHistoryToggle"></ReaderDialogs>
  141. </div>
  142. </div>
  143. </template>
  144. <script>
  145. //-----------------------------------------------------------------------------
  146. import vueComponent from '../vueComponent.js';
  147. import _ from 'lodash';
  148. import {Buffer} from 'safe-buffer';
  149. import LoaderPage from './LoaderPage/LoaderPage.vue';
  150. import TextPage from './TextPage/TextPage.vue';
  151. import ProgressPage from './ProgressPage/ProgressPage.vue';
  152. import SetPositionPage from './SetPositionPage/SetPositionPage.vue';
  153. import SearchPage from './SearchPage/SearchPage.vue';
  154. import CopyTextPage from './CopyTextPage/CopyTextPage.vue';
  155. import LibsPage from './LibsPage/LibsPage.vue';
  156. import RecentBooksPage from './RecentBooksPage/RecentBooksPage.vue';
  157. import SettingsPage from './SettingsPage/SettingsPage.vue';
  158. import HelpPage from './HelpPage/HelpPage.vue';
  159. import ClickMapPage from './ClickMapPage/ClickMapPage.vue';
  160. import ContentsPage from './ContentsPage/ContentsPage.vue';
  161. import ServerStorage from './ServerStorage/ServerStorage.vue';
  162. import ReaderDialogs from './ReaderDialogs/ReaderDialogs.vue';
  163. import bookManager from './share/bookManager';
  164. import wallpaperStorage from './share/wallpaperStorage';
  165. import dynamicCss from '../../share/dynamicCss';
  166. import rstore from '../../store/modules/reader';
  167. import readerApi from '../../api/reader';
  168. import miscApi from '../../api/misc';
  169. import {versionHistory} from './versionHistory';
  170. import * as utils from '../../share/utils';
  171. const componentOptions = {
  172. components: {
  173. LoaderPage,
  174. TextPage,
  175. ProgressPage,
  176. SetPositionPage,
  177. SearchPage,
  178. CopyTextPage,
  179. LibsPage,
  180. RecentBooksPage,
  181. SettingsPage,
  182. HelpPage,
  183. ClickMapPage,
  184. ContentsPage,
  185. ServerStorage,
  186. ReaderDialogs,
  187. },
  188. watch: {
  189. bookPos: function(newValue) {
  190. if (newValue !== undefined && this.activePage == 'TextPage') {
  191. const textPage = this.$refs.page;
  192. if (textPage.bookPos != newValue) {
  193. textPage.bookPos = newValue;
  194. }
  195. if (!this.scrollingActive)
  196. this.debouncedSetRecentBook(newValue);
  197. else
  198. this.scrollingSetRecentBook(newValue);
  199. }
  200. },
  201. routeParamPos: function(newValue) {
  202. if (!this.paramPosIgnore && newValue !== undefined && newValue != this.bookPos) {
  203. this.bookPos = newValue;
  204. }
  205. },
  206. routeParamUrl: function(newValue) {
  207. if (newValue !== '' && newValue !== this.mostRecentBook().url) {
  208. this.loadBook({url: newValue, bookPos: this.routeParamPos});
  209. }
  210. },
  211. settings: function() {
  212. this.loadSettings();
  213. this.updateRoute();
  214. },
  215. loaderActive: function(newValue) {
  216. (async() => {
  217. const recent = this.mostRecentBook();
  218. if (!newValue && !this.loading && recent && !await bookManager.hasBookParsed(recent)) {
  219. this.loadBook(recent);
  220. }
  221. })();
  222. },
  223. dualPageMode(newValue) {
  224. if (newValue)
  225. this.stopScrolling();
  226. },
  227. },
  228. };
  229. class Reader {
  230. _options = componentOptions;
  231. rstore = {};
  232. loaderActive = false;
  233. fullScreenActive = false;
  234. setPositionActive = false;
  235. searchActive = false;
  236. copyTextActive = false;
  237. convOptionsActive = false;
  238. refreshActive = false;
  239. contentsActive = false;
  240. libsActive = false;
  241. recentBooksActive = false;
  242. offlineModeActive = false;
  243. settingsActive = false;
  244. clickMapActive = false;
  245. helpActive = false;
  246. scrollingActive = false;
  247. progressActive = false;
  248. bookPos = null;
  249. allowUrlParamBookPos = false;
  250. showRefreshIcon = true;
  251. mostRecentBookReactive = null;
  252. showToolButton = {};
  253. actionList = [];
  254. actionCur = -1;
  255. hidden = false;
  256. whatsNewVisible = false;
  257. whatsNewContent = '';
  258. donationVisible = false;
  259. dualPageMode = false;
  260. created() {
  261. this.rstore = rstore;
  262. this.loading = true;
  263. this.commit = this.$store.commit;
  264. this.reader = this.$store.state.reader;
  265. this.config = this.$store.state.config;
  266. this.$root.addEventHook('key', this.keyHook);
  267. this.lastActivePage = false;
  268. this.$watch(
  269. () => this.$route.path,
  270. (newValue) => {
  271. if (newValue == '/reader') {
  272. this.updateRoute();
  273. }
  274. }
  275. );
  276. this.debouncedSetRecentBook = _.debounce(async(newValue) => {
  277. const recent = this.mostRecentBook();
  278. if (recent && (recent.bookPos != newValue || recent.bookPosSeen !== this.bookPosSeen)) {
  279. await bookManager.setRecentBook(Object.assign({}, recent, {bookPos: newValue, bookPosSeen: this.bookPosSeen}));
  280. if (this.actionCur < 0 || (this.actionCur >= 0 && this.actionList[this.actionCur] != newValue))
  281. this.addAction(newValue);
  282. this.paramPosIgnore = true;
  283. this.updateRoute();
  284. await this.$nextTick();
  285. this.paramPosIgnore = false;
  286. }
  287. }, 250, {maxWait: 5000});
  288. this.scrollingSetRecentBook = _.debounce((newValue) => {
  289. this.debouncedSetRecentBook(newValue);
  290. }, 15000, {maxWait: 20000});
  291. document.addEventListener('fullscreenchange', () => {
  292. this.fullScreenActive = (document.fullscreenElement !== null);
  293. });
  294. this.loadSettings();
  295. }
  296. mounted() {
  297. this.updateHeaderMinWidth();
  298. (async() => {
  299. await wallpaperStorage.init();
  300. await bookManager.init(this.settings);
  301. bookManager.addEventListener(this.bookManagerEvent);
  302. if (this.$root.getRootRoute() == '/reader') {
  303. if (this.routeParamUrl) {
  304. await this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos, force: this.routeParamRefresh});
  305. } else {
  306. this.loaderActive = true;
  307. }
  308. }
  309. await this.$refs.serverStorage.init();
  310. this.checkSetStorageAccessKey();
  311. this.checkActivateDonateHelpPage();
  312. this.loading = false;
  313. //проверим состояние Settings, и обновим, если надо
  314. const newSettings = rstore.addDefaultsToSettings(this.settings);
  315. if (newSettings) {
  316. this.commit('reader/setSettings', newSettings);
  317. }
  318. this.updateRoute();
  319. await this.$refs.dialogs.init();
  320. })();
  321. (async() => {
  322. this.isFirstNeedUpdateNotify = true;
  323. //вечный цикл, запрашиваем периодически конфиг для проверки выхода новой версии читалки
  324. while (true) {// eslint-disable-line no-constant-condition
  325. await this.checkNewVersionAvailable();
  326. await utils.sleep(3600*1000); //каждый час
  327. }
  328. //дальше кода нет
  329. })();
  330. }
  331. loadSettings() {
  332. const settings = this.settings;
  333. this.allowUrlParamBookPos = settings.allowUrlParamBookPos;
  334. this.copyFullText = settings.copyFullText;
  335. this.showClickMapPage = settings.showClickMapPage;
  336. this.clickControl = settings.clickControl;
  337. this.blinkCachedLoad = settings.blinkCachedLoad;
  338. this.showToolButton = settings.showToolButton;
  339. this.enableSitesFilter = settings.enableSitesFilter;
  340. this.showNeedUpdateNotify = settings.showNeedUpdateNotify;
  341. this.splitToPara = settings.splitToPara;
  342. this.djvuQuality = settings.djvuQuality;
  343. this.pdfAsText = settings.pdfAsText;
  344. this.pdfQuality = settings.pdfQuality;
  345. this.dualPageMode = settings.dualPageMode;
  346. this.userWallpapers = settings.userWallpapers;
  347. this.readerActionByKeyCode = utils.userHotKeysObjectSwap(settings.userHotKeys);
  348. this.$root.readerActionByKeyEvent = (event) => {
  349. return this.readerActionByKeyCode[utils.keyEventToCode(event)];
  350. }
  351. this.updateHeaderMinWidth();
  352. this.loadWallpapers();//no await
  353. }
  354. showHelpOnErrorIfNeeded(errorMessage) {
  355. //небольшая эвристика
  356. let i = errorMessage.indexOf('http://');
  357. if (i < 0)
  358. i = errorMessage.indexOf('https://');
  359. errorMessage = errorMessage.substring(i + 7);
  360. const perCount = errorMessage.split('%').length - 1;
  361. if (perCount > errorMessage.length/3.2) {
  362. this.$refs.dialogs.showUrlHelp();
  363. return true;
  364. }
  365. return false;
  366. }
  367. //wallpaper css
  368. async loadWallpapers() {
  369. const wallpaperDataLength = await wallpaperStorage.getLength();
  370. if (wallpaperDataLength !== this.wallpaperDataLength) {//оптимизация
  371. this.wallpaperDataLength = wallpaperDataLength;
  372. let newCss = '';
  373. for (const wp of this.userWallpapers) {
  374. const data = await wallpaperStorage.getData(wp.cssClass);
  375. if (!data) {
  376. //здесь будем восстанавливать данные с сервера
  377. }
  378. if (data) {
  379. newCss += `.${wp.cssClass} {background: url(${data}) center; background-size: 100% 100%;}`;
  380. }
  381. }
  382. dynamicCss.replace('wallpapers', newCss);
  383. }
  384. }
  385. async checkNewVersionAvailable() {
  386. if (!this.checkingNewVersion && this.showNeedUpdateNotify) {
  387. this.checkingNewVersion = true;
  388. try {
  389. await utils.sleep(15*1000); //подождем 15 секунд, чтобы прогрузился ServiceWorker при выходе новой версии
  390. const config = await miscApi.loadConfig();
  391. this.commit('config/setConfig', config);
  392. let againMes = '';
  393. if (this.isFirstNeedUpdateNotify) {
  394. againMes = ' еще один раз';
  395. }
  396. if (this.version != this.clientVersion)
  397. this.$root.notify.info(`Вышла новая версия (v${this.version}) читалки.<br>Пожалуйста, обновите страницу${againMes}.`, 'Обновление');
  398. } catch(e) {
  399. console.error(e);
  400. } finally {
  401. this.checkingNewVersion = false;
  402. }
  403. this.isFirstNeedUpdateNotify = false;
  404. }
  405. }
  406. updateHeaderMinWidth() {
  407. const showButtonCount = Object.values(this.showToolButton).reduce((a, b) => a + (b ? 1 : 0), 0);
  408. if (this.$refs.buttons)
  409. this.$refs.buttons.style.minWidth = 65*showButtonCount + 'px';
  410. (async() => {
  411. await utils.sleep(1000);
  412. if (this.$refs.header)
  413. this.$refs.header.style.overflowX = 'auto';
  414. })();
  415. }
  416. checkSetStorageAccessKey() {
  417. const q = this.$route.query;
  418. if (q['setStorageAccessKey']) {
  419. this.$router.replace(`/reader`);
  420. this.settingsToggle();
  421. this.$nextTick(() => {
  422. this.$refs.settingsPage.enterServerStorageKey(
  423. Buffer.from(utils.fromBase58(q['setStorageAccessKey'])).toString()
  424. );
  425. });
  426. }
  427. }
  428. checkActivateDonateHelpPage() {
  429. const q = this.$route.query;
  430. if (q['donate']) {
  431. this.$router.replace(`/reader`);
  432. this.helpToggle();
  433. this.$nextTick(() => {
  434. this.$refs.helpPage.activateDonateHelpPage();
  435. });
  436. }
  437. }
  438. checkBookPosPercent() {
  439. const q = this.$route.query;
  440. if (q['__pp']) {
  441. let pp = q['__pp'];
  442. if (pp) {
  443. pp = parseFloat(pp) || 0;
  444. const recent = this.mostRecentBook();
  445. (async() => {
  446. await utils.sleep(100);
  447. this.bookPos = Math.floor(recent.textLength*pp/100);
  448. })();
  449. }
  450. }
  451. }
  452. get routeParamPos() {
  453. let result = undefined;
  454. const q = this.$route.query;
  455. if (q['__p']) {
  456. result = q['__p'];
  457. if (Array.isArray(result))
  458. result = result[0];
  459. }
  460. return (result ? parseInt(result, 10) || 0 : result);
  461. }
  462. updateRoute(isNewRoute) {
  463. if (this.loading)
  464. return;
  465. const recent = this.mostRecentBook();
  466. const pos = (recent && recent.bookPos && this.allowUrlParamBookPos ? `__p=${recent.bookPos}&` : '');
  467. const url = (recent ? `url=${recent.url}` : '');
  468. if (isNewRoute)
  469. this.$router.push(`/reader?${pos}${url}`).catch(() => {});
  470. else
  471. this.$router.replace(`/reader?${pos}${url}`).catch(() => {});
  472. }
  473. get mode() {
  474. return this.$store.state.config.mode;
  475. }
  476. get version() {
  477. return this.$store.state.config.version;
  478. }
  479. get clientVersion() {
  480. return versionHistory[0].version;
  481. }
  482. get routeParamUrl() {
  483. let result = '';
  484. const path = this.$route.fullPath;
  485. const i = path.indexOf('url=');
  486. if (i >= 0) {
  487. result = path.substr(i + 4);
  488. }
  489. return decodeURIComponent(result);
  490. }
  491. get routeParamRefresh() {
  492. const q = this.$route.query;
  493. return !!q['__refresh'];
  494. }
  495. bookPosChanged(event) {
  496. if (event.bookPosSeen !== undefined)
  497. this.bookPosSeen = event.bookPosSeen;
  498. this.bookPos = event.bookPos;
  499. }
  500. async bookManagerEvent(eventName, value) {
  501. if (eventName == 'set-recent' || eventName == 'recent-deleted') {
  502. const oldBook = (this.textPage ? this.textPage.lastBook : null);
  503. const oldPos = (this.textPage ? this.textPage.bookPos : null);
  504. const newBook = bookManager.mostRecentBook();
  505. if (!(oldBook && newBook && oldBook.key == newBook.key)) {
  506. this.mostRecentBook();
  507. }
  508. if (oldBook && newBook) {
  509. if (oldBook.key != newBook.key || oldBook.path != newBook.path) {
  510. this.loadingBook = true;
  511. try {
  512. await this.loadBook(newBook);
  513. } finally {
  514. this.loadingBook = false;
  515. }
  516. } else if (oldPos != newBook.bookPos) {
  517. while (this.loadingBook) await utils.sleep(100);
  518. this.bookPosChanged({bookPos: newBook.bookPos});
  519. }
  520. }
  521. }
  522. if (eventName == 'recent-changed') {
  523. if (this.recentBooksActive) {
  524. await this.$refs.recentBooksPage.updateTableData();
  525. }
  526. //сохранение в serverStorage
  527. if (value) {
  528. await utils.sleep(500);
  529. let timer = setTimeout(() => {
  530. if (!this.offlineModeActive)
  531. this.$root.notify.error('Таймаут соединения');
  532. }, 10000);
  533. try {
  534. await this.$refs.serverStorage.saveRecent(value);
  535. } catch (e) {
  536. if (!this.offlineModeActive)
  537. this.$root.notify.error(e.message);
  538. } finally {
  539. clearTimeout(timer);
  540. }
  541. }
  542. }
  543. }
  544. get toolBarActive() {
  545. return this.reader.toolBarActive;
  546. }
  547. mostRecentBook() {
  548. const result = bookManager.mostRecentBook();
  549. this.mostRecentBookReactive = result;
  550. return result;
  551. }
  552. get settings() {
  553. return this.$store.state.reader.settings;
  554. }
  555. addAction(pos) {
  556. let a = this.actionList;
  557. if (!a.length || a[a.length - 1] != pos) {
  558. a.push(pos);
  559. if (a.length > 20)
  560. a.shift();
  561. this.actionCur = a.length - 1;
  562. }
  563. }
  564. toolBarToggle() {
  565. this.commit('reader/setToolBarActive', !this.toolBarActive);
  566. this.$root.eventHook('resize');
  567. }
  568. fullScreenToggle() {
  569. this.fullScreenActive = !this.fullScreenActive;
  570. if (this.fullScreenActive) {
  571. this.$q.fullscreen.request();
  572. } else {
  573. this.$q.fullscreen.exit();
  574. }
  575. }
  576. closeAllWindows() {
  577. this.setPositionActive = false;
  578. this.copyTextActive = false;
  579. this.recentBooksActive = false;
  580. this.settingsActive = false;
  581. this.stopScrolling();
  582. this.stopSearch();
  583. this.helpActive = false;
  584. this.contentsActive = false;
  585. }
  586. loaderToggle() {
  587. this.loaderActive = !this.loaderActive;
  588. if (this.loaderActive) {
  589. this.closeAllWindows();
  590. }
  591. }
  592. setPositionToggle() {
  593. this.setPositionActive = !this.setPositionActive;
  594. const page = this.$refs.page;
  595. if (this.setPositionActive && this.activePage == 'TextPage' && page.parsed) {
  596. this.closeAllWindows();
  597. this.setPositionActive = true;
  598. this.$nextTick(() => {
  599. const recent = this.mostRecentBook();
  600. this.$refs.setPositionPage.init(recent.bookPos, recent.textLength - 1);
  601. });
  602. } else {
  603. this.setPositionActive = false;
  604. }
  605. }
  606. stopScrolling() {
  607. if (this.scrollingActive)
  608. this.scrollingToggle();
  609. }
  610. scrollingToggle() {
  611. this.scrollingActive = !this.scrollingActive;
  612. if (this.activePage == 'TextPage') {
  613. const page = this.$refs.page;
  614. if (this.scrollingActive) {
  615. page.startTextScrolling();
  616. } else {
  617. page.stopTextScrolling();
  618. }
  619. }
  620. if (!this.scrollingActive) {
  621. this.scrollingSetRecentBook.flush();
  622. }
  623. }
  624. stopSearch() {
  625. if (this.searchActive)
  626. this.searchToggle();
  627. }
  628. startTextSearch(opts) {
  629. if (this.activePage == 'TextPage')
  630. this.$refs.page.startSearch(opts.needle);
  631. }
  632. stopTextSearch() {
  633. if (this.activePage == 'TextPage')
  634. this.$refs.page.stopSearch();
  635. }
  636. searchToggle() {
  637. this.searchActive = !this.searchActive;
  638. const page = this.$refs.page;
  639. if (this.searchActive && this.activePage == 'TextPage' && page.parsed) {
  640. this.closeAllWindows();
  641. this.searchActive = true;
  642. this.$nextTick(() => {
  643. this.$refs.searchPage.init(page.parsed);
  644. });
  645. } else {
  646. this.stopTextSearch();
  647. this.searchActive = false;
  648. }
  649. }
  650. copyTextToggle() {
  651. this.copyTextActive = !this.copyTextActive;
  652. const page = this.$refs.page;
  653. if (this.copyTextActive && this.activePage == 'TextPage' && page.parsed) {
  654. this.closeAllWindows();
  655. this.copyTextActive = true;
  656. this.$nextTick(() => {
  657. this.$refs.copyTextPage.init(this.mostRecentBook().bookPos, page.parsed, this.copyFullText);
  658. });
  659. } else {
  660. this.copyTextActive = false;
  661. }
  662. }
  663. recentBooksClose() {
  664. this.recentBooksActive = false;
  665. }
  666. recentBooksToggle() {
  667. this.recentBooksActive = !this.recentBooksActive;
  668. if (this.recentBooksActive) {
  669. this.closeAllWindows();
  670. this.$refs.recentBooksPage.init();
  671. this.recentBooksActive = true;
  672. } else {
  673. this.recentBooksActive = false;
  674. }
  675. }
  676. contentsPageToggle() {
  677. this.contentsActive = !this.contentsActive;
  678. const page = this.$refs.page;
  679. if (this.contentsActive && this.activePage == 'TextPage' && page.parsed) {
  680. this.closeAllWindows();
  681. this.contentsActive = true;
  682. this.$nextTick(() => {
  683. this.$refs.contentsPage.init(this.mostRecentBook(), page.parsed);
  684. });
  685. } else {
  686. this.contentsActive = false;
  687. }
  688. }
  689. libsClose() {
  690. if (this.libsActive)
  691. this.libsToogle();
  692. }
  693. libsToogle() {
  694. this.libsActive = !this.libsActive;
  695. if (this.libsActive) {
  696. this.$refs.libsPage.init();
  697. } else {
  698. this.$refs.libsPage.done();
  699. }
  700. }
  701. offlineModeToggle() {
  702. this.offlineModeActive = !this.offlineModeActive;
  703. this.$refs.serverStorage.offlineModeActive = this.offlineModeActive;
  704. }
  705. settingsToggle() {
  706. this.settingsActive = !this.settingsActive;
  707. if (this.settingsActive) {
  708. this.closeAllWindows();
  709. this.settingsActive = true;
  710. this.$nextTick(() => {
  711. this.$refs.settingsPage.init();
  712. });
  713. } else {
  714. this.settingsActive = false;
  715. }
  716. }
  717. convOptionsToggle() {
  718. this.settingsToggle();
  719. if (this.settingsActive)
  720. this.$refs.settingsPage.selectedTab = 'convert';
  721. }
  722. helpToggle() {
  723. this.helpActive = !this.helpActive;
  724. if (this.helpActive) {
  725. this.closeAllWindows();
  726. this.helpActive = true;
  727. }
  728. }
  729. donateToggle() {
  730. this.helpToggle();
  731. if (this.helpActive) {
  732. this.$nextTick(() => {
  733. this.$refs.helpPage.activateDonateHelpPage();
  734. });
  735. }
  736. }
  737. versionHistoryToggle() {
  738. this.helpToggle();
  739. if (this.helpActive) {
  740. this.$nextTick(() => {
  741. this.$refs.helpPage.activateVersionHistoryHelpPage();
  742. });
  743. }
  744. }
  745. refreshBook() {
  746. const mrb = this.mostRecentBook();
  747. this.loadBook({url: mrb.url, uploadFileName: mrb.uploadFileName, force: true});
  748. }
  749. undoAction() {
  750. if (this.actionCur > 0) {
  751. this.actionCur--;
  752. this.bookPosChanged({bookPos: this.actionList[this.actionCur]});
  753. }
  754. }
  755. redoAction() {
  756. if (this.actionCur < this.actionList.length - 1) {
  757. this.actionCur++;
  758. this.bookPosChanged({bookPos: this.actionList[this.actionCur]});
  759. }
  760. }
  761. buttonClick(action) {
  762. const activeClass = this.buttonActiveClass(action);
  763. this.$refs[action].blur();
  764. if (activeClass['tool-button-disabled'])
  765. return;
  766. this.doAction({action});
  767. }
  768. buttonActiveClass(action) {
  769. const classActive = { 'tool-button-active': true, 'tool-button-active:hover': true };
  770. const classDisabled = { 'tool-button-disabled': true, 'tool-button-disabled:hover': true };
  771. let classResult = {};
  772. switch (action) {
  773. case 'loader':
  774. case 'help':
  775. case 'fullScreen':
  776. case 'setPosition':
  777. case 'search':
  778. case 'copyText':
  779. case 'convOptions':
  780. case 'refresh':
  781. case 'contents':
  782. case 'libs':
  783. case 'recentBooks':
  784. case 'offlineMode':
  785. case 'settings':
  786. if (this.progressActive) {
  787. classResult = classDisabled;
  788. } else if (this[`${action}Active`]) {
  789. classResult = classActive;
  790. }
  791. break;
  792. case 'scrolling':
  793. if (this.progressActive || this.dualPageMode) {
  794. classResult = classDisabled;
  795. } else if (this[`${action}Active`]) {
  796. classResult = classActive;
  797. }
  798. break;
  799. case 'undoAction':
  800. if (this.actionCur <= 0)
  801. classResult = classDisabled;
  802. break;
  803. case 'redoAction':
  804. if (this.actionCur == this.actionList.length - 1)
  805. classResult = classDisabled;
  806. break;
  807. }
  808. if (this.activePage == 'LoaderPage' || !this.mostRecentBookReactive) {
  809. switch (action) {
  810. case 'undoAction':
  811. case 'redoAction':
  812. case 'setPosition':
  813. case 'scrolling':
  814. case 'search':
  815. case 'copyText':
  816. case 'contents':
  817. classResult = classDisabled;
  818. break;
  819. case 'refresh':
  820. case 'recentBooks':
  821. if (!this.mostRecentBookReactive)
  822. classResult = classDisabled;
  823. break;
  824. }
  825. }
  826. return classResult;
  827. }
  828. async activateClickMapPage() {
  829. if (this.clickControl && this.showClickMapPage && !this.clickMapActive) {
  830. this.clickMapActive = true;
  831. await this.$refs.clickMapPage.slowDisappear();
  832. this.clickMapActive = false;
  833. }
  834. }
  835. get activePage() {
  836. let result = undefined;
  837. if (this.progressActive)
  838. result = 'ProgressPage';
  839. else if (this.loaderActive)
  840. result = 'LoaderPage';
  841. else if (this.mostRecentBookReactive)
  842. result = 'TextPage';
  843. if (!result && !this.loading) {
  844. this.loaderActive = true;
  845. result = 'LoaderPage';
  846. }
  847. if (result != 'TextPage') {
  848. this.$root.setAppTitle();
  849. }
  850. // на LoaderPage всегда показываем toolBar
  851. if (result == 'LoaderPage' && !this.toolBarActive) {
  852. this.toolBarToggle();
  853. }
  854. if (this.lastActivePage != result && result == 'TextPage') {
  855. //акивируем страницу с текстом
  856. this.$nextTick(async() => {
  857. const last = this.mostRecentBookReactive;
  858. const isParsed = await bookManager.hasBookParsed(last);
  859. if (!isParsed) {
  860. this.$root.setAppTitle();
  861. return;
  862. }
  863. this.updateRoute();
  864. const textPage = this.$refs.page;
  865. if (textPage.showBook) {
  866. this.textPage = textPage;
  867. textPage.lastBook = last;
  868. textPage.bookPos = (last.bookPos !== undefined ? last.bookPos : 0);
  869. textPage.showBook();
  870. }
  871. });
  872. }
  873. this.lastActivePage = result;
  874. return result;
  875. }
  876. async loadBook(opts) {
  877. if (!opts || !opts.url) {
  878. this.mostRecentBook();
  879. return;
  880. }
  881. this.closeAllWindows();
  882. let url = encodeURI(decodeURI(opts.url));
  883. //TODO: убрать конвертирование 'file://' после 06.2021
  884. if (url.length == 71 && url.indexOf('file://') == 0)
  885. url = url.replace(/^file/, 'disk');
  886. if ((url.indexOf('http://') != 0) && (url.indexOf('https://') != 0) &&
  887. (url.indexOf('disk://') != 0))
  888. url = 'http://' + url;
  889. // уже просматривается сейчас
  890. const lastBook = (this.textPage ? this.textPage.lastBook : null);
  891. if (!opts.force && lastBook && lastBook.url == url &&
  892. (!opts.path || opts.path == lastBook.path) &&
  893. await bookManager.hasBookParsed(lastBook)) {
  894. this.loaderActive = false;
  895. return;
  896. }
  897. this.progressActive = true;
  898. await this.$nextTick();
  899. const progress = this.$refs.page;
  900. this.actionList = [];
  901. this.actionCur = -1;
  902. try {
  903. progress.show();
  904. progress.setState({state: 'parse'});
  905. // есть ли среди недавних
  906. const key = bookManager.keyFromUrl(url);
  907. let wasOpened = await bookManager.getRecentBook({key});
  908. wasOpened = (wasOpened ? wasOpened : {});
  909. const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
  910. const bookPosSeen = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPosSeen);
  911. const uploadFileName = (opts.uploadFileName ? opts.uploadFileName : '');
  912. let book = null;
  913. if (!opts.force) {
  914. // пытаемся загрузить и распарсить книгу в менеджере из локального кэша
  915. const bookParsed = await bookManager.getBook({url, path: opts.path}, (prog) => {
  916. progress.setState({progress: prog});
  917. });
  918. // если есть в локальном кэше
  919. if (bookParsed) {
  920. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen}, bookParsed));
  921. this.mostRecentBook();
  922. this.addAction(bookPos);
  923. this.loaderActive = false;
  924. progress.hide(); this.progressActive = false;
  925. this.blinkCachedLoadMessage();
  926. this.checkBookPosPercent();
  927. await this.activateClickMapPage();
  928. return;
  929. }
  930. // иначе идем на сервер
  931. // пытаемся загрузить готовый файл с сервера
  932. if (wasOpened.path) {
  933. progress.setState({totalSteps: 5});
  934. try {
  935. const resp = await readerApi.loadCachedBook(wasOpened.path, (state) => {
  936. progress.setState(state);
  937. });
  938. book = Object.assign({}, wasOpened, {data: resp.data});
  939. } catch (e) {
  940. //молчим
  941. }
  942. }
  943. }
  944. progress.setState({totalSteps: 5});
  945. // не удалось, скачиваем книгу полностью с конвертацией
  946. let loadCached = true;
  947. if (!book) {
  948. book = await readerApi.loadBook({
  949. url,
  950. uploadFileName,
  951. enableSitesFilter: this.enableSitesFilter,
  952. skipHtmlCheck: (this.splitToPara ? true : false),
  953. isText: (this.splitToPara ? true : false),
  954. djvuQuality: this.djvuQuality,
  955. pdfAsText: this.pdfAsText,
  956. pdfQuality: this.pdfQuality,
  957. },
  958. (state) => {
  959. progress.setState(state);
  960. }
  961. );
  962. loadCached = false;
  963. }
  964. // добавляем в bookManager
  965. progress.setState({state: 'parse', step: 5});
  966. const addedBook = await bookManager.addBook(book, (prog) => {
  967. progress.setState({progress: prog});
  968. });
  969. // добавляем в историю
  970. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen, uploadFileName}, addedBook));
  971. this.mostRecentBook();
  972. this.addAction(bookPos);
  973. this.updateRoute(true);
  974. this.loaderActive = false;
  975. progress.hide(); this.progressActive = false;
  976. if (loadCached) {
  977. this.blinkCachedLoadMessage();
  978. } else
  979. this.stopBlink = true;
  980. this.checkBookPosPercent();
  981. await this.activateClickMapPage();
  982. } catch (e) {
  983. progress.hide(); this.progressActive = false;
  984. this.loaderActive = true;
  985. if (!this.showHelpOnErrorIfNeeded(e.message)) {
  986. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  987. }
  988. } finally {
  989. this.checkNewVersionAvailable();
  990. }
  991. }
  992. async loadFile(opts) {
  993. this.progressActive = true;
  994. await this.$nextTick();
  995. const progress = this.$refs.page;
  996. try {
  997. progress.show();
  998. progress.setState({state: 'upload'});
  999. const url = await readerApi.uploadFile(opts.file, this.config.maxUploadFileSize, (state) => {
  1000. progress.setState(state);
  1001. });
  1002. progress.hide(); this.progressActive = false;
  1003. await this.loadBook({url, uploadFileName: opts.file.name, force: true});
  1004. } catch (e) {
  1005. progress.hide(); this.progressActive = false;
  1006. this.loaderActive = true;
  1007. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  1008. }
  1009. }
  1010. blinkCachedLoadMessage() {
  1011. if (!this.blinkCachedLoad)
  1012. return;
  1013. this.blinkCount = 30;
  1014. if (!this.inBlink) {
  1015. this.inBlink = true;
  1016. this.stopBlink = false;
  1017. this.$nextTick(async() => {
  1018. let page = this.$refs.page;
  1019. while (this.blinkCount) {
  1020. this.showRefreshIcon = !this.showRefreshIcon;
  1021. if (page && page.blinkCachedLoadMessage)
  1022. page.blinkCachedLoadMessage(this.showRefreshIcon);
  1023. await utils.sleep(500);
  1024. if (this.stopBlink)
  1025. break;
  1026. this.blinkCount--;
  1027. page = this.$refs.page;
  1028. }
  1029. this.showRefreshIcon = true;
  1030. this.inBlink = false;
  1031. if (page && page.blinkCachedLoadMessage)
  1032. page.blinkCachedLoadMessage('finish');
  1033. });
  1034. }
  1035. }
  1036. doAction(opts) {
  1037. let result = true;
  1038. let {action = '', event = false} = opts;
  1039. switch (action) {
  1040. case 'loader':
  1041. this.loaderToggle();
  1042. break;
  1043. case 'help':
  1044. this.helpToggle();
  1045. break;
  1046. case 'undoAction':
  1047. this.undoAction();
  1048. break;
  1049. case 'redoAction':
  1050. this.redoAction();
  1051. break;
  1052. case 'fullScreen':
  1053. this.fullScreenToggle();
  1054. break;
  1055. case 'scrolling':
  1056. this.scrollingToggle();
  1057. break;
  1058. case 'stopScrolling':
  1059. this.stopScrolling();
  1060. break;
  1061. case 'setPosition':
  1062. this.setPositionToggle();
  1063. break;
  1064. case 'search':
  1065. this.searchToggle();
  1066. break;
  1067. case 'copyText':
  1068. this.copyTextToggle();
  1069. break;
  1070. case 'convOptions':
  1071. this.convOptionsToggle();
  1072. break;
  1073. case 'refresh':
  1074. this.refreshBook();
  1075. break;
  1076. case 'contents':
  1077. this.contentsPageToggle();
  1078. break;
  1079. case 'libs':
  1080. this.libsToogle();
  1081. break;
  1082. case 'recentBooks':
  1083. this.recentBooksToggle();
  1084. break;
  1085. case 'offlineMode':
  1086. this.offlineModeToggle();
  1087. break;
  1088. case 'settings':
  1089. this.settingsToggle();
  1090. break;
  1091. case 'switchToolbar':
  1092. this.toolBarToggle();
  1093. break;
  1094. case 'donate':
  1095. this.donateToggle();
  1096. break;
  1097. default:
  1098. result = false;
  1099. break;
  1100. }
  1101. if (!result && this.activePage == 'TextPage' && this.$refs.page) {
  1102. result = true;
  1103. const textPage = this.$refs.page;
  1104. switch (action) {
  1105. case 'bookBegin':
  1106. textPage.doHome();
  1107. break;
  1108. case 'bookEnd':
  1109. textPage.doEnd();
  1110. break;
  1111. case 'pageBack':
  1112. textPage.doPageUp();
  1113. break;
  1114. case 'pageForward':
  1115. textPage.doPageDown();
  1116. break;
  1117. case 'lineBack':
  1118. textPage.doUp();
  1119. break;
  1120. case 'lineForward':
  1121. textPage.doDown();
  1122. break;
  1123. case 'incFontSize':
  1124. textPage.doFontSizeInc();
  1125. break;
  1126. case 'decFontSize':
  1127. textPage.doFontSizeDec();
  1128. break;
  1129. case 'scrollingSpeedUp':
  1130. textPage.doScrollingSpeedUp();
  1131. break;
  1132. case 'scrollingSpeedDown':
  1133. textPage.doScrollingSpeedDown();
  1134. break;
  1135. default:
  1136. result = false;
  1137. break;
  1138. }
  1139. }
  1140. if (result && event) {
  1141. event.preventDefault();
  1142. event.stopPropagation();
  1143. }
  1144. return result;
  1145. }
  1146. keyHook(event) {
  1147. let result = false;
  1148. if (this.$root.getRootRoute() == '/reader') {
  1149. if (this.$root.stdDialog.active)
  1150. return result;
  1151. if (!result)
  1152. result = this.$refs.dialogs.keyHook(event);
  1153. if (!result && this.helpActive)
  1154. result = this.$refs.helpPage.keyHook(event);
  1155. if (!result && this.settingsActive)
  1156. result = this.$refs.settingsPage.keyHook(event);
  1157. if (!result && this.recentBooksActive)
  1158. result = this.$refs.recentBooksPage.keyHook(event);
  1159. if (!result && this.setPositionActive)
  1160. result = this.$refs.setPositionPage.keyHook(event);
  1161. if (!result && this.searchActive)
  1162. result = this.$refs.searchPage.keyHook(event);
  1163. if (!result && this.copyTextActive)
  1164. result = this.$refs.copyTextPage.keyHook(event);
  1165. if (!result && this.contentsActive)
  1166. result = this.$refs.contentsPage.keyHook(event);
  1167. if (!result && this.$refs.page && this.$refs.page.keyHook)
  1168. result = this.$refs.page.keyHook(event);
  1169. if (!result && event.type == 'keydown') {
  1170. const action = this.$root.readerActionByKeyEvent(event);
  1171. if (action == 'loader') {
  1172. result = this.doAction({action, event});
  1173. }
  1174. if (!result && this.activePage == 'TextPage') {
  1175. result = this.doAction({action, event});
  1176. }
  1177. }
  1178. }
  1179. return result;
  1180. }
  1181. }
  1182. export default vueComponent(Reader);
  1183. //-----------------------------------------------------------------------------
  1184. </script>
  1185. <style scoped>
  1186. .header {
  1187. padding-left: 5px;
  1188. padding-right: 5px;
  1189. background-color: #1B695F;
  1190. color: #000;
  1191. overflow: hidden;
  1192. height: 50px;
  1193. }
  1194. .main {
  1195. background-color: #EBE2C9;
  1196. color: #000;
  1197. }
  1198. .tool-button {
  1199. margin: 0px 2px 0 2px;
  1200. padding: 0;
  1201. color: #3E843E;
  1202. background-color: #E6EDF4;
  1203. margin-top: 5px;
  1204. height: 38px;
  1205. width: 38px;
  1206. border: 0;
  1207. border-radius: 6px;
  1208. box-shadow: 3px 3px 5px black;
  1209. outline: 0;
  1210. }
  1211. .tool-button:hover {
  1212. background-color: white;
  1213. cursor: pointer;
  1214. }
  1215. .tool-button-active {
  1216. box-shadow: 0 0 0;
  1217. color: white;
  1218. background-color: #8AB45F;
  1219. position: relative;
  1220. top: 1px;
  1221. left: 1px;
  1222. }
  1223. .tool-button-active:hover {
  1224. color: white;
  1225. background-color: #81C581;
  1226. cursor: pointer;
  1227. }
  1228. .tool-button-disabled {
  1229. color: lightgray;
  1230. background-color: gray;
  1231. cursor: default;
  1232. }
  1233. .tool-button-disabled:hover {
  1234. color: lightgray;
  1235. background-color: gray;
  1236. cursor: default;
  1237. }
  1238. .space {
  1239. width: 10px;
  1240. display: inline-block;
  1241. }
  1242. .clear {
  1243. color: rgba(0,0,0,0);
  1244. }
  1245. </style>