mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-06 03:57:49 +08:00
2 lines
8.2 KiB
JavaScript
2 lines
8.2 KiB
JavaScript
import{A as g,u as A,a as x,b as $}from"./hooks-CUITr7hu.js";import{o as v,c as E}from"./lodash-es@4.17.21-CWC3zScj.js";import{c as l}from"./currency.js@2.0.4-9OAR_aOO.js";import"./dayjs@1.11.10-BYZwCyGy.js";import"./awesome-qr@2.1.5-rc.0-Ds7AaOTE.js";import"./vue-hooks-plus@1.8.8_vue@3.4.21-C_BRgauB.js";import"./lodash@4.17.21-CM7ROh5r.js";import"./js-cookie@3.0.5-Z_8Sd105.js";import"./screenfull@5.2.0-DuGDi0R7.js";import"./jsbarcode@3.11.6-BvokPght.js";import"./print-js@1.6.0-C3lAJnMa.js";var m=(e=>(e.Windows="Windows",e.MacOS="MacOS",e.Linux="Linux",e.Android="Android",e.IOS="IOS",e.Unknown="Unknown",e))(m||{}),C={VITE_APP_URL:"/",VITE_APP_OFFICE_PROXY_URL:"https://office.yka.one/",VITE_APP_OFFICE_SCRIPT_URL:"https://office.yka.one/web-apps/apps/api/documents/api.js",BASE_URL:"/ray-template/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const M=()=>C,P=(e,r)=>{const t=document.createElement("a");t.href=e,t.download=r,t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t)},y=(e,r)=>Object.prototype.toString.call(e).includes(r),X=(e=16,r=62)=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),s=[],o=window.crypto||window.msCrypto;let i=0;for(i=0;i<e;i++){const n=new Uint32Array(1);o.getRandomValues(n);const a=n[0]%r;s.push(t[a])}return s.join("")},J=(e,r)=>new Promise((t,s)=>{let o;try{if(typeof e=="string")return P(e,r),t();if(e instanceof ArrayBuffer)o=new Blob([new Uint8Array(e)],{type:"application/octet-stream"});else if(e instanceof File||e instanceof Blob)o=e;else return s(new Error("downloadAnyFile: Unsupported data type."));const i=URL.createObjectURL(o),n=document.createElement("a");n.href=i,n.download=r,n.style.display="none";const a=()=>{URL.revokeObjectURL(i),document.body.removeChild(n)};n.addEventListener("load",()=>(a(),t())),n.addEventListener("error",c=>(a(),s(c))),document.body.appendChild(n),n.click()}catch(i){return s(i)}}),Y=()=>{const e=navigator.userAgent;return/windows/i.test(e)?m.Windows:/macintosh|mac os x/i.test(e)?m.MacOS:/linux/i.test(e)?m.Linux:/android/i.test(e)?m.Android:/iphone|ipad|ipod/i.test(e)?m.IOS:m.Unknown},G=(e,r)=>{const t=e.split("?").filter(Boolean)[0],s=r.split("?").filter(Boolean)[0],o=/\/$/;return t.replace(o,"")===s.replace(o,"")};function H(e,r="sessionStorage",t){const{prefix:s,prefixKey:o}=t??{},i=s?o||g:"",n=r==="localStorage"?window.localStorage:window.sessionStorage;return!!Object.keys(n).find(a=>a===i+e)}function Q(e,r,t="sessionStorage",s){if(!e){console.error(`[setStorage]: Failed to set stored data: key ${e} is empty`);return}const{prefix:o,prefixKey:i}=s??{},n=o?i||g:"";try{const a=JSON.stringify(r);t==="localStorage"?window.localStorage.setItem(n+e,a):window.sessionStorage.setItem(n+e,a)}catch(a){console.error(`[setStorage]: Failed to set stored data for key '${e}'`,a)}}function Z(e,r="sessionStorage",t){const{prefix:s,prefixKey:o,defaultValue:i}=t??{},n=s?o||g:"";try{const a=r==="localStorage"?window.localStorage.getItem(n+e):window.sessionStorage.getItem(n+e);return a===null?i??null:JSON.parse(a)}catch(a){return console.error(`[getStorage]: Failed to get stored data for key '${e}'`,a),i??null}}const N=(e,r,t)=>{if(!e){console.error(`[removeStorage]: Failed to remove stored data: key ${e} is empty or undefined`);return}const{prefix:s,prefixKey:o}=t??{},i=s?o||g:"",n=Object.keys(window.localStorage),a=Object.keys(window.sessionStorage),c=(f,w)=>{(f?[...a,...n]:w==="localStorage"?n:a).forEach(p=>{e==="__all__"?(window.sessionStorage.removeItem(i+p),window.localStorage.removeItem(i+p)):w==="localStorage"?window.localStorage.removeItem(i+p):window.sessionStorage.removeItem(i+p)})};switch(e){case"__all__":c(!0);break;case"__all_sessionStorage__":c(!1,"sessionStorage");break;case"__all_localStorage__":c(!1,"localStorage");break;default:r==="localStorage"?window.localStorage.removeItem(i+e):window.sessionStorage.removeItem(i+e);break}},T=(e,r)=>{var i;const{domToImageOptions:t,printOptions:s}=r??{},{create:o}=A(e,{...t,beforeCreate:n=>{var a,c;(a=t==null?void 0:t.beforeCreate)==null||a.call(t,n),(c=window.$loadingBar)==null||c.start()},created(n,a){var c,f;(c=t==null?void 0:t.created)==null||c.call(t,n,a),(f=window.$loadingBar)==null||f.finish()},createdError(n){var a,c;(a=t==null?void 0:t.createdError)==null||a.call(t,n),(c=window.$loadingBar)==null||c.error()}});(i=o("jpeg"))==null||i.then(n=>{const{print:a}=x(n,{type:"image",base64:!0,targetStyles:["*"],...v(s,["type","base64"])});a()})},z=(e,r)=>{const t=()=>{const o=d(e);o&&(typeof r=="string"?r.trim().split(" "):r).forEach(n=>{n&&o.classList.add(n)})},s=Vue.watch(()=>d(e),t,{immediate:!0});h(s)},ee=(e,r)=>{const t=()=>{const o=d(e);if(o)if(r==="removeAllClass"){const i=o.classList;i.forEach(n=>i.remove(n))}else(typeof r=="string"?r.trim().split(" "):r).forEach(n=>{n&&o.classList.remove(n)})},s=Vue.watch(()=>d(e),t,{immediate:!0});h(s)},te=(e,r)=>{const t=Vue.ref(!1),s=()=>{const i=d(e);if(!i)t.value=!1;else{const n=i.className,a=typeof r=="string"?r.trim().split(" ").filter(c=>c!==""):r;t.value=a.some(c=>n.includes(c))}},o=Vue.watch(()=>d(e),s,{immediate:!0});return h(o),t},I=e=>{const r=["webkit","moz","ms","o"],t={};return r.forEach(s=>{t[`${s}${e.charAt(0).toUpperCase()}${e.slice(1)}`]=e}),t[e]=e,t},re=(e,r)=>{const t=(i,n)=>{i.split(";").forEach(a=>{const[c,f]=a.split(":");if(c&&f){const w=c.trim(),b=f.trim();if(c.startsWith("--"))n.style.setProperty(w,b);else if(c.startsWith("-"))n.style[c]=f;else{const p=I(w);Object.keys(p).forEach(_=>{n.style[_]=p[_]}),n.style[w]=b}}})},s=()=>{const i=d(e);i&&(y(r,"String")?t(r,i):y(r,"Array")?r.forEach(n=>{t(n,i)}):Object.keys(r).forEach(a=>{t(`${a}: ${r[a]}`,i)}))},o=Vue.watch(()=>d(e),s,{immediate:!0});h(o)},ne=(e,r=1)=>{if(e.includes("rgba"))return e;if(e.includes("rgb"))return e.replace("rgb","rgba").replace(")",`, ${r})`);if(e.includes("#")){const t=e.replace("#","");switch(t.length){case 3:return`rgba(${parseInt(t[0]+t[0],16)}, ${parseInt(t[1]+t[1],16)}, ${parseInt(t[2]+t[2],16)}, ${r})`;case 6:return`rgba(${parseInt(t.slice(0,2),16)}, ${parseInt(t.slice(2,4),16)}, ${parseInt(t.slice(4,6),16)}, ${r})`;case 8:return`rgba(${parseInt(t.slice(0,2),16)}, ${parseInt(t.slice(2,4),16)}, ${parseInt(t.slice(4,6),16)}, ${(parseInt(t.slice(6,8),16)/255).toFixed(2)})`;default:return e}}return e},oe=(e,r)=>{const{defaultElement:t}=r||{};if(!e)return t?[t]:null;const s=e.startsWith("attr:")?`[${e.replace("attr:","")}]`:e;try{const o=Array.from(document.querySelectorAll(s));return!o.length&&t?[t]:o}catch(o){return console.error(`[queryElements]: Failed to get elements for selector '${e}'`,o),t?[t]:null}},se=(e,r="px")=>e==="auto"?e:typeof e=="number"?e.toString()+r:y(e,"String")&&$.cssUnit.test(e)?e:e+r,u={precision:8,decimal:"."},S=(e,r,t)=>e!=null&&e.length?e.length===1?l(e[0],u):e.reduce((o,i,n,a)=>(o=t==null?void 0:t(o,i,n,a),o),r):0,k=(e,r)=>{const t=Object.assign({},u,r),s=l(e,t),{type:o="number"}=t;return o==="number"?s.value:s.toString()},ie=(...e)=>e.length===1?l(e[0],u).add(0):S(e,0,(r,t)=>l(r,u).add(t)),ae=(...e)=>{if(e.length===1)return l(e[0],u).subtract(0);if(e.length===2){const[s,o]=e;return l(s,u).subtract(o)}const r=E(e),t=r.shift();return r.length?S(r,t,(s,o)=>l(s,u).subtract(o)):t},ce=(...e)=>e.length===1?l(e[0],u).multiply(1):S(e,1,(r,t)=>l(r,u).multiply(t)),le=(...e)=>{if(e.length===1)return l(e[0],u).divide(1);if(e.length===2){const[s,o]=e;return l(s,u).divide(o)}const r=E(e),t=r.shift();return S(r,t,(s,o)=>l(s,u).divide(o))},ue=(e,r,t)=>{if(r<=1)return[e||0];if(!e)return new Array(r).fill(0);const s=Object.assign({},u,t);return l(e,s).distribute(r).map(i=>k(i,s))};function R(e,...r){if(Array.isArray(e))e.forEach(t=>R(t,...r));else return e(...r)}function d(e,r){var s;if(!e)return r;let t;return typeof e=="function"?t=e():Vue.isRef(e)?t=((s=e.value)==null?void 0:s.$el)??e.value:t=e,t}function fe(e,r){if(!e){const{defaultElement:t=null}=r??{};return typeof t=="function"?t:()=>t}if(typeof e=="string"||y(e,"Object"))return()=>e;if(typeof e=="function")return e}function h(e){return Vue.getCurrentScope()?(Vue.onScopeDispose(e),!0):!1}function de(e,r){const t=Vue.watchEffect(e,r);h(t)}export{ie as A,ae as B,ce as C,le as D,M as a,se as b,ne as c,R as d,P as e,re as f,Z as g,z as h,y as i,J as j,h as k,G as l,N as m,ee as n,Y as o,T as p,oe as q,fe as r,Q as s,te as t,X as u,d as v,de as w,H as x,k as y,ue as z};
|