手持机

This commit is contained in:
张怡蓉
2025-09-10 15:03:51 +08:00
parent 94e3a9d000
commit 0e82934fc3
38 changed files with 905 additions and 131 deletions

View File

@@ -1,19 +1,19 @@
<template>
<view class="setting-container" :style="{height: `${windowHeight}px`}">
<view class="menu-list">
<!-- <view class="list-cell list-cell-arrow" @click="handleToPwd">
<!-- <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> -->
<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="list-cell list-cell-arrow" @click="handleCleanTmp">
<view class="menu-item-box">
<view class="iconfont icon-clean menu-icon"></view>
<view>清理缓存</view>
@@ -37,6 +37,7 @@
</template>
<script>
import {updateUrl} from '@/api/login'
export default {
data() {
return {
@@ -47,24 +48,32 @@
handleToPwd() {
this.$tab.navigateTo('/pages/mine/pwd/index')
},
handleToUpgrade() {
const currentVersion = getApp().globalData.config.appInfo.version;
async handleToUpgrade() {
// const currentVersion = getApp().globalData.config.appInfo.version;
this.$modal.confirm(`是否下载安装包?`).then(async () => {
// 从服务器获取最新版本信息
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;
const response = await updateUrl()
console.log(response)
if (response.code === 200) {
// const latestVersion = res.data.data.version;
const downloadUrl = response.data.downloadUrl;
if (this.compareVersion(currentVersion, latestVersion) >= 0) {
this.$modal.showToast('当前已是最新版本');
if (downloadUrl == '' || downloadUrl == null) {
this.$modal.showToast('获取下载路径失败!');
} else {
this.$modal.confirm(`发现新版本${latestVersion},是否立即更新?`).then(() => {
let fullDownloadUrl = downloadUrl;
const serverSettings = uni.getStorageSync('serverSettings');
if (serverSettings) {
const settings = JSON.parse(serverSettings);
fullDownloadUrl = `http://${settings.ip}:${settings.port}${downloadUrl}`;
}
// 下载更新包
const downloadTask = uni.downloadFile({
url: downloadUrl,
url: fullDownloadUrl,
success: (res) => {
if (res.statusCode === 200) {
// 安装更新
@@ -92,18 +101,16 @@
this.$modal.showToast(`正在下载:${progress}%`);
}
});
}).catch(() => {
this.$modal.showToast('已取消更新');
});
}
} else {
this.$modal.showToast('获取版本信息失败');
}
},
fail: () => {
this.$modal.showToast('检查更新失败,请检查网络');
}
});
}).catch(() => {
this.$modal.showToast('已取消更新');
});
},
// 版本号比较方法
compareVersion(v1, v2) {