mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-06-13 04:03:37 +08:00
2 lines
8.4 KiB
JavaScript
2 lines
8.4 KiB
JavaScript
import{A as S,u as A,a as x,b as v}from"./hooks-BhHffBS8.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-CBeGMwb0.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"./qs@6.11.2-5yoVYNs7.js";import"./print-js@1.6.0-C3lAJnMa.js";import{c as _}from"./lodash-es@4.17.21-C8H4BJij.js";var p=(e=>(e.Windows="Windows",e.MacOS="MacOS",e.Linux="Linux",e.Android="Android",e.IOS="IOS",e.Unknown="Unknown",e))(p||{}),P={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 X=()=>P,k=(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),J=(e=16,r=62)=>{const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),o=[],i=window.crypto||window.msCrypto;let s=0;for(s=0;s<e;s++){const n=new Uint32Array(1);i.getRandomValues(n);const a=n[0]%r;o.push(t[a])}return o.join("")},Y=(e,r)=>new Promise((t,o)=>{let i;try{if(typeof e=="string")return k(e,r),t();if(e instanceof ArrayBuffer)i=new Blob([new Uint8Array(e)],{type:"application/octet-stream"});else if(e instanceof File||e instanceof Blob)i=e;else return o(new Error("downloadAnyFile: Unsupported data type."));const s=URL.createObjectURL(i),n=document.createElement("a");n.href=s,n.download=r,n.style.display="none";const a=()=>{URL.revokeObjectURL(s),document.body.removeChild(n)};n.addEventListener("load",()=>(a(),t())),n.addEventListener("error",c=>(a(),o(c))),document.body.appendChild(n),n.click()}catch(s){return o(s)}});function C(e,r){if(!e)return console.warn(`[omit]: The targetObject is expected to be an object, but got ${e}.`),{};const t=Array.isArray(r)?r:[r];return t.length&&t.forEach(o=>{delete e[o]}),e}function G(e,r){if(!e)return console.warn(`[pick]: The targetObject is expected to be an object, but got ${e}.`),{};const t=Array.isArray(r)?r:[r];return t.length?t.reduce((i,s)=>(Reflect.has(e,s)&&(i[s]=e[s]),i),{}):e}const H=()=>{const e=navigator.userAgent;return/windows/i.test(e)?p.Windows:/macintosh|mac os x/i.test(e)?p.MacOS:/linux/i.test(e)?p.Linux:/android/i.test(e)?p.Android:/iphone|ipad|ipod/i.test(e)?p.IOS:p.Unknown},Q=(e,r)=>{const t=e.endsWith("/"),o=r.endsWith("/");return t&&o?e.slice(0,-1)===r.slice(0,-1):!t&&!o?e===r:e===r||e.slice(0,-1)===r||e===r.slice(0,-1)};function Z(e,r="sessionStorage",t){const{prefix:o,prefixKey:i}=t??{},s=o?i||S:"",n=r==="localStorage"?window.localStorage:window.sessionStorage;return!!Object.keys(n).find(a=>a===s+e)}function O(e,r,t="sessionStorage",o){if(!e){console.error(`[setStorage]: Failed to set stored data: key ${e} is empty`);return}const{prefix:i,prefixKey:s}=o??{},n=i?s||S:"";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 T(e,r="sessionStorage",t){const{prefix:o,prefixKey:i,defaultValue:s}=t??{},n=o?i||S:"";try{const a=r==="localStorage"?window.localStorage.getItem(n+e):window.sessionStorage.getItem(n+e);return a===null?s??null:JSON.parse(a)}catch(a){return console.error(`[getStorage]: Failed to get stored data for key '${e}'`,a),s??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:i}=t??{},s=o?i||S:"",n=Object.keys(window.localStorage),a=Object.keys(window.sessionStorage),c=(w,m)=>{(w?[...a,...n]:m==="localStorage"?n:a).forEach(d=>{e==="__all__"?(window.sessionStorage.removeItem(s+d),window.localStorage.removeItem(s+d)):m==="localStorage"?window.localStorage.removeItem(s+d):window.sessionStorage.removeItem(s+d)})};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(s+e):window.sessionStorage.removeItem(s+e);break}},N=(e,r)=>{var s;const{domToImageOptions:t,printOptions:o}=r??{},{create:i}=A(e,{...t,beforeCreate:n=>{var a;(a=t==null?void 0:t.beforeCreate)==null||a.call(t,n),window==null||window.$loadingBar.start()},created(n,a){var c;(c=t==null?void 0:t.created)==null||c.call(t,n,a),window==null||window.$loadingBar.finish()},createdError(n){var a;(a=t==null?void 0:t.createdError)==null||a.call(t,n),window==null||window.$loadingBar.error()}});(s=i("jpeg"))==null||s.then(n=>{const{print:a}=x(n,{type:"image",base64:!0,targetStyles:["*"],...C(o,["type","base64"])});a()})},ee=(e,r)=>{const t=()=>{const i=f(e);i&&(typeof r=="string"?r.trim().split(" "):r).forEach(n=>{n&&i.classList.add(n)})},o=Vue.watch(()=>f(e),t,{immediate:!0});h(o)},te=(e,r)=>{const t=()=>{const i=f(e);if(i)if(r==="removeAllClass"){const s=i.classList;s.forEach(n=>s.remove(n))}else(typeof r=="string"?r.trim().split(" "):r).forEach(n=>{n&&i.classList.remove(n)})},o=Vue.watch(()=>f(e),t,{immediate:!0});h(o)},re=(e,r)=>{const t=Vue.ref(!1),o=()=>{const s=f(e);if(!s)t.value=!1;else{const n=s.className,a=typeof r=="string"?r.trim().split(" ").filter(c=>c!==""):r;t.value=a.some(c=>n.includes(c))}},i=Vue.watch(()=>f(e),o,{immediate:!0});return h(i),t},R=e=>{const r=["webkit","moz","ms","o"],t={};return r.forEach(o=>{t[`${o}${e.charAt(0).toUpperCase()}${e.slice(1)}`]=e}),t},ne=(e,r)=>{const t=(s,n)=>{s.split(";").forEach(a=>{const[c,w]=a.split(":");if(c&&w){const m=c.trim(),g=w.trim();if(c.startsWith("--"))n.style.setProperty(m,g);else if(c.startsWith("-"))n.style[c]=w;else{const d=R(m);Object.keys(d).forEach(E=>{n.style[E]=d[E]}),n.style[m]=g}}})},o=()=>{const s=f(e);s&&(y(r,"String")?t(r,s):y(r,"Array")?r.forEach(n=>{t(n,s)}):Object.keys(r).forEach(a=>{t(`${a}: ${r[a]}`,s)}))},i=Vue.watch(()=>f(e),o,{immediate:!0});h(i)},se=(e,r=1)=>{const t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i,o=/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/i,i=/^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*(?:\.\d+)?)\)$/i;let s;if(t.test(e)){const n=e.substring(1);s="rgb("+[parseInt(n.substring(0,2),16),parseInt(n.substring(2,4),16),parseInt(n.substring(4,6),16)].join(", ")+")"}else return o.test(e)||i.test(e),e;return s&&!s.startsWith("rgba")&&(s=s.replace("rgb","rgba").replace(")",`, ${r})`)),s},oe=(e,r)=>{const{defaultElement:t}=r||{};if(!e)return t?[t]:null;const o=e.startsWith("attr:")?`[${e.replace("attr:","")}]`:e;try{return Array.from(document.querySelectorAll(o))}catch(i){return console.error(`[queryElements]: Failed to get elements for selector '${e}'`,i),t?[t]:null}},ie=(e,r="px")=>typeof e=="number"?e.toString()+r:y(e,"String")&&v.cssUnit.test(e)?e:e+r,u={precision:8,decimal:"."},b=(e,r,t)=>e!=null&&e.length?e.length===1?l(e[0],u):e.reduce((i,s,n,a)=>(i=t==null?void 0:t(i,s,n,a),i),r):0,$=(e,r,t="number")=>{const o=Object.assign({},u,r),i=l(e,o);return t==="number"?i.value:i.toString()},ae=(...e)=>e.length===1?l(e[0],u).add(0):b(e,0,(r,t)=>l(r,u).add(t)),ce=(...e)=>{if(e.length===1)return l(e[0],u).subtract(0);if(e.length===2){const[o,i]=e;return l(o,u).subtract(i)}const r=_(e),t=r.shift();return r.length?b(r,t,(o,i)=>l(o,u).subtract(i)):t},le=(...e)=>e.length===1?l(e[0],u).multiply(1):b(e,1,(r,t)=>l(r,u).multiply(t)),ue=(...e)=>{if(e.length===1)return l(e[0],u).divide(1);if(e.length===2){const[o,i]=e;return l(o,u).divide(i)}const r=_(e),t=r.shift();return b(r,t,(o,i)=>l(o,u).divide(i))},fe=(e,r)=>r<=1?[e||0]:e?l(e,u).distribute(r).map(o=>$(o)):new Array(r).fill(0);function V(e,...r){if(Array.isArray(e))e.forEach(t=>V(t,...r));else return e(...r)}function f(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 de(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 pe(e,r){const t=Vue.watchEffect(e,r);h(t)}export{$ as A,fe as B,ae as C,ce as D,le as E,ue as F,ie as a,V as b,se as c,k as d,Y as e,G as f,T as g,Q as h,y as i,z as j,X as k,te as l,ee as m,H as n,re as o,N as p,oe as q,de as r,O as s,h as t,J as u,f as v,pe as w,C as x,ne as y,Z as z};
|