| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <!-- index.vue -->
- <template>
- <view class="container">
- <!-- 列表区域 -->
- <view class="list-item" @click="pwdEdit">
- <view>
- <uni-icons type="locked" size="20"></uni-icons>
- <text>修改密码</text>
- </view>
- <text>></text>
- </view>
- <view class="list-item" @click="checkUpdate">
- <view>
- <uni-icons type="refreshempty" size="20"></uni-icons>
- <text>检查更新</text>
- </view>
- <text>></text>
- </view>
- <view class="list-item" @click="clearCache">
- <view>
- <uni-icons type="trash" size="20"></uni-icons>
- <text>清理缓存</text>
- </view>
- <text>></text>
- </view>
- <!-- 退出登录按钮 -->
- <view class="uni-padding-wrap uni-common-mt">
- <button type="warn" @click="logOut">退出登录</button>
- </view>
- </view>
- </template>
- <script setup>
- import $tab from "@/plugins/tab.js"
- import { useUserStore } from '@/store/user.js'
- const userStore = useUserStore()
- // 退出登录
- function logOut() {
- uni.showModal({
- title: '系统提示',
- content: '确定注销并退出系统吗?',
- success: function(res) {
- if (res.confirm) {
- userStore.LogOut()
- $tab.reLaunch('/pages/login')
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- };
- // 清理缓存
- function clearCache() {
- uni.showModal({
- title: '系统提示',
- content: '是否确定要清理缓存?',
- success: function(res) {
- if (res.confirm) {
- uni.clearStorageSync();
- // 提示用户缓存清理成功
- uni.showToast({
- title: '缓存清理成功',
- icon: 'success',
- duration: 2000
- });
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- }
- // 修改密码
- function pwdEdit() {
- $tab.navigateTo('/pages/mine/setting/pwdEdit/pwdEdit');
- };
- // 检查更新
- function checkUpdate() {
- const updateManager = uni.getUpdateManager();
- updateManager.onCheckForUpdate(function(res) {
- // 请求完新版本信息的回调
- if (res.hasUpdate) {
- updateManager.onUpdateReady(function(res) {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate();
- }
- }
- });
- });
- } else {
- uni.showToast({
- title: '暂无版本更新',
- icon: 'none'
- });
- }
- });
- }
- </script>
- <style lang="scss" scoped>
- .container {
- padding: 20px;
- }
- .list-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 50px;
- border-bottom: 1px solid #eee;
- font-size: 16px;
- }
- </style>
|