Reader.vue 26 KB

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