ReaderDialogs.vue 7.3 KB

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