version.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <view class="version-info-page">
  3. <u-cell-group :border="false" customStyle="background:#ffffff">
  4. <u-cell title="当前版本号(正式版)" :value="userInfo.version || '无'" />
  5. <u-cell
  6. title="检测更新"
  7. :value="userInfo.updateStatus || '无'"
  8. :border="false"
  9. @click="checkForUpdates"
  10. />
  11. </u-cell-group>
  12. </view>
  13. </template>
  14. <script setup>
  15. import { reactive } from 'vue'
  16. const userInfo = reactive({
  17. version: 'v_2024050400_1', // Example version number
  18. updateStatus: '已经是新版本' // Example update status
  19. })
  20. function checkForUpdates() {
  21. // Simulate checking for updates
  22. setTimeout(() => {
  23. const newVersionAvailable = true; // Simulate a new version check
  24. if (newVersionAvailable) {
  25. userInfo.updateStatus = '发现新版本,正在下载...';
  26. downloadNewVersion();
  27. } else {
  28. userInfo.updateStatus = '已经是新版本';
  29. }
  30. }, 1000);
  31. }
  32. function downloadNewVersion() {
  33. // Simulate downloading the new version
  34. setTimeout(() => {
  35. userInfo.updateStatus = '下载完成,准备安装';
  36. // Add logic to install the new version if needed
  37. }, 2000);
  38. }
  39. </script>
  40. <style>
  41. .version-info-page {
  42. padding: 20rpx;
  43. border-radius: 20rpx;
  44. }
  45. </style>