setting.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <!-- index.vue -->
  2. <template>
  3. <page-meta root-font-size="system" />
  4. <view class="container">
  5. <!-- 列表区域 -->
  6. <view class="list-item" @click="pwdEdit">
  7. <view>
  8. <uni-icons type="locked-filled" size="20"></uni-icons>
  9. <text>修改密码</text>
  10. </view>
  11. <text class="desc"></text>
  12. </view>
  13. <view class="list-item" @click="checkUpdate">
  14. <view>
  15. <uni-icons type="refreshempty" size="20"></uni-icons>
  16. <text>检查更新</text>
  17. </view>
  18. <text class="desc"></text>
  19. </view>
  20. <view class="list-item" @click="clearCache">
  21. <view>
  22. <uni-icons type="trash-filled" size="20"></uni-icons>
  23. <text>清理缓存</text>
  24. </view>
  25. <text class="desc"></text>
  26. </view>
  27. <!-- 退出登录按钮 -->
  28. <view class="logOut">
  29. <button type="warn" @click="logOut">退出登录</button>
  30. </view>
  31. </view>
  32. </template>
  33. <script setup lang="ts">
  34. import $tab from "@/plugins/tab.js"
  35. import $modal from '@/plugins/modal.js'
  36. import { useUserStore } from '@/store/user.js'
  37. import { clearCache } from '@/utils/ygoa.js'
  38. const userStore = useUserStore()
  39. // 退出登录
  40. function logOut() {
  41. $modal.confirm('确定注销并退出系统吗?')
  42. .then(res => {
  43. userStore.LogOut()
  44. $tab.reLaunch('/pages/login')
  45. }).catch(() => { })
  46. };
  47. // 修改密码
  48. function pwdEdit() {
  49. $tab.navigateTo('/pages/mine/setting/pwdEdit/pwdEdit');
  50. };
  51. // 检查更新
  52. function checkUpdate() {
  53. const updateManager = uni.getUpdateManager();
  54. updateManager.onCheckForUpdate(function (res) {
  55. // 请求完新版本信息的回调
  56. if (res.hasUpdate) {
  57. updateManager.onUpdateReady(function (res) {
  58. $modal.confirm('新版本已经准备好,是否重启应用?', '更新提示').then(res => {
  59. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  60. updateManager.applyUpdate();
  61. }).catch(() => { })
  62. });
  63. } else {
  64. $modal.showToast('暂无版本更新')
  65. }
  66. });
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .container {
  71. padding: 20px;
  72. }
  73. .list-item {
  74. color: #666;
  75. display: flex;
  76. align-items: center;
  77. justify-content: space-between;
  78. font-size: calc(1rem + 0px);
  79. padding: 0.75rem;
  80. background-color: #ffffff;
  81. border-radius: 10rpx;
  82. margin-bottom: 0.75rem;
  83. border-bottom: 1px solid gainsboro;
  84. ::v-deep .uni-icons {
  85. font-size: calc(1.25rem + 0px) !important;
  86. margin-right: 6px;
  87. }
  88. }
  89. .logOut {
  90. margin-top: 2rem;
  91. button {
  92. font-size: calc(18px + .5*(1rem - 16px));
  93. }
  94. }
  95. .desc {
  96. color: #777;
  97. margin-right: 0.5rem;
  98. }
  99. .desc::after {
  100. content: ">";
  101. }
  102. </style>