setting.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <!-- index.vue -->
  2. <template>
  3. <view class="container">
  4. <!-- 列表区域 -->
  5. <view class="list-item" @click="pwdEdit">
  6. <view>
  7. <uni-icons type="locked" 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" size="20"></uni-icons>
  22. <text>清理缓存</text>
  23. </view>
  24. <text>></text>
  25. </view>
  26. <!-- 退出登录按钮 -->
  27. <view class="uni-padding-wrap uni-common-mt">
  28. <button type="warn" @click="logOut">退出登录</button>
  29. </view>
  30. </view>
  31. </template>
  32. <script setup>
  33. import $tab from "@/plugins/tab.js"
  34. import { useUserStore } from '@/store/user.js'
  35. const userStore = useUserStore()
  36. // 退出登录
  37. function logOut() {
  38. uni.showModal({
  39. title: '系统提示',
  40. content: '确定注销并退出系统吗?',
  41. success: function(res) {
  42. if (res.confirm) {
  43. userStore.LogOut()
  44. $tab.reLaunch('/pages/login')
  45. } else if (res.cancel) {
  46. console.log('用户点击取消');
  47. }
  48. }
  49. });
  50. };
  51. // 清理缓存
  52. function clearCache() {
  53. uni.showModal({
  54. title: '系统提示',
  55. content: '是否确定要清理缓存?',
  56. success: function(res) {
  57. if (res.confirm) {
  58. uni.clearStorageSync();
  59. // 提示用户缓存清理成功
  60. uni.showToast({
  61. title: '缓存清理成功',
  62. icon: 'success',
  63. duration: 2000
  64. });
  65. } else if (res.cancel) {
  66. console.log('用户点击取消');
  67. }
  68. }
  69. });
  70. }
  71. // 修改密码
  72. function pwdEdit() {
  73. $tab.navigateTo('/pages/mine/setting/pwdEdit/pwdEdit');
  74. };
  75. // 检查更新
  76. function checkUpdate() {
  77. const updateManager = uni.getUpdateManager();
  78. updateManager.onCheckForUpdate(function(res) {
  79. // 请求完新版本信息的回调
  80. if (res.hasUpdate) {
  81. updateManager.onUpdateReady(function(res) {
  82. uni.showModal({
  83. title: '更新提示',
  84. content: '新版本已经准备好,是否重启应用?',
  85. success(res) {
  86. if (res.confirm) {
  87. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  88. updateManager.applyUpdate();
  89. }
  90. }
  91. });
  92. });
  93. } else {
  94. uni.showToast({
  95. title: '暂无版本更新',
  96. icon: 'none'
  97. });
  98. }
  99. });
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .container {
  104. padding: 20px;
  105. }
  106. .list-item {
  107. display: flex;
  108. align-items: center;
  109. justify-content: space-between;
  110. height: 50px;
  111. border-bottom: 1px solid #eee;
  112. font-size: 16px;
  113. }
  114. </style>