ReaderDialogs.vue 7.4 KB

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