@gindow/vue 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +154 -109
- package/dist/style.css +1 -1
- package/dist/{vue-go.d.ts → vue.d.ts} +9 -0
- package/package.json +1 -1
- package/src/components/VueIcon.vue +24 -0
- package/src/hooks/useIcon.ts +9 -0
- package/src/index.ts +3 -2
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("vue"),l=require("js-cookie");l=s(l,1);let u=require("axios");u=s(u,1);let d=require("dayjs");d=s(d,1);let f=require("nanoid"),p=require("nanoid/non-secure"),m=require("file-type-checker");m=s(m,1);let h=require("heic2any");h=s(h,1);let g=require("compressorjs");g=s(g,1);var _={cancel:`取消`,confirm:`确认`,empty:{noData:`暂无数据`},dialog:{tip:`操作提示`,confirm:`操作确认`}},v={cancel:`Cancel`,confirm:`Confirm`,empty:{noData:`No data`},dialog:{tip:`Tip`,confirm:`Confirm`}},y=()=>{let e=[`en`,`zh-CN`],t=localStorage.getItem(`locale`),n=navigator.language;return t&&e.includes(t)?t:n&&e.includes(n)?n:n&&e.includes(n.split(`-`)[0])?n.split(`-`)[0]:e[0]??`zh-CN`},b=Symbol(`vue-go-locale`),x=(0,c.ref)(y()),S=(0,c.reactive)({en:v,"zh-CN":_}),C=e=>{if(e?.locale&&(x.value=e.locale),e?.messages)for(let[t,n]of Object.entries(e.messages))S[t]=n;return(0,c.provide)(b,{locale:x,messages:S}),{locale:x,messages:S}},w=()=>{let e=(0,c.inject)(b,void 0),t=e?.locale??x,n=e?.messages??S;return{locale:t,t:(e,r)=>{let i=n[t.value],a=e.replace(/\[(\d+)]/g,`.$1`).split(`.`),o=i;for(let t of a)if(o=o?.[t],o===void 0)return e;let s=o??e;return r&&typeof s==`string`&&(s=s.replace(/\{(\w+)\}/g,(e,t)=>r[t]===void 0?`{${t}}`:String(r[t]))),s}}},T=e=>x.value=e,E=()=>x.value,D=class e{static get userAgent(){return window.navigator.userAgent.toLowerCase()}static get isFlutter(){return e.userAgent.match(/flutter/i)!==null}static get isFlutterIOS(){return e.isFlutter&&e.isIOS}static get isWeb(){return window.matchMedia(`(min-width: 992px)`).matches}static get isMobile(){return e.userAgent.match(/(phone|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)!==null}static get isIOS(){return e.userAgent.match(/iphone|ipad|ipod|ios/i)!==null}static get isWechat(){return e.userAgent.match(/MicroMessenger/i)!==null}static get isWxwork(){return e.userAgent.match(/MicroMessenger/i)!==null&&e.userAgent.match(/wxwork/i)!==null}static get isMiniprogram(){return e.userAgent.match(/MicroMessenger/i)!==null&&e.userAgent.match(/miniprogram/i)!==null}},O=e=>{let t={...e};return typeof t?.search==`string`?t:(t?.search&&(t.search=Object.keys(t.search).filter(e=>t.search[e]!==null&&t.search[e]!==``).map(e=>e+`:`+t.search[e]).join(`;`)),t?.searchFields&&(t.searchFields=Object.keys(t.searchFields).filter(e=>t.searchFields[e]).map(e=>e+`:`+t.searchFields[e]).join(`;`)),t)},k={baseURL:``,publicKey:``,headers:{Accept:`application/json`},instance:null,accessToken:`accessToken`,init(e={}){this.baseURL=e.baseURL??``,this.publicKey=e.publicKey??``;let t=()=>{this.delToken(),location.reload()};this.instance=u.default.create({baseURL:this.baseURL}),this.instance.interceptors.request.use(e=>{let t=localStorage.getItem(`locale`);return t&&(e.headers[`Accept-Language`]=t),e}),this.instance.interceptors.response.use(e=>e.config.responseType===`blob`?e:e.data.code===401?t():e.data.code===200?e.data:Promise.reject(e.data),({response:e})=>Promise.reject(e.data))},setToken(e,t={}){t={...t,domain:`.`+location.hostname},l.default.set(this.accessToken,e,t)},getToken(){return l.default.get(this.accessToken)||``},delToken(){l.default.remove(this.accessToken,{domain:`.`+location.hostname})},get(e,t,n=!1){return this.request({method:`GET`,url:e,params:t},n)},put(e,t,n=!1){return this.request({method:`PUT`,url:e,data:t},n)},patch(e,t,n=!1){return this.request({method:`PATCH`,url:e,data:t},n)},delete(e,t,n=!1){return this.request({method:`DELETE`,url:e,params:t},n)},post(e,t,n=!1){return this.request({method:`POST`,url:e,data:t},n)},blob(e,t,n=!1){return this.request({method:`GET`,url:e,params:t,responseType:`blob`},n)},request(e,t=!1){let n=e.headers??this.headers;return t&&(n.Authorization=`Bearer `+this.getToken()),e.params&&=O(e.params),this.instance({...e,headers:n})},async download(e,t,n,r=!1){let i=await this.blob(e,t,r);if(D.isFlutter)return i;let a=()=>{let e=i.headers[`content-disposition`].split(`filename*=`)[1].split(`;`)[0].trim();return decodeURIComponent(e.replace(/^UTF-8''/i,``))},o=document.createElement(`a`);return o.href=window.URL.createObjectURL(i.data),o.download=n??a(),o.click(),i},async upload(e,t={}){let n={...this.headers,"Content-Type":`multipart/form-data`};return this.instance.post(e,t,{headers:n})},sse(e,t){let n=t?Object.keys(t).map(e=>e+`=`+t[e]).join(`&`):``;return new EventSource(this.baseURL+`/`+e+`?`+n)},setHeader(e,t){this.headers[e]=t},delHeader(e){delete this.headers[e]}},A=class{url;auth;constructor(e,t=!1){this.url=e,this.auth=t}select=e=>k.get(this.url,e,this.auth);create=e=>k.post(this.url,e,this.auth);find=(e,t)=>k.get(this.url+`/`+e,t,this.auth);update=(e,t)=>k.patch(this.url+`/`+e,t,this.auth);delete=(e,t)=>k.delete(this.url+`/`+e,t,this.auth);async get(e){e.size=1;let t=await this.select(e);return t.data=t.data[0]||{},t}},j=(e,t,n)=>{if(e==null)return n;let r=Array.isArray(t)?t:t.replace(/\[(\d+)]/g,`.$1`).split(`.`).filter(Boolean),i=e;for(let e of r)if(i=i?.[e],i===void 0)return n;return i},M=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.style.display=`none`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},N=class{static config={};static set=e=>this.config=e;static id=(e=``)=>e.slice(-12).toUpperCase();static date=(e=``)=>e.substring(0,10)+` `+e.substring(11,19);static idcard=(e=``)=>e?e.substring(0,6)+`****`+e.substring(14):``;static phone=(e=``,t=!1)=>t||!e?e:e.substring(0,3)+`****`+e.substring(e.length-4);static email=(e=``)=>{let[t,n]=e.split(`@`);return!t||!n?e:`${t.length>2?t[0]+`****`+t[t.length-1]:t}@${n}`};static bankcard=(e=``)=>e.substring(0,4)+`****`+e.substring(e.length-4);static url=(e=``)=>e.replace(/:\/\//g,`:##`).replace(/\/+/g,`/`).replace(/:##/g,`://`);static price=(e=0,t)=>{let{locale:n,decimals:r,currency:i}=this.config,a=typeof e==`string`?parseFloat(e):e;return new Intl.NumberFormat(n,{style:`currency`,currency:t??i??`CNY`,minimumFractionDigits:r??2,maximumFractionDigits:r??2}).format(a/100)};static currency=(e=0,t)=>this.price(e,t)},P=class e{static country=``;static set=e=>this.country=e;static get phone_pattern(){return this.country.toUpperCase()===`CN`?/([1][3,4,5,6,7,8,9][0-9]{9})$/:/^(?:\+?[1-9]\d{7,14}|\d{6,11})$/}static email_pattern=/^([a-zA-Z0-9_\.-]+)@([\da-zA-Z\.-]+)\.([a-zA-Z\.]{2,6})$/;static idcard_pattern=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;static cname_pattern=/^(?:[\u4e00-\u9fa5·]{2,16})$/;static password_pattern=/^(?![A-Za-z]+$)(?![0-9]+$)(?![^A-Za-z0-9]+$).{8,20}$/;static phone=t=>e.phone_pattern.test(t);static email=t=>e.email_pattern.test(t);static idcard=t=>e.idcard_pattern.test(t);static cname=t=>e.cname_pattern.test(t)},F=class e{static dayjs=d.default;static s(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH:mm:ss`.replace(/\//g,n))}static m(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH:mm`.replace(/\//g,n))}static h(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH`.replace(/\//g,n))}static d(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD`.replace(/\//g,n))}static M(t,n=`/`){return e.dayjs(t).format(`YYYY/MM`.replace(/\//g,n))}static y(t){return e.dayjs(t).format(`YYYY`)}static date(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD`.replace(/\//g,n))}static time(t){return e.dayjs(t).format(`HH:mm`)}static format(t,n=`YYYY/MM/DD HH:mm:ss`){return e.dayjs(t).format(n)}},I=768,L=()=>{let e=(0,c.ref)(typeof window<`u`?window.matchMedia(`(min-width: ${I}px)`).matches:!0),t,n=t=>e.value=t.matches;(0,c.onMounted)(()=>{typeof window>`u`||(t=window.matchMedia(`(min-width: ${I}px)`),e.value=t.matches,t.addEventListener(`change`,n))}),(0,c.onBeforeUnmount)(()=>t?.removeEventListener(`change`,n));let r=(0,c.computed)(()=>e.value);return{isMobile:(0,c.computed)(()=>!e.value),isDesktop:r}},R=()=>({nanoid:f.nanoid,numeric:(e=10)=>(0,p.customAlphabet)(`1234567890`,e)()}),z=e=>{let t=(0,c.ref)(0),n=(0,c.ref)(!1),r=(t={})=>new Promise((r,a)=>{n.value||(n.value=!0,e(t).then(()=>{i(),r(!0)}).catch(e=>a(e)).finally(()=>n.value=!1))}),i=()=>{t.value=60;let e=setInterval(()=>{t.value--,t.value||clearTimeout(e)},1e3)};return{waiting:t,send:r}},B=()=>{let e=e=>new Promise(async t=>{let n=await(0,h.default)({blob:e,toType:`image/jpeg`,quality:.9});return t(new File([n],e.name,{type:n.type,lastModified:Date.now()}))}),t=e=>new Promise(t=>{new g.default(e,{quality:.9,success:e=>t(e)})});return{handler:(n,r={compressor:!0})=>new Promise(i=>{let a=new FileReader;a.readAsArrayBuffer(n),a.onload=()=>{let o=m.default.validateFileType(a.result,[`heic`]),s=m.default.validateFileType(a.result,[`jpeg`,`png`,`gif`,`bmp`]);o?i(e(n)):s&&r.compressor?i(t(n)):i(n)}}),getDimension:async e=>new Promise((t,n)=>{let r=new Image;r.src=URL.createObjectURL(e),r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=e=>n(e)}),getFileType:e=>new Promise(t=>{let n=new FileReader;n.readAsArrayBuffer(e),n.onload=()=>{t({mimeType:m.default.detectFile(n.result)?.mimeType})}})}},V=(e,t)=>({sendMessage:async(n,r)=>{let{onMessage:i,onEnd:a,onError:o,onFinish:s}=r;try{let{ok:r,status:c,statusText:l,body:u}=await fetch(`${e}/chat-messages`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({...n,response_mode:`streaming`})});if(!r)return o?.({code:String(c),message:l});let d=u?.getReader();if(!d)return o?.({code:`reader_error`,message:`Failed to get response reader`});let f=new TextDecoder,p=``;for(;;){let{done:e,value:t}=await d.read();if(e)break;p+=f.decode(t,{stream:!0});let n=p.split(`
|
|
2
|
-
`);p=n.pop()||``;for(let e of n)if(e.startsWith(`data:`))try{let t=e.slice(5).trim();if(!t)continue;let n=JSON.parse(t);if(n.event===`agent_message`)i?.(n.answer||``);else if(n.event===`message_end`)a?.(n.conversation_id,n.message_id);else if(n.event===`error`){let{code:e,message:t}=n;o?.({code:e,message:t})}s?.()}catch{}}}catch(e){o?.({code:`network_error`,message:String(e)})}}}),H={install(e,t){
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("vue"),l=require("js-cookie");l=s(l,1);let u=require("axios");u=s(u,1);let d=require("dayjs");d=s(d,1);let f=require("@iconify/vue"),p=require("nanoid"),m=require("nanoid/non-secure"),h=require("file-type-checker");h=s(h,1);let g=require("heic2any");g=s(g,1);let _=require("compressorjs");_=s(_,1);var v={cancel:`取消`,confirm:`确认`,empty:{noData:`暂无数据`},dialog:{tip:`操作提示`,confirm:`操作确认`}},y={cancel:`Cancel`,confirm:`Confirm`,empty:{noData:`No data`},dialog:{tip:`Tip`,confirm:`Confirm`}},b=()=>{let e=[`en`,`zh-CN`],t=localStorage.getItem(`locale`),n=navigator.language;return t&&e.includes(t)?t:n&&e.includes(n)?n:n&&e.includes(n.split(`-`)[0])?n.split(`-`)[0]:e[0]??`zh-CN`},x=Symbol(`vue-go-locale`),S=(0,c.ref)(b()),C=(0,c.reactive)({en:y,"zh-CN":v}),w=e=>{if(e?.locale&&(S.value=e.locale),e?.messages)for(let[t,n]of Object.entries(e.messages))C[t]=n;return(0,c.provide)(x,{locale:S,messages:C}),{locale:S,messages:C}},T=()=>{let e=(0,c.inject)(x,void 0),t=e?.locale??S,n=e?.messages??C;return{locale:t,t:(e,r)=>{let i=n[t.value],a=e.replace(/\[(\d+)]/g,`.$1`).split(`.`),o=i;for(let t of a)if(o=o?.[t],o===void 0)return e;let s=o??e;return r&&typeof s==`string`&&(s=s.replace(/\{(\w+)\}/g,(e,t)=>r[t]===void 0?`{${t}}`:String(r[t]))),s}}},E=e=>S.value=e,D=()=>S.value,O=class e{static get userAgent(){return window.navigator.userAgent.toLowerCase()}static get isFlutter(){return e.userAgent.match(/flutter/i)!==null}static get isFlutterIOS(){return e.isFlutter&&e.isIOS}static get isWeb(){return window.matchMedia(`(min-width: 992px)`).matches}static get isMobile(){return e.userAgent.match(/(phone|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)!==null}static get isIOS(){return e.userAgent.match(/iphone|ipad|ipod|ios/i)!==null}static get isWechat(){return e.userAgent.match(/MicroMessenger/i)!==null}static get isWxwork(){return e.userAgent.match(/MicroMessenger/i)!==null&&e.userAgent.match(/wxwork/i)!==null}static get isMiniprogram(){return e.userAgent.match(/MicroMessenger/i)!==null&&e.userAgent.match(/miniprogram/i)!==null}},k=e=>{let t={...e};return typeof t?.search==`string`?t:(t?.search&&(t.search=Object.keys(t.search).filter(e=>t.search[e]!==null&&t.search[e]!==``).map(e=>e+`:`+t.search[e]).join(`;`)),t?.searchFields&&(t.searchFields=Object.keys(t.searchFields).filter(e=>t.searchFields[e]).map(e=>e+`:`+t.searchFields[e]).join(`;`)),t)},A={baseURL:``,publicKey:``,headers:{Accept:`application/json`},instance:null,accessToken:`accessToken`,init(e={}){this.baseURL=e.baseURL??``,this.publicKey=e.publicKey??``;let t=()=>{this.delToken(),location.reload()};this.instance=u.default.create({baseURL:this.baseURL}),this.instance.interceptors.request.use(e=>{let t=localStorage.getItem(`locale`);return t&&(e.headers[`Accept-Language`]=t),e}),this.instance.interceptors.response.use(e=>e.config.responseType===`blob`?e:e.data.code===401?t():e.data.code===200?e.data:Promise.reject(e.data),({response:e})=>Promise.reject(e.data))},setToken(e,t={}){t={...t,domain:`.`+location.hostname},l.default.set(this.accessToken,e,t)},getToken(){return l.default.get(this.accessToken)||``},delToken(){l.default.remove(this.accessToken,{domain:`.`+location.hostname})},get(e,t,n=!1){return this.request({method:`GET`,url:e,params:t},n)},put(e,t,n=!1){return this.request({method:`PUT`,url:e,data:t},n)},patch(e,t,n=!1){return this.request({method:`PATCH`,url:e,data:t},n)},delete(e,t,n=!1){return this.request({method:`DELETE`,url:e,params:t},n)},post(e,t,n=!1){return this.request({method:`POST`,url:e,data:t},n)},blob(e,t,n=!1){return this.request({method:`GET`,url:e,params:t,responseType:`blob`},n)},request(e,t=!1){let n=e.headers??this.headers;return t&&(n.Authorization=`Bearer `+this.getToken()),e.params&&=k(e.params),this.instance({...e,headers:n})},async download(e,t,n,r=!1){let i=await this.blob(e,t,r);if(O.isFlutter)return i;let a=()=>{let e=i.headers[`content-disposition`].split(`filename*=`)[1].split(`;`)[0].trim();return decodeURIComponent(e.replace(/^UTF-8''/i,``))},o=document.createElement(`a`);return o.href=window.URL.createObjectURL(i.data),o.download=n??a(),o.click(),i},async upload(e,t={}){let n={...this.headers,"Content-Type":`multipart/form-data`};return this.instance.post(e,t,{headers:n})},sse(e,t){let n=t?Object.keys(t).map(e=>e+`=`+t[e]).join(`&`):``;return new EventSource(this.baseURL+`/`+e+`?`+n)},setHeader(e,t){this.headers[e]=t},delHeader(e){delete this.headers[e]}},j=class{url;auth;constructor(e,t=!1){this.url=e,this.auth=t}select=e=>A.get(this.url,e,this.auth);create=e=>A.post(this.url,e,this.auth);find=(e,t)=>A.get(this.url+`/`+e,t,this.auth);update=(e,t)=>A.patch(this.url+`/`+e,t,this.auth);delete=(e,t)=>A.delete(this.url+`/`+e,t,this.auth);async get(e){e.size=1;let t=await this.select(e);return t.data=t.data[0]||{},t}},M=(e,t,n)=>{if(e==null)return n;let r=Array.isArray(t)?t:t.replace(/\[(\d+)]/g,`.$1`).split(`.`).filter(Boolean),i=e;for(let e of r)if(i=i?.[e],i===void 0)return n;return i},N=(e,t)=>{let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.style.display=`none`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)},P=class{static config={};static set=e=>this.config=e;static id=(e=``)=>e.slice(-12).toUpperCase();static date=(e=``)=>e.substring(0,10)+` `+e.substring(11,19);static idcard=(e=``)=>e?e.substring(0,6)+`****`+e.substring(14):``;static phone=(e=``,t=!1)=>t||!e?e:e.substring(0,3)+`****`+e.substring(e.length-4);static email=(e=``)=>{let[t,n]=e.split(`@`);return!t||!n?e:`${t.length>2?t[0]+`****`+t[t.length-1]:t}@${n}`};static bankcard=(e=``)=>e.substring(0,4)+`****`+e.substring(e.length-4);static url=(e=``)=>e.replace(/:\/\//g,`:##`).replace(/\/+/g,`/`).replace(/:##/g,`://`);static price=(e=0,t)=>{let{locale:n,decimals:r,currency:i}=this.config,a=typeof e==`string`?parseFloat(e):e;return new Intl.NumberFormat(n,{style:`currency`,currency:t??i??`CNY`,minimumFractionDigits:r??2,maximumFractionDigits:r??2}).format(a/100)};static currency=(e=0,t)=>this.price(e,t)},F=class e{static country=``;static set=e=>this.country=e;static get phone_pattern(){return this.country.toUpperCase()===`CN`?/([1][3,4,5,6,7,8,9][0-9]{9})$/:/^(?:\+?[1-9]\d{7,14}|\d{6,11})$/}static email_pattern=/^([a-zA-Z0-9_\.-]+)@([\da-zA-Z\.-]+)\.([a-zA-Z\.]{2,6})$/;static idcard_pattern=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;static cname_pattern=/^(?:[\u4e00-\u9fa5·]{2,16})$/;static password_pattern=/^(?![A-Za-z]+$)(?![0-9]+$)(?![^A-Za-z0-9]+$).{8,20}$/;static phone=t=>e.phone_pattern.test(t);static email=t=>e.email_pattern.test(t);static idcard=t=>e.idcard_pattern.test(t);static cname=t=>e.cname_pattern.test(t)},I=class e{static dayjs=d.default;static s(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH:mm:ss`.replace(/\//g,n))}static m(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH:mm`.replace(/\//g,n))}static h(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH`.replace(/\//g,n))}static d(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD`.replace(/\//g,n))}static M(t,n=`/`){return e.dayjs(t).format(`YYYY/MM`.replace(/\//g,n))}static y(t){return e.dayjs(t).format(`YYYY`)}static date(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD`.replace(/\//g,n))}static time(t){return e.dayjs(t).format(`HH:mm`)}static format(t,n=`YYYY/MM/DD HH:mm:ss`){return e.dayjs(t).format(n)}},L=768,R=()=>{let e=(0,c.ref)(typeof window<`u`?window.matchMedia(`(min-width: ${L}px)`).matches:!0),t,n=t=>e.value=t.matches;(0,c.onMounted)(()=>{typeof window>`u`||(t=window.matchMedia(`(min-width: ${L}px)`),e.value=t.matches,t.addEventListener(`change`,n))}),(0,c.onBeforeUnmount)(()=>t?.removeEventListener(`change`,n));let r=(0,c.computed)(()=>e.value);return{isMobile:(0,c.computed)(()=>!e.value),isDesktop:r}},z=e=>{let t=(0,c.ref)(0),n=(0,c.ref)(!1),r=(t={})=>new Promise((r,a)=>{n.value||(n.value=!0,e(t).then(()=>{i(),r(!0)}).catch(e=>a(e)).finally(()=>n.value=!1))}),i=()=>{t.value=60;let e=setInterval(()=>{t.value--,t.value||clearTimeout(e)},1e3)};return{waiting:t,send:r}},B=(e,t)=>({sendMessage:async(n,r)=>{let{onMessage:i,onEnd:a,onError:o,onFinish:s}=r;try{let{ok:r,status:c,statusText:l,body:u}=await fetch(`${e}/chat-messages`,{method:`POST`,headers:{Authorization:`Bearer ${t}`,"Content-Type":`application/json`},body:JSON.stringify({...n,response_mode:`streaming`})});if(!r)return o?.({code:String(c),message:l});let d=u?.getReader();if(!d)return o?.({code:`reader_error`,message:`Failed to get response reader`});let f=new TextDecoder,p=``;for(;;){let{done:e,value:t}=await d.read();if(e)break;p+=f.decode(t,{stream:!0});let n=p.split(`
|
|
2
|
+
`);p=n.pop()||``;for(let e of n)if(e.startsWith(`data:`))try{let t=e.slice(5).trim();if(!t)continue;let n=JSON.parse(t);if(n.event===`agent_message`)i?.(n.answer||``);else if(n.event===`message_end`)a?.(n.conversation_id,n.message_id);else if(n.event===`error`){let{code:e,message:t}=n;o?.({code:e,message:t})}s?.()}catch{}}}catch(e){o?.({code:`network_error`,message:String(e)})}}}),V=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})((0,c.defineComponent)({__name:`VueIcon`,props:{vendor:{type:String,default:`icon-park-outline`},icon:{type:String,default:``},size:{type:Number,default:16},strokeWidth:{type:Number,default:4},color:{type:String}},setup(e){(0,c.useCssVars)(e=>({v1903d129:i.value}));let t=e,n=(0,c.computed)(()=>t.icon.indexOf(`:`)===-1?`${t.vendor}:${t.icon}`:t.icon),r=(0,c.computed)(()=>t.color?{color:t.color}:void 0),i=(0,c.computed)(()=>t.strokeWidth);return(t,i)=>((0,c.openBlock)(),(0,c.createBlock)((0,c.unref)(f.Icon),{icon:n.value,width:e.size,height:e.size,style:(0,c.normalizeStyle)(r.value),"aria-hidden":null},null,8,[`icon`,`width`,`height`,`style`]))}}),[[`__scopeId`,`data-v-2533db5c`]]),H=()=>({i:(e,t={})=>e?(0,c.h)(V,{icon:e,...t}):void 0}),U=()=>({nanoid:p.nanoid,numeric:(e=10)=>(0,m.customAlphabet)(`1234567890`,e)()}),W=()=>{let e=e=>new Promise(async t=>{let n=await(0,g.default)({blob:e,toType:`image/jpeg`,quality:.9});return t(new File([n],e.name,{type:n.type,lastModified:Date.now()}))}),t=e=>new Promise(t=>{new _.default(e,{quality:.9,success:e=>t(e)})});return{handler:(n,r={compressor:!0})=>new Promise(i=>{let a=new FileReader;a.readAsArrayBuffer(n),a.onload=()=>{let o=h.default.validateFileType(a.result,[`heic`]),s=h.default.validateFileType(a.result,[`jpeg`,`png`,`gif`,`bmp`]);o?i(e(n)):s&&r.compressor?i(t(n)):i(n)}}),getDimension:async e=>new Promise((t,n)=>{let r=new Image;r.src=URL.createObjectURL(e),r.onload=()=>t({width:r.naturalWidth,height:r.naturalHeight}),r.onerror=e=>n(e)}),getFileType:e=>new Promise(t=>{let n=new FileReader;n.readAsArrayBuffer(e),n.onload=()=>{t({mimeType:h.default.detectFile(n.result)?.mimeType})}})}},G={install(e,t){w(t),e.config.globalProperties.$setLocale=E,e.config.globalProperties.$getLocale=D}};exports.$params=k,exports.DateTime=I,exports.Formatter=P,exports.Platform=O,exports.Validate=F,exports.default=G,exports.download=N,exports.get=M,exports.getLocale=D,exports.request=A,exports.resource=j,exports.setLocale=E,exports.useBreak=R,exports.useCaptcha=z,exports.useChat=B,exports.useIcon=H,exports.useLocale=T,exports.useNanoid=U,exports.useUpload=W;
|
package/dist/index.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { computed as e,
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import { computed as e, createBlock as t, defineComponent as n, h as r, inject as i, normalizeStyle as a, onBeforeUnmount as o, onMounted as s, openBlock as c, provide as l, reactive as u, ref as d, unref as f, useCssVars as p } from "vue";
|
|
2
|
+
import m from "js-cookie";
|
|
3
|
+
import h from "axios";
|
|
4
|
+
import g from "dayjs";
|
|
5
|
+
import { Icon as _ } from "@iconify/vue";
|
|
6
|
+
import { nanoid as v } from "nanoid";
|
|
7
|
+
import { customAlphabet as y } from "nanoid/non-secure";
|
|
8
|
+
import b from "file-type-checker";
|
|
9
|
+
import x from "heic2any";
|
|
10
|
+
import S from "compressorjs";
|
|
10
11
|
//#region src/locale/zh-CN.ts
|
|
11
|
-
var
|
|
12
|
+
var C = {
|
|
12
13
|
cancel: "取消",
|
|
13
14
|
confirm: "确认",
|
|
14
15
|
empty: { noData: "暂无数据" },
|
|
@@ -16,7 +17,7 @@ var h = {
|
|
|
16
17
|
tip: "操作提示",
|
|
17
18
|
confirm: "操作确认"
|
|
18
19
|
}
|
|
19
|
-
},
|
|
20
|
+
}, w = {
|
|
20
21
|
cancel: "Cancel",
|
|
21
22
|
confirm: "Confirm",
|
|
22
23
|
empty: { noData: "No data" },
|
|
@@ -24,33 +25,33 @@ var h = {
|
|
|
24
25
|
tip: "Tip",
|
|
25
26
|
confirm: "Confirm"
|
|
26
27
|
}
|
|
27
|
-
},
|
|
28
|
+
}, T = () => {
|
|
28
29
|
let e = ["en", "zh-CN"], t = localStorage.getItem("locale"), n = navigator.language;
|
|
29
30
|
return t && e.includes(t) ? t : n && e.includes(n) ? n : n && e.includes(n.split("-")[0]) ? n.split("-")[0] : e[0] ?? "zh-CN";
|
|
30
|
-
},
|
|
31
|
-
en:
|
|
32
|
-
"zh-CN":
|
|
33
|
-
}),
|
|
34
|
-
if (e?.locale && (
|
|
35
|
-
return
|
|
36
|
-
locale:
|
|
37
|
-
messages:
|
|
31
|
+
}, E = Symbol("vue-go-locale"), D = d(T()), O = u({
|
|
32
|
+
en: w,
|
|
33
|
+
"zh-CN": C
|
|
34
|
+
}), k = (e) => {
|
|
35
|
+
if (e?.locale && (D.value = e.locale), e?.messages) for (let [t, n] of Object.entries(e.messages)) O[t] = n;
|
|
36
|
+
return l(E, {
|
|
37
|
+
locale: D,
|
|
38
|
+
messages: O
|
|
38
39
|
}), {
|
|
39
|
-
locale:
|
|
40
|
-
messages:
|
|
40
|
+
locale: D,
|
|
41
|
+
messages: O
|
|
41
42
|
};
|
|
42
|
-
},
|
|
43
|
-
let e =
|
|
43
|
+
}, A = () => {
|
|
44
|
+
let e = i(E, void 0), t = e?.locale ?? D, n = e?.messages ?? O;
|
|
44
45
|
return {
|
|
45
|
-
locale:
|
|
46
|
-
t: (e,
|
|
47
|
-
let i =
|
|
46
|
+
locale: t,
|
|
47
|
+
t: (e, r) => {
|
|
48
|
+
let i = n[t.value], a = e.replace(/\[(\d+)]/g, ".$1").split("."), o = i;
|
|
48
49
|
for (let t of a) if (o = o?.[t], o === void 0) return e;
|
|
49
50
|
let s = o ?? e;
|
|
50
|
-
return
|
|
51
|
+
return r && typeof s == "string" && (s = s.replace(/\{(\w+)\}/g, (e, t) => r[t] === void 0 ? `{${t}}` : String(r[t]))), s;
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
|
-
},
|
|
54
|
+
}, j = (e) => D.value = e, M = () => D.value, N = class e {
|
|
54
55
|
static get userAgent() {
|
|
55
56
|
return window.navigator.userAgent.toLowerCase();
|
|
56
57
|
}
|
|
@@ -78,10 +79,10 @@ var h = {
|
|
|
78
79
|
static get isMiniprogram() {
|
|
79
80
|
return e.userAgent.match(/MicroMessenger/i) !== null && e.userAgent.match(/miniprogram/i) !== null;
|
|
80
81
|
}
|
|
81
|
-
},
|
|
82
|
+
}, P = (e) => {
|
|
82
83
|
let t = { ...e };
|
|
83
84
|
return typeof t?.search == "string" ? t : (t?.search && (t.search = Object.keys(t.search).filter((e) => t.search[e] !== null && t.search[e] !== "").map((e) => e + ":" + t.search[e]).join(";")), t?.searchFields && (t.searchFields = Object.keys(t.searchFields).filter((e) => t.searchFields[e]).map((e) => e + ":" + t.searchFields[e]).join(";")), t);
|
|
84
|
-
},
|
|
85
|
+
}, F = {
|
|
85
86
|
baseURL: "",
|
|
86
87
|
publicKey: "",
|
|
87
88
|
headers: { Accept: "application/json" },
|
|
@@ -92,7 +93,7 @@ var h = {
|
|
|
92
93
|
let t = () => {
|
|
93
94
|
this.delToken(), location.reload();
|
|
94
95
|
};
|
|
95
|
-
this.instance =
|
|
96
|
+
this.instance = h.create({ baseURL: this.baseURL }), this.instance.interceptors.request.use((e) => {
|
|
96
97
|
let t = localStorage.getItem("locale");
|
|
97
98
|
return t && (e.headers["Accept-Language"] = t), e;
|
|
98
99
|
}), this.instance.interceptors.response.use((e) => e.config.responseType === "blob" ? e : e.data.code === 401 ? t() : e.data.code === 200 ? e.data : Promise.reject(e.data), ({ response: e }) => Promise.reject(e.data));
|
|
@@ -101,13 +102,13 @@ var h = {
|
|
|
101
102
|
t = {
|
|
102
103
|
...t,
|
|
103
104
|
domain: "." + location.hostname
|
|
104
|
-
},
|
|
105
|
+
}, m.set(this.accessToken, e, t);
|
|
105
106
|
},
|
|
106
107
|
getToken() {
|
|
107
|
-
return
|
|
108
|
+
return m.get(this.accessToken) || "";
|
|
108
109
|
},
|
|
109
110
|
delToken() {
|
|
110
|
-
|
|
111
|
+
m.remove(this.accessToken, { domain: "." + location.hostname });
|
|
111
112
|
},
|
|
112
113
|
get(e, t, n = !1) {
|
|
113
114
|
return this.request({
|
|
@@ -154,14 +155,14 @@ var h = {
|
|
|
154
155
|
},
|
|
155
156
|
request(e, t = !1) {
|
|
156
157
|
let n = e.headers ?? this.headers;
|
|
157
|
-
return t && (n.Authorization = "Bearer " + this.getToken()), e.params &&=
|
|
158
|
+
return t && (n.Authorization = "Bearer " + this.getToken()), e.params &&= P(e.params), this.instance({
|
|
158
159
|
...e,
|
|
159
160
|
headers: n
|
|
160
161
|
});
|
|
161
162
|
},
|
|
162
163
|
async download(e, t, n, r = !1) {
|
|
163
164
|
let i = await this.blob(e, t, r);
|
|
164
|
-
if (
|
|
165
|
+
if (N.isFlutter) return i;
|
|
165
166
|
let a = () => {
|
|
166
167
|
let e = i.headers["content-disposition"].split("filename*=")[1].split(";")[0].trim();
|
|
167
168
|
return decodeURIComponent(e.replace(/^UTF-8''/i, ""));
|
|
@@ -185,31 +186,31 @@ var h = {
|
|
|
185
186
|
delHeader(e) {
|
|
186
187
|
delete this.headers[e];
|
|
187
188
|
}
|
|
188
|
-
},
|
|
189
|
+
}, I = class {
|
|
189
190
|
url;
|
|
190
191
|
auth;
|
|
191
192
|
constructor(e, t = !1) {
|
|
192
193
|
this.url = e, this.auth = t;
|
|
193
194
|
}
|
|
194
|
-
select = (e) =>
|
|
195
|
-
create = (e) =>
|
|
196
|
-
find = (e, t) =>
|
|
197
|
-
update = (e, t) =>
|
|
198
|
-
delete = (e, t) =>
|
|
195
|
+
select = (e) => F.get(this.url, e, this.auth);
|
|
196
|
+
create = (e) => F.post(this.url, e, this.auth);
|
|
197
|
+
find = (e, t) => F.get(this.url + "/" + e, t, this.auth);
|
|
198
|
+
update = (e, t) => F.patch(this.url + "/" + e, t, this.auth);
|
|
199
|
+
delete = (e, t) => F.delete(this.url + "/" + e, t, this.auth);
|
|
199
200
|
async get(e) {
|
|
200
201
|
e.size = 1;
|
|
201
202
|
let t = await this.select(e);
|
|
202
203
|
return t.data = t.data[0] || {}, t;
|
|
203
204
|
}
|
|
204
|
-
},
|
|
205
|
+
}, L = (e, t, n) => {
|
|
205
206
|
if (e == null) return n;
|
|
206
207
|
let r = Array.isArray(t) ? t : t.replace(/\[(\d+)]/g, ".$1").split(".").filter(Boolean), i = e;
|
|
207
208
|
for (let e of r) if (i = i?.[e], i === void 0) return n;
|
|
208
209
|
return i;
|
|
209
|
-
},
|
|
210
|
+
}, R = (e, t) => {
|
|
210
211
|
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
211
212
|
r.href = n, r.download = t, r.style.display = "none", document.body.appendChild(r), r.click(), document.body.removeChild(r), URL.revokeObjectURL(n);
|
|
212
|
-
},
|
|
213
|
+
}, z = class {
|
|
213
214
|
static config = {};
|
|
214
215
|
static set = (e) => this.config = e;
|
|
215
216
|
static id = (e = "") => e.slice(-12).toUpperCase();
|
|
@@ -232,7 +233,7 @@ var h = {
|
|
|
232
233
|
}).format(a / 100);
|
|
233
234
|
};
|
|
234
235
|
static currency = (e = 0, t) => this.price(e, t);
|
|
235
|
-
},
|
|
236
|
+
}, B = class e {
|
|
236
237
|
static country = "";
|
|
237
238
|
static set = (e) => this.country = e;
|
|
238
239
|
static get phone_pattern() {
|
|
@@ -246,8 +247,8 @@ var h = {
|
|
|
246
247
|
static email = (t) => e.email_pattern.test(t);
|
|
247
248
|
static idcard = (t) => e.idcard_pattern.test(t);
|
|
248
249
|
static cname = (t) => e.cname_pattern.test(t);
|
|
249
|
-
},
|
|
250
|
-
static dayjs =
|
|
250
|
+
}, V = class e {
|
|
251
|
+
static dayjs = g;
|
|
251
252
|
static s(t, n = "/") {
|
|
252
253
|
return e.dayjs(t).format("YYYY/MM/DD HH:mm:ss".replace(/\//g, n));
|
|
253
254
|
}
|
|
@@ -275,21 +276,18 @@ var h = {
|
|
|
275
276
|
static format(t, n = "YYYY/MM/DD HH:mm:ss") {
|
|
276
277
|
return e.dayjs(t).format(n);
|
|
277
278
|
}
|
|
278
|
-
},
|
|
279
|
-
let t =
|
|
280
|
-
|
|
281
|
-
typeof window > "u" || (
|
|
282
|
-
}),
|
|
283
|
-
let
|
|
279
|
+
}, H = 768, U = () => {
|
|
280
|
+
let t = d(typeof window < "u" ? window.matchMedia(`(min-width: ${H}px)`).matches : !0), n, r = (e) => t.value = e.matches;
|
|
281
|
+
s(() => {
|
|
282
|
+
typeof window > "u" || (n = window.matchMedia(`(min-width: ${H}px)`), t.value = n.matches, n.addEventListener("change", r));
|
|
283
|
+
}), o(() => n?.removeEventListener("change", r));
|
|
284
|
+
let i = e(() => t.value);
|
|
284
285
|
return {
|
|
285
286
|
isMobile: e(() => !t.value),
|
|
286
|
-
isDesktop:
|
|
287
|
+
isDesktop: i
|
|
287
288
|
};
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
numeric: (e = 10) => d("1234567890", e)()
|
|
291
|
-
}), L = (e) => {
|
|
292
|
-
let t = o(0), n = o(!1), r = (t = {}) => new Promise((r, a) => {
|
|
289
|
+
}, W = (e) => {
|
|
290
|
+
let t = d(0), n = d(!1), r = (t = {}) => new Promise((r, a) => {
|
|
293
291
|
n.value || (n.value = !0, e(t).then(() => {
|
|
294
292
|
i(), r(!0);
|
|
295
293
|
}).catch((e) => a(e)).finally(() => n.value = !1));
|
|
@@ -303,51 +301,7 @@ var h = {
|
|
|
303
301
|
waiting: t,
|
|
304
302
|
send: r
|
|
305
303
|
};
|
|
306
|
-
},
|
|
307
|
-
let e = (e) => new Promise(async (t) => {
|
|
308
|
-
let n = await p({
|
|
309
|
-
blob: e,
|
|
310
|
-
toType: "image/jpeg",
|
|
311
|
-
quality: .9
|
|
312
|
-
});
|
|
313
|
-
return t(new File([n], e.name, {
|
|
314
|
-
type: n.type,
|
|
315
|
-
lastModified: Date.now()
|
|
316
|
-
}));
|
|
317
|
-
}), t = (e) => new Promise((t) => {
|
|
318
|
-
new m(e, {
|
|
319
|
-
quality: .9,
|
|
320
|
-
success: (e) => t(e)
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
return {
|
|
324
|
-
handler: (n, r = { compressor: !0 }) => new Promise((i) => {
|
|
325
|
-
let a = new FileReader();
|
|
326
|
-
a.readAsArrayBuffer(n), a.onload = () => {
|
|
327
|
-
let o = f.validateFileType(a.result, ["heic"]), s = f.validateFileType(a.result, [
|
|
328
|
-
"jpeg",
|
|
329
|
-
"png",
|
|
330
|
-
"gif",
|
|
331
|
-
"bmp"
|
|
332
|
-
]);
|
|
333
|
-
o ? i(e(n)) : s && r.compressor ? i(t(n)) : i(n);
|
|
334
|
-
};
|
|
335
|
-
}),
|
|
336
|
-
getDimension: async (e) => new Promise((t, n) => {
|
|
337
|
-
let r = new Image();
|
|
338
|
-
r.src = URL.createObjectURL(e), r.onload = () => t({
|
|
339
|
-
width: r.naturalWidth,
|
|
340
|
-
height: r.naturalHeight
|
|
341
|
-
}), r.onerror = (e) => n(e);
|
|
342
|
-
}),
|
|
343
|
-
getFileType: (e) => new Promise((t) => {
|
|
344
|
-
let n = new FileReader();
|
|
345
|
-
n.readAsArrayBuffer(e), n.onload = () => {
|
|
346
|
-
t({ mimeType: f.detectFile(n.result)?.mimeType });
|
|
347
|
-
};
|
|
348
|
-
})
|
|
349
|
-
};
|
|
350
|
-
}, z = (e, t) => ({ sendMessage: async (n, r) => {
|
|
304
|
+
}, G = (e, t) => ({ sendMessage: async (n, r) => {
|
|
351
305
|
let { onMessage: i, onEnd: a, onError: o, onFinish: s } = r;
|
|
352
306
|
try {
|
|
353
307
|
let { ok: r, status: c, statusText: l, body: u } = await fetch(`${e}/chat-messages`, {
|
|
@@ -399,8 +353,99 @@ var h = {
|
|
|
399
353
|
message: String(e)
|
|
400
354
|
});
|
|
401
355
|
}
|
|
402
|
-
} }),
|
|
403
|
-
|
|
356
|
+
} }), K = /* @__PURE__ */ ((e, t) => {
|
|
357
|
+
let n = e.__vccOpts || e;
|
|
358
|
+
for (let [e, r] of t) n[e] = r;
|
|
359
|
+
return n;
|
|
360
|
+
})(/* @__PURE__ */ n({
|
|
361
|
+
__name: "VueIcon",
|
|
362
|
+
props: {
|
|
363
|
+
vendor: {
|
|
364
|
+
type: String,
|
|
365
|
+
default: "icon-park-outline"
|
|
366
|
+
},
|
|
367
|
+
icon: {
|
|
368
|
+
type: String,
|
|
369
|
+
default: ""
|
|
370
|
+
},
|
|
371
|
+
size: {
|
|
372
|
+
type: Number,
|
|
373
|
+
default: 16
|
|
374
|
+
},
|
|
375
|
+
strokeWidth: {
|
|
376
|
+
type: Number,
|
|
377
|
+
default: 4
|
|
378
|
+
},
|
|
379
|
+
color: { type: String }
|
|
380
|
+
},
|
|
381
|
+
setup(n) {
|
|
382
|
+
p((e) => ({ v1903d129: s.value }));
|
|
383
|
+
let r = n, i = e(() => r.icon.indexOf(":") === -1 ? `${r.vendor}:${r.icon}` : r.icon), o = e(() => r.color ? { color: r.color } : void 0), s = e(() => r.strokeWidth);
|
|
384
|
+
return (e, r) => (c(), t(f(_), {
|
|
385
|
+
icon: i.value,
|
|
386
|
+
width: n.size,
|
|
387
|
+
height: n.size,
|
|
388
|
+
style: a(o.value),
|
|
389
|
+
"aria-hidden": null
|
|
390
|
+
}, null, 8, [
|
|
391
|
+
"icon",
|
|
392
|
+
"width",
|
|
393
|
+
"height",
|
|
394
|
+
"style"
|
|
395
|
+
]));
|
|
396
|
+
}
|
|
397
|
+
}), [["__scopeId", "data-v-2533db5c"]]), q = () => ({ i: (e, t = {}) => e ? r(K, {
|
|
398
|
+
icon: e,
|
|
399
|
+
...t
|
|
400
|
+
}) : void 0 }), J = () => ({
|
|
401
|
+
nanoid: v,
|
|
402
|
+
numeric: (e = 10) => y("1234567890", e)()
|
|
403
|
+
}), Y = () => {
|
|
404
|
+
let e = (e) => new Promise(async (t) => {
|
|
405
|
+
let n = await x({
|
|
406
|
+
blob: e,
|
|
407
|
+
toType: "image/jpeg",
|
|
408
|
+
quality: .9
|
|
409
|
+
});
|
|
410
|
+
return t(new File([n], e.name, {
|
|
411
|
+
type: n.type,
|
|
412
|
+
lastModified: Date.now()
|
|
413
|
+
}));
|
|
414
|
+
}), t = (e) => new Promise((t) => {
|
|
415
|
+
new S(e, {
|
|
416
|
+
quality: .9,
|
|
417
|
+
success: (e) => t(e)
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
return {
|
|
421
|
+
handler: (n, r = { compressor: !0 }) => new Promise((i) => {
|
|
422
|
+
let a = new FileReader();
|
|
423
|
+
a.readAsArrayBuffer(n), a.onload = () => {
|
|
424
|
+
let o = b.validateFileType(a.result, ["heic"]), s = b.validateFileType(a.result, [
|
|
425
|
+
"jpeg",
|
|
426
|
+
"png",
|
|
427
|
+
"gif",
|
|
428
|
+
"bmp"
|
|
429
|
+
]);
|
|
430
|
+
o ? i(e(n)) : s && r.compressor ? i(t(n)) : i(n);
|
|
431
|
+
};
|
|
432
|
+
}),
|
|
433
|
+
getDimension: async (e) => new Promise((t, n) => {
|
|
434
|
+
let r = new Image();
|
|
435
|
+
r.src = URL.createObjectURL(e), r.onload = () => t({
|
|
436
|
+
width: r.naturalWidth,
|
|
437
|
+
height: r.naturalHeight
|
|
438
|
+
}), r.onerror = (e) => n(e);
|
|
439
|
+
}),
|
|
440
|
+
getFileType: (e) => new Promise((t) => {
|
|
441
|
+
let n = new FileReader();
|
|
442
|
+
n.readAsArrayBuffer(e), n.onload = () => {
|
|
443
|
+
t({ mimeType: b.detectFile(n.result)?.mimeType });
|
|
444
|
+
};
|
|
445
|
+
})
|
|
446
|
+
};
|
|
447
|
+
}, X = { install(e, t) {
|
|
448
|
+
k(t), e.config.globalProperties.$setLocale = j, e.config.globalProperties.$getLocale = M;
|
|
404
449
|
} };
|
|
405
450
|
//#endregion
|
|
406
|
-
export {
|
|
451
|
+
export { P as $params, V as DateTime, z as Formatter, N as Platform, B as Validate, X as default, R as download, L as get, M as getLocale, F as request, I as resource, j as setLocale, U as useBreak, W as useCaptcha, G as useChat, q as useIcon, A as useLocale, J as useNanoid, Y as useUpload };
|
package/dist/style.css
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! tailwindcss v4.3.0 | MIT License | https://tailwindcss.com */
|
|
2
|
-
@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.static{position:static}.shrink{flex-shrink:1}}.flex-center{justify-content:center;align-items:center;display:flex!important}.flex-center-end{justify-content:end;align-items:center;display:flex!important}.flex-center-between{justify-content:space-between;align-items:center;display:flex!important}.flex-center-items{align-items:center;display:flex!important}.text-light{color:#ccc}.dark .text-light{color:#333}
|
|
2
|
+
@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.static{position:static}.shrink{flex-shrink:1}}.flex-center{justify-content:center;align-items:center;display:flex!important}.flex-center-end{justify-content:end;align-items:center;display:flex!important}.flex-center-between{justify-content:space-between;align-items:center;display:flex!important}.flex-center-items{align-items:center;display:flex!important}.text-light{color:#ccc}.dark .text-light{color:#333}[data-v-2533db5c] g,[data-v-2533db5c] path{stroke-width:var(--v1903d129)}
|
|
3
3
|
/*$vite$:1*/
|
|
@@ -5,6 +5,9 @@ import { default as default_2 } from 'dayjs';
|
|
|
5
5
|
import { nanoid } from 'nanoid';
|
|
6
6
|
import { Plugin as Plugin_2 } from 'vue';
|
|
7
7
|
import { Ref } from 'vue';
|
|
8
|
+
import { RendererElement } from 'vue';
|
|
9
|
+
import { RendererNode } from 'vue';
|
|
10
|
+
import { VNode } from 'vue';
|
|
8
11
|
|
|
9
12
|
export declare const $params: (params: IModel) => {
|
|
10
13
|
[property: string]: any;
|
|
@@ -351,6 +354,12 @@ export declare const useChat: (baseURL: string, apiKey: string) => {
|
|
|
351
354
|
}) => Promise<void>;
|
|
352
355
|
};
|
|
353
356
|
|
|
357
|
+
export declare const useIcon: () => {
|
|
358
|
+
i: (icon: string, para?: Object) => VNode<RendererNode, RendererElement, {
|
|
359
|
+
[key: string]: any;
|
|
360
|
+
}> | undefined;
|
|
361
|
+
};
|
|
362
|
+
|
|
354
363
|
export declare const useLocale: () => {
|
|
355
364
|
locale: Ref<string, string>;
|
|
356
365
|
t: (path: string, params?: Record<string, string | number>) => string;
|
package/package.json
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Icon :icon="name" :width="size" :height="size" :style="iconStyle" :aria-hidden="null" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import { Icon } from '@iconify/vue'
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
vendor: { type: String, default: 'icon-park-outline' },
|
|
11
|
+
icon: { type: String, default: '' },
|
|
12
|
+
size: { type: Number, default: 16 },
|
|
13
|
+
strokeWidth: { type: Number, default: 4 },
|
|
14
|
+
color: { type: String },
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const name = computed(() => props.icon.indexOf(':') !== -1 ? props.icon : `${props.vendor}:${props.icon}`)
|
|
18
|
+
const iconStyle = computed(() => props.color ? { color: props.color } : undefined)
|
|
19
|
+
const strokeWidth = computed(() => props.strokeWidth)
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<style scoped>
|
|
23
|
+
:deep(g), :deep(path) { stroke-width: v-bind(strokeWidth) }
|
|
24
|
+
</style>
|
package/src/index.ts
CHANGED
|
@@ -14,10 +14,11 @@ export * from './types'
|
|
|
14
14
|
export * from './types/chat'
|
|
15
15
|
export * from './utils'
|
|
16
16
|
export { useBreak } from './hooks/useBreak'
|
|
17
|
-
export { useNanoid } from './hooks/useNanoid'
|
|
18
17
|
export { useCaptcha } from './hooks/useCaptcha'
|
|
19
|
-
export { useUpload } from './hooks/useUpload'
|
|
20
18
|
export { useChat } from './hooks/useChat'
|
|
19
|
+
export { useIcon } from './hooks/useIcon'
|
|
20
|
+
export { useNanoid } from './hooks/useNanoid'
|
|
21
|
+
export { useUpload } from './hooks/useUpload'
|
|
21
22
|
export type { IChatMessage, IMessageEvent, IUsageEvent, IErrorEvent, ISendMessageParams } from './hooks/useChat'
|
|
22
23
|
|
|
23
24
|
export default VueGo
|