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-BoMYEKHV.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"./print-js@1.6.0-C3lAJnMa.js";var w=(e=>(e.Windows="Windows",e.MacOS="MacOS",e.Linux="Linux",e.Android="Android",e.IOS="IOS",e.Unknown="Unknown",e))(w||{}),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 q=()=>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),M=(e=16,r=62)=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[],s=window.crypto||window.msCrypto;let i=0;for(i=0;i<e;i++){const n=new Uint32Array(1);s.getRandomValues(n);const a=n[0]%r;o.push(t[a])}return o.join("")},X=(e,r)=>new Promise((t,o)=>{let s;try{if(typeof e=="string")return P(e,r),t();if(e instanceof ArrayBuffer)s=new Blob([new Uint8Array(e)],{type:"application/octet-stream"});else if(e instanceof File||e instanceof Blob)s=e;else return o(new Error("downloadAnyFile: Unsupported data type."));const i=URL.createObjectURL(s),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(),o(c))),document.body.appendChild(n),n.click()}catch(i){return o(i)}}),J=()=>{const e=navigator.userAgent;return/windows/i.test(e)?w.Windows:/macintosh|mac os x/i.test(e)?w.MacOS:/linux/i.test(e)?w.Linux:/android/i.test(e)?w.Android:/iphone|ipad|ipod/i.test(e)?w.IOS:w.Unknown},Y=(e,r)=>{const t=e.split("?").filter(Boolean)[0],o=r.split("?").filter(Boolean)[0],s=/\/$/;return t.replace(s,"")===o.replace(s,"")};function G(e,r="sessionStorage",t){const{prefix:o,prefixKey:s}=t??{},i=o?s||g:"",n=r==="localStorage"?window.localStorage:window.sessionStorage;return!!Object.keys(n).find(a=>a===i+e)}function H(e,r,t="sessionStorage",o){if(!e){console.error(`[setStorage]: Failed to set stored data: key ${e} is empty`);return}const{prefix:s,prefixKey:i}=o??{},n=s?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 Q(e,r="sessionStorage",t){const{prefix:o,prefixKey:s,defaultValue:i}=t??{},n=o?s||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 Z=(e,r,t)=>{if(!e){console.error(`[removeStorage]: Failed to remove stored data: key ${e} is empty or undefined`);return}const{prefix:o,prefixKey:s}=t??{},i=o?s||g:"",n=Object.keys(window.localStorage),a=Object.keys(window.sessionStorage),c=(f,m)=>{(f?[...a,...n]:m==="localStorage"?n:a).forEach(p=>{e==="__all__"?(window.sessionStorage.removeItem(i+p),window.localStorage.removeItem(i+p)):m==="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}},N=(e,r)=>{var i;const{domToImageOptions:t,printOptions:o}=r??{},{create:s}=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=s("jpeg"))==null||i.then(n=>{const{print:a}=x(n,{type:"image",base64:!0,targetStyles:["*"],...v(o,["type","base64"])});a()})},T=(e,r)=>{const t=()=>{const s=d(e);s&&(typeof r=="string"?r.trim().split(" "):r).forEach(n=>{n&&s.classList.add(n)})},o=Vue.watch(()=>d(e),t,{immediate:!0});h(o)},z=(e,r)=>{const t=()=>{const s=d(e);if(s)if(r==="removeAllClass"){const i=s.classList;i.forEach(n=>i.remove(n))}else(typeof r=="string"?r.trim().split(" "):r).forEach(n=>{n&&s.classList.remove(n)})},o=Vue.watch(()=>d(e),t,{immediate:!0});h(o)},ee=(e,r)=>{const t=Vue.ref(!1),o=()=>{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))}},s=Vue.watch(()=>d(e),o,{immediate:!0});return h(s),t},I=e=>{const r=["webkit","moz","ms","o"],t={};return r.forEach(o=>{t[`${o}${e.charAt(0).toUpperCase()}${e.slice(1)}`]=e}),t[e]=e,t},te=(e,r)=>{const t=(i,n)=>{i.split(";").forEach(a=>{const[c,f]=a.split(":");if(c&&f){const m=c.trim(),b=f.trim();if(c.startsWith("--"))n.style.setProperty(m,b);else if(c.startsWith("-"))n.style[c]=f;else{const p=I(m);Object.keys(p).forEach(_=>{n.style[_]=p[_]}),n.style[m]=b}}})},o=()=>{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)}))},s=Vue.watch(()=>d(e),o,{immediate:!0});h(s)},re=(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},ne=(e,r)=>{const{defaultElement:t}=r||{};if(!e)return t?[t]:null;const o=e.startsWith("attr:")?`[${e.replace("attr:","")}]`:e;try{const s=Array.from(document.querySelectorAll(o));return!s.length&&t?[t]:s}catch(s){return console.error(`[queryElements]: Failed to get elements for selector '${e}'`,s),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((s,i,n,a)=>(s=t==null?void 0:t(s,i,n,a),s),r):0,k=(e,r)=>{const t=Object.assign({},u,r),o=l(e,t),{type:s="number"}=t;return s==="number"?o.value:o.toString()},oe=(...e)=>e.length===1?l(e[0],u).add(0):S(e,0,(r,t)=>l(r,u).add(t)),ie=(...e)=>{if(e.length===1)return l(e[0],u).subtract(0);if(e.length===2){const[o,s]=e;return l(o,u).subtract(s)}const r=E(e),t=r.shift();return r.length?S(r,t,(o,s)=>l(o,u).subtract(s)):t},ae=(...e)=>e.length===1?l(e[0],u).multiply(1):S(e,1,(r,t)=>l(r,u).multiply(t)),ce=(...e)=>{if(e.length===1)return l(e[0],u).divide(1);if(e.length===2){const[o,s]=e;return l(o,u).divide(s)}const r=E(e),t=r.shift();return S(r,t,(o,s)=>l(o,u).divide(s))},le=(e,r,t)=>{if(r<=1)return[e||0];if(!e)return new Array(r).fill(0);const o=Object.assign({},u,t);return l(e,o).distribute(r).map(i=>k(i,o))};function R(e,...r){if(Array.isArray(e))e.forEach(t=>R(t,...r));else return e(...r)}function d(e,r){var o;if(!e)return r;let t;return typeof e=="function"?t=e():Vue.isRef(e)?t=((o=e.value)==null?void 0:o.$el)??e.value:t=e,t}function ue(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 fe(e,r){const t=Vue.watchEffect(e,r);h(t)}export{oe as A,ie as B,ae as C,ce as D,q as a,se as b,re as c,R as d,P as e,te as f,Q as g,T as h,y as i,X as j,h as k,Y as l,Z as m,z as n,J as o,N as p,ne as q,ue as r,H as s,ee as t,M as u,d as v,fe as w,G as x,k as y,le as z};
|