ReaderDialogs.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 @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. <q-icon class="q-mr-xs" name="la la-comment" size="24px" />
  73. Из буфера обмена
  74. </q-btn>
  75. на странице загрузки.
  76. </div>
  77. </Dialog>
  78. </div>
  79. </template>
  80. <script>
  81. //-----------------------------------------------------------------------------
  82. import vueComponent from '../../vueComponent.js';
  83. import Dialog from '../../share/Dialog.vue';
  84. import * as utils from '../../../share/utils';
  85. import {versionHistory} from '../versionHistory';
  86. const componentOptions = {
  87. components: {
  88. Dialog
  89. },
  90. watch: {
  91. settings: function() {
  92. this.loadSettings();
  93. },
  94. },
  95. };
  96. class ReaderDialogs {
  97. _options = componentOptions;
  98. whatsNewVisible = false;
  99. whatsNewContent = '';
  100. donationVisible = false;
  101. urlHelpVisible = false;
  102. created() {
  103. this.commit = this.$store.commit;
  104. this.loadSettings();
  105. }
  106. mounted() {
  107. }
  108. async init() {
  109. await this.showWhatsNew();
  110. await this.showDonation();
  111. }
  112. loadSettings() {
  113. const settings = this.settings;
  114. this.showWhatsNewDialog = settings.showWhatsNewDialog;
  115. this.showDonationDialog2020 = settings.showDonationDialog2020;
  116. }
  117. async showWhatsNew() {
  118. const whatsNew = versionHistory[0];
  119. if (this.showWhatsNewDialog &&
  120. whatsNew.showUntil >= utils.formatDate(new Date(), 'coDate') &&
  121. this.whatsNewHeader != this.whatsNewContentHash) {
  122. await utils.sleep(2000);
  123. this.whatsNewContent = 'Версия ' + this.whatsNewHeader + whatsNew.content;
  124. this.whatsNewVisible = true;
  125. }
  126. }
  127. async showDonation() {
  128. const today = utils.formatDate(new Date(), 'coDate');
  129. if ((this.mode == 'omnireader' || this.mode == 'liberama.top') && today < '2020-03-01' && this.showDonationDialog2020 && this.donationRemindDate != today) {
  130. await utils.sleep(3000);
  131. this.donationVisible = true;
  132. }
  133. }
  134. async showUrlHelp() {
  135. this.urlHelpVisible = true;
  136. }
  137. loadBufferClick() {
  138. this.$emit('load-buffer-toggle');
  139. this.urlHelpVisible = false;
  140. }
  141. donationDialogDisable() {
  142. this.donationVisible = false;
  143. if (this.showDonationDialog2020) {
  144. this.commit('reader/setSettings', { showDonationDialog2020: false });
  145. }
  146. }
  147. donationDialogRemind() {
  148. this.donationVisible = false;
  149. this.commit('reader/setDonationRemindDate', utils.formatDate(new Date(), 'coDate'));
  150. }
  151. openDonate() {
  152. this.donationVisible = false;
  153. this.$emit('donate-toggle');
  154. }
  155. async copyLink(link) {
  156. const result = await utils.copyTextToClipboard(link);
  157. if (result)
  158. this.$root.notify.success(`Ссылка ${link} успешно скопирована в буфер обмена`);
  159. else
  160. this.$root.notify.error('Копирование не удалось');
  161. }
  162. openVersionHistory() {
  163. this.whatsNewVisible = false;
  164. this.$emit('version-history-toggle');
  165. }
  166. whatsNewDisable() {
  167. this.whatsNewVisible = false;
  168. this.commit('reader/setWhatsNewContentHash', this.whatsNewHeader);
  169. }
  170. get whatsNewHeader() {
  171. return `${versionHistory[0].version} (${versionHistory[0].releaseDate})`;
  172. }
  173. get mode() {
  174. return this.$store.state.config.mode;
  175. }
  176. get settings() {
  177. return this.$store.state.reader.settings;
  178. }
  179. get whatsNewContentHash() {
  180. return this.$store.state.reader.whatsNewContentHash;
  181. }
  182. get donationRemindDate() {
  183. return this.$store.state.reader.donationRemindDate;
  184. }
  185. keyHook() {
  186. if (this.$refs.dialog1.active || this.$refs.dialog2.active || this.$refs.dialog3.active)
  187. return true;
  188. return false;
  189. }
  190. }
  191. export default vueComponent(ReaderDialogs);
  192. //-----------------------------------------------------------------------------
  193. </script>
  194. <style scoped>
  195. .clickable {
  196. color: blue;
  197. text-decoration: underline;
  198. cursor: pointer;
  199. }
  200. .copy-icon {
  201. cursor: pointer;
  202. font-size: 120%;
  203. color: blue;
  204. }
  205. </style>