ReaderDialogs.vue 7.6 KB

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