Reader.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776
  1. <template>
  2. <el-container>
  3. <el-header v-show="toolBarActive" height='50px'>
  4. <div class="header">
  5. <el-tooltip content="Загрузить книгу" :open-delay="1000" effect="light">
  6. <el-button ref="loader" class="tool-button" :class="buttonActiveClass('loader')" @click="buttonClick('loader')"><i class="el-icon-back"></i></el-button>
  7. </el-tooltip>
  8. <div>
  9. <el-tooltip content="Действие назад" :open-delay="1000" effect="light">
  10. <el-button ref="undoAction" class="tool-button" :class="buttonActiveClass('undoAction')" @click="buttonClick('undoAction')" ><i class="el-icon-arrow-left"></i></el-button>
  11. </el-tooltip>
  12. <el-tooltip content="Действие вперед" :open-delay="1000" effect="light">
  13. <el-button ref="redoAction" class="tool-button" :class="buttonActiveClass('redoAction')" @click="buttonClick('redoAction')" ><i class="el-icon-arrow-right"></i></el-button>
  14. </el-tooltip>
  15. <div class="space"></div>
  16. <el-tooltip content="На весь экран" :open-delay="1000" effect="light">
  17. <el-button ref="fullScreen" class="tool-button" :class="buttonActiveClass('fullScreen')" @click="buttonClick('fullScreen')"><i class="el-icon-rank"></i></el-button>
  18. </el-tooltip>
  19. <el-tooltip content="Плавный скроллинг" :open-delay="1000" effect="light">
  20. <el-button ref="scrolling" class="tool-button" :class="buttonActiveClass('scrolling')" @click="buttonClick('scrolling')"><i class="el-icon-sort"></i></el-button>
  21. </el-tooltip>
  22. <el-tooltip content="Прокрутка книги" :open-delay="1000" effect="light">
  23. <el-button ref="setPosition" class="tool-button" :class="buttonActiveClass('setPosition')" @click="buttonClick('setPosition')"><i class="el-icon-d-arrow-right"></i></el-button>
  24. </el-tooltip>
  25. <el-tooltip content="Найти в тексте" :open-delay="1000" effect="light">
  26. <el-button ref="search" class="tool-button" :class="buttonActiveClass('search')" @click="buttonClick('search')"><i class="el-icon-search"></i></el-button>
  27. </el-tooltip>
  28. <el-tooltip content="Скопировать текст со страницы" :open-delay="1000" effect="light">
  29. <el-button ref="copyText" class="tool-button" :class="buttonActiveClass('copyText')" @click="buttonClick('copyText')"><i class="el-icon-edit-outline"></i></el-button>
  30. </el-tooltip>
  31. <el-tooltip content="Принудительно обновить книгу в обход кеша" :open-delay="1000" effect="light">
  32. <el-button ref="refresh" class="tool-button" :class="buttonActiveClass('refresh')" @click="buttonClick('refresh')">
  33. <i class="el-icon-refresh" :class="{clear: !showRefreshIcon}"></i>
  34. </el-button>
  35. </el-tooltip>
  36. <div class="space"></div>
  37. <el-tooltip content="Открыть недавние" :open-delay="1000" effect="light">
  38. <el-button ref="history" class="tool-button" :class="buttonActiveClass('history')" @click="buttonClick('history')"><i class="el-icon-document"></i></el-button>
  39. </el-tooltip>
  40. </div>
  41. <el-tooltip content="Настроить" :open-delay="1000" effect="light">
  42. <el-button ref="settings" class="tool-button" :class="buttonActiveClass('settings')" @click="buttonClick('settings')"><i class="el-icon-setting"></i></el-button>
  43. </el-tooltip>
  44. </div>
  45. </el-header>
  46. <el-main>
  47. <keep-alive>
  48. <component ref="page" :is="activePage"
  49. @load-book="loadBook"
  50. @book-pos-changed="bookPosChanged"
  51. @tool-bar-toggle="toolBarToggle"
  52. @full-screen-toogle="fullScreenToggle"
  53. @stop-scrolling="stopScrolling"
  54. @scrolling-toggle="scrollingToggle"
  55. ></component>
  56. </keep-alive>
  57. <SetPositionPage v-if="setPositionActive" ref="setPositionPage" @set-position-toggle="setPositionToggle" @book-pos-changed="bookPosChanged"></SetPositionPage>
  58. <SearchPage v-show="searchActive" ref="searchPage"
  59. @search-toggle="searchToggle"
  60. @book-pos-changed="bookPosChanged"
  61. @start-text-search="startTextSearch"
  62. @stop-text-search="stopTextSearch">
  63. </SearchPage>
  64. <CopyTextPage v-if="copyTextActive" ref="copyTextPage" @copy-text-toggle="copyTextToggle"></CopyTextPage>
  65. <HistoryPage v-if="historyActive" ref="historyPage" @load-book="loadBook" @history-toggle="historyToggle"></HistoryPage>
  66. <SettingsPage v-if="settingsActive" ref="settingsPage" @settings-toggle="settingsToggle"></SettingsPage>
  67. </el-main>
  68. </el-container>
  69. </template>
  70. <script>
  71. //-----------------------------------------------------------------------------
  72. import Vue from 'vue';
  73. import Component from 'vue-class-component';
  74. import LoaderPage from './LoaderPage/LoaderPage.vue';
  75. import TextPage from './TextPage/TextPage.vue';
  76. import ProgressPage from './ProgressPage/ProgressPage.vue';
  77. import SetPositionPage from './SetPositionPage/SetPositionPage.vue';
  78. import SearchPage from './SearchPage/SearchPage.vue';
  79. import CopyTextPage from './CopyTextPage/CopyTextPage.vue';
  80. import HistoryPage from './HistoryPage/HistoryPage.vue';
  81. import SettingsPage from './SettingsPage/SettingsPage.vue';
  82. import bookManager from './share/bookManager';
  83. import readerApi from '../../api/reader';
  84. import _ from 'lodash';
  85. import {sleep} from '../../share/utils';
  86. export default @Component({
  87. components: {
  88. LoaderPage,
  89. TextPage,
  90. ProgressPage,
  91. SetPositionPage,
  92. SearchPage,
  93. CopyTextPage,
  94. HistoryPage,
  95. SettingsPage,
  96. },
  97. watch: {
  98. bookPos: function(newValue) {
  99. if (newValue !== undefined && this.activePage == 'TextPage') {
  100. const textPage = this.$refs.page;
  101. if (textPage.bookPos != newValue) {
  102. textPage.bookPos = newValue;
  103. }
  104. this.debouncedSetRecentBook(newValue);
  105. }
  106. },
  107. routeParamPos: function(newValue) {
  108. if (newValue !== undefined && newValue != this.bookPos) {
  109. this.bookPos = newValue;
  110. }
  111. },
  112. routeParamUrl: function(newValue) {
  113. if (newValue !== '' && newValue !== this.mostRecentBook().url) {
  114. this.loadBook({url: newValue, bookPos: this.routeParamPos});
  115. }
  116. },
  117. settings: function(newValue) {
  118. this.allowUrlParamBookPos = newValue.allowUrlParamBookPos;
  119. this.copyFullText = newValue.copyFullText;
  120. this.updateRoute();
  121. },
  122. },
  123. })
  124. class Reader extends Vue {
  125. loaderActive = false;
  126. progressActive = false;
  127. fullScreenActive = false;
  128. scrollingActive = false;
  129. setPositionActive = false;
  130. searchActive = false;
  131. copyTextActive = false;
  132. historyActive = false;
  133. settingsActive = false;
  134. bookPos = null;
  135. allowUrlParamBookPos = false;
  136. showRefreshIcon = true;
  137. mostRecentBookReactive = null;
  138. created() {
  139. this.loading = true;
  140. this.commit = this.$store.commit;
  141. this.dispatch = this.$store.dispatch;
  142. this.reader = this.$store.state.reader;
  143. this.$root.addKeyHook(this.keyHook);
  144. this.lastActivePage = false;
  145. this.debouncedUpdateRoute = _.debounce(() => {
  146. this.updateRoute();
  147. }, 1000);
  148. this.debouncedSetRecentBook = _.debounce(async(newValue) => {
  149. const recent = this.mostRecentBook();
  150. if (recent && recent.bookPos != newValue) {
  151. await bookManager.setRecentBook(Object.assign({}, recent, {bookPos: newValue, bookPosSeen: this.bookPosSeen}));
  152. }
  153. }, 500);
  154. document.addEventListener('fullscreenchange', () => {
  155. this.fullScreenActive = (document.fullscreenElement !== null);
  156. });
  157. this.allowUrlParamBookPos = this.settings.allowUrlParamBookPos;
  158. this.copyFullText = this.settings.copyFullText;
  159. }
  160. mounted() {
  161. (async() => {
  162. await bookManager.init();
  163. if (this.$root.rootRoute == '/reader') {
  164. if (this.routeParamUrl) {
  165. this.loadBook({url: this.routeParamUrl, bookPos: this.routeParamPos});
  166. } else if (this.mostRecentBook()) {
  167. this.loadBook({url: this.mostRecentBook().url});
  168. } else {
  169. this.loaderActive = true;
  170. }
  171. }
  172. this.loading = false;
  173. })();
  174. }
  175. get routeParamPos() {
  176. let result = undefined;
  177. const q = this.$route.query;
  178. if (q['__p']) {
  179. result = q['__p'];
  180. if (Array.isArray(result))
  181. result = result[0];
  182. }
  183. return (result ? parseInt(result, 10) || 0 : result);
  184. }
  185. updateRoute(isNewRoute) {
  186. const recent = this.mostRecentBook();
  187. const pos = (recent && recent.bookPos && this.allowUrlParamBookPos ? `__p=${recent.bookPos}&` : '');
  188. const url = (recent ? `url=${recent.url}` : '');
  189. if (isNewRoute)
  190. this.$router.push(`/reader?${pos}${url}`);
  191. else
  192. this.$router.replace(`/reader?${pos}${url}`);
  193. }
  194. get routeParamUrl() {
  195. let result = '';
  196. const path = this.$route.fullPath;
  197. const i = path.indexOf('url=');
  198. if (i >= 0) {
  199. result = path.substr(i + 4);
  200. }
  201. return decodeURIComponent(result);
  202. }
  203. bookPosChanged(event) {
  204. if (event.bookPosSeen !== undefined)
  205. this.bookPosSeen = event.bookPosSeen;
  206. this.bookPos = event.bookPos;
  207. this.debouncedUpdateRoute();
  208. }
  209. get toolBarActive() {
  210. return this.reader.toolBarActive;
  211. }
  212. mostRecentBook() {
  213. const result = bookManager.mostRecentBook();
  214. this.mostRecentBookReactive = result;
  215. return result;
  216. }
  217. get settings() {
  218. return this.$store.state.reader.settings;
  219. }
  220. toolBarToggle() {
  221. this.commit('reader/setToolBarActive', !this.toolBarActive);
  222. this.$root.$emit('resize');
  223. }
  224. fullScreenToggle() {
  225. this.fullScreenActive = !this.fullScreenActive;
  226. if (this.fullScreenActive) {
  227. const element = document.documentElement;
  228. if (element.requestFullscreen) {
  229. element.requestFullscreen();
  230. } else if (element.webkitrequestFullscreen) {
  231. element.webkitRequestFullscreen();
  232. } else if (element.mozRequestFullscreen) {
  233. element.mozRequestFullScreen();
  234. }
  235. } else {
  236. if (document.cancelFullScreen) {
  237. document.cancelFullScreen();
  238. } else if (document.mozCancelFullScreen) {
  239. document.mozCancelFullScreen();
  240. } else if (document.webkitCancelFullScreen) {
  241. document.webkitCancelFullScreen();
  242. }
  243. }
  244. }
  245. closeAllTextPages() {
  246. this.setPositionActive = false;
  247. this.copyTextActive = false;
  248. this.historyActive = false;
  249. this.settingsActive = false;
  250. this.stopScrolling();
  251. this.stopSearch();
  252. }
  253. loaderToggle() {
  254. this.loaderActive = !this.loaderActive;
  255. if (this.loaderActive) {
  256. this.closeAllTextPages();
  257. }
  258. }
  259. setPositionToggle() {
  260. this.setPositionActive = !this.setPositionActive;
  261. if (this.setPositionActive && this.activePage == 'TextPage' && this.mostRecentBook()) {
  262. this.closeAllTextPages();
  263. this.setPositionActive = true;
  264. this.$nextTick(() => {
  265. this.$refs.setPositionPage.sliderMax = this.mostRecentBook().textLength - 1;
  266. this.$refs.setPositionPage.sliderValue = this.mostRecentBook().bookPos;
  267. });
  268. } else {
  269. this.setPositionActive = false;
  270. }
  271. }
  272. stopScrolling() {
  273. if (this.scrollingActive)
  274. this.scrollingToggle();
  275. }
  276. scrollingToggle() {
  277. this.scrollingActive = !this.scrollingActive;
  278. if (this.activePage == 'TextPage') {
  279. const page = this.$refs.page;
  280. if (this.scrollingActive) {
  281. page.startTextScrolling();
  282. } else {
  283. page.stopTextScrolling();
  284. }
  285. }
  286. }
  287. stopSearch() {
  288. if (this.searchActive)
  289. this.searchToggle();
  290. }
  291. startTextSearch(opts) {
  292. if (this.activePage == 'TextPage')
  293. this.$refs.page.startSearch(opts.needle);
  294. }
  295. stopTextSearch() {
  296. if (this.activePage == 'TextPage')
  297. this.$refs.page.stopSearch();
  298. }
  299. searchToggle() {
  300. this.searchActive = !this.searchActive;
  301. const page = this.$refs.page;
  302. if (this.searchActive && this.activePage == 'TextPage' && page.parsed) {
  303. this.closeAllTextPages();
  304. this.searchActive = true;
  305. this.$nextTick(() => {
  306. this.$refs.searchPage.init(page.parsed);
  307. });
  308. } else {
  309. this.stopTextSearch();
  310. this.searchActive = false;
  311. }
  312. }
  313. copyTextToggle() {
  314. this.copyTextActive = !this.copyTextActive;
  315. const page = this.$refs.page;
  316. if (this.copyTextActive && this.activePage == 'TextPage' && page.parsed) {
  317. this.closeAllTextPages();
  318. this.copyTextActive = true;
  319. this.$nextTick(() => {
  320. this.$refs.copyTextPage.init(this.mostRecentBook().bookPos, page.parsed, this.copyFullText);
  321. });
  322. } else {
  323. this.copyTextActive = false;
  324. }
  325. }
  326. historyToggle() {
  327. this.historyActive = !this.historyActive;
  328. if (this.historyActive) {
  329. this.closeAllTextPages();
  330. this.historyActive = true;
  331. } else {
  332. this.historyActive = false;
  333. }
  334. }
  335. settingsToggle() {
  336. this.settingsActive = !this.settingsActive;
  337. if (this.settingsActive) {
  338. this.closeAllTextPages();
  339. this.settingsActive = true;
  340. } else {
  341. this.settingsActive = false;
  342. }
  343. }
  344. buttonClick(button) {
  345. switch (button) {
  346. case 'loader':
  347. this.loaderToggle();
  348. break;
  349. case 'fullScreen':
  350. this.fullScreenToggle();
  351. break;
  352. case 'setPosition':
  353. this.setPositionToggle();
  354. break;
  355. case 'scrolling':
  356. this.scrollingToggle();
  357. break;
  358. case 'search':
  359. this.searchToggle();
  360. break;
  361. case 'copyText':
  362. this.copyTextToggle();
  363. break;
  364. case 'history':
  365. this.historyToggle();
  366. break;
  367. case 'refresh':
  368. if (this.mostRecentBook()) {
  369. this.loadBook({url: this.mostRecentBook().url, force: true});
  370. }
  371. break;
  372. case 'settings':
  373. this.settingsToggle();
  374. break;
  375. }
  376. this.$refs[button].$el.blur();
  377. }
  378. buttonActiveClass(button) {
  379. const classActive = { 'tool-button-active': true, 'tool-button-active:hover': true };
  380. const classDisabled = { 'tool-button-disabled': true, 'tool-button-disabled:hover': true };
  381. let classResult = {};
  382. switch (button) {
  383. case 'loader':
  384. case 'fullScreen':
  385. case 'setPosition':
  386. case 'scrolling':
  387. case 'search':
  388. case 'copyText':
  389. case 'history':
  390. case 'settings':
  391. if (this[`${button}Active`])
  392. classResult = classActive;
  393. break;
  394. }
  395. if (this.activePage == 'LoaderPage' || !this.mostRecentBook()) {
  396. switch (button) {
  397. case 'undoAction':
  398. case 'redoAction':
  399. case 'setPosition':
  400. case 'scrolling':
  401. case 'search':
  402. case 'copyText':
  403. classResult = classDisabled;
  404. break;
  405. case 'history':
  406. case 'refresh':
  407. if (!this.mostRecentBook())
  408. classResult = classDisabled;
  409. break;
  410. }
  411. }
  412. return classResult;
  413. }
  414. get activePage() {
  415. let result = '';
  416. if (this.progressActive)
  417. result = 'ProgressPage';
  418. else if (this.loaderActive)
  419. result = 'LoaderPage';
  420. else if (this.mostRecentBookReactive)
  421. result = 'TextPage';
  422. if (!result && !this.loading) {
  423. this.loaderActive = true;
  424. result = 'LoaderPage';
  425. }
  426. if (result != 'TextPage') {
  427. this.$root.$emit('set-app-title');
  428. }
  429. if (this.lastActivePage != result && result == 'TextPage') {
  430. //акивируем страницу с текстом
  431. this.$nextTick(async() => {
  432. const last = this.mostRecentBookReactive;
  433. const isParsed = bookManager.hasBookParsed(last);
  434. if (!isParsed) {
  435. this.$root.$emit('set-app-title');
  436. return;
  437. }
  438. this.updateRoute();
  439. const textPage = this.$refs.page;
  440. if (textPage.showBook) {
  441. textPage.lastBook = last;
  442. textPage.bookPos = (last.bookPos !== undefined ? last.bookPos : 0);
  443. textPage.showBook();
  444. }
  445. });
  446. }
  447. this.lastActivePage = result;
  448. return result;
  449. }
  450. loadBook(opts) {
  451. if (!opts) {
  452. this.mostRecentBook();
  453. return;
  454. }
  455. // уже просматривается сейчас
  456. const recent = this.mostRecentBook();
  457. if (!opts.force && recent && recent.url == opts.url && bookManager.hasBookParsed(recent)) {
  458. this.loaderActive = false;
  459. return;
  460. }
  461. this.progressActive = true;
  462. this.$nextTick(async() => {
  463. const progress = this.$refs.page;
  464. try {
  465. progress.show();
  466. progress.setState({state: 'parse'});
  467. // есть ли среди недавних
  468. const key = bookManager.keyFromUrl(opts.url);
  469. let wasOpened = await bookManager.getRecentBook({key});
  470. wasOpened = (wasOpened ? wasOpened : {});
  471. const bookPos = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPos);
  472. const bookPosSeen = (opts.bookPos !== undefined ? opts.bookPos : wasOpened.bookPosSeen);
  473. let book = null;
  474. if (!opts.force) {
  475. // пытаемся загрузить и распарсить книгу в менеджере из локального кеша
  476. const bookParsed = await bookManager.getBook({url: opts.url}, (prog) => {
  477. progress.setState({progress: prog});
  478. });
  479. // если есть в локальном кеше
  480. if (bookParsed) {
  481. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen}, bookManager.metaOnly(bookParsed)));
  482. this.mostRecentBook();
  483. this.loaderActive = false;
  484. progress.hide(); this.progressActive = false;
  485. this.blinkCachedLoadMessage();
  486. return;
  487. }
  488. // иначе идем на сервер
  489. // пытаемся загрузить готовый файл с сервера
  490. if (wasOpened.path) {
  491. try {
  492. const resp = await readerApi.loadCachedBook(wasOpened.path, (state) => {
  493. progress.setState(state);
  494. });
  495. book = Object.assign({}, wasOpened, {data: resp.data});
  496. } catch (e) {
  497. //молчим
  498. }
  499. }
  500. }
  501. progress.setState({totalSteps: 5});
  502. // не удалось, скачиваем книгу полностью с конвертацией
  503. let loadCached = true;
  504. if (!book) {
  505. book = await readerApi.loadBook(opts.url, (state) => {
  506. progress.setState(state);
  507. });
  508. loadCached = false;
  509. }
  510. // добавляем в bookManager
  511. progress.setState({state: 'parse', step: 5});
  512. const addedBook = await bookManager.addBook(book, (prog) => {
  513. progress.setState({progress: prog});
  514. });
  515. // добавляем в историю
  516. await bookManager.setRecentBook(Object.assign({bookPos, bookPosSeen}, bookManager.metaOnly(addedBook)));
  517. this.mostRecentBook();
  518. this.updateRoute(true);
  519. this.loaderActive = false;
  520. progress.hide(); this.progressActive = false;
  521. if (loadCached) {
  522. this.blinkCachedLoadMessage();
  523. } else
  524. this.stopBlink = true;
  525. } catch (e) {
  526. progress.hide(); this.progressActive = false;
  527. this.loaderActive = true;
  528. this.$alert(e.message, 'Ошибка', {type: 'error'});
  529. }
  530. });
  531. }
  532. blinkCachedLoadMessage() {
  533. this.blinkCount = 30;
  534. if (!this.inBlink) {
  535. this.inBlink = true;
  536. this.stopBlink = false;
  537. this.$nextTick(async() => {
  538. let page = this.$refs.page;
  539. while (this.blinkCount) {
  540. this.showRefreshIcon = !this.showRefreshIcon;
  541. if (page.blinkCachedLoadMessage)
  542. page.blinkCachedLoadMessage(this.showRefreshIcon);
  543. await sleep(500);
  544. if (this.stopBlink)
  545. break;
  546. this.blinkCount--;
  547. page = this.$refs.page;
  548. }
  549. this.showRefreshIcon = true;
  550. this.inBlink = false;
  551. if (page.blinkCachedLoadMessage)
  552. page.blinkCachedLoadMessage('finish');
  553. });
  554. }
  555. }
  556. keyHook(event) {
  557. if (this.$root.rootRoute == '/reader') {
  558. let handled = false;
  559. if (!handled && this.settingsActive)
  560. handled = this.$refs.settingsPage.keyHook(event);
  561. if (!handled && this.historyActive)
  562. handled = this.$refs.historyPage.keyHook(event);
  563. if (!handled && this.setPositionActive)
  564. handled = this.$refs.setPositionPage.keyHook(event);
  565. if (!handled && this.searchActive)
  566. handled = this.$refs.searchPage.keyHook(event);
  567. if (!handled && this.copyTextActive)
  568. handled = this.$refs.copyTextPage.keyHook(event);
  569. if (!handled && this.$refs.page && this.$refs.page.keyHook)
  570. handled = this.$refs.page.keyHook(event);
  571. if (!handled && event.type == 'keydown') {
  572. if (event.code == 'Escape')
  573. this.loaderToggle();
  574. if (this.activePage == 'TextPage') {
  575. switch (event.code) {
  576. case 'KeyP':
  577. this.setPositionToggle();
  578. break;
  579. case 'KeyF':
  580. if (event.ctrlKey) {
  581. this.searchToggle();
  582. event.preventDefault();
  583. event.stopPropagation();
  584. }
  585. break;
  586. case 'KeyC':
  587. if (event.ctrlKey) {
  588. this.copyTextToggle();
  589. event.preventDefault();
  590. event.stopPropagation();
  591. }
  592. break;
  593. case 'KeyZ':
  594. this.scrollingToggle();
  595. break;
  596. case 'KeyH':
  597. this.historyToggle();
  598. break;
  599. case 'KeyS':
  600. this.settingsToggle();
  601. break;
  602. }
  603. }
  604. }
  605. }
  606. }
  607. }
  608. //-----------------------------------------------------------------------------
  609. </script>
  610. <style scoped>
  611. .el-container {
  612. padding: 0;
  613. margin: 0;
  614. height: 100%;
  615. }
  616. .el-header {
  617. padding-left: 5px;
  618. padding-right: 5px;
  619. background-color: #1B695F;
  620. color: #000;
  621. overflow-x: auto;
  622. overflow-y: hidden;
  623. }
  624. .header {
  625. display: flex;
  626. justify-content: space-between;
  627. min-width: 550px;
  628. }
  629. .el-main {
  630. position: relative;
  631. display: flex;
  632. padding: 0;
  633. margin: 0;
  634. background-color: #EBE2C9;
  635. color: #000;
  636. }
  637. .tool-button {
  638. margin: 0 2px 0 2px;
  639. padding: 0;
  640. color: #3E843E;
  641. background-color: #E6EDF4;
  642. margin-top: 5px;
  643. height: 38px;
  644. width: 38px;
  645. border: 0;
  646. box-shadow: 3px 3px 5px black;
  647. }
  648. .tool-button:hover {
  649. background-color: white;
  650. }
  651. .tool-button-active {
  652. box-shadow: 0 0 0;
  653. color: white;
  654. background-color: #8AB45F;
  655. position: relative;
  656. top: 1px;
  657. left: 1px;
  658. }
  659. .tool-button-active:hover {
  660. color: white;
  661. background-color: #81C581;
  662. }
  663. .tool-button-disabled {
  664. color: lightgray;
  665. background-color: gray;
  666. }
  667. .tool-button-disabled:hover {
  668. color: lightgray;
  669. background-color: gray;
  670. }
  671. i {
  672. font-size: 200%;
  673. }
  674. .space {
  675. width: 10px;
  676. display: inline-block;
  677. }
  678. .clear {
  679. color: rgba(0,0,0,0);
  680. }
  681. </style>