Reader.vue 49 KB

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