Reader.vue 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405
  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. let v = versionHistory[0].header;
  462. v = v.split(' ')[0];
  463. return v;
  464. }
  465. get routeParamUrl() {
  466. let result = '';
  467. const path = this.$route.fullPath;
  468. const i = path.indexOf('url=');
  469. if (i >= 0) {
  470. result = path.substr(i + 4);
  471. }
  472. return decodeURIComponent(result);
  473. }
  474. get routeParamRefresh() {
  475. const q = this.$route.query;
  476. return !!q['__refresh'];
  477. }
  478. bookPosChanged(event) {
  479. if (event.bookPosSeen !== undefined)
  480. this.bookPosSeen = event.bookPosSeen;
  481. this.bookPos = event.bookPos;
  482. }
  483. async bookManagerEvent(eventName, value) {
  484. if (eventName == 'set-recent' || eventName == 'recent-deleted') {
  485. const oldBook = (this.textPage ? this.textPage.lastBook : null);
  486. const oldPos = (this.textPage ? this.textPage.bookPos : null);
  487. const newBook = bookManager.mostRecentBook();
  488. if (!(oldBook && newBook && oldBook.key == newBook.key)) {
  489. this.mostRecentBook();
  490. }
  491. if (oldBook && newBook) {
  492. if (oldBook.key != newBook.key || oldBook.path != newBook.path) {
  493. this.loadingBook = true;
  494. try {
  495. await this.loadBook(newBook);
  496. } finally {
  497. this.loadingBook = false;
  498. }
  499. } else if (oldPos != newBook.bookPos) {
  500. while (this.loadingBook) await utils.sleep(100);
  501. this.bookPosChanged({bookPos: newBook.bookPos});
  502. }
  503. }
  504. }
  505. if (eventName == 'recent-changed') {
  506. if (this.recentBooksActive) {
  507. await this.$refs.recentBooksPage.updateTableData();
  508. }
  509. //сохранение в serverStorage
  510. if (value) {
  511. await utils.sleep(500);
  512. await this.$refs.serverStorage.saveRecent(value);
  513. }
  514. }
  515. }
  516. get toolBarActive() {
  517. return this.reader.toolBarActive;
  518. }
  519. mostRecentBook() {
  520. const result = bookManager.mostRecentBook();
  521. this.mostRecentBookReactive = result;
  522. return result;
  523. }
  524. get settings() {
  525. return this.$store.state.reader.settings;
  526. }
  527. addAction(pos) {
  528. let a = this.actionList;
  529. if (!a.length || a[a.length - 1] != pos) {
  530. a.push(pos);
  531. if (a.length > 20)
  532. a.shift();
  533. this.actionCur = a.length - 1;
  534. }
  535. }
  536. toolBarToggle() {
  537. this.commit('reader/setToolBarActive', !this.toolBarActive);
  538. this.$root.eventHook('resize');
  539. }
  540. fullScreenToggle() {
  541. this.fullScreenActive = !this.fullScreenActive;
  542. if (this.fullScreenActive) {
  543. this.$q.fullscreen.request();
  544. } else {
  545. this.$q.fullscreen.exit();
  546. }
  547. }
  548. closeAllWindows() {
  549. this.setPositionActive = false;
  550. this.copyTextActive = false;
  551. this.recentBooksActive = false;
  552. this.settingsActive = false;
  553. this.stopScrolling();
  554. this.stopSearch();
  555. this.helpActive = false;
  556. this.contentsActive = false;
  557. }
  558. loaderToggle() {
  559. this.loaderActive = !this.loaderActive;
  560. if (this.loaderActive) {
  561. this.closeAllWindows();
  562. }
  563. }
  564. setPositionToggle() {
  565. this.setPositionActive = !this.setPositionActive;
  566. const page = this.$refs.page;
  567. if (this.setPositionActive && this.activePage == 'TextPage' && page.parsed) {
  568. this.closeAllWindows();
  569. this.setPositionActive = true;
  570. this.$nextTick(() => {
  571. const recent = this.mostRecentBook();
  572. this.$refs.setPositionPage.init(recent.bookPos, recent.textLength - 1);
  573. });
  574. } else {
  575. this.setPositionActive = false;
  576. }
  577. }
  578. stopScrolling() {
  579. if (this.scrollingActive)
  580. this.scrollingToggle();
  581. }
  582. scrollingToggle() {
  583. this.scrollingActive = !this.scrollingActive;
  584. if (this.activePage == 'TextPage') {
  585. const page = this.$refs.page;
  586. if (this.scrollingActive) {
  587. page.startTextScrolling();
  588. } else {
  589. page.stopTextScrolling();
  590. }
  591. }
  592. if (!this.scrollingActive) {
  593. this.scrollingSetRecentBook.flush();
  594. }
  595. }
  596. stopSearch() {
  597. if (this.searchActive)
  598. this.searchToggle();
  599. }
  600. startTextSearch(opts) {
  601. if (this.activePage == 'TextPage')
  602. this.$refs.page.startSearch(opts.needle);
  603. }
  604. stopTextSearch() {
  605. if (this.activePage == 'TextPage')
  606. this.$refs.page.stopSearch();
  607. }
  608. searchToggle() {
  609. this.searchActive = !this.searchActive;
  610. const page = this.$refs.page;
  611. if (this.searchActive && this.activePage == 'TextPage' && page.parsed) {
  612. this.closeAllWindows();
  613. this.searchActive = true;
  614. this.$nextTick(() => {
  615. this.$refs.searchPage.init(page.parsed);
  616. });
  617. } else {
  618. this.stopTextSearch();
  619. this.searchActive = false;
  620. }
  621. }
  622. copyTextToggle() {
  623. this.copyTextActive = !this.copyTextActive;
  624. const page = this.$refs.page;
  625. if (this.copyTextActive && this.activePage == 'TextPage' && page.parsed) {
  626. this.closeAllWindows();
  627. this.copyTextActive = true;
  628. this.$nextTick(() => {
  629. this.$refs.copyTextPage.init(this.mostRecentBook().bookPos, page.parsed, this.copyFullText);
  630. });
  631. } else {
  632. this.copyTextActive = false;
  633. }
  634. }
  635. recentBooksClose() {
  636. this.recentBooksActive = false;
  637. }
  638. recentBooksToggle() {
  639. this.recentBooksActive = !this.recentBooksActive;
  640. if (this.recentBooksActive) {
  641. this.closeAllWindows();
  642. this.$refs.recentBooksPage.init();
  643. this.recentBooksActive = true;
  644. } else {
  645. this.recentBooksActive = false;
  646. }
  647. }
  648. contentsPageToggle() {
  649. this.contentsActive = !this.contentsActive;
  650. const page = this.$refs.page;
  651. if (this.contentsActive && this.activePage == 'TextPage' && page.parsed) {
  652. this.closeAllWindows();
  653. this.contentsActive = true;
  654. this.$nextTick(() => {
  655. this.$refs.contentsPage.init(this.mostRecentBook(), page.parsed);
  656. });
  657. } else {
  658. this.contentsActive = false;
  659. }
  660. }
  661. libsClose() {
  662. if (this.libsActive)
  663. this.libsToogle();
  664. }
  665. libsToogle() {
  666. this.libsActive = !this.libsActive;
  667. if (this.libsActive) {
  668. this.$refs.libsPage.init();
  669. } else {
  670. this.$refs.libsPage.done();
  671. }
  672. }
  673. offlineModeToggle() {
  674. this.offlineModeActive = !this.offlineModeActive;
  675. this.$refs.serverStorage.offlineModeActive = this.offlineModeActive;
  676. }
  677. settingsToggle() {
  678. this.settingsActive = !this.settingsActive;
  679. if (this.settingsActive) {
  680. this.closeAllWindows();
  681. this.settingsActive = true;
  682. this.$nextTick(() => {
  683. this.$refs.settingsPage.init();
  684. });
  685. } else {
  686. this.settingsActive = false;
  687. }
  688. }
  689. convOptionsToggle() {
  690. this.settingsToggle();
  691. if (this.settingsActive)
  692. this.$refs.settingsPage.selectedTab = 'convert';
  693. }
  694. helpToggle() {
  695. this.helpActive = !this.helpActive;
  696. if (this.helpActive) {
  697. this.closeAllWindows();
  698. this.helpActive = true;
  699. }
  700. }
  701. donateToggle() {
  702. this.helpToggle();
  703. if (this.helpActive) {
  704. this.$nextTick(() => {
  705. this.$refs.helpPage.activateDonateHelpPage();
  706. });
  707. }
  708. }
  709. versionHistoryToggle() {
  710. this.helpToggle();
  711. if (this.helpActive) {
  712. this.$nextTick(() => {
  713. this.$refs.helpPage.activateVersionHistoryHelpPage();
  714. });
  715. }
  716. }
  717. refreshBook() {
  718. const mrb = this.mostRecentBook();
  719. this.loadBook({url: mrb.url, uploadFileName: mrb.uploadFileName, force: true});
  720. }
  721. undoAction() {
  722. if (this.actionCur > 0) {
  723. this.actionCur--;
  724. this.bookPosChanged({bookPos: this.actionList[this.actionCur]});
  725. }
  726. }
  727. redoAction() {
  728. if (this.actionCur < this.actionList.length - 1) {
  729. this.actionCur++;
  730. this.bookPosChanged({bookPos: this.actionList[this.actionCur]});
  731. }
  732. }
  733. buttonClick(action) {
  734. const activeClass = this.buttonActiveClass(action);
  735. this.$refs[action].blur();
  736. if (activeClass['tool-button-disabled'])
  737. return;
  738. this.doAction({action});
  739. }
  740. buttonActiveClass(action) {
  741. const classActive = { 'tool-button-active': true, 'tool-button-active:hover': true };
  742. const classDisabled = { 'tool-button-disabled': true, 'tool-button-disabled:hover': true };
  743. let classResult = {};
  744. switch (action) {
  745. case 'loader':
  746. case 'fullScreen':
  747. case 'setPosition':
  748. case 'search':
  749. case 'copyText':
  750. case 'convOptions':
  751. case 'refresh':
  752. case 'contents':
  753. case 'libs':
  754. case 'recentBooks':
  755. case 'offlineMode':
  756. case 'settings':
  757. if (this.progressActive) {
  758. classResult = classDisabled;
  759. } else if (this[`${action}Active`]) {
  760. classResult = classActive;
  761. }
  762. break;
  763. case 'scrolling':
  764. if (this.progressActive || this.dualPageMode) {
  765. classResult = classDisabled;
  766. } else if (this[`${action}Active`]) {
  767. classResult = classActive;
  768. }
  769. break;
  770. case 'undoAction':
  771. if (this.actionCur <= 0)
  772. classResult = classDisabled;
  773. break;
  774. case 'redoAction':
  775. if (this.actionCur == this.actionList.length - 1)
  776. classResult = classDisabled;
  777. break;
  778. }
  779. if (this.activePage == 'LoaderPage' || !this.mostRecentBookReactive) {
  780. switch (action) {
  781. case 'undoAction':
  782. case 'redoAction':
  783. case 'setPosition':
  784. case 'scrolling':
  785. case 'search':
  786. case 'copyText':
  787. case 'contents':
  788. classResult = classDisabled;
  789. break;
  790. case 'refresh':
  791. case 'recentBooks':
  792. if (!this.mostRecentBookReactive)
  793. classResult = classDisabled;
  794. break;
  795. }
  796. }
  797. return classResult;
  798. }
  799. async activateClickMapPage() {
  800. if (this.clickControl && this.showClickMapPage && !this.clickMapActive) {
  801. this.clickMapActive = true;
  802. await this.$refs.clickMapPage.slowDisappear();
  803. this.clickMapActive = false;
  804. }
  805. }
  806. get activePage() {
  807. let result = undefined;
  808. if (this.progressActive)
  809. result = 'ProgressPage';
  810. else if (this.loaderActive)
  811. result = 'LoaderPage';
  812. else if (this.mostRecentBookReactive)
  813. result = 'TextPage';
  814. if (!result && !this.loading) {
  815. this.loaderActive = true;
  816. result = 'LoaderPage';
  817. }
  818. if (result != 'TextPage') {
  819. this.$root.setAppTitle();
  820. }
  821. // на LoaderPage всегда показываем toolBar
  822. if (result == 'LoaderPage' && !this.toolBarActive) {
  823. this.toolBarToggle();
  824. }
  825. if (this.lastActivePage != result && result == 'TextPage') {
  826. //акивируем страницу с текстом
  827. this.$nextTick(async() => {
  828. const last = this.mostRecentBookReactive;
  829. const isParsed = await bookManager.hasBookParsed(last);
  830. if (!isParsed) {
  831. this.$root.setAppTitle();
  832. return;
  833. }
  834. this.updateRoute();
  835. const textPage = this.$refs.page;
  836. if (textPage.showBook) {
  837. this.textPage = textPage;
  838. textPage.lastBook = last;
  839. textPage.bookPos = (last.bookPos !== undefined ? last.bookPos : 0);
  840. textPage.showBook();
  841. }
  842. });
  843. }
  844. this.lastActivePage = result;
  845. return result;
  846. }
  847. async loadBook(opts) {
  848. if (!opts || !opts.url) {
  849. this.mostRecentBook();
  850. return;
  851. }
  852. this.closeAllWindows();
  853. let url = encodeURI(decodeURI(opts.url));
  854. //TODO: убрать конвертирование 'file://' после 06.2021
  855. if (url.length == 71 && url.indexOf('file://') == 0)
  856. url = url.replace(/^file/, 'disk');
  857. if ((url.indexOf('http://') != 0) && (url.indexOf('https://') != 0) &&
  858. (url.indexOf('disk://') != 0))
  859. url = 'http://' + url;
  860. // уже просматривается сейчас
  861. const lastBook = (this.textPage ? this.textPage.lastBook : null);
  862. if (!opts.force && lastBook && lastBook.url == url &&
  863. (!opts.path || opts.path == lastBook.path) &&
  864. await bookManager.hasBookParsed(lastBook)) {
  865. this.loaderActive = false;
  866. return;
  867. }
  868. this.progressActive = true;
  869. await this.$nextTick();
  870. const progress = this.$refs.page;
  871. this.actionList = [];
  872. this.actionCur = -1;
  873. try {
  874. progress.show();
  875. progress.setState({state: 'parse'});
  876. // есть ли среди недавних
  877. const key = bookManager.keyFromUrl(url);
  878. let wasOpened = await bookManager.getRecentBook({key});
  879. wasOpened = (wasOpened ? wasOpened : {});
  880. const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
  881. const bookPosSeen = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPosSeen);
  882. const uploadFileName = (opts.uploadFileName ? opts.uploadFileName : '');
  883. let book = null;
  884. if (!opts.force) {
  885. // пытаемся загрузить и распарсить книгу в менеджере из локального кэша
  886. const bookParsed = await bookManager.getBook({url, path: opts.path}, (prog) => {
  887. progress.setState({progress: prog});
  888. });
  889. // если есть в локальном кэше
  890. if (bookParsed) {
  891. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen}, bookParsed));
  892. this.mostRecentBook();
  893. this.addAction(bookPos);
  894. this.loaderActive = false;
  895. progress.hide(); this.progressActive = false;
  896. this.blinkCachedLoadMessage();
  897. this.checkBookPosPercent();
  898. await this.activateClickMapPage();
  899. return;
  900. }
  901. // иначе идем на сервер
  902. // пытаемся загрузить готовый файл с сервера
  903. if (wasOpened.path) {
  904. progress.setState({totalSteps: 5});
  905. try {
  906. const resp = await readerApi.loadCachedBook(wasOpened.path, (state) => {
  907. progress.setState(state);
  908. });
  909. book = Object.assign({}, wasOpened, {data: resp.data});
  910. } catch (e) {
  911. //молчим
  912. }
  913. }
  914. }
  915. progress.setState({totalSteps: 5});
  916. // не удалось, скачиваем книгу полностью с конвертацией
  917. let loadCached = true;
  918. if (!book) {
  919. book = await readerApi.loadBook({
  920. url,
  921. uploadFileName,
  922. enableSitesFilter: this.enableSitesFilter,
  923. skipHtmlCheck: (this.splitToPara ? true : false),
  924. isText: (this.splitToPara ? true : false),
  925. djvuQuality: this.djvuQuality,
  926. pdfAsText: this.pdfAsText,
  927. pdfQuality: this.pdfQuality,
  928. },
  929. (state) => {
  930. progress.setState(state);
  931. }
  932. );
  933. loadCached = false;
  934. }
  935. // добавляем в bookManager
  936. progress.setState({state: 'parse', step: 5});
  937. const addedBook = await bookManager.addBook(book, (prog) => {
  938. progress.setState({progress: prog});
  939. });
  940. // добавляем в историю
  941. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen, uploadFileName}, addedBook));
  942. this.mostRecentBook();
  943. this.addAction(bookPos);
  944. this.updateRoute(true);
  945. this.loaderActive = false;
  946. progress.hide(); this.progressActive = false;
  947. if (loadCached) {
  948. this.blinkCachedLoadMessage();
  949. } else
  950. this.stopBlink = true;
  951. this.checkBookPosPercent();
  952. await this.activateClickMapPage();
  953. } catch (e) {
  954. progress.hide(); this.progressActive = false;
  955. this.loaderActive = true;
  956. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  957. } finally {
  958. this.checkNewVersionAvailable();
  959. }
  960. }
  961. async loadFile(opts) {
  962. this.progressActive = true;
  963. await this.$nextTick();
  964. const progress = this.$refs.page;
  965. try {
  966. progress.show();
  967. progress.setState({state: 'upload'});
  968. const url = await readerApi.uploadFile(opts.file, this.config.maxUploadFileSize, (state) => {
  969. progress.setState(state);
  970. });
  971. progress.hide(); this.progressActive = false;
  972. await this.loadBook({url, uploadFileName: opts.file.name, force: true});
  973. } catch (e) {
  974. progress.hide(); this.progressActive = false;
  975. this.loaderActive = true;
  976. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  977. }
  978. }
  979. blinkCachedLoadMessage() {
  980. if (!this.blinkCachedLoad)
  981. return;
  982. this.blinkCount = 30;
  983. if (!this.inBlink) {
  984. this.inBlink = true;
  985. this.stopBlink = false;
  986. this.$nextTick(async() => {
  987. let page = this.$refs.page;
  988. while (this.blinkCount) {
  989. this.showRefreshIcon = !this.showRefreshIcon;
  990. if (page && page.blinkCachedLoadMessage)
  991. page.blinkCachedLoadMessage(this.showRefreshIcon);
  992. await utils.sleep(500);
  993. if (this.stopBlink)
  994. break;
  995. this.blinkCount--;
  996. page = this.$refs.page;
  997. }
  998. this.showRefreshIcon = true;
  999. this.inBlink = false;
  1000. if (page && page.blinkCachedLoadMessage)
  1001. page.blinkCachedLoadMessage('finish');
  1002. });
  1003. }
  1004. }
  1005. doAction(opts) {
  1006. let result = true;
  1007. let {action = '', event = false} = opts;
  1008. switch (action) {
  1009. case 'loader':
  1010. this.loaderToggle();
  1011. break;
  1012. case 'help':
  1013. this.helpToggle();
  1014. break;
  1015. case 'undoAction':
  1016. this.undoAction();
  1017. break;
  1018. case 'redoAction':
  1019. this.redoAction();
  1020. break;
  1021. case 'fullScreen':
  1022. this.fullScreenToggle();
  1023. break;
  1024. case 'scrolling':
  1025. this.scrollingToggle();
  1026. break;
  1027. case 'stopScrolling':
  1028. this.stopScrolling();
  1029. break;
  1030. case 'setPosition':
  1031. this.setPositionToggle();
  1032. break;
  1033. case 'search':
  1034. this.searchToggle();
  1035. break;
  1036. case 'copyText':
  1037. this.copyTextToggle();
  1038. break;
  1039. case 'convOptions':
  1040. this.convOptionsToggle();
  1041. break;
  1042. case 'refresh':
  1043. this.refreshBook();
  1044. break;
  1045. case 'contents':
  1046. this.contentsPageToggle();
  1047. break;
  1048. case 'libs':
  1049. this.libsToogle();
  1050. break;
  1051. case 'recentBooks':
  1052. this.recentBooksToggle();
  1053. break;
  1054. case 'offlineMode':
  1055. this.offlineModeToggle();
  1056. break;
  1057. case 'settings':
  1058. this.settingsToggle();
  1059. break;
  1060. case 'switchToolbar':
  1061. this.toolBarToggle();
  1062. break;
  1063. case 'donate':
  1064. this.donateToggle();
  1065. break;
  1066. default:
  1067. result = false;
  1068. break;
  1069. }
  1070. if (!result && this.activePage == 'TextPage' && this.$refs.page) {
  1071. result = true;
  1072. const textPage = this.$refs.page;
  1073. switch (action) {
  1074. case 'bookBegin':
  1075. textPage.doHome();
  1076. break;
  1077. case 'bookEnd':
  1078. textPage.doEnd();
  1079. break;
  1080. case 'pageBack':
  1081. textPage.doPageUp();
  1082. break;
  1083. case 'pageForward':
  1084. textPage.doPageDown();
  1085. break;
  1086. case 'lineBack':
  1087. textPage.doUp();
  1088. break;
  1089. case 'lineForward':
  1090. textPage.doDown();
  1091. break;
  1092. case 'incFontSize':
  1093. textPage.doFontSizeInc();
  1094. break;
  1095. case 'decFontSize':
  1096. textPage.doFontSizeDec();
  1097. break;
  1098. case 'scrollingSpeedUp':
  1099. textPage.doScrollingSpeedUp();
  1100. break;
  1101. case 'scrollingSpeedDown':
  1102. textPage.doScrollingSpeedDown();
  1103. break;
  1104. default:
  1105. result = false;
  1106. break;
  1107. }
  1108. }
  1109. if (result && event) {
  1110. event.preventDefault();
  1111. event.stopPropagation();
  1112. }
  1113. return result;
  1114. }
  1115. keyHook(event) {
  1116. let result = false;
  1117. if (this.$root.getRootRoute() == '/reader') {
  1118. if (this.$root.stdDialog.active)
  1119. return result;
  1120. if (!result)
  1121. result = this.$refs.dialogs.keyHook(event);
  1122. if (!result && this.helpActive)
  1123. result = this.$refs.helpPage.keyHook(event);
  1124. if (!result && this.settingsActive)
  1125. result = this.$refs.settingsPage.keyHook(event);
  1126. if (!result && this.recentBooksActive)
  1127. result = this.$refs.recentBooksPage.keyHook(event);
  1128. if (!result && this.setPositionActive)
  1129. result = this.$refs.setPositionPage.keyHook(event);
  1130. if (!result && this.searchActive)
  1131. result = this.$refs.searchPage.keyHook(event);
  1132. if (!result && this.copyTextActive)
  1133. result = this.$refs.copyTextPage.keyHook(event);
  1134. if (!result && this.contentsActive)
  1135. result = this.$refs.contentsPage.keyHook(event);
  1136. if (!result && this.$refs.page && this.$refs.page.keyHook)
  1137. result = this.$refs.page.keyHook(event);
  1138. if (!result && event.type == 'keydown') {
  1139. const action = this.$root.readerActionByKeyEvent(event);
  1140. if (action == 'loader') {
  1141. result = this.doAction({action, event});
  1142. }
  1143. if (!result && this.activePage == 'TextPage') {
  1144. result = this.doAction({action, event});
  1145. }
  1146. }
  1147. }
  1148. return result;
  1149. }
  1150. }
  1151. export default vueComponent(Reader);
  1152. //-----------------------------------------------------------------------------
  1153. </script>
  1154. <style scoped>
  1155. .header {
  1156. padding-left: 5px;
  1157. padding-right: 5px;
  1158. background-color: #1B695F;
  1159. color: #000;
  1160. overflow: hidden;
  1161. height: 50px;
  1162. }
  1163. .main {
  1164. background-color: #EBE2C9;
  1165. color: #000;
  1166. }
  1167. .tool-button {
  1168. margin: 0px 2px 0 2px;
  1169. padding: 0;
  1170. color: #3E843E;
  1171. background-color: #E6EDF4;
  1172. margin-top: 5px;
  1173. height: 38px;
  1174. width: 38px;
  1175. border: 0;
  1176. border-radius: 6px;
  1177. box-shadow: 3px 3px 5px black;
  1178. outline: 0;
  1179. }
  1180. .tool-button:hover {
  1181. background-color: white;
  1182. cursor: pointer;
  1183. }
  1184. .tool-button-active {
  1185. box-shadow: 0 0 0;
  1186. color: white;
  1187. background-color: #8AB45F;
  1188. position: relative;
  1189. top: 1px;
  1190. left: 1px;
  1191. }
  1192. .tool-button-active:hover {
  1193. color: white;
  1194. background-color: #81C581;
  1195. cursor: pointer;
  1196. }
  1197. .tool-button-disabled {
  1198. color: lightgray;
  1199. background-color: gray;
  1200. cursor: default;
  1201. }
  1202. .tool-button-disabled:hover {
  1203. color: lightgray;
  1204. background-color: gray;
  1205. cursor: default;
  1206. }
  1207. .space {
  1208. width: 10px;
  1209. display: inline-block;
  1210. }
  1211. .clear {
  1212. color: rgba(0,0,0,0);
  1213. }
  1214. </style>