mirror of
https://github.com/JasonYANG170/IOTConnect-Web.git
synced 2024-11-23 20:26:28 +00:00
2 lines
2.3 KiB
JavaScript
2 lines
2.3 KiB
JavaScript
import{m as S}from"./mqtt.esm-DNZjafBp.js";import{u as U,r as s,o as A,a as B,c as F,b as t,t as a,d as c,e as O}from"./index-BkEAVEI4.js";const D={class:"container my-5"},Q={class:"row p-4 pb-0 pe-lg-0 pt-lg-5 align-items-center rounded-3 border shadow-lg"},j={class:"col-lg-7 p-3 p-lg-5 pt-lg-3"},z=t("h3",null,"更新检查",-1),E={class:"display-4 fw-bold lh-1 text-body-emphasis"},N=t("h3",null,"最新固件版本:",-1),R=t("p",{class:"lead"},"更新日志:",-1),G={class:"lead"},H={class:"d-grid gap-2 d-md-flex justify-content-md-start mb-4 mb-lg-3"},J=["disabled"],K=t("div",{class:"col-lg-4 offset-lg-1 p-0 overflow-hidden shadow-lg"},null,-1),X={__name:"UpdateView",setup(L){document.title="更新检查";const v=U(),u=s(v.query.inputValue),f=s(u.value.match(/fp(\d+)/)[1]),x=s(null);let w=s([]),l=null,_=s("离线"),i=null,y="暂无更新!",d="暂无更新",T=null,m="未发现新版本";A(()=>{V()});const V=()=>{l=S.connect("wss://bemfa.com:9504/wss",{clientId:"46d36c5368444235903989ab8d581993"}),l.on("connect",()=>{console.log("已连接到 MQTT 代理"),l.subscribe("Flowerpot")}),l.on("message",(b,o)=>{const e=o.toString(),g=e.indexOf("#"),h=e.indexOf("#",g+1);if(g!==-1&&h!==-1&&e.substring(g+3,h)===f.value){_.value="在线";const n=e.split("#");x.value=n[8].toString();let M=n[8].charAt(0),$=n[8].charAt(1),k=n[8].charAt(2),C=`V${M}.${$}.${k}`;i=s(C),i.value!=T.value&&(m="发现新版本",d="立即更新"),console.log("分割后的数值:",n),console.log("接收到符合条件的消息:",e),w.value.push(e)}})};let r=s(60);const p=s(!1),I=()=>{if(l&&l.connected){let o=`#IDTO${u._value.substring(2)}&Updata`;l.publish("Flowerpot",o),console.log("已发送消息:",o),p.value=!0;const e=setInterval(()=>{r.value>0?r.value--:(clearInterval(e),p.value=!1)},1e3);d=`固件更新中,请等待${r._value}s`}else console.log("未连接到 MQTT 代理或连接断开。")},q=()=>{O.push({path:"/control",query:{inputValue:u.value}})};return(b,o)=>(B(),F("div",D,[t("div",Q,[t("div",j,[z,t("h1",E,a(c(m)),1),t("h3",null,"设备状态:"+a(c(_)),1),t("h3",null,"当前固件版本:"+a(c(i)),1),N,R,t("p",G,a(c(y)),1),t("div",H,[t("button",{disabled:p.value,onClick:I,type:"button",class:"btn btn-primary btn-lg px-4 me-md-2"},a(c(d)),9,J),t("button",{onClick:q,type:"button",class:"btn btn-outline-secondary btn-lg px-4"},"下次再说")])]),K])]))}};export{X as default};
|