IOTConnect-Web/dist/assets/ControlView-CqKstEQZ.js

2 lines
7.1 KiB
JavaScript
Raw Normal View History

2024-05-09 01:49:52 +00:00
import{m as V}from"./mqtt.esm-DNZjafBp.js";import{u as Q,r as c,o as q,a as N,c as P,b as t,t as d,d as u,F as H,e as T}from"./index-BkEAVEI4.js";const z={class:"container my-5"},R={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"},G=t("h1",{class:"display-4 fw-bold lh-1 text-body-emphasis"},"智能交互花盆",-1),J={class:"row row-cols-3 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4 py-5"},K={class:"fw-bold mb-0 fs-4 white-text"},W={class:"fw-bold mb-0 fs-4 white-text"},X={class:"fw-bold mb-0 fs-4 white-text"},Y=t("div",{class:"col-lg-4 offset-lg-1 p-0 overflow-hidden shadow-lg"},null,-1),Z={class:"container px-4 py-5",id:"icon-grid"},tt=t("h2",{class:"pb-2 border-bottom fw-bold"},"AI引擎",-1),et=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"AUTO自动控制",-1),st=t("p",null,"开启本功能将启用AI自动控制模式由AI模型进行自动化管理",-1),ot=[et,st],lt={class:"row row-cols-2 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 g-4 py-5"},nt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"AI对话",-1),it=t("p",null,"为植物生成交互模型",-1),ct=[nt,it],at={class:"col d-flex align-items-start"},dt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"AI生长预测",-1),ut=t("p",null,"为植物预测生长方向",-1),rt=[dt,ut],bt=t("h2",{class:"pb-2 border-bottom fw-bold"},"控制台",-1),mt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"环境恒温",-1),gt=t("p",null,"为植物土壤开启恒温模式",-1),pt=[mt,gt],ht=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"环境光照",-1),_t=t("p",null,"将为植物开启光合作用",-1),vt=[ht,_t],wt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"自动浇水",-1),ft=t("p",null,"土壤湿度不足时自动浇水",-1),yt=[wt,ft],Tt=t("h3",{class:"fw-bold mb-0 fs-4 white-text"},"更新检查",-1),xt=t("p",null,"检测花盆版本,固件更新",-1),It=[Tt,xt],Lt={__name:"ControlView",setup(Ot){document.title="Flowerpot控制中心";const x=Q(),n=c(x.query.inputValue),I=c(n.value.match(/fp(\d+)/)[1]);let h=c(null),_=c(null),v=c(null);const O=c(null);let F=c([]),e=null,w=c("离线"),f=null,r=null,b=null,m=null,g=null;q(()=>{U()});const U=()=>{e=V.connect("mqtt://23.95.222.237:1883",{clientId:"ViteVueTest"}),e.on("connect",()=>{console.log("已连接到 MQTT 代理"),e.subscribe("Flowerpot")}),e.on("message",(i,s)=>{const a=s.toString(),p=a.indexOf("#"),y=a.indexOf("#",p+1);if(p!==-1&&y!==-1&&a.substring(p+3,y)===I.value){w.value="在线";const l=a.split("#");if(O.value=l[8].toString(),h=l[2].toString(),v=l[3].toString(),_=l[4].toString(),l[9].toString()!=="0"){const o=document.getElementById("autobt");o.classList.remove("btn-outline-secondary"),o.classList.add("btn-primary"),r=1}else{const o=document.getElementById("autobt");o.classList.remove("btn-primary"),o.classList.add("btn-outline-secondary"),r=0}if(l[6].toString()!=="0"){const o=document.getElementById("tempbt");o.classList.remove("btn-outline-secondary"),o.classList.add("btn-primary"),b=1}else{const o=document.getElementById("tempbt");o.classList.remove("btn-primary"),o.classList.add("btn-outline-secondary"),b=0}if(l[5].toString()!=="0"){const o=document.getElementById("waterbt");o.classList.remove("btn-outline-secondary"),o.classList.add("btn-primary"),m=1}else{const o=document.getElementById("waterbt");o.classList.remove("btn-primary"),o.classList.add("btn-outline-secondary"),m=0}if(l[7].toString()!=="0"){const o=document.getElementById("lightbt");o.classList.remove("btn-outline-secondary"),o.classList.add("btn-primary"),g=1}else{const o=document.getElementById("lightbt");o.classList.remove("btn-primary"),o.classList.add("btn-outline-secondary"),g=0}let E=l[8].charAt(0),S=l[8].charAt(1),$=l[8].charAt(2),k=`V${E}.${S}.${$}`;f=c(k),console.log("分割后的数值:",l),console.log("接收到符合条件的消息:",a),F.value.push(a)}})},L=()=>{if(r==0)if(e&&e.connected){let s=`#IDTO${n._value.substring(2)}&ONAUTO`;e.publish("Flowerpot",s),console.log("已发送消息:",s)}else console.log("未连接到 MQTT 代理或连接<EFBFBD><EFBFBD>