setting.vue 2.2 KB

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