mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-06 03:57:49 +08:00
2 lines
6.0 KiB
JavaScript
2 lines
6.0 KiB
JavaScript
import{p as b}from"./print-js@1.6.0-gYKv6oGQ.js";import{c as g}from"./lodash-es@4.17.21-B0eCOOcg.js";import{c}from"./currency.js@2.0.4--or6eeOG.js";function _(e,t,r="sessionStorage"){if(!e){console.error("Failed to set stored data: key is empty or undefined");return}try{const n=JSON.stringify(t);r==="localStorage"?window.localStorage.setItem(e,n):window.sessionStorage.setItem(e,n)}catch(n){console.error(`Failed to set stored data for key '${e}'`,n)}}function L(e,t="sessionStorage",r){try{const n=t==="localStorage"?window.localStorage.getItem(e):window.sessionStorage.getItem(e);return n===null?r??null:JSON.parse(n)}catch(n){return console.error(`Failed to get stored data for key '${e}'`,n),r??null}}function F(e,t="sessionStorage"){switch(e){case"all":window.window.localStorage.clear(),window.sessionStorage.clear();break;case"all-sessionStorage":window.sessionStorage.clear();break;case"all-localStorage":window.localStorage.clear();break;default:if(!e){console.error("Failed to remove stored data: key is empty or undefined");return}t==="localStorage"?window.localStorage.removeItem(e):window.sessionStorage.removeItem(e)}}function S(e,...t){if(Array.isArray(e))e.forEach(r=>S(r,...t));else return e(...t)}function d(e,t){var n;if(!e)return t;let r;return typeof e=="function"?r=e():Vue.isRef(e)?r=((n=e.value)==null?void 0:n.$el)??e.value:r=e,r}function U(e,t){if(!e){const{defaultElement:r=null}=t??{};return typeof r=="function"?r:()=>r}if(typeof e=="string"||w(e,"Object"))return()=>e;if(typeof e=="function")return e}function E(e){return Vue.getCurrentScope()?(Vue.onScopeDispose(e),!0):!1}function f(e,t){const r=Vue.watchEffect(e,t);E(r)}var v={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 j=()=>v,V=(e,t)=>{const r=document.createElement("a");r.href=e,r.download=t,r.style.display="none",document.body.appendChild(r),r.click(),document.body.removeChild(r)},w=(e,t)=>Object.prototype.toString.call(e).includes(t),x=(e=16,t=62)=>{const r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),n=[],a=window.crypto||window.msCrypto;let s=0;for(s=0;s<e;s++){const o=new Uint32Array(1);a.getRandomValues(o);const i=o[0]%t;n.push(r[i])}return n.join("")},O=(e,t)=>new Promise((r,n)=>{let a;try{if(typeof e=="string"){V(e,t),r();return}if(e instanceof ArrayBuffer)a=new Blob([new Uint8Array(e)],{type:"application/octet-stream"});else if(e instanceof File||e instanceof Blob)a=e;else{n(new Error("downloadAnyFile: Unsupported data type."));return}const s=URL.createObjectURL(a),o=document.createElement("a");o.href=s,o.download=t,o.style.display="none";const i=()=>{URL.revokeObjectURL(s),document.body.removeChild(o)};o.addEventListener("load",()=>{i(),r()}),o.addEventListener("error",u=>{i(),n(u)}),document.body.appendChild(o),o.click()}catch(s){n(s)}});function $(e,t){const r=Vue.computed(()=>d(e)),{printable:n,...a}=t??{},s=i=>{b({...a,printable:i})},o=Vue.watch(r,i=>s(i),{immediate:!0});f(o)}const A={validCSSUnit:/^\d+(\.\d+)?(px|em|rem|%|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ch|ex|q|s|ms|deg|rad|turn|grad|hz|khz|dpi|dpcm|dppx|fr|auto)$/},D=(e,t)=>{const r=Vue.computed(()=>d(e)),n=s=>{s&&t.trim().split(" ").forEach(i=>{i&&s.classList.add(i)})},a=Vue.watch(r,s=>n(s),{immediate:!0});f(a)},k=(e,t)=>{const r=Vue.computed(()=>d(e)),n=s=>{if(s)if(t==="removeAllClass"){const o=s.classList;o.forEach(i=>o.remove(i))}else t.trim().split(" ").forEach(i=>{i&&s.classList.remove(i)})},a=Vue.watch(r,s=>n(s),{immediate:!0});f(a)},T=(e,t)=>{const r=Vue.computed(()=>d(e)),n=Vue.ref(!1),a=o=>{if(!o)n.value=!1;else{const i=o.className,u=t.trim().split(" ").filter(m=>m!=="");n.value=i.includes(u.join(" "))}},s=Vue.watch(r,o=>a(o),{immediate:!0});return f(s),n},q=(e,t)=>{const r=Vue.computed(()=>d(e));let n;const a=o=>{o&&(w(t,"String")?n=t.split(";").reduce((i,u)=>{const[m,h]=u.split(":").map(y=>y.trim());return m&&h&&(i[m]=h),i},{}):n=t,Object.keys(n).forEach(i=>{const u=n[i];i in o.style&&(o.style[i]=u)}))},s=Vue.watch(r,o=>a(o),{immediate:!0});f(s)},B=(e,t)=>{const r=Vue.computed(()=>d(e)),n=s=>{s&&t.forEach(o=>{s.style.removeProperty(o)})},a=Vue.watch(r,s=>n(s),{immediate:!0});f(a)},J=(e,t=1)=>{const r=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i,a=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/i;let s;if(r.test(e)){const o=e.substring(1);s="rgb("+[parseInt(o.substring(0,2),16),parseInt(o.substring(2,4),16),parseInt(o.substring(4,6),16)].join(", ")+")"}else n.test(e)||a.test(e),s=e;return s&&!s.startsWith("rgba")&&(s=s.replace("rgb","rgba").replace(")",`, ${t})`)),s},N=e=>{if(!e)return null;const t=e.startsWith("attr:")?`[${e.replace("attr:","")}]`:e;try{return Array.from(document.querySelectorAll(t))}catch(r){return console.error(`Failed to get elements for selector '${e}'`,r),null}},W=(e,t="px")=>typeof e=="number"?e.toString()+t:w(e,"String")&&A.validCSSUnit.test(e)?e:e+t,l={precision:8,decimal:"."},p=(e,t,r)=>e!=null&&e.length?e.length===1?c(e[0],l):e.reduce((a,s,o,i)=>(a=r==null?void 0:r(a,s,o,i),a),t):0,C=(e,t,r="number")=>{const n=Object.assign({},l,t),a=c(e,n);return r==="number"?a.value:a.toString()},X=(...e)=>e.length===1?c(e[0],l).add(0):p(e,0,(t,r)=>c(t,l).add(r)),G=(...e)=>{if(e.length===1)return c(e[0],l).subtract(0);if(e.length===2){const[n,a]=e;return c(n,l).subtract(a)}const t=g(e),r=t.shift();return t.length?p(t,r,(n,a)=>c(n,l).subtract(a)):r},M=(...e)=>e.length===1?c(e[0],l).multiply(1):p(e,1,(t,r)=>c(t,l).multiply(r)),Y=(...e)=>{if(e.length===1)return c(e[0],l).divide(1);if(e.length===2){const[n,a]=e;return c(n,l).divide(a)}const t=g(e),r=t.shift();return p(t,r,(n,a)=>c(n,l).divide(a))},H=(e,t)=>t<=1?[e||0]:e?c(e,l).distribute(t).map(n=>C(n)):new Array(t).fill(0);export{Y as A,q as a,j as b,W as c,U as d,S as e,V as f,L as g,x as h,w as i,O as j,k,D as l,T as m,J as n,F as o,$ as p,N as q,B as r,_ as s,C as t,d as u,H as v,f as w,X as x,G as y,M as z};
|