TextPage.vue 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322
  1. <template>
  2. <div ref="main" class="main">
  3. <div class="layout back" @wheel.prevent.stop="onMouseWheel">
  4. <div class="absolute" v-html="background"></div>
  5. <div class="absolute" v-html="pageDivider"></div>
  6. </div>
  7. <div ref="scrollBox1" class="layout over-hidden" @wheel.prevent.stop="onMouseWheel">
  8. <div ref="scrollingPage1" class="layout over-hidden" @transitionend="onPage1TransitionEnd" @animationend="onPage1AnimationEnd">
  9. <div @copy.prevent="copyText" v-html="page1"></div>
  10. </div>
  11. </div>
  12. <div ref="scrollBox2" class="layout over-hidden" @wheel.prevent.stop="onMouseWheel">
  13. <div ref="scrollingPage2" class="layout over-hidden" @transitionend="onPage2TransitionEnd" @animationend="onPage2AnimationEnd">
  14. <div @copy.prevent="copyText" v-html="page2"></div>
  15. </div>
  16. </div>
  17. <div v-show="showStatusBar" ref="statusBar" class="layout">
  18. <div v-html="statusBar"></div>
  19. </div>
  20. <div
  21. v-show="clickControl" ref="layoutEvents" class="layout events"
  22. oncontextmenu="return false;"
  23. @mousedown.prevent.stop="onMouseDown" @mouseup.prevent.stop="onMouseUp"
  24. @wheel.prevent.stop="onMouseWheel"
  25. @touchstart.stop="onTouchStart" @touchend.stop="onTouchEnd" @touchmove.stop="onTouchMove" @touchcancel.prevent.stop="onTouchCancel"
  26. >
  27. <div
  28. v-show="showStatusBar && statusBarClickOpen" @mousedown.prevent.stop @touchstart.stop
  29. @click.prevent.stop="onStatusBarClick"
  30. v-html="statusBarClickable"
  31. ></div>
  32. </div>
  33. <div
  34. v-show="!clickControl && showStatusBar && statusBarClickOpen" class="layout"
  35. @mousedown.prevent.stop @touchstart.stop
  36. @click.prevent.stop="onStatusBarClick"
  37. v-html="statusBarClickable"
  38. >
  39. </div>
  40. <!-- невидимым делать нельзя (display: none), вовремя не подгружаютя шрифты -->
  41. <canvas ref="offscreenCanvas" class="layout" style="visibility: hidden"></canvas>
  42. <div ref="measureWidth" style="position: absolute; visibility: hidden"></div>
  43. </div>
  44. </template>
  45. <script>
  46. //-----------------------------------------------------------------------------
  47. import vueComponent from '../../vueComponent.js';
  48. import {loadCSS} from 'fg-loadcss';
  49. import _ from 'lodash';
  50. import he from 'he';
  51. import './TextPage.css';
  52. import * as utils from '../../../share/utils';
  53. import bookManager from '../share/bookManager';
  54. import DrawHelper from './DrawHelper';
  55. import rstore from '../../../store/modules/reader';
  56. import {clickMap} from '../share/clickMap';
  57. const minLayoutWidth = 100;
  58. const componentOptions = {
  59. watch: {
  60. bookPos: function() {
  61. this.$emit('book-pos-changed', {bookPos: this.bookPos, bookPosSeen: this.bookPosSeen});
  62. this.draw();
  63. if (this.userBookPosChange) {
  64. this.$emit('hide-tool-bar', {show: (this.bookPos == 0 || this.bookPos < this.prevBookPos)});
  65. this.prevBookPos = this.bookPos;
  66. this.userBookPosChange = false;
  67. }
  68. },
  69. bookPosSeen: function() {
  70. this.$emit('book-pos-changed', {bookPos: this.bookPos, bookPosSeen: this.bookPosSeen});
  71. },
  72. settings: function() {
  73. this.debouncedLoadSettings();
  74. },
  75. toggleLayout: function() {
  76. this.updateLayout();
  77. },
  78. inAnimation: function() {
  79. this.updateLayout();
  80. },
  81. },
  82. };
  83. class TextPage {
  84. _options = componentOptions;
  85. toggleLayout = false;
  86. showStatusBar = false;
  87. clickControl = true;
  88. background = null;
  89. pageDivider = null;
  90. page1 = null;
  91. page2 = null;
  92. statusBar = null;
  93. statusBarClickable = null;
  94. lastBook = null;
  95. bookPos = 0;
  96. bookPosSeen = null;
  97. prevBookPos = 0;
  98. userBookPosChange = false;
  99. fontStyle = null;
  100. fontSize = null;
  101. fontName = null;
  102. fontWeight = null;
  103. inAnimation = false;
  104. meta = null;
  105. created() {
  106. this.drawHelper = new DrawHelper();
  107. this.commit = this.$store.commit;
  108. this.dispatch = this.$store.dispatch;
  109. this.config = this.$store.state.config;
  110. this.reader = this.$store.state.reader;
  111. this.debouncedStartClickRepeat = _.debounce((x, y) => {
  112. this.startClickRepeat(x, y);
  113. }, 800);
  114. this.debouncedPrepareNextPage = _.debounce(() => {
  115. this.prepareNextPage();
  116. }, 100);
  117. this.debouncedDrawStatusBar = _.throttle(() => {
  118. this.drawStatusBar();
  119. }, 60);
  120. this.debouncedDrawPageDividerAndOrnament = _.throttle(() => {
  121. this.drawPageDividerAndOrnament();
  122. }, 65);
  123. this.debouncedLoadSettings = _.debounce(() => {
  124. this.loadSettings();
  125. }, 50);
  126. this.debouncedUpdatePage = _.debounce(async(lines) => {
  127. if (!this.pageChangeAnimation)
  128. this.toggleLayout = !this.toggleLayout;
  129. else {
  130. this.page2 = this.page1;
  131. this.toggleLayout = true;
  132. }
  133. if (this.toggleLayout)
  134. this.page1 = this.drawHelper.drawPage(lines);
  135. else
  136. this.page2 = this.drawHelper.drawPage(lines);
  137. await this.doPageAnimation();
  138. }, 10);
  139. this.$root.addEventHook('resize', async() => {
  140. await utils.sleep(200);
  141. this.$nextTick(this.onResize);
  142. });
  143. }
  144. mounted() {
  145. this.context = this.$refs.offscreenCanvas.getContext('2d');
  146. }
  147. hex2rgba(hex, alpha = 1) {
  148. const [r, g, b] = hex.match(/\w\w/g).map(x => parseInt(x, 16));
  149. return `rgba(${r},${g},${b},${alpha})`;
  150. }
  151. calcDrawProps() {
  152. const wideLetter = 'Щ';
  153. //preloaded fonts
  154. this.fontList = [`12px '${this.fontName}'`];
  155. //widths
  156. this.realWidth = this.$refs.main.clientWidth;
  157. this.realHeight = this.$refs.main.clientHeight;
  158. this.$refs.layoutEvents.style.width = this.realWidth + 'px';
  159. this.$refs.layoutEvents.style.height = this.realHeight + 'px';
  160. const dual = (this.dualPageMode ? 2 : 1);
  161. this.boxW = this.realWidth - 2*this.indentLR;
  162. this.w = this.boxW/dual - (this.dualPageMode ? 2*this.dualIndentLR : 0);
  163. this.scrollHeight = this.realHeight - (this.showStatusBar ? this.statusBarHeight : 0);
  164. this.h = this.scrollHeight - 2*this.indentTB;
  165. this.lineHeight = this.fontSize + this.lineInterval;
  166. this.pageRowsCount = 1 + Math.floor((this.h - this.lineHeight + this.lineInterval/2)/this.lineHeight);
  167. this.pageLineCount = (this.dualPageMode ? this.pageRowsCount*2 : this.pageRowsCount)
  168. //stuff
  169. this.currentAnimation = '';
  170. this.pageChangeDirectionDown = true;
  171. this.fontShift = this.fontVertShift/100;
  172. this.textShift = this.textVertShift/100 + this.fontShift;
  173. //statusBar
  174. this.$refs.statusBar.style.left = '0px';
  175. this.$refs.statusBar.style.top = (this.statusBarTop ? 1 : this.realHeight - this.statusBarHeight) + 'px';
  176. const sbColor = (this.statusBarColorAsText ? this.textColor : this.statusBarColor);
  177. this.statusBarRgbaColor = this.hex2rgba(sbColor || '#000000', this.statusBarColorAlpha);
  178. const ddColor = (this.dualDivColorAsText ? this.textColor : this.dualDivColor);
  179. this.dualDivRgbaColor = this.hex2rgba(ddColor || '#000000', this.dualDivColorAlpha);
  180. //drawHelper
  181. this.drawHelper.realWidth = this.realWidth;
  182. this.drawHelper.realHeight = this.realHeight;
  183. this.drawHelper.lastBook = this.lastBook;
  184. this.drawHelper.book = this.book;
  185. this.drawHelper.parsed = this.parsed;
  186. this.drawHelper.pageRowsCount = this.pageRowsCount;
  187. this.drawHelper.pageLineCount = this.pageLineCount;
  188. this.drawHelper.dualPageMode = this.dualPageMode;
  189. this.drawHelper.dualIndentLR = this.dualIndentLR;
  190. /*this.drawHelper.dualDivWidth = this.dualDivWidth;
  191. this.drawHelper.dualDivHeight = this.dualDivHeight;
  192. this.drawHelper.dualDivRgbaColor = this.dualDivRgbaColor;
  193. this.drawHelper.dualDivStrokeFill = this.dualDivStrokeFill;
  194. this.drawHelper.dualDivStrokeGap = this.dualDivStrokeGap;
  195. this.drawHelper.dualDivShadowWidth = this.dualDivShadowWidth;*/
  196. this.drawHelper.backgroundColor = this.backgroundColor;
  197. this.drawHelper.statusBarRgbaColor = this.statusBarRgbaColor;
  198. this.drawHelper.fontStyle = this.fontStyle;
  199. this.drawHelper.fontWeight = this.fontWeight;
  200. this.drawHelper.fontSize = this.fontSize;
  201. this.drawHelper.fontName = this.fontName;
  202. this.drawHelper.fontShift = this.fontShift;
  203. this.drawHelper.textColor = this.textColor;
  204. this.drawHelper.textShift = this.textShift;
  205. this.drawHelper.p = this.p;
  206. this.drawHelper.boxW = this.boxW;
  207. this.drawHelper.w = this.w;
  208. this.drawHelper.h = this.h;
  209. this.drawHelper.indentLR = this.indentLR;
  210. this.drawHelper.textAlignJustify = this.textAlignJustify;
  211. this.drawHelper.lineHeight = this.lineHeight;
  212. this.drawHelper.context = this.context;
  213. //альтернатива context.measureText
  214. if (!this.context.measureText(wideLetter).width) {
  215. const ctx = this.$refs.measureWidth;
  216. this.drawHelper.measureText = function(text, style) {
  217. ctx.innerText = text;
  218. ctx.style.font = this.fontByStyle(style);
  219. return ctx.clientWidth;
  220. };
  221. this.drawHelper.measureTextFont = function(text, font) {
  222. ctx.innerText = text;
  223. ctx.style.font = font;
  224. return ctx.clientWidth;
  225. }
  226. }
  227. //statusBar
  228. this.statusBarClickable = this.drawHelper.statusBarClickable(this.statusBarTop, this.statusBarHeight);
  229. //parsed
  230. if (this.parsed) {
  231. let wideLine = wideLetter;
  232. if (!this.drawHelper.measureText(wideLine, {}))
  233. throw new Error('Ошибка measureText');
  234. while (this.drawHelper.measureText(wideLine, {}) < this.w) wideLine += wideLetter;
  235. this.parsed.setSettings({
  236. p: this.p,
  237. w: this.w,
  238. font: this.font,
  239. fontSize: this.fontSize,
  240. wordWrap: this.wordWrap,
  241. cutEmptyParagraphs: this.cutEmptyParagraphs,
  242. addEmptyParagraphs: this.addEmptyParagraphs,
  243. maxWordLength: wideLine.length - 1,
  244. lineHeight: this.lineHeight,
  245. showImages: this.showImages,
  246. showInlineImagesInCenter: this.showInlineImagesInCenter,
  247. imageHeightLines: this.imageHeightLines,
  248. imageFitWidth: this.imageFitWidth,
  249. compactTextPerc: this.compactTextPerc,
  250. testWidth: 0,
  251. measureText: this.drawHelper.measureText.bind(this.drawHelper),
  252. });
  253. }
  254. //scrolling page
  255. const pageSpace = this.scrollHeight - this.pageRowsCount*this.lineHeight;
  256. let top = pageSpace/2;
  257. if (this.showStatusBar)
  258. top += this.statusBarHeight*(this.statusBarTop ? 1 : 0);
  259. let page1 = this.$refs.scrollBox1.style;
  260. let page2 = this.$refs.scrollBox2.style;
  261. page1.perspective = page2.perspective = '3072px';
  262. page1.width = page2.width = this.boxW + this.indentLR + 'px';
  263. page1.height = page2.height = this.scrollHeight - (pageSpace > 0 ? pageSpace : 0) + 'px';
  264. page1.top = page2.top = top + 'px';
  265. page1.left = page2.left = this.indentLR + 'px';
  266. page1 = this.$refs.scrollingPage1.style;
  267. page2 = this.$refs.scrollingPage2.style;
  268. page1.width = page2.width = this.boxW + this.indentLR + 'px';
  269. page1.height = page2.height = this.scrollHeight + this.lineHeight + 'px';
  270. }
  271. async checkLoadedFonts() {
  272. let loaded = await Promise.all(this.fontList.map(font => document.fonts.check(font)));
  273. if (loaded.some(r => !r)) {
  274. await Promise.all(this.fontList.map(font => document.fonts.load(font)));
  275. }
  276. }
  277. async loadFonts() {
  278. this.fontsLoading = true;
  279. let close = null;
  280. (async() => {
  281. await utils.sleep(500);
  282. if (this.fontsLoading)
  283. close = this.$root.notify.info('Загрузка шрифта &nbsp;<i class="la la-snowflake icon-rotate" style="font-size: 150%"></i>');
  284. })();
  285. if (!this.fontsLoaded)
  286. this.fontsLoaded = {};
  287. //загрузка дин.шрифта
  288. const loaded = this.fontsLoaded[this.fontCssUrl];
  289. if (this.fontCssUrl && !loaded) {
  290. loadCSS(this.fontCssUrl);
  291. this.fontsLoaded[this.fontCssUrl] = 1;
  292. }
  293. try {
  294. await this.checkLoadedFonts();
  295. } catch (e) {
  296. this.$root.notify.error('Некоторые шрифты не удалось загрузить', 'Ошибка загрузки');
  297. }
  298. this.fontsLoading = false;
  299. if (close)
  300. close();
  301. }
  302. getSettings() {
  303. const settings = this.settings;
  304. for (let prop in rstore.settingDefaults) {
  305. this[prop] = settings[prop];
  306. }
  307. const wf = this.webFontName;
  308. const i = _.findIndex(rstore.webFonts, ['name', wf]);
  309. if (wf && i >= 0) {
  310. this.fontName = wf;
  311. this.fontCssUrl = rstore.webFonts[i].css;
  312. this.fontVertShift = settings.fontShifts[wf] || 0;
  313. }
  314. }
  315. async calcPropsAndLoadFonts(omitLoadFonts) {
  316. this.calcDrawProps();
  317. this.setBackground();
  318. if (!omitLoadFonts)
  319. await this.loadFonts();
  320. if (omitLoadFonts) {
  321. this.draw();
  322. } else {
  323. // ширина шрифта некоторое время выдается неверно,
  324. // не удалось событийно отловить этот момент, поэтому костыль
  325. while (this.checkingFont) {
  326. this.stopCheckingFont = true;
  327. await utils.sleep(100);
  328. }
  329. this.checkingFont = true;
  330. this.stopCheckingFont = false;
  331. try {
  332. const parsed = this.parsed;
  333. let i = 0;
  334. const t = 'Это тестовый текст. Его ширина выдается системой неправильно некоторое время.';
  335. let twprev = 0;
  336. //5 секунд проверяем изменения шрифта
  337. while (!this.stopCheckingFont && i++ < 50 && this.parsed === parsed) {
  338. const tw = this.drawHelper.measureText(t, {});
  339. if (tw !== twprev) {
  340. this.parsed.setSettings({testWidth: tw});
  341. this.draw();
  342. twprev = tw;
  343. }
  344. await utils.sleep(100);
  345. }
  346. } finally {
  347. this.checkingFont = false;
  348. }
  349. }
  350. }
  351. loadSettings() {
  352. (async() => {
  353. let fontName = this.fontName;
  354. this.getSettings();
  355. await this.calcPropsAndLoadFonts(fontName == this.fontName);
  356. })();
  357. }
  358. showBook() {
  359. this.$refs.main.focus();
  360. this.toggleLayout = false;
  361. this.updateLayout();
  362. this.book = null;
  363. this.meta = null;
  364. this.parsed = null;
  365. this.linesUp = null;
  366. this.linesDown = null;
  367. this.statusBarMessage = '';
  368. this.getSettings();
  369. this.calcDrawProps();
  370. this.draw();// пока не загрузили, очистим канвас
  371. if (this.lastBook) {
  372. (async() => {
  373. try {
  374. //подождем ленивый парсинг
  375. this.stopLazyParse = true;
  376. while (this.doingLazyParse) await utils.sleep(10);
  377. const isParsed = await bookManager.hasBookParsed(this.lastBook);
  378. if (!isParsed) {
  379. return;
  380. }
  381. this.book = await bookManager.getBook(this.lastBook);
  382. this.meta = bookManager.metaOnly(this.book);
  383. const bt = utils.getBookTitle(this.meta.fb2);
  384. this.title = bt.fullTitle;
  385. this.$root.setAppTitle(this.title);
  386. this.parsed = this.book.parsed;
  387. this.page1 = null;
  388. this.page2 = null;
  389. this.statusBar = null;
  390. await this.stopTextScrolling();
  391. await this.calcPropsAndLoadFonts();
  392. this.refreshTime();
  393. if (this.lazyParseEnabled)
  394. this.lazyParsePara();
  395. } catch (e) {
  396. this.$root.stdDialog.alert(e.message, 'Ошибка', {color: 'negative'});
  397. }
  398. })();
  399. }
  400. }
  401. updateLayout() {
  402. if (this.inAnimation) {
  403. this.$refs.scrollBox1.style.visibility = 'visible';
  404. this.$refs.scrollBox2.style.visibility = 'visible';
  405. } else if (this.toggleLayout) {
  406. this.$refs.scrollBox1.style.visibility = 'visible';
  407. this.$refs.scrollBox2.style.visibility = 'hidden';
  408. } else {
  409. this.$refs.scrollBox1.style.visibility = 'hidden';
  410. this.$refs.scrollBox2.style.visibility = 'visible';
  411. }
  412. }
  413. setBackground() {
  414. if (this.wallpaperIgnoreStatusBar) {
  415. this.background = `<div class="layout" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` +
  416. ` background-color: ${this.backgroundColor}">` +
  417. `<div class="layout ${this.wallpaper}" style="width: ${this.realWidth}px; height: ${this.scrollHeight}px; ` +
  418. `top: ${(this.showStatusBar && this.statusBarTop ? this.statusBarHeight + 1 : 0)}px; position: relative;">` +
  419. `</div>` +
  420. `</div>`;
  421. } else {
  422. this.background = `<div class="layout ${this.wallpaper}" style="width: ${this.realWidth}px; height: ${this.realHeight}px;` +
  423. ` background-color: ${this.backgroundColor}"></div>`;
  424. }
  425. }
  426. async onResize() {
  427. if (this.resizing)
  428. return;
  429. this.resizing = true;
  430. try {
  431. const scrolled = this.doingScrolling;
  432. if (scrolled)
  433. await this.stopTextScrolling();
  434. this.calcDrawProps();
  435. this.setBackground();
  436. this.draw();
  437. if (scrolled)
  438. this.startTextScrolling();
  439. } catch (e) {
  440. //
  441. } finally {
  442. this.resizing = false;
  443. }
  444. }
  445. get settings() {
  446. return this.$store.state.reader.settings;
  447. }
  448. get font() {
  449. return `${this.fontStyle} ${this.fontWeight} ${this.fontSize}px '${this.fontName}'`;
  450. }
  451. onPage1TransitionEnd() {
  452. if (this.resolveTransition1Finish)
  453. this.resolveTransition1Finish();
  454. }
  455. onPage2TransitionEnd() {
  456. if (this.resolveTransition2Finish)
  457. this.resolveTransition2Finish();
  458. }
  459. startSearch(needle) {
  460. this.drawHelper.needle = needle;
  461. this.drawHelper.searching = true;
  462. this.draw();
  463. }
  464. stopSearch() {
  465. this.drawHelper.searching = false;
  466. this.draw();
  467. }
  468. generateWaitingFunc(waitingHandlerName, stopPropertyName) {
  469. const func = (timeout) => {
  470. return new Promise((resolve, reject) => { (async() => {
  471. this[waitingHandlerName] = resolve;
  472. let wait = (timeout + 201)/100;
  473. while (wait > 0 && !this[stopPropertyName]) {
  474. wait--;
  475. await utils.sleep(100);
  476. }
  477. resolve();
  478. })().catch(reject); });
  479. };
  480. return func;
  481. }
  482. async startTextScrolling() {
  483. if (this.doingScrolling || !this.book || !this.parsed.textLength || !this.linesDown || this.pageLineCount < 1 ||
  484. this.linesDown.length <= this.pageLineCount || this.dualPageMode) {
  485. this.doStopScrolling();
  486. return;
  487. }
  488. //ждем анимацию
  489. while (this.inAnimation) await utils.sleep(10);
  490. this.stopScrolling = false;
  491. this.doingScrolling = true;
  492. const transitionFinish = this.generateWaitingFunc('resolveTransition1Finish', 'stopScrolling');
  493. if (!this.toggleLayout)
  494. this.page1 = this.page2;
  495. this.toggleLayout = true;
  496. await this.$nextTick();
  497. await utils.sleep(50);
  498. this.cachedPos = -1;
  499. this.draw();
  500. const page = this.$refs.scrollingPage1;
  501. let i = 0;
  502. while (!this.stopScrolling) {
  503. page.style.transition = `${this.scrollingDelay}ms ${this.scrollingType}`;
  504. page.style.transform = `translateY(-${this.lineHeight}px)`;
  505. if (i > 0) {
  506. this.doDown();
  507. if (this.linesDown.length <= this.pageLineCount + 1) {
  508. this.stopScrolling = true;
  509. }
  510. }
  511. await transitionFinish(this.scrollingDelay);
  512. page.style.transition = '';
  513. page.style.transform = 'none';
  514. page.offsetHeight;
  515. i++;
  516. }
  517. this.resolveTransition1Finish = null;
  518. this.doingScrolling = false;
  519. this.doStopScrolling();
  520. this.draw();
  521. }
  522. async stopTextScrolling() {
  523. this.stopScrolling = true;
  524. const page = this.$refs.scrollingPage1;
  525. page.style.transition = '';
  526. page.style.transform = 'none';
  527. page.offsetHeight;
  528. while (this.doingScrolling) await utils.sleep(10);
  529. }
  530. draw() {
  531. //scrolling
  532. if (this.doingScrolling) {
  533. this.currentAnimation = '';
  534. if (this.cachedPos == this.bookPos) {
  535. this.linesDown = this.linesCached.linesDown;
  536. this.linesUp = this.linesCached.linesUp;
  537. this.page1 = this.pageCached;
  538. } else {
  539. const lines = this.getLines(this.bookPos);
  540. this.linesDown = lines.linesDown;
  541. this.linesUp = lines.linesUp;
  542. this.page1 = this.drawHelper.drawPage(lines.linesDown, true);
  543. }
  544. //caching next
  545. if (this.cachedPageTimer)
  546. clearTimeout(this.cachedPageTimer);
  547. this.cachedPageTimer = setTimeout(() => {
  548. if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
  549. this.cachedPos = this.linesDown[1].begin;
  550. this.linesCached = this.getLines(this.cachedPos);
  551. this.pageCached = this.drawHelper.drawPage(this.linesCached.linesDown, true);
  552. }
  553. this.cachedPageTimer = null;
  554. }, 20);
  555. this.debouncedDrawStatusBar();
  556. return;
  557. }
  558. //check
  559. if (this.w < minLayoutWidth) {
  560. this.page1 = null;
  561. this.page2 = null;
  562. this.statusBar = null;
  563. return;
  564. }
  565. if (this.book && this.bookPos > 0 && this.bookPos >= this.parsed.textLength) {
  566. this.doEnd(true, false);
  567. return;
  568. }
  569. //fast draw prepared
  570. if (!this.pageChangeAnimation && this.pageChangeDirectionDown && this.pagePrepared && this.bookPos == this.bookPosPrepared) {
  571. this.toggleLayout = !this.toggleLayout;
  572. this.linesDown = this.linesDownNext;
  573. this.linesUp = this.linesUpNext;
  574. } else {//normal debounced draw
  575. const lines = this.getLines(this.bookPos);
  576. this.linesDown = lines.linesDown;
  577. this.linesUp = lines.linesUp;
  578. this.debouncedUpdatePage(lines.linesDown);
  579. }
  580. this.pagePrepared = false;
  581. if (!this.pageChangeAnimation)
  582. this.debouncedPrepareNextPage();
  583. this.debouncedDrawStatusBar();
  584. this.debouncedDrawPageDividerAndOrnament();
  585. if (this.book && this.linesDown && this.linesDown.length < this.pageLineCount) {
  586. this.doEnd(true, false);
  587. return;
  588. }
  589. }
  590. onPage1AnimationEnd() {
  591. if (this.resolveAnimation1Finish)
  592. this.resolveAnimation1Finish();
  593. }
  594. onPage2AnimationEnd() {
  595. if (this.resolveAnimation2Finish)
  596. this.resolveAnimation2Finish();
  597. }
  598. async doPageAnimation() {
  599. if (this.currentAnimation && !this.inAnimation) {
  600. this.inAnimation = true;
  601. const animation1Finish = this.generateWaitingFunc('resolveAnimation1Finish', 'stopAnimation');
  602. const animation2Finish = this.generateWaitingFunc('resolveAnimation2Finish', 'stopAnimation');
  603. const transition1Finish = this.generateWaitingFunc('resolveTransition1Finish', 'stopAnimation');
  604. const transition2Finish = this.generateWaitingFunc('resolveTransition2Finish', 'stopAnimation');
  605. const duration = Math.round(3000*(1 - this.pageChangeAnimationSpeed/100));
  606. let page1 = this.$refs.scrollingPage1;
  607. let page2 = this.$refs.scrollingPage2;
  608. switch (this.currentAnimation) {
  609. case 'thaw':
  610. await this.drawHelper.doPageAnimationThaw(page1, page2,
  611. duration, this.pageChangeDirectionDown, animation1Finish);
  612. break;
  613. case 'blink':
  614. await this.drawHelper.doPageAnimationBlink(page1, page2,
  615. duration, this.pageChangeDirectionDown, animation1Finish, animation2Finish);
  616. break;
  617. case 'rightShift':
  618. await this.drawHelper.doPageAnimationRightShift(page1, page2,
  619. duration, this.pageChangeDirectionDown, transition1Finish);
  620. break;
  621. case 'downShift':
  622. page1.style.height = this.scrollHeight + 'px';
  623. page2.style.height = this.scrollHeight + 'px';
  624. await this.drawHelper.doPageAnimationDownShift(page1, page2,
  625. duration, this.pageChangeDirectionDown, transition1Finish);
  626. page1.style.height = this.scrollHeight + this.lineHeight + 'px';
  627. page2.style.height = this.scrollHeight + this.lineHeight + 'px';
  628. break;
  629. case 'rotate':
  630. await this.drawHelper.doPageAnimationRotate(page1, page2,
  631. duration, this.pageChangeDirectionDown, transition1Finish, transition2Finish);
  632. break;
  633. case 'flip':
  634. await this.drawHelper.doPageAnimationFlip(page1, page2,
  635. duration, this.pageChangeDirectionDown, transition1Finish, transition2Finish, this.backgroundColor);
  636. break;
  637. }
  638. this.resolveAnimation1Finish = null;
  639. this.resolveAnimation2Finish = null;
  640. this.resolveTransition1Finish = null;
  641. this.resolveTransition2Finish = null;
  642. page1.style.animation = '';
  643. page2.style.animation = '';
  644. page1.style.transition = '';
  645. page1.style.transform = 'none';
  646. page1.offsetHeight;
  647. page2.style.transition = '';
  648. page2.style.transform = 'none';
  649. page2.offsetHeight;
  650. this.currentAnimation = '';
  651. this.pageChangeDirectionDown = false;//true только если PgDown
  652. this.inAnimation = false;
  653. this.stopAnimation = false;
  654. }
  655. }
  656. getLines(bookPos) {
  657. if (!this.parsed || this.pageLineCount < 1)
  658. return {};
  659. return {
  660. linesDown: this.parsed.getLines(bookPos, 2*this.pageLineCount),
  661. linesUp: this.parsed.getLines(bookPos, -2*this.pageLineCount)
  662. };
  663. }
  664. drawStatusBar(message) {
  665. if (this.w < minLayoutWidth) {
  666. this.statusBar = null;
  667. return;
  668. }
  669. if (this.showStatusBar && this.linesDown && this.pageLineCount > 0) {
  670. const lines = this.linesDown;
  671. let i = this.pageLineCount;
  672. if (this.keepLastToFirst)
  673. i--;
  674. i = (i > lines.length - 1 ? lines.length - 1 : i);
  675. if (i >= 0) {
  676. if (!message)
  677. message = this.statusBarMessage;
  678. if (!message)
  679. message = this.title;
  680. //check image num
  681. let imageNum = 0;
  682. const len = (lines.length > 2 ? 2 : lines.length);
  683. loop:
  684. for (let j = 0; j < len; j++) {
  685. const line = lines[j];
  686. for (const part of line.parts) {
  687. if (part.image) {
  688. imageNum = part.image.num;
  689. break loop;
  690. }
  691. }
  692. }
  693. //drawing
  694. this.statusBar = this.drawHelper.drawStatusBar(this.statusBarTop, this.statusBarHeight,
  695. lines[i].end, this.parsed.textLength, message, imageNum, this.parsed.images.length);
  696. this.bookPosSeen = lines[i].end;
  697. }
  698. } else {
  699. this.statusBar = '';
  700. }
  701. }
  702. drawPageDividerAndOrnament() {
  703. if (this.dualPageMode) {
  704. this.pageDivider = `<div class="layout" style="width: ${this.realWidth}px; height: ${this.scrollHeight}px; ` +
  705. `top: ${(this.showStatusBar && this.statusBarTop ? this.statusBarHeight + 1 : 0)}px; position: relative;">` +
  706. `<div class="fit row justify-center items-center no-wrap">` +
  707. `<div style="height: ${Math.round(this.scrollHeight*this.dualDivHeight/100)}px; width: ${this.dualDivWidth}px; ` +
  708. `box-shadow: 0 0 ${this.dualDivShadowWidth}px ${this.dualDivRgbaColor}; ` +
  709. `background-image: url(&quot;data:image/svg+xml;utf8,<svg width='100%' height='100%' xmlns='http://www.w3.org/2000/svg'>` +
  710. `<line x1='${this.dualDivWidth/2}' y1='0' x2='${this.dualDivWidth/2}' y2='100%' stroke='${this.dualDivRgbaColor}' ` +
  711. `stroke-width='${this.dualDivWidth}' stroke-dasharray='${this.dualDivStrokeFill} ${this.dualDivStrokeGap}'/>` +
  712. `</svg>&quot;);">` +
  713. `</div>` +
  714. `</div>` +
  715. `</div>`;
  716. } else {
  717. this.pageDivider = null;
  718. }
  719. }
  720. blinkCachedLoadMessage(state) {
  721. if (state === 'finish') {
  722. this.statusBarMessage = '';
  723. } else if (state) {
  724. this.statusBarMessage = 'Книга загружена из кэша';
  725. } else {
  726. this.statusBarMessage = ' ';
  727. }
  728. this.drawStatusBar();
  729. }
  730. async lazyParsePara() {
  731. if (!this.parsed || this.doingLazyParse)
  732. return;
  733. this.doingLazyParse = true;
  734. let j = 0;
  735. let k = 0;
  736. let prevPerc = 0;
  737. this.stopLazyParse = false;
  738. for (let i = 0; i < this.parsed.para.length; i++) {
  739. j++;
  740. if (j > 1) {
  741. await utils.sleep(1);
  742. j = 0;
  743. }
  744. if (this.stopLazyParse)
  745. break;
  746. this.parsed.parsePara(i);
  747. k++;
  748. if (k > 100) {
  749. let perc = Math.round(i/this.parsed.para.length*100);
  750. if (perc != prevPerc)
  751. this.drawStatusBar(`Обработка текста ${perc}%`);
  752. prevPerc = perc;
  753. k = 0;
  754. }
  755. }
  756. this.drawStatusBar();
  757. this.doingLazyParse = false;
  758. }
  759. async refreshTime() {
  760. if (!this.timeRefreshing) {
  761. this.timeRefreshing = true;
  762. await utils.sleep(60*1000);
  763. if (this.book && this.parsed.textLength) {
  764. this.debouncedDrawStatusBar();
  765. }
  766. this.timeRefreshing = false;
  767. this.refreshTime();
  768. }
  769. }
  770. prepareNextPage() {
  771. // подготовка следующей страницы заранее
  772. if (!this.book || !this.parsed.textLength || !this.linesDown || this.pageLineCount < 1)
  773. return;
  774. let i = this.pageLineCount;
  775. if (this.keepLastToFirst)
  776. i--;
  777. if (i >= 0 && this.linesDown.length > i) {
  778. this.bookPosPrepared = this.linesDown[i].begin;
  779. const lines = this.getLines(this.bookPosPrepared);
  780. this.linesDownNext = lines.linesDown;
  781. this.linesUpNext = lines.linesUp;
  782. if (this.toggleLayout)
  783. this.page2 = this.drawHelper.drawPage(lines.linesDown);//наоборот
  784. else
  785. this.page1 = this.drawHelper.drawPage(lines.linesDown);
  786. this.pagePrepared = true;
  787. }
  788. }
  789. doDown() {
  790. if (this.linesDown && this.linesDown.length > this.pageLineCount && this.pageLineCount > 0) {
  791. this.userBookPosChange = true;
  792. this.bookPos = this.linesDown[1].begin;
  793. }
  794. }
  795. doUp() {
  796. if (this.linesUp && this.linesUp.length > 1 && this.pageLineCount > 0) {
  797. this.userBookPosChange = true;
  798. this.bookPos = this.linesUp[1].begin;
  799. }
  800. }
  801. doPageDown() {
  802. if (this.linesDown && this.pageLineCount > 0) {
  803. let i = this.pageLineCount;
  804. if (this.keepLastToFirst)
  805. i--;
  806. if (i >= 0 && this.linesDown.length >= 2*i + (this.keepLastToFirst ? 1 : 0)) {
  807. this.currentAnimation = this.pageChangeAnimation;
  808. this.pageChangeDirectionDown = true;
  809. this.userBookPosChange = true;
  810. this.bookPos = this.linesDown[i].begin;
  811. } else
  812. this.doEnd();
  813. }
  814. }
  815. doPageUp() {
  816. if (this.linesUp && this.pageLineCount > 0) {
  817. let i = this.pageLineCount;
  818. if (this.keepLastToFirst)
  819. i--;
  820. i = (i > this.linesUp.length - 1 ? this.linesUp.length - 1 : i);
  821. if (i >= 0 && this.linesUp.length > i) {
  822. this.currentAnimation = this.pageChangeAnimation;
  823. this.pageChangeDirectionDown = false;
  824. this.userBookPosChange = true;
  825. this.bookPos = this.linesUp[i].begin;
  826. }
  827. }
  828. }
  829. doHome() {
  830. this.currentAnimation = this.pageChangeAnimation;
  831. this.pageChangeDirectionDown = false;
  832. this.userBookPosChange = true;
  833. this.bookPos = 0;
  834. }
  835. doEnd(noAni, isUser = true) {
  836. if (this.parsed.para.length && this.pageLineCount > 0) {
  837. let i = this.parsed.para.length - 1;
  838. let lastPos = this.parsed.para[i].offset + this.parsed.para[i].length - 1;
  839. const lines = this.parsed.getLines(lastPos, -this.pageLineCount);
  840. if (lines) {
  841. i = this.pageLineCount - 1;
  842. i = (i > lines.length - 1 ? lines.length - 1 : i);
  843. if (!noAni)
  844. this.currentAnimation = this.pageChangeAnimation;
  845. this.pageChangeDirectionDown = true;
  846. this.userBookPosChange = isUser;
  847. this.bookPos = lines[i].begin;
  848. }
  849. }
  850. }
  851. doToolBarToggle(event) {
  852. this.$emit('do-action', {action: 'switchToolbar', event});
  853. }
  854. doScrollingToggle() {
  855. this.$emit('do-action', {action: 'scrolling', event});
  856. }
  857. doFullScreenToggle() {
  858. this.$emit('do-action', {action: 'fullScreen', event});
  859. }
  860. doStopScrolling() {
  861. this.$emit('do-action', {action: 'stopScrolling', event});
  862. }
  863. async doFontSizeInc() {
  864. if (!this.settingsChanging) {
  865. this.settingsChanging = true;
  866. const newSize = (this.settings.fontSize + 1 < 200 ? this.settings.fontSize + 1 : 100);
  867. this.commit('reader/setSettings', {fontSize: newSize});
  868. await utils.sleep(50);
  869. this.settingsChanging = false;
  870. }
  871. }
  872. async doFontSizeDec() {
  873. if (!this.settingsChanging) {
  874. this.settingsChanging = true;
  875. const newSize = (this.settings.fontSize - 1 > 5 ? this.settings.fontSize - 1 : 5);
  876. this.commit('reader/setSettings', {fontSize: newSize});
  877. await utils.sleep(50);
  878. this.settingsChanging = false;
  879. }
  880. }
  881. async doScrollingSpeedUp() {
  882. if (!this.settingsChanging) {
  883. this.settingsChanging = true;
  884. const newDelay = (this.settings.scrollingDelay - 50 > 1 ? this.settings.scrollingDelay - 50 : 1);
  885. this.commit('reader/setSettings', {scrollingDelay: newDelay});
  886. await utils.sleep(50);
  887. this.settingsChanging = false;
  888. }
  889. }
  890. async doScrollingSpeedDown() {
  891. if (!this.settingsChanging) {
  892. this.settingsChanging = true;
  893. const newDelay = (this.settings.scrollingDelay + 50 < 10000 ? this.settings.scrollingDelay + 50 : 10000);
  894. this.commit('reader/setSettings', {scrollingDelay: newDelay});
  895. await utils.sleep(50);
  896. this.settingsChanging = false;
  897. }
  898. }
  899. async startClickRepeat(pointX, pointY) {
  900. this.repX = pointX;
  901. this.repY = pointY;
  902. if (!this.repInit && this.repDoing) {
  903. this.repInit = true;
  904. let delay = 400;
  905. while (this.repDoing) {
  906. this.handleClick(pointX, pointY);
  907. await utils.sleep(delay);
  908. if (delay > 15)
  909. delay *= 0.8;
  910. }
  911. this.repInit = false;
  912. }
  913. }
  914. endClickRepeat() {
  915. this.repDoing = false;
  916. }
  917. onTouchStart(event) {
  918. if (!this.$root.isMobileDevice)
  919. return;
  920. this.endClickRepeat();
  921. if (event.touches.length == 1) {
  922. const touch = event.touches[0];
  923. const rect = event.target.getBoundingClientRect();
  924. const x = touch.pageX - rect.left;
  925. const y = touch.pageY - rect.top;
  926. const hc = this.handleClick(x, y, new Set(['Menu']));
  927. if (hc) {
  928. if (hc != 'Menu') {
  929. this.repDoing = true;
  930. this.debouncedStartClickRepeat(x, y);
  931. } else {
  932. this.startTouch = {x, y};
  933. }
  934. }
  935. }
  936. }
  937. onTouchMove(event) {
  938. if (this.startTouch) {
  939. event.preventDefault();
  940. }
  941. }
  942. onTouchEnd(event) {
  943. if (!this.$root.isMobileDevice)
  944. return;
  945. this.endClickRepeat();
  946. if (event.changedTouches.length == 1) {
  947. const touch = event.changedTouches[0];
  948. const rect = event.target.getBoundingClientRect();
  949. const x = touch.pageX - rect.left;
  950. const y = touch.pageY - rect.top;
  951. if (this.startTouch) {
  952. const dy = this.startTouch.y - y;
  953. const dx = this.startTouch.x - x;
  954. const moveDelta = 30;
  955. const touchDelta = 15;
  956. if (dy > 0 && Math.abs(dy) >= moveDelta && Math.abs(dy) > Math.abs(dx)) {
  957. //движение вверх
  958. this.doFullScreenToggle();
  959. } else if (dy < 0 && Math.abs(dy) >= moveDelta && Math.abs(dy) > Math.abs(dx)) {
  960. //движение вниз
  961. this.doScrollingToggle();
  962. } else if (dx > 0 && Math.abs(dx) >= moveDelta && Math.abs(dy) < Math.abs(dx)) {
  963. //движение влево
  964. this.doScrollingSpeedDown();
  965. } else if (dx < 0 && Math.abs(dx) >= moveDelta && Math.abs(dy) < Math.abs(dx)) {
  966. //движение вправо
  967. this.doScrollingSpeedUp();
  968. } else if (Math.abs(dy) < touchDelta && Math.abs(dx) < touchDelta) {
  969. this.doToolBarToggle(event);
  970. }
  971. this.startTouch = null;
  972. }
  973. }
  974. }
  975. onTouchCancel() {
  976. if (!this.$root.isMobileDevice)
  977. return;
  978. this.endClickRepeat();
  979. }
  980. onMouseDown(event) {
  981. if (this.$root.isMobileDevice)
  982. return;
  983. this.endClickRepeat();
  984. if (event.button == 0) {
  985. const hc = this.handleClick(event.offsetX, event.offsetY);
  986. if (hc && hc != 'Menu') {
  987. this.repDoing = true;
  988. this.debouncedStartClickRepeat(event.offsetX, event.offsetY);
  989. }
  990. } else if (event.button == 1) {
  991. this.doScrollingToggle();
  992. } else if (event.button == 2) {
  993. this.doToolBarToggle(event);
  994. }
  995. }
  996. onMouseUp() {
  997. if (this.$root.isMobileDevice)
  998. return;
  999. this.endClickRepeat();
  1000. }
  1001. onMouseWheel(event) {
  1002. if (this.$root.isMobileDevice)
  1003. return;
  1004. if (event.deltaY > 0) {
  1005. this.doDown();
  1006. } else if (event.deltaY < 0) {
  1007. this.doUp();
  1008. }
  1009. }
  1010. onStatusBarClick() {
  1011. const url = this.meta.url;
  1012. if (url && url.indexOf('disk://') != 0) {
  1013. window.open(url, '_blank');
  1014. } else {
  1015. this.$root.stdDialog.alert('Оригинал недоступен, т.к. файл книги был загружен с локального диска.', ' ', {color: 'info'});
  1016. }
  1017. }
  1018. getClickAction(pointX, pointY) {
  1019. const w = pointX/this.realWidth*100;
  1020. const h = pointY/this.realHeight*100;
  1021. let action = '';
  1022. loops: {
  1023. for (const x in clickMap) {
  1024. for (const y in clickMap[x]) {
  1025. if (w < x && h < y) {
  1026. action = clickMap[x][y];
  1027. break loops;
  1028. }
  1029. }
  1030. }
  1031. }
  1032. return action;
  1033. }
  1034. handleClick(pointX, pointY, exclude) {
  1035. const action = this.getClickAction(pointX, pointY);
  1036. if (!exclude || !exclude.has(action)) {
  1037. switch (action) {
  1038. case 'Down' ://Down
  1039. this.doDown();
  1040. break;
  1041. case 'Up' ://Up
  1042. this.doUp();
  1043. break;
  1044. case 'PgDown' ://PgDown
  1045. this.doPageDown();
  1046. break;
  1047. case 'PgUp' ://PgUp
  1048. this.doPageUp();
  1049. break;
  1050. case 'Menu' :
  1051. this.doToolBarToggle();
  1052. break;
  1053. default :
  1054. // Nothing
  1055. }
  1056. }
  1057. return action;
  1058. }
  1059. copyText(event) {
  1060. //все это для того, чтобы правильно расставить переносы \n при копировании текста
  1061. //прямо с текущей страницы
  1062. //подготовка, вытаскиваем весь текст страницы
  1063. const lines = this.getLines(this.bookPos);
  1064. const decodedLines = [];
  1065. for (const line of lines.linesDown) {
  1066. let lineText = '';
  1067. for (const part of line.parts) {
  1068. lineText += part.text;
  1069. }
  1070. decodedLines.push({text: he.decode(lineText), first: line.first});
  1071. }
  1072. let i = 0;
  1073. const findDecoded = (line) => {
  1074. for (let j = i; j < decodedLines.length; j++) {
  1075. const decoded = decodedLines[j];
  1076. if (decoded.text.indexOf(line) >= 0) {
  1077. i = j;
  1078. return decoded;
  1079. }
  1080. }
  1081. return;
  1082. }
  1083. const selection = document.getSelection();
  1084. const splitted = selection.toString().split(/[\n\r]/);
  1085. let filtered = '';
  1086. //формируем filtered, учитывая переносы из decodedLines
  1087. for (const line of splitted) {
  1088. const found = findDecoded(line);
  1089. if (found && found.first) {
  1090. filtered += (filtered ? '\n' : '') + line;
  1091. } else {
  1092. filtered += (filtered ? '\r ' : '') + line;
  1093. }
  1094. }
  1095. //маленькие хитрости, убираем переносы по слогам
  1096. filtered = filtered.replace(/-\r /g, '').replace(/\r /g, ' ');
  1097. event.clipboardData.setData('text/plain', filtered);
  1098. }
  1099. }
  1100. export default vueComponent(TextPage);
  1101. //-----------------------------------------------------------------------------
  1102. </script>
  1103. <style scoped>
  1104. .main {
  1105. flex: 1;
  1106. margin: 0;
  1107. padding: 0;
  1108. overflow: hidden;
  1109. position: relative;
  1110. min-width: 200px;
  1111. }
  1112. .layout {
  1113. margin: 0;
  1114. padding: 0;
  1115. position: absolute;
  1116. z-index: 10;
  1117. }
  1118. .over-hidden {
  1119. overflow: hidden;
  1120. }
  1121. .on-top {
  1122. z-index: 100;
  1123. }
  1124. .back {
  1125. z-index: 5;
  1126. }
  1127. .events {
  1128. z-index: 20;
  1129. background-color: rgba(0,0,0,0);
  1130. }
  1131. </style>