mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-06-03 04:39:17 +08:00
2 lines
2.6 KiB
JavaScript
2 lines
2.6 KiB
JavaScript
import{p as c,d as p,h as a,q as y}from"./index-8c40f85f.js";import{l as m}from"./awesome-qr@2.1.5-rc.0-7b2b96ae.js";import{k as g,D as h,n as b,f as S,b as t,F as v}from"./@vue_runtime-core@3.3.4-e708ccad.js";import{k as R}from"./@vue_reactivity@3.3.4-1f79d3d1.js";import{c as A,P as k}from"./naive-ui@2.34.4_vue@3.3.4-32c47a39.js";const N={watchText:{type:Boolean,default:!0},status:{type:String},errorDescription:{type:[String,Object],default:"二维码已过期"},errorActionDescription:{type:String,default:"重新加载"},text:{type:String,required:!0},size:{type:Number,default:160},margin:{type:Number,default:12},correctLevel:{type:Number,default:1,validator:r=>[0,1,2,3].includes(r)},maskPattern:{type:Number},version:{type:Number},components:{type:Object,default:()=>({data:{scale:1},timing:{scale:1,protectors:!1},alignment:{scale:1,protectors:!1},cornerAlignment:{scale:1,protectors:!0}})},colorDark:{type:String,default:"#000000"},colorLight:{type:String,default:"#ffffff"},autoColor:{type:Boolean,default:!0},backgroundImage:{type:String},backgroundDimming:{type:String,default:"rgba(0, 0, 0, 0)"},gifBackground:{type:ArrayBuffer},whiteMargin:{type:Boolean,default:!0},logoImage:{type:String},logoScale:{type:Number,default:.4},logoMargin:{type:Number,default:6},logoCornerRadius:{type:Number,default:8},onSuccess:{type:[Function,Array],default:null},onError:{type:[Function,Array],default:null},onReload:{type:[Function,Array],default:null}},B=g({name:"RayQRcode",props:N,setup(r,i){const{expose:l}=i,o=R(),u={opacitySpinning:"0.1"},s=()=>{new m.AwesomeQR({...r}).draw().then(e=>{const{onSuccess:n}=r;n&&a(n,e),o.value=e}).catch(e=>{const{onError:n}=r;n&&a(n,e)})},d=()=>{if(i.slots.errorAction)return;const{onReload:e}=r;e&&a(e)},f=e=>{o.value&&c(o.value,"String")&&y(o.value,e)};return h(()=>{r.watchText&&b().then(()=>{s()})}),l({downloadQRCode:f}),S(()=>{s()}),{qrcodeURL:o,spinOverrides:u,errorActionClick:d}},render(){return t("div",{class:"ray-qrcode"},[t(A,{show:this.status==="loading",themeOverrides:this.spinOverrides},{default:()=>[t("img",{src:this.qrcodeURL},null)]}),this.status==="error"?t("div",{class:"ray-qrcode__error"},[t("div",{class:"ray-qrcode__error-content"},[c(this.errorDescription,"String")?this.errorDescription:()=>this.errorDescription]),t("div",{class:"ray-qrcode__error-btn",onClick:this.errorActionClick.bind(this)},[this.$slots.errorAction?this.$slots.errorAction():t(v,null,[t(k,{text:!0,color:"#ffffff"},{default:()=>this.errorActionDescription,icon:()=>t(p,{name:"reload",size:"16",color:"#ffffff"},null)})])])]):null])}}),O="/ray-template/assets/ray-ab649d1c.svg";export{O as L,B as R};
|