Files
aiot-platform-ui/apps/web-antd/dist/js/device-detail-config-aRHycUZY.js
lzh 64681a9d55
Some checks failed
Web UI CI/CD / build-and-deploy (push) Has been cancelled
chore: build and deploy web-antd
2025-12-28 01:40:21 +08:00

2 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var f=(N,S,n)=>new Promise((O,i)=>{var u=a=>{try{t(n.next(a))}catch(v){i(v)}},e=a=>{try{t(n.throw(a))}catch(v){i(v)}},t=a=>a.done?O(a.value):Promise.resolve(a.value).then(u,e);t((n=n.apply(N,S)).next())});import{s as I,u as j}from"./index-DO6sfdKP.js";import{I as M}from"./constants-B5TthjFC.js";import{co as V,ay as g,bS as F,a9 as p,ac as P}from"./bootstrap-DZnIDovD.js";import{m as T,b9 as d,bF as U,aa as C,ad as h,b2 as l,ab as r,ac as J,ae as k,u as c,bJ as y,ai as m,bp as A}from"../jse/index-index-DaIpbNAe.js";const G={class:"mt-5 text-center"},H={key:1,class:"json-viewer-container"},L={class:"json-code"},q=T({name:"DeviceDetailConfig",__name:"device-detail-config",props:{device:{}},emits:["success"],setup(N,{emit:S}){const n=N,O=S,i=d(!1),u=d(!1),e=d({}),t=d("");U(()=>{try{e.value=n.device.config?JSON.parse(n.device.config):{},t.value=JSON.stringify(e.value,null,2)}catch(s){e.value={},t.value="{}"}});const a=d(!1),v=C(()=>{try{return typeof e.value=="string"?JSON.stringify(JSON.parse(e.value),null,2):JSON.stringify(e.value,null,2)}catch(s){return JSON.stringify(e.value,null,2)}}),b=C(()=>e.value&&Object.keys(e.value).length>0);function _(){a.value=!0,t.value=JSON.stringify(e.value,null,2)}function D(){try{e.value=n.device.config?JSON.parse(n.device.config):{},t.value=JSON.stringify(e.value,null,2)}catch(s){e.value={},t.value="{}"}a.value=!1}function w(){return f(this,null,function*(){try{e.value=JSON.parse(t.value)}catch(s){console.error("JSON格式错误:",s),p.error({content:"JSON格式错误请修正后再提交"});return}yield E(),a.value=!1})}function x(){return f(this,null,function*(){try{u.value=!0,yield I({deviceId:n.device.id,method:M.CONFIG_PUSH.method,params:e.value}),p.success({content:"配置推送成功!"})}catch(s){s!=="cancel"&&(p.error({content:"配置推送失败!"}),console.error("配置推送错误:",s))}finally{u.value=!1}})}function E(){return f(this,null,function*(){try{i.value=!0,yield j({id:n.device.id,config:JSON.stringify(e.value)}),p.success({content:"更新成功!"}),O("success")}catch(s){console.error(s)}finally{i.value=!1}})}return(s,o)=>(l(),h("div",null,[b.value?J("",!0):(l(),r(c(V),{key:0,message:"支持远程更新设备的配置文件(JSON 格式),可以在下方编辑配置模板,对设备的系统参数、网络参数等进行远程配置。配置完成后,需点击「下发」按钮,设备即可进行远程配置。",type:"info","show-icon":"",class:"my-4",description:"如需编辑文件,请点击下方编辑按钮"})),k("div",G,[a.value?(l(),r(c(g),{key:0,onClick:D},{default:y(()=>[...o[1]||(o[1]=[m("取消",-1)])]),_:1})):J("",!0),a.value?(l(),r(c(g),{key:1,type:"primary",onClick:w,loading:i.value},{default:y(()=>[...o[2]||(o[2]=[m(" 保存 ",-1)])]),_:1},8,["loading"])):(l(),r(c(g),{key:2,onClick:_},{default:y(()=>[...o[3]||(o[3]=[m("编辑",-1)])]),_:1})),a.value?J("",!0):(l(),r(c(g),{key:3,type:"primary",onClick:x,loading:u.value},{default:y(()=>[...o[4]||(o[4]=[m(" 配置推送 ",-1)])]),_:1},8,["loading"]))]),a.value?(l(),r(c(F),{key:2,value:t.value,"onUpdate:value":o[0]||(o[0]=B=>t.value=B),rows:20,placeholder:"请输入 JSON 格式的配置信息",class:"json-editor"},null,8,["value"])):(l(),h("div",H,[k("pre",L,[k("code",null,A(v.value),1)])]))]))}}),X=P(q,[["__scopeId","data-v-d1b4c88b"]]);export{X as default};