Reader.vue 26 KB

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