项目初始化
This commit is contained in:
156
RuoYi-App-master/pages/mine/setting/index.vue
Normal file
156
RuoYi-App-master/pages/mine/setting/index.vue
Normal file
@@ -0,0 +1,156 @@
|
||||
<template>
|
||||
<view class="setting-container" :style="{height: `${windowHeight}px`}">
|
||||
<view class="menu-list">
|
||||
<!-- <view class="list-cell list-cell-arrow" @click="handleToPwd">
|
||||
<view class="menu-item-box">
|
||||
<view class="iconfont icon-password menu-icon"></view>
|
||||
<view>修改密码</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-cell list-cell-arrow" @click="handleToUpgrade">
|
||||
<view class="menu-item-box">
|
||||
<view class="iconfont icon-refresh menu-icon"></view>
|
||||
<view>检查更新</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="list-cell list-cell-arrow" @click="handleCleanTmp">
|
||||
<view class="menu-item-box">
|
||||
<view class="iconfont icon-clean menu-icon"></view>
|
||||
<view>清理缓存</view>
|
||||
</view>
|
||||
</view> -->
|
||||
<view class="list-cell list-cell-arrow" @click="handleToServerConfig">
|
||||
<view class="menu-item-box">
|
||||
<view class="iconfont icon-edit menu-icon"></view>
|
||||
<view> {{ $t('mine.setting.updateServer') }}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cu-list menu">
|
||||
<view class="cu-item item-box">
|
||||
<view class="content text-center" @click="handleLogout">
|
||||
<text class="text-black">{{ $t('mine.setting.logout') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
windowHeight: uni.getSystemInfoSync().windowHeight
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleToPwd() {
|
||||
this.$tab.navigateTo('/pages/mine/pwd/index')
|
||||
},
|
||||
handleToUpgrade() {
|
||||
const currentVersion = getApp().globalData.config.appInfo.version;
|
||||
// 从服务器获取最新版本信息
|
||||
uni.request({
|
||||
url:'/system/app/version',
|
||||
method: 'GET',
|
||||
success: (res) => {
|
||||
if (res.data.code === 200) {
|
||||
const latestVersion = res.data.data.version;
|
||||
const downloadUrl = res.data.data.downloadUrl;
|
||||
|
||||
if (this.compareVersion(currentVersion, latestVersion) >= 0) {
|
||||
this.$modal.showToast('当前已是最新版本');
|
||||
} else {
|
||||
this.$modal.confirm(`发现新版本${latestVersion},是否立即更新?`).then(() => {
|
||||
// 下载更新包
|
||||
const downloadTask = uni.downloadFile({
|
||||
url: downloadUrl,
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
// 安装更新
|
||||
plus.runtime.install(res.tempFilePath, {
|
||||
force: false
|
||||
}, () => {
|
||||
this.$modal.showToast('安装完成,重启应用');
|
||||
setTimeout(() => {
|
||||
plus.runtime.restart();
|
||||
}, 1000);
|
||||
}, (e) => {
|
||||
this.$modal.showToast('安装失败:' + e.message);
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
this.$modal.showToast('下载失败:' + err.errMsg);
|
||||
}
|
||||
});
|
||||
|
||||
// 监听下载进度
|
||||
downloadTask.onProgressUpdate((res) => {
|
||||
const progress = res.progress;
|
||||
if (progress < 100) {
|
||||
this.$modal.showToast(`正在下载:${progress}%`);
|
||||
}
|
||||
});
|
||||
}).catch(() => {
|
||||
this.$modal.showToast('已取消更新');
|
||||
});
|
||||
}
|
||||
} else {
|
||||
this.$modal.showToast('获取版本信息失败');
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
this.$modal.showToast('检查更新失败,请检查网络');
|
||||
}
|
||||
});
|
||||
},
|
||||
// 版本号比较方法
|
||||
compareVersion(v1, v2) {
|
||||
const v1Parts = v1.split('.');
|
||||
const v2Parts = v2.split('.');
|
||||
const length = Math.max(v1Parts.length, v2Parts.length);
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
const v1Part = parseInt(v1Parts[i] || 0);
|
||||
const v2Part = parseInt(v2Parts[i] || 0);
|
||||
if (v1Part > v2Part) return 1;
|
||||
if (v1Part < v2Part) return -1;
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
handleCleanTmp() {
|
||||
this.$modal.showToast('模块建设中~')
|
||||
},
|
||||
handleToServerConfig() {
|
||||
this.$tab.navigateTo('/pages/setting')
|
||||
},
|
||||
handleLogout() {
|
||||
this.$modal.confirm(this.$t('mine.logoutConfirm')).then(() => {
|
||||
this.$store.dispatch('LogOut').then(() => {
|
||||
this.$tab.reLaunch('/pages/login')
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.page {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.item-box {
|
||||
background-color: #FFFFFF;
|
||||
margin: 30rpx;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 10rpx;
|
||||
border-radius: 8rpx;
|
||||
color: #303133;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user