app-update-sheet.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view v-if="visible" class="upd-mask" @tap.stop="onMaskTap">
  3. <view class="upd-sheet" @tap.stop>
  4. <view class="upd-head">
  5. <view class="upd-head-icon-wrap">
  6. <text class="upd-head-icon">↑</text>
  7. </view>
  8. <view class="upd-head-text">
  9. <text class="upd-title">{{ meta.title || copy.title }}</text>
  10. <text class="upd-version">{{ copy.latest }} {{ meta.versionName || '' }}</text>
  11. </view>
  12. </view>
  13. <scroll-view scroll-y class="upd-body">
  14. <rich-text class="upd-content" :nodes="meta.content || ''" />
  15. </scroll-view>
  16. <view v-if="download.start" class="upd-progress-wrap">
  17. <view class="upd-progress-bar">
  18. <view class="upd-progress-fill" :style="{ width: download.progress + '%' }" />
  19. </view>
  20. <text class="upd-progress-txt">{{ download.progress }}%</text>
  21. <text class="upd-progress-sub">
  22. {{ copy.downloading }}
  23. </text>
  24. </view>
  25. <view v-else-if="download.install" class="upd-install">
  26. <text class="upd-install-txt">{{ copy.installing }}</text>
  27. </view>
  28. <view v-else class="upd-actions">
  29. <button
  30. v-if="!enforce"
  31. class="upd-btn upd-btn--ghost"
  32. @tap="onIgnore"
  33. >
  34. <text class="upd-btn-txt">{{ copy.ignore }}</text>
  35. </button>
  36. <button class="upd-btn upd-btn--primary" @tap="onDownload">
  37. <text class="upd-btn-txt upd-btn-txt--light">{{ copy.updateNow }}</text>
  38. </button>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import { mapState } from 'vuex'
  45. export default {
  46. name: 'AppUpdateSheet',
  47. computed: {
  48. ...mapState('release', {
  49. visible: (state) => state.visible,
  50. meta: (state) => state.meta,
  51. download: (state) => state.download,
  52. link: (state) => state.link
  53. }),
  54. enforce() {
  55. return Number(this.meta && this.meta.enforce) === 1
  56. },
  57. copy() {
  58. const t = this.$t.bind(this)
  59. return {
  60. title: t('update.title'),
  61. latest: t('update.latest'),
  62. ignore: t('update.ignore'),
  63. updateNow: t('update.updateNow'),
  64. installing: t('update.installing'),
  65. downloading: t('update.downloading')
  66. }
  67. }
  68. },
  69. methods: {
  70. onMaskTap() {
  71. if (this.enforce) return
  72. this.onIgnore()
  73. },
  74. onIgnore() {
  75. this.$store.dispatch('release/ignore')
  76. },
  77. onDownload() {
  78. if (!this.link || !this.link.url) {
  79. this.$appKit.msg(this.copy.updateNow)
  80. return
  81. }
  82. this.$store.dispatch('release/startDownload')
  83. }
  84. }
  85. }
  86. </script>
  87. <style scoped>
  88. .upd-mask {
  89. position: fixed;
  90. left: 0;
  91. right: 0;
  92. top: 0;
  93. bottom: 0;
  94. z-index: 9999;
  95. background: rgba(15, 23, 42, 0.45);
  96. display: flex;
  97. align-items: center;
  98. justify-content: center;
  99. padding: 48rpx 40rpx;
  100. box-sizing: border-box;
  101. }
  102. .upd-sheet {
  103. width: 100%;
  104. max-width: 640rpx;
  105. background: #ffffff;
  106. border-radius: 28rpx;
  107. overflow: hidden;
  108. box-shadow: 0 24rpx 64rpx rgba(74, 140, 255, 0.18);
  109. }
  110. .upd-head {
  111. display: flex;
  112. flex-direction: row;
  113. align-items: center;
  114. padding: 32rpx 32rpx 20rpx;
  115. background: linear-gradient(135deg, #4a8cff 0%, #6b5cff 100%);
  116. }
  117. .upd-head-icon-wrap {
  118. width: 88rpx;
  119. height: 88rpx;
  120. border-radius: 24rpx;
  121. background: rgba(255, 255, 255, 0.2);
  122. display: flex;
  123. align-items: center;
  124. justify-content: center;
  125. margin-right: 20rpx;
  126. flex-shrink: 0;
  127. }
  128. .upd-head-icon {
  129. font-size: 44rpx;
  130. color: #ffffff;
  131. font-weight: 700;
  132. line-height: 1;
  133. }
  134. .upd-head-text {
  135. flex: 1;
  136. min-width: 0;
  137. }
  138. .upd-title {
  139. display: block;
  140. font-size: 32rpx;
  141. font-weight: 700;
  142. color: #ffffff;
  143. margin-bottom: 8rpx;
  144. }
  145. .upd-version {
  146. display: block;
  147. font-size: 24rpx;
  148. color: rgba(255, 255, 255, 0.88);
  149. }
  150. .upd-body {
  151. max-height: 360rpx;
  152. padding: 24rpx 32rpx 8rpx;
  153. box-sizing: border-box;
  154. }
  155. .upd-content {
  156. font-size: 28rpx;
  157. line-height: 1.55;
  158. color: #4b5563;
  159. }
  160. .upd-progress-wrap {
  161. padding: 8rpx 32rpx 32rpx;
  162. }
  163. .upd-progress-bar {
  164. height: 12rpx;
  165. border-radius: 6rpx;
  166. background: #eef1f6;
  167. overflow: hidden;
  168. margin-bottom: 12rpx;
  169. }
  170. .upd-progress-fill {
  171. height: 100%;
  172. background: linear-gradient(90deg, #4a8cff 0%, #6b5cff 100%);
  173. border-radius: 6rpx;
  174. }
  175. .upd-progress-txt {
  176. display: block;
  177. font-size: 26rpx;
  178. color: #1a1d26;
  179. font-weight: 600;
  180. text-align: center;
  181. }
  182. .upd-progress-sub {
  183. display: block;
  184. margin-top: 8rpx;
  185. font-size: 24rpx;
  186. color: #8a8d9e;
  187. text-align: center;
  188. }
  189. .upd-install {
  190. padding: 24rpx 32rpx 36rpx;
  191. text-align: center;
  192. }
  193. .upd-install-txt {
  194. font-size: 28rpx;
  195. color: #4a8cff;
  196. }
  197. .upd-actions {
  198. display: flex;
  199. flex-direction: row;
  200. padding: 16rpx 32rpx 32rpx;
  201. box-sizing: border-box;
  202. }
  203. .upd-btn {
  204. flex: 1;
  205. margin-right: 20rpx;
  206. height: 88rpx;
  207. line-height: 88rpx;
  208. border-radius: 44rpx;
  209. margin: 0;
  210. padding: 0;
  211. border: none;
  212. }
  213. .upd-btn::after {
  214. border: none;
  215. }
  216. .upd-btn--ghost {
  217. background: #f0f3f8;
  218. }
  219. .upd-btn--primary {
  220. background: linear-gradient(135deg, #4a8cff 0%, #6b5cff 100%);
  221. box-shadow: 0 10rpx 28rpx rgba(74, 140, 255, 0.28);
  222. margin-right: 0;
  223. }
  224. .upd-btn-txt {
  225. font-size: 30rpx;
  226. font-weight: 600;
  227. color: #4b5563;
  228. }
  229. .upd-btn-txt--light {
  230. color: #ffffff;
  231. }
  232. </style>