mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2025-12-18 13:22:49 +00:00
2 lines
4.0 KiB
JavaScript
2 lines
4.0 KiB
JavaScript
import{d as J,r as n,v as j,q as F,l as W,at as z,ah as A,P as C,k as t,h as g,c as B,a as o,J as y,aa as h,t as i,u as s,e as l,w as p,i as O,m as T,z as G,B as H,ax as K,D as Q,E as X,G as Y,C as Z,H as ee}from"./index-a59af0dd.js";/* empty css *//* empty css *//* empty css */import"./el-form-item-4ed993c7.js";/* empty css *//* empty css */import{g as ae}from"./weapp-e0641ca7.js";import{r as te}from"./sys-d9b3645a.js";import{b as oe}from"./browser-a1ac24ac.js";const se={class:"main-container w-[375px] mx-auto mt-[20px] mb-[40px] relative"},le={class:"flex full-container h-[800px]"},ne=["src"],pe={class:"w-[375px] border border-slate-100 bg-body pt-[20px] px-[20px]"},re={class:"font-bold text-xl mb-[40px]"},ie={class:"mb-[20px] flex flex-col"},ce={class:"mb-[10px]"},de={key:0,class:"w-[400px] absolute bg-body top-[10%] -right-[450px]"},ue={class:"info-wrap mt-[20px]"},me={class:"px-[20px] pb-[10px] font-bold"},ve={class:"px-[20px] pb-[10px] font-bold mt-[40px]"},_e={class:"text-gray-400"},Ee=J({__name:"preview",setup(fe){const u=n(""),m=n(""),v=n(""),r=n(""),d=n(!1),_=n(!1),D=n(0),I=n(0),f=j();f.query.page=f.query.page||"",F("setLayout")("decorate"),te().then(e=>{u.value=e.data.wap_url,k()});const M=()=>{if(m.value.trim().length==0){C({type:"warning",message:`${t("wapDomainPlaceholder")}`});return}u.value=m.value+"/wap",k(),K.set({key:"wap_domain",data:u.value}),d.value=!0,_.value=!1},k=()=>{if(f.query.page){r.value=`${u.value}${f.query.page}`,oe.toDataURL(r.value,{errorCorrectionLevel:"L",margin:0,width:100}).then(w=>{v.value=w});const e=()=>{D.value=new Date().getTime(),P()};e();let a=0,c=setInterval(()=>{if(q.value||a>=50){clearInterval(c);return}e(),a++},200);setTimeout(()=>{I.value==0&&E()},1e3*10)}},q=n(!1);window.addEventListener("message",e=>{try{let a={type:""};if(typeof e.data=="string"?a=JSON.parse(e.data):typeof e.data=="object"&&(a=e.data),a.type&&["appOnLaunch","appOnReady"].indexOf(a.type)!=-1){_.value=!1,d.value=!0;let c=new Date().getTime();q.value=!0,I.value=c-D.value}}catch(a){E(),console.log("preview 后台接受数据错误",a)}},!1);const P=()=>{const e=JSON.stringify({type:"appOnReady",message:"加载完成"});window.previewIframe&&window.previewIframe.contentWindow.postMessage(e,"*")},E=()=>{_.value=!0,d.value=!1,r.value="",v.value=""},b=W({qr_code:""});ae().then(e=>{if(e.code==1){const a=e.data;b.qr_code=a.qr_code}});const{copy:R,isSupported:U,copied:L}=z(),$=e=>{U.value||C({message:t("notSupportCopy"),type:"warning"}),R(e)};return A(L,()=>{L.value&&C({message:t("copySuccess"),type:"success"})}),(e,a)=>{const c=Q,w=X,x=Y,S=Z,V=ee;return g(),B("div",se,[o("div",le,[y(o("iframe",{class:"w-[375px]",src:r.value,frameborder:"0",id:"previewIframe"},null,8,ne),[[h,d.value]]),y(o("div",pe,[o("div",re,i(s(t)("developTitle")),1),o("div",ie,[o("text",ce,i(s(t)("wapDomain")),1),l(c,{modelValue:m.value,"onUpdate:modelValue":a[0]||(a[0]=N=>m.value=N),modelModifiers:{trim:!0},placeholder:s(t)("wapDomainPlaceholder"),clearable:""},null,8,["modelValue","placeholder"])]),l(w,{type:"primary",onClick:M},{default:p(()=>[O(i(s(t)("confirm")),1)]),_:1})],512),[[h,_.value]]),d.value?(g(),B("div",de,[o("div",ue,[o("div",me,i(s(t)("h5")),1),l(V,{"label-width":"40px",class:"px-[20px]"},{default:p(()=>[y(l(x,{label:s(t)("link")},{default:p(()=>[l(c,{readonly:"",value:r.value},{append:p(()=>[l(w,{onClick:a[1]||(a[1]=N=>$(r.value)),class:"bg-primary copy"},{default:p(()=>[O(i(s(t)("copy")),1)]),_:1})]),_:1},8,["value"])]),_:1},8,["label"]),[[h,r.value]]),y(l(x,{label:" "},{default:p(()=>[l(S,{src:v.value},null,8,["src"])]),_:1},512),[[h,v.value]])]),_:1}),o("div",ve,i(s(t)("weapp")),1),l(V,{"label-width":"40px",class:"px-[20px]"},{default:p(()=>[b.qr_code?(g(),T(x,{key:0,label:" "},{default:p(()=>[l(S,{class:"w-[100px] h-[100px]",src:s(G)(b.qr_code)},null,8,["src"])]),_:1})):(g(),T(x,{key:1,label:" "},{default:p(()=>[o("span",_e,i(s(t)("weappNotSet")),1)]),_:1}))]),_:1})])])):H("",!0)])])}}});export{Ee as default};
|