ReaderDialogs.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <div>
  3. <Dialog ref="dialog1" v-model="whatsNewVisible">
  4. <template #header>
  5. Что нового:
  6. </template>
  7. <div style="line-height: 20px; min-width: 300px">
  8. <div v-html="whatsNewContent"></div>
  9. </div>
  10. <span class="clickable" style="font-size: 13px" @click="openVersionHistory">Посмотреть историю версий</span>
  11. <template #footer>
  12. <q-btn class="q-px-md" dense no-caps @click="whatsNewDisable">
  13. Больше не показывать
  14. </q-btn>
  15. </template>
  16. </Dialog>
  17. <Dialog ref="dialog2" v-model="donationVisible">
  18. <template #header>
  19. Здравствуйте, уважаемые читатели!
  20. </template>
  21. <div style="word-break: normal">
  22. Стартовала ежегодная акция "Оплатим хостинг вместе".<br><br>
  23. Для оплаты годового хостинга читалки, необходимо собрать около 2000 рублей.
  24. В настоящий момент у автора эта сумма есть в наличии. Однако будет справедливо, если каждый
  25. сможет проголосовать рублем за то, чтобы читалка так и оставалась:
  26. <ul>
  27. <li>непрерывно улучшаемой</li>
  28. <li>без рекламы</li>
  29. <li>без регистрации</li>
  30. <li>Open Source</li>
  31. </ul>
  32. Автор также обращается с просьбой о помощи в распространении
  33. <a href="https://omnireader.ru" target="_blank">ссылки</a>
  34. <q-icon class="copy-icon" name="la la-copy" @click="copyLink('https://omnireader.ru')">
  35. <q-tooltip :delay="1000" anchor="top middle" self="center middle" content-style="font-size: 80%">
  36. Скопировать
  37. </q-tooltip>
  38. </q-icon>
  39. на читалку через тематические форумы, соцсети, мессенджеры и пр.
  40. Чем нас больше, тем легче оставаться на плаву и тем больше мотивации у разработчика, чтобы продолжать работать над проектом.
  41. <br><br>
  42. Если соберется бóльшая сумма, то разработка децентрализованной библиотеки для свободного обмена книгами будет по возможности ускорена.
  43. <br><br>
  44. P.S. При необходимости можно воспользоваться подходящим обменником на <a href="https://www.bestchange.ru" target="_blank">bestchange.ru</a>
  45. <br><br>
  46. <div class="row justify-center">
  47. <!--q-btn class="q-px-sm" color="primary" dense no-caps rounded @click="openDonate">
  48. Помочь проекту
  49. </q-btn-->
  50. </div>
  51. </div>
  52. <template #footer>
  53. <span class="clickable row justify-end" style="font-size: 60%; color: grey" @click="donationDialogDisable">Больше не показывать</span>
  54. <br>
  55. <q-btn class="q-px-sm" dense no-caps @click="donationDialogRemind">
  56. Напомнить позже
  57. </q-btn>
  58. </template>
  59. </Dialog>
  60. <Dialog ref="dialog3" v-model="urlHelpVisible">
  61. <template #header>
  62. Обнаружена невалидная ссылка в поле "URL книги".
  63. <br>
  64. </template>
  65. <div style="word-break: normal">
  66. Если вы хотите найти определенную книгу и открыть в читалке, добро пожаловать в
  67. раздел "Сетевая библиотека" (кнопка <q-icon name="la la-sitemap" size="32px" />) на сайте
  68. <a href="https://liberama.top" target="_blank">liberama.top</a>
  69. <br><br>
  70. Если же вы пытаетесь вставить текст в читалку из буфера обмена, пожалуйста воспользуйтесь кнопкой
  71. <q-btn no-caps dense class="q-px-sm" color="primary" size="13px" @click="loadBufferClick">
  72. Из буфера обмена
  73. </q-btn>
  74. на странице загрузки.
  75. </div>
  76. </Dialog>
  77. </div>
  78. </template>
  79. <script>
  80. //-----------------------------------------------------------------------------
  81. import vueComponent from '../../vueComponent.js';
  82. import Dialog from '../../share/Dialog.vue';
  83. import * as utils from '../../../share/utils';
  84. import {versionHistory} from '../versionHistory';
  85. const componentOptions = {
  86. components: {
  87. Dialog
  88. },
  89. watch: {
  90. settings: function() {
  91. this.loadSettings();
  92. },
  93. },
  94. };
  95. class ReaderDialogs {
  96. _options = componentOptions;
  97. whatsNewVisible = false;
  98. whatsNewContent = '';
  99. donationVisible = false;
  100. urlHelpVisible = false;
  101. created() {
  102. this.commit = this.$store.commit;
  103. this.loadSettings();
  104. }
  105. mounted() {
  106. }
  107. async init() {
  108. await this.showWhatsNew();
  109. await this.showDonation();
  110. }
  111. loadSettings() {
  112. const settings = this.settings;
  113. this.showWhatsNewDialog = settings.showWhatsNewDialog;
  114. this.showDonationDialog2020 = settings.showDonationDialog2020;
  115. }
  116. async showWhatsNew() {
  117. const whatsNew = versionHistory[0];
  118. if (this.showWhatsNewDialog &&
  119. whatsNew.showUntil >= utils.formatDate(new Date(), 'coDate') &&
  120. this.whatsNewHeader != this.whatsNewContentHash) {
  121. await utils.sleep(2000);
  122. this.whatsNewContent = 'Версия ' + this.whatsNewHeader + whatsNew.content;
  123. this.whatsNewVisible = true;
  124. }
  125. }
  126. async showDonation() {
  127. const today = utils.formatDate(new Date(), 'coDate');
  128. if ((this.mode == 'omnireader' || this.mode == 'liberama.top') && today < '2020-03-01' && this.showDonationDialog2020 && this.donationRemindDate != today) {
  129. await utils.sleep(3000);
  130. this.donationVisible = true;
  131. }
  132. }
  133. async showUrlHelp() {
  134. this.urlHelpVisible = true;
  135. }
  136. loadBufferClick() {
  137. this.urlHelpVisible = false;
  138. }
  139. donationDialogDisable() {
  140. this.donationVisible = false;
  141. if (this.showDonationDialog2020) {
  142. this.commit('reader/setSettings', { showDonationDialog2020: false });
  143. }
  144. }
  145. donationDialogRemind() {
  146. this.donationVisible = false;
  147. this.commit('reader/setDonationRemindDate', utils.formatDate(new Date(), 'coDate'));
  148. }
  149. openDonate() {
  150. this.donationVisible = false;
  151. this.$emit('donate-toggle');
  152. }
  153. async copyLink(link) {
  154. const result = await utils.copyTextToClipboard(link);
  155. if (result)
  156. this.$root.notify.success(`Ссылка ${link} успешно скопирована в буфер обмена`);
  157. else
  158. this.$root.notify.error('Копирование не удалось');
  159. }
  160. openVersionHistory() {
  161. this.whatsNewVisible = false;
  162. this.$emit('version-history-toggle');
  163. }
  164. whatsNewDisable() {
  165. this.whatsNewVisible = false;
  166. this.commit('reader/setWhatsNewContentHash', this.whatsNewHeader);
  167. }
  168. get whatsNewHeader() {
  169. return `${versionHistory[0].version} (${versionHistory[0].releaseDate})`;
  170. }
  171. get mode() {
  172. return this.$store.state.config.mode;
  173. }
  174. get settings() {
  175. return this.$store.state.reader.settings;
  176. }
  177. get whatsNewContentHash() {
  178. return this.$store.state.reader.whatsNewContentHash;
  179. }
  180. get donationRemindDate() {
  181. return this.$store.state.reader.donationRemindDate;
  182. }
  183. keyHook() {
  184. if (this.$refs.dialog1.active || this.$refs.dialog2.active || this.$refs.dialog3.active)
  185. return true;
  186. return false;
  187. }
  188. }
  189. export default vueComponent(ReaderDialogs);
  190. //-----------------------------------------------------------------------------
  191. </script>
  192. <style scoped>
  193. .clickable {
  194. color: blue;
  195. text-decoration: underline;
  196. cursor: pointer;
  197. }
  198. .copy-icon {
  199. cursor: pointer;
  200. font-size: 120%;
  201. color: blue;
  202. }
  203. </style>