From 6a8c84b70a86cc66bf2755beebd613497078d64d Mon Sep 17 00:00:00 2001 From: Iruka <1017819588@qq.com> Date: Mon, 10 Feb 2025 17:27:31 +0800 Subject: [PATCH] . --- App.vue | 45 +++ api/index.js | 8 + .../custom-app-update/custom-app-update.vue | 276 ++++++++++++++++++ manifest.json | 4 +- pages/index.vue | 4 + pages/mine/index.vue | 17 +- pages/mine/setting/index.vue | 41 ++- 7 files changed, 368 insertions(+), 27 deletions(-) create mode 100644 components/custom-app-update/custom-app-update.vue diff --git a/App.vue b/App.vue index 5635b5f..a45aa72 100644 --- a/App.vue +++ b/App.vue @@ -8,6 +8,9 @@ } from "@/utils/indexUtil/dc.js" import mqttUtil from "@/utils/mqttUtil.js" const mqttUrl = import.meta.env.VITE_BASE_MQTT; + import { + getNewAppVersion + } from '@/api/index.js' export default { data() { @@ -19,6 +22,10 @@ topics: null, mqttFun: {}, landFun: {}, + version: { + oldV: null, + newV: null, + }, } }, globalData: {}, @@ -54,6 +61,26 @@ // this.ijs = new indexUtil(); //全局地块列表管理 // this.dc = new deviceControl(2, this.dcEventHandler); // 设备控制类 this.mqtt = new mqttUtil(mqttUrl, this.mqttStateHandler, this.mqttMsgHandler); //Mqtt + + // 检测新版本 + // #ifdef H5 + this.version.oldV = { + versionName: "1.0.0", //网页版 + versionCode: "1", + // versionCode: "9999999999", + } + // #endif + // #ifdef APP-PLUS + plus.runtime.getProperty(plus.runtime.appid, widgetInfo => { + this.version.oldV = { + versionName: widgetInfo.version, + versionCode: widgetInfo.versionCode, + } + }) + getNewAppVersion().then(res => { + this.setUpdateVersion(res.data); + }) + // #endif }, // 添加一个消息回调 on(type, key, callBack) { @@ -141,6 +168,7 @@ }); break; case dcEventType.refreshApi: // 接口刷新阀门 + console.error("refreshApi:", params); break; case dcEventType.send: // 命令控制设备 this.ijs.sendDeviceControl(params); @@ -200,6 +228,23 @@ data: JSON.parse(data), }); }, + setUpdateVersion(data) { + if (data) { + let isLatestVersion = Number(this.version.oldV.versionCode) >= Number(data.versionCode); + if (isLatestVersion) { + this.version.newV = null; + } else { + this.version.newV = { + versionName: data.versionName, //版本名称 + versionCode: data.versionCode, //版本号 + versionUrl: data.versionUrl, //下载地址 + isForceUpdate: data.forceUpgrade == 0, //强制升级 + } + } + } else { + this.version.newV = null; + } + }, } } diff --git a/api/index.js b/api/index.js index 9956960..d68a755 100644 --- a/api/index.js +++ b/api/index.js @@ -23,4 +23,12 @@ export function getDeviceList(data) { method: "get", data: data }) +} + +//查询最新版本 +export function getNewAppVersion() { + return request({ + url: "/system/appVersion/getNewAppVersion", + method: "get" + }) } \ No newline at end of file diff --git a/components/custom-app-update/custom-app-update.vue b/components/custom-app-update/custom-app-update.vue new file mode 100644 index 0000000..5f70f90 --- /dev/null +++ b/components/custom-app-update/custom-app-update.vue @@ -0,0 +1,276 @@ + + + + \ No newline at end of file diff --git a/manifest.json b/manifest.json index 8037e81..51b4f19 100644 --- a/manifest.json +++ b/manifest.json @@ -2,8 +2,8 @@ "name" : "及时雨智能灌溉管理系统v1.0", "appid" : "__UNI__5ACF7F6", "description" : "", - "versionName" : "1.0.0", - "versionCode" : "100", + "versionName" : "1.4.5", + "versionCode" : 145, "transformPx" : false, /* 5+App特有相关 */ "app-plus" : { diff --git a/pages/index.vue b/pages/index.vue index ae227f6..25884fa 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -546,6 +546,7 @@ +