ReaderDialogs.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. const whatsNew = versionHistory[0];
  90. if (this.showWhatsNewDialog &&
  91. whatsNew.showUntil >= utils.formatDate(new Date(), 'coDate') &&
  92. whatsNew.header != this.whatsNewContentHash) {
  93. await utils.sleep(2000);
  94. this.whatsNewContent = 'Версия ' + whatsNew.header + whatsNew.content;
  95. this.whatsNewVisible = true;
  96. }
  97. }
  98. async showDonation() {
  99. const today = utils.formatDate(new Date(), 'coDate');
  100. if ((this.mode == 'omnireader' || this.mode == 'liberama.top') && today < '2020-03-01' && this.showDonationDialog2020 && this.donationRemindDate != today) {
  101. await utils.sleep(3000);
  102. this.donationVisible = true;
  103. }
  104. }
  105. donationDialogDisable() {
  106. this.donationVisible = false;
  107. if (this.showDonationDialog2020) {
  108. this.commit('reader/setSettings', { showDonationDialog2020: false });
  109. }
  110. }
  111. donationDialogRemind() {
  112. this.donationVisible = false;
  113. this.commit('reader/setDonationRemindDate', utils.formatDate(new Date(), 'coDate'));
  114. }
  115. openDonate() {
  116. this.donationVisible = false;
  117. this.$emit('donate-toggle');
  118. }
  119. async copyLink(link) {
  120. const result = await utils.copyTextToClipboard(link);
  121. if (result)
  122. this.$root.notify.success(`Ссылка ${link} успешно скопирована в буфер обмена`);
  123. else
  124. this.$root.notify.error('Копирование не удалось');
  125. }
  126. openVersionHistory() {
  127. this.whatsNewVisible = false;
  128. this.$emit('version-history-toggle');
  129. }
  130. whatsNewDisable() {
  131. this.whatsNewVisible = false;
  132. const whatsNew = versionHistory[0];
  133. this.commit('reader/setWhatsNewContentHash', whatsNew.header);
  134. }
  135. get mode() {
  136. return this.$store.state.config.mode;
  137. }
  138. get settings() {
  139. return this.$store.state.reader.settings;
  140. }
  141. get whatsNewContentHash() {
  142. return this.$store.state.reader.whatsNewContentHash;
  143. }
  144. get donationRemindDate() {
  145. return this.$store.state.reader.donationRemindDate;
  146. }
  147. keyHook() {
  148. if (this.$refs.dialog1.active || this.$refs.dialog2.active)
  149. return true;
  150. return false;
  151. }
  152. }
  153. //-----------------------------------------------------------------------------
  154. </script>
  155. <style scoped>
  156. .clickable {
  157. color: blue;
  158. text-decoration: underline;
  159. cursor: pointer;
  160. }
  161. .copy-icon {
  162. cursor: pointer;
  163. font-size: 120%;
  164. color: blue;
  165. }
  166. </style>