@weaveui/web 0.0.1 → 0.0.3
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/LICENSE +12 -12
- package/README.md +15 -18
- package/THIRD_PARTY_NOTICES +2 -2
- package/dist/index.d.ts +440 -333
- package/dist/index.es.js +18408 -2694
- package/dist/index.umd.cjs +176 -6
- package/dist/style.css +1 -1
- package/package.json +11 -30
- package/dist/apm-log.es.js +0 -996
- package/dist/apm-log.umd.cjs +0 -1
- package/dist/business/apm-log/behavior-directive.d.ts +0 -9
- package/dist/business/apm-log/behavior-log.d.ts +0 -6
- package/dist/business/apm-log/behavior-types.d.ts +0 -121
- package/dist/business/apm-log/browser.d.ts +0 -3
- package/dist/business/apm-log/directive.d.ts +0 -13
- package/dist/business/apm-log/index.d.ts +0 -8
- package/dist/business/apm-log/legacy-apm-log.d.ts +0 -6
- package/dist/business/apm-log/types.d.ts +0 -147
- package/dist/business/apm-log/vue.d.ts +0 -5
- package/dist/business/monitor/index.d.ts +0 -81
- package/dist/business/monitor/monitor-plugin.d.ts +0 -9
- package/dist/business/monitor/runtime-types.d.ts +0 -166
- package/dist/business/monitor/runtime.d.ts +0 -6
- package/dist/business/monitor/types.d.ts +0 -221
- package/dist/business/permission/Permission.d.ts +0 -18
- package/dist/business/permission/PermissionPluginClass.d.ts +0 -40
- package/dist/business/permission/directive.d.ts +0 -7
- package/dist/business/permission/index.d.ts +0 -35
- package/dist/business/permission/permission-plugin.d.ts +0 -16
- package/dist/business/permission/storage.d.ts +0 -30
- package/dist/business/permission/tree.d.ts +0 -19
- package/dist/business/permission/types.d.ts +0 -115
- package/dist/business/upload-cos/index.d.ts +0 -117
- package/dist/business/upload-cos/src/UploadCos.vue.d.ts +0 -70
- package/dist/business/upload-cos/src/types.d.ts +0 -72
- package/dist/business/upload-cos/src/utils.d.ts +0 -9
- package/dist/monitor.es.js +0 -1217
- package/dist/monitor.umd.cjs +0 -1
- package/dist/permission.es.js +0 -631
- package/dist/permission.umd.cjs +0 -1
- package/dist/upload-cos.es.js +0 -426
- package/dist/upload-cos.style.css +0 -1
- package/dist/upload-cos.umd.cjs +0 -1
- package/dist/utils/index.d.ts +0 -3
- package/dist/utils/is.d.ts +0 -2
- package/dist/utils/withInstall.d.ts +0 -7
package/dist/permission.umd.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(d,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],c):(d=typeof globalThis<"u"?globalThis:d||self,c(d.ElementCustomUIPermission={},d.Vue))})(this,function(d,c){"use strict";var it=Object.defineProperty;var st=(d,c,g)=>c in d?it(d,c,{enumerable:!0,configurable:!0,writable:!0,value:g}):d[c]=g;var l=(d,c,g)=>st(d,typeof c!="symbol"?c+"":c,g);const g="permissionPluginClass";function h(t){return t===void 0?"":String(t).trim()}function y(t){const n=(Array.isArray(t)?t:[t]).flatMap(r=>{if(typeof r=="string")return r.split(",").map(a=>a.trim());if(typeof r=="number")return[String(r)];if(r&&typeof r=="object"&&"pageId"in r){const a=r.pageId;return typeof a=="string"||typeof a=="number"?[String(a).trim()]:[]}return[]});return[...new Set(n.filter(Boolean))]}function P(t){return t===!0||t===1||t==="1"}function p(t){var e;return P((e=t.extraContent)==null?void 0:e.isPsMg)}function f(t){return Array.isArray(t.children)?t.children:[]}function A(t){return{...t??{}}}function w(t){return{...t,extraContent:A(t.extraContent),...t.parentIds?{parentIds:[...t.parentIds]}:{},children:f(t).map(e=>w(e))}}function x(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t=="string"&&t.trim()){const e=Number(t);return Number.isFinite(e)?e:0}return 0}function E(t){if(!t)return 0;const e=Date.parse(t);return Number.isFinite(e)?e:0}function I(t){return t.sort((e,n)=>{const r=x(e.sort)-x(n.sort);return r!==0?r:E(e.createTime)-E(n.createTime)})}function O(t){const e=[],n=(r,a,i)=>{for(const o of r){const s=w(o),u=h(s.pageId);a.length>0&&(s.parentIds=[...a]),Number(s.type)===2&&i===!1&&(s.extraContent={...s.extraContent,isPsMg:0}),e.push(s),n(f(s),u?[...a,u]:a,p(s))}};return n(t,[],null),e}function L(t){const e=A(t.extraContent);return{...e,path:typeof t.routingAddress=="string"?t.routingAddress:"",name:typeof e.assemblyName=="string"?e.assemblyName:h(t.pageId),component:typeof e.assemblyAddress=="string"?e.assemblyAddress:"",meta:{title:typeof t.pageName=="string"?t.pageName:"",icon:typeof t.icon=="string"?t.icon:""},id:h(t.pageId),eventIdList:Array.isArray(t.eventIdList)?[...t.eventIdList]:[],...t.createTime?{createTime:t.createTime}:{},...t.isShow!==void 0?{isShow:t.isShow}:{},...t.sort!==void 0?{sort:t.sort}:{},...t.type!==void 0?{type:t.type}:{},...t.updateTime?{updateTime:t.updateTime}:{},children:[]}}function S(t){var n;const e=(n=t.extraContent)==null?void 0:n.menuStatus;return e===void 0||P(e)}function R(t,e){var o;if(!p(t))return!0;const n=f(t);if(P((o=t.extraContent)==null?void 0:o.isBigScreen))return e.has(h(t.pageId))&&S(t);if(n.length===0)return!1;const r=n.filter(s=>{var u;return P((u=s.extraContent)==null?void 0:u.isRelateParent)});if(r.length>0)return r.some(s=>!p(s)||e.has(h(s.pageId)))&&S(t);const a=n.every(s=>e.has(h(s.pageId))),i=n.every(s=>!p(s));return(a||i)&&S(t)}function k(t,e){const n=new Set(e),r=a=>{const i=[];for(const o of a){const s=Number(o.type);if(s===0){const u=r(f(o));if(u.length>0){const v=L(o);v.children=u,i.push(v)}continue}s!==1||!R(o,n)||i.push(L(o))}return I(i)};return r(t)}function z(t){const e=n=>{const r=[];for(const a of n){if(!p(a))continue;const i=w(a);i.children=e(f(a)),r.push(i)}return I(r)};return e(t)}function B(t){const e=n=>{const r=n.map(a=>{const i=w(a);return i.children=e(f(a)),i});return I(r)};return e(t)}function M(t){const e=n=>{const r=[];for(const a of n){const i=e(f(a));if(!p(a)||i.length>0){const o=w(a);o.children=i,r.push(o)}}return r};return e(t)}function _(t){const e=[],n=r=>{var a;for(const i of r)Number(i.type)===1&&P(i.isShow)&&P((a=i.extraContent)==null?void 0:a.isCache)&&e.push(w(i)),n(f(i))};return n(t),e}function J(t,e){const n=new Set,r=a=>{for(const i of a){const o=f(i);if(o.length>0){r(o);continue}(!p(i)||e.has(h(i.pageId)))&&y(i.eventIdList).forEach(s=>n.add(s))}};return r(t),[...n]}function N(t){if(typeof t=="boolean")return t;if(typeof t=="function")try{return!!t()}catch{return!1}return y(t).length===0}const U=c.defineComponent({name:"Permission",props:{sign:{type:[String,Number,Boolean,Array,Function],default:""}},setup(t,{slots:e}){const n=c.inject(g,null),r=c.ref(N(t.sign));let a=0;const i=async()=>{const o=++a,s=n?await n.checkPermission(t.sign):N(t.sign);o===a&&(r.value=s)};return c.watch([()=>t.sign,()=>(n==null?void 0:n.revision.value)??0],()=>{i()},{immediate:!0,deep:!0}),()=>{var o,s,u;return c.h("div",r.value?(o=e.default)==null?void 0:o.call(e):((s=e.emptySlot)==null?void 0:s.call(e))??((u=e.fallback)==null?void 0:u.call(e)))}}});function b(t){return typeof t=="object"&&t!==null}function D(t){return JSON.parse(JSON.stringify(t))}function V(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function q(){return typeof window>"u"?null:window.indexedDB??null}function G(t){if(!b(t))return{cfg:{},data:{}};const e=b(t.cfg)?t.cfg:{},n=b(t.data)?t.data:{};return{...t,cfg:Object.fromEntries(Object.entries(e).filter(([,r])=>b(r))),data:Object.fromEntries(Object.entries(n).filter(([,r])=>b(r)))}}function $(t){return new Promise((e,n)=>{t.onsuccess=()=>e(t.result),t.onerror=()=>n(t.error)})}function W(t){return new Promise((e,n)=>{t.oncomplete=()=>e(),t.onerror=()=>n(t.error),t.onabort=()=>n(t.error)})}class H{constructor(e,n={}){l(this,"memoryPayload",{cfg:{},data:{}});l(this,"storage");l(this,"indexedDb");l(this,"dbPromise");this.dbName=e,this.storage=n.storage===void 0?V():n.storage,this.indexedDb=n.indexedDB===void 0?q():n.indexedDB,this.dbPromise=this.openDatabase()}get supportsIndexedDb(){return this.indexedDb!==null}async ready(){await this.dbPromise}async read(e,n){const r=await this.dbPromise;if(r)try{const a=r.transaction(e,"readonly"),i=await $(a.objectStore(e).get(n));if(b(i))return D(i)}catch{}return this.readFallback(e,n)}async write(e,n){const r=await this.dbPromise;if(r)try{const a=r.transaction(e,"readwrite");a.objectStore(e).put(D(n)),await W(a);return}catch{}this.writeFallback(e,n)}async openDatabase(){if(!this.indexedDb)return null;try{return await new Promise(e=>{var r;const n=(r=this.indexedDb)==null?void 0:r.open(this.dbName,1);if(!n){e(null);return}n.onupgradeneeded=()=>{const a=n.result;for(const i of["cfg","data"])a.objectStoreNames.contains(i)||a.createObjectStore(i,{keyPath:"appChannelId"})},n.onsuccess=()=>e(n.result),n.onerror=()=>e(null),n.onblocked=()=>e(null)})}catch{return null}}readFallback(e,n){const a=this.getFallbackPayload()[e][n];return a?D(a):null}writeFallback(e,n){const r=this.getFallbackPayload();if(r[e][n.appChannelId]=D(n),this.memoryPayload.cfg=r.cfg,this.memoryPayload.data=r.data,!!this.storage)try{this.storage.setItem("permissionPluginData",JSON.stringify(r))}catch{}}getFallbackPayload(){if(!this.storage)return{cfg:{...this.memoryPayload.cfg},data:{...this.memoryPayload.data}};try{const e=this.storage.getItem("permissionPluginData");if(!e)return{cfg:{...this.memoryPayload.cfg},data:{...this.memoryPayload.data}};const n=G(JSON.parse(e));return this.memoryPayload.cfg=n.cfg,this.memoryPayload.data=n.data,n}catch{return{cfg:{...this.memoryPayload.cfg},data:{...this.memoryPayload.data}}}}}function m(t){return typeof t=="object"&&t!==null}function j(t){return t==="cfg"?"cfg":"data"}function Y(t){return(Array.isArray(t)?t:t?[t]:[]).filter(n=>!!n&&typeof n.appChannelId=="string"&&typeof n.dataChannelId=="string"&&typeof n.prefixUrl=="string").map(n=>({...n}))}function K(t){var n,r,a;const e=Y(t.apiCfg);return{apiCfg:e,dbName:((n=t.dbName)==null?void 0:n.trim())||"permissionPluginDb",projectAppChannelId:((r=t.projectAppChannelId)==null?void 0:r.trim())||((a=e[0])==null?void 0:a.appChannelId)||""}}function Q(){return typeof window>"u"||typeof window.fetch!="function"?null:window.fetch.bind(window)}function X(t){return`${t.replace(/\/+$/,"")}/getPageTree`}function Z(t){if(Array.isArray(t))return t.filter(m);if(!m(t)||!Array.isArray(t.data))return[];const e=t.code;return e===void 0||e==="00000"||e===0||e===200||e==="200"?t.data.filter(m):[]}function C(t){return m(t)&&"eventIdList"in t?y(t.eventIdList):y(t)}function tt(t,e){return t?e?t[e]??[]:t:[]}class F{constructor(e={}){l(this,"ifSupportIndexDb");l(this,"pluginCfg");l(this,"revision",c.ref(0));l(this,"fetcher");l(this,"storage");l(this,"initialization");this.pluginCfg=K(e),this.storage=new H(this.pluginCfg.dbName,{storage:e.storage,indexedDB:e.indexedDB}),this.ifSupportIndexDb=this.storage.supportsIndexedDb,this.fetcher=e.fetcher??Q(),this.initialization=this.initialize(e.autoSync!==!1).catch(()=>{})}async whenReady(){await this.initialization}async excuteDbLogic(){await this.whenReady()}async excuteLocalStorageLogic(){await this.whenReady()}async loopApiCfgListForGetData(){await Promise.allSettled(this.pluginCfg.apiCfg.map(async e=>{await this.setData(e.appChannelId,"cfg",e),await this.getDataFromApi(e)}))}async getDataFromApi(e){const n=this.fetcher;if(!n)return[];try{const r=await n(X(e.prefixUrl),{method:"POST",headers:{"Content-Type":"application/json","x-app_channel_id":e.appChannelId,"x-data_channel_id":e.dataChannelId},body:JSON.stringify(e)}),a=Z(await r.json());return await this.generateSaveToStorageDataAndSave(e.appChannelId,a),a}catch{return[]}}parseStorage(e){return JSON.parse(e)}async generateSaveToStorageDataAndSave(e,n){await this.setData(e,"data",{pageEventData:[...n],horizontalPageEventData:O(n)})}async getPageEventDataFromApiNew(){await this.loopApiCfgListForGetData()}async getPageEventDataFromApiSync(e){return await this.setData(e.appChannelId,"cfg",e),this.getDataFromApi(e)}async getData(e=this.pluginCfg.projectAppChannelId,n,r=""){await this.storage.ready();const a=await this.storage.read(j(n),e);return tt(a,r)}async setData(e=this.pluginCfg.projectAppChannelId,n,r,a){await this.storage.ready();const i=j(n),s={...await this.storage.read(i,e)??{appChannelId:e},appChannelId:e};a?s[a]=r:m(r)?Object.assign(s,r):s.value=r,await this.storage.write(i,s),i==="data"&&this.bumpRevision()}async getPageEventDataFromDbOrLocal(e=this.pluginCfg.projectAppChannelId){await this.whenReady();const n=await this.getData(e,"data","pageEventData");return Array.isArray(n)?n.filter(m):[]}async getHorizontalPageEventData(e=this.pluginCfg.projectAppChannelId){await this.whenReady();const n=await this.getData(e,"data","horizontalPageEventData");return Array.isArray(n)?n.filter(m):[]}async setEventIdSync(e,n){await this.setData(e,"data",C(n),"eventIdList")}async getNeedCacheRouter(e=this.pluginCfg.projectAppChannelId){return _(await this.getPageEventDataFromDbOrLocal(e))}async generateRouterNew(e=this.pluginCfg.projectAppChannelId){const[n,r]=await Promise.all([this.getPageEventDataFromDbOrLocal(e),this.getData(e,"data","eventIdList")]);return k(n,C(r))}async generatePermissionMgTree(e=this.pluginCfg.projectAppChannelId){return z(await this.getPageEventDataFromDbOrLocal(e))}async generatePermissionMgTreeForShop(e=this.pluginCfg.projectAppChannelId,n){return B(await this.getPageEventDataFromDbOrLocal(e))}async getApiEventList(e=this.pluginCfg.projectAppChannelId,n=[]){const[r,a]=await Promise.all([this.getPageEventDataFromDbOrLocal(e),this.getData(e,"data","eventIdList")]),i=n.length>0?y(n):C(a);return J(r,new Set(i))}async getNoPmPageTree(e=this.pluginCfg.projectAppChannelId){return M(await this.getPageEventDataFromDbOrLocal(e))}async checkPermission(e){if(typeof e=="boolean")return e;if(typeof e=="function")try{return!!e()}catch{return!1}const n=y(e);if(n.length===0)return!0;const r=this.pluginCfg.projectAppChannelId,[a,i]=await Promise.all([this.getData(r,"data","eventIdList"),this.getHorizontalPageEventData(r)]),o=new Set(C(a));return n.some(s=>o.has(s))?!0:i.some(s=>n.includes(h(s.pageId))&&!p(s))}async initialize(e){await this.storage.ready(),await Promise.all(this.pluginCfg.apiCfg.map(n=>this.setData(n.appChannelId,"cfg",n))),e&&await this.getPageEventDataFromApiNew()}bumpRevision(){this.revision.value+=1}}function et(t){if(typeof t=="boolean")return t;if(typeof t=="function")try{return!!t()}catch{return!1}return y(t).length===0}function nt(t){const e=new WeakMap;function n(a){var o,s;return((s=(o=a.instance)==null?void 0:o.$)==null?void 0:s.appContext.provides[g])??t}const r=async(a,i,o)=>{const s=(e.get(a)??0)+1;e.set(a,s);const u=n(o),v=u?await u.checkPermission(i):et(i);s===e.get(a)&&!v&&a.remove()};return{mounted(a,i){r(a,i.value,i)},updated(a,i){r(a,i.value,i)}}}const T=new WeakMap;function rt(t,e={}){const n=T.get(t);if(n)return n;const r=e.permissionPluginClass??new F(e);T.set(t,r),t.provide(g,r),t.component("Permission",U),t.directive("permission",nt(r));const a=t.config.globalProperties;return a.permissionPluginClass=r,r}const at={PermissionPluginClass:F,install(t,e={}){rt(t,e)}};d.default=at,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/upload-cos.es.js
DELETED
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
import { defineComponent as le, ref as m, watch as ue, onBeforeUnmount as de, openBlock as O, createElementBlock as A, createElementVNode as pe, renderSlot as W, toDisplayString as fe, createCommentVNode as me } from "vue";
|
|
2
|
-
const V = /* @__PURE__ */ new WeakMap();
|
|
3
|
-
function he(r, i) {
|
|
4
|
-
const c = r, a = i;
|
|
5
|
-
let s = V.get(r);
|
|
6
|
-
return s || (s = /* @__PURE__ */ new Set(), V.set(r, s), c.install = (U) => {
|
|
7
|
-
s == null || s.forEach((p) => {
|
|
8
|
-
U.component(p, r);
|
|
9
|
-
});
|
|
10
|
-
}), s.add(a), c;
|
|
11
|
-
}
|
|
12
|
-
function H() {
|
|
13
|
-
const r = globalThis.crypto;
|
|
14
|
-
if (typeof (r == null ? void 0 : r.randomUUID) == "function")
|
|
15
|
-
return r.randomUUID().replace(/-/g, "");
|
|
16
|
-
if (typeof (r == null ? void 0 : r.getRandomValues) == "function") {
|
|
17
|
-
const i = new Uint32Array(4);
|
|
18
|
-
return r.getRandomValues(i), Array.from(i, (c) => c.toString(16).padStart(8, "0")).join("");
|
|
19
|
-
}
|
|
20
|
-
return `${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`;
|
|
21
|
-
}
|
|
22
|
-
function ge(r) {
|
|
23
|
-
const i = Number.isFinite(r) && r > 0 ? r : 0;
|
|
24
|
-
return i < 1024 ? `${i} B` : i < 1024 * 1024 ? `${(i / 1024).toFixed(2)} KB` : i < 1024 * 1024 * 1024 ? `${(i / (1024 * 1024)).toFixed(2)} MB` : `${(i / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
25
|
-
}
|
|
26
|
-
function we(r) {
|
|
27
|
-
var c;
|
|
28
|
-
const i = (c = r.split(".").pop()) == null ? void 0 : c.trim().toLowerCase();
|
|
29
|
-
return !i || i === r.toLowerCase() ? "bin" : i.replace(/[^a-z0-9]/g, "") || "bin";
|
|
30
|
-
}
|
|
31
|
-
function ye(r, i) {
|
|
32
|
-
const c = Se(r, "easy-oil"), a = H(), s = a.slice(0, 12);
|
|
33
|
-
return {
|
|
34
|
-
fileId: a,
|
|
35
|
-
fileName: `${c}_${Date.now()}_${s}.${i}`
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function Ue(r) {
|
|
39
|
-
if (!r)
|
|
40
|
-
return "";
|
|
41
|
-
const i = r.trim().replace(/^\/+/, "").replace(/\/{2,}/g, "/");
|
|
42
|
-
return i && !i.endsWith("/") ? `${i}/` : i;
|
|
43
|
-
}
|
|
44
|
-
function q(r, i) {
|
|
45
|
-
const c = i.replace(/^\/+/, ""), a = r.replace(/\/+$/, "");
|
|
46
|
-
return a ? `${a}/${c}` : `/${c}`;
|
|
47
|
-
}
|
|
48
|
-
function Se(r, i) {
|
|
49
|
-
return r.trim().replace(/[\\/\u0000-\u001f]+/g, "-").replace(/\s+/g, "-") || i;
|
|
50
|
-
}
|
|
51
|
-
const Ce = { class: "wui-upload-cos" }, Te = ["accept", "multiple"], be = {
|
|
52
|
-
key: 0,
|
|
53
|
-
class: "wui-upload-cos__toast",
|
|
54
|
-
role: "status"
|
|
55
|
-
}, Ie = /* @__PURE__ */ le({
|
|
56
|
-
name: "UploadCos",
|
|
57
|
-
__name: "UploadCos",
|
|
58
|
-
props: {
|
|
59
|
-
appChanneId: { default: "" },
|
|
60
|
-
multiple: { type: Boolean, default: !0 },
|
|
61
|
-
accept: { default: "" },
|
|
62
|
-
baseUrl: { default: "" },
|
|
63
|
-
limit: { default: 0 },
|
|
64
|
-
overLoaderList: { default: () => [] },
|
|
65
|
-
fileType: { default: "file" },
|
|
66
|
-
appName: { default: "qingyiweb" },
|
|
67
|
-
isUseCos: { type: Boolean, default: !0 },
|
|
68
|
-
defaultUploadConfig: { default: () => ({}) }
|
|
69
|
-
},
|
|
70
|
-
emits: ["uploadfiles", "errorUpLoad", "overLimitTips", "update:overLoaderList", "upload-progress"],
|
|
71
|
-
setup(r, { expose: i, emit: c }) {
|
|
72
|
-
const a = r, s = c, U = m(), p = m([]), S = m(!1), F = m(""), b = m(!1), h = m({});
|
|
73
|
-
let f;
|
|
74
|
-
ue(
|
|
75
|
-
() => a.overLoaderList,
|
|
76
|
-
(e) => {
|
|
77
|
-
p.value = Array.from(e ?? []);
|
|
78
|
-
},
|
|
79
|
-
{ immediate: !0 }
|
|
80
|
-
), de(() => {
|
|
81
|
-
f && clearTimeout(f);
|
|
82
|
-
});
|
|
83
|
-
function C(e) {
|
|
84
|
-
F.value = e, b.value = !0, f && clearTimeout(f), f = setTimeout(() => {
|
|
85
|
-
b.value = !1, f = void 0;
|
|
86
|
-
}, 2e3);
|
|
87
|
-
}
|
|
88
|
-
function L() {
|
|
89
|
-
var e;
|
|
90
|
-
S.value || (e = U.value) == null || e.click();
|
|
91
|
-
}
|
|
92
|
-
function J(e) {
|
|
93
|
-
if (!(!e.url || typeof window > "u"))
|
|
94
|
-
try {
|
|
95
|
-
const t = new URL(e.url, window.location.href);
|
|
96
|
-
if (!["http:", "https:", "blob:"].includes(t.protocol))
|
|
97
|
-
return;
|
|
98
|
-
const n = window.open(t.href, "_blank", "noopener,noreferrer");
|
|
99
|
-
n && (n.opener = null);
|
|
100
|
-
} catch {
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
async function G(e) {
|
|
104
|
-
const t = e.target;
|
|
105
|
-
if (!(t instanceof HTMLInputElement))
|
|
106
|
-
return;
|
|
107
|
-
const n = Array.from(t.files ?? []);
|
|
108
|
-
if (!n.length)
|
|
109
|
-
return;
|
|
110
|
-
const o = a.limit > 0 ? Math.max(a.limit - p.value.length, 0) : n.length, l = a.multiple ? o : Math.min(o, 1), u = n.slice(0, l);
|
|
111
|
-
if (a.limit > 0 && u.length < n.length && s("overLimitTips"), !!u.length) {
|
|
112
|
-
S.value = !0;
|
|
113
|
-
try {
|
|
114
|
-
let y;
|
|
115
|
-
if (a.isUseCos)
|
|
116
|
-
try {
|
|
117
|
-
y = await _();
|
|
118
|
-
} catch {
|
|
119
|
-
C("获取上传凭证失败");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
for (const d of u) {
|
|
123
|
-
if (d.size <= 0) {
|
|
124
|
-
C(`文件 ${d.name} 无效,大小为 0`);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
try {
|
|
128
|
-
y ? await E(d, y) : await x(d);
|
|
129
|
-
} catch {
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
} finally {
|
|
133
|
-
t.value = "", S.value = !1;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
async function E(e, t) {
|
|
138
|
-
const n = M(e);
|
|
139
|
-
T(n, e, 0);
|
|
140
|
-
try {
|
|
141
|
-
const o = t ?? await _(), l = await Q(e, o, n);
|
|
142
|
-
return T(n, e, 100), z(l);
|
|
143
|
-
} catch (o) {
|
|
144
|
-
throw s("errorUpLoad", o), C("上传失败"), o;
|
|
145
|
-
} finally {
|
|
146
|
-
N(n);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
async function x(e) {
|
|
150
|
-
const t = M(e), n = (o) => T(t, e, o);
|
|
151
|
-
n(0);
|
|
152
|
-
try {
|
|
153
|
-
const o = await ee(e, n);
|
|
154
|
-
return n(100), z(j(o, I(e)));
|
|
155
|
-
} catch (o) {
|
|
156
|
-
throw s("errorUpLoad", o), C("上传失败"), o;
|
|
157
|
-
} finally {
|
|
158
|
-
N(t);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
async function _() {
|
|
162
|
-
if (!a.baseUrl)
|
|
163
|
-
throw new Error("baseUrl is required.");
|
|
164
|
-
const e = await $(
|
|
165
|
-
q(a.baseUrl, "ms-attachment/cos/getAccessInfo"),
|
|
166
|
-
{
|
|
167
|
-
method: "POST",
|
|
168
|
-
headers: { "Content-Type": "application/json" },
|
|
169
|
-
body: JSON.stringify({ _appid: R() })
|
|
170
|
-
}
|
|
171
|
-
), t = await D(e, "获取上传凭证失败");
|
|
172
|
-
if (!k(t, 200))
|
|
173
|
-
throw new Error("获取上传凭证失败");
|
|
174
|
-
return ne(t.data);
|
|
175
|
-
}
|
|
176
|
-
async function Q(e, t, n) {
|
|
177
|
-
const o = te(e), l = we(e.name), { fileId: u, fileName: y } = ye(a.appName, l), d = `${Ue(t.dir)}${y}`, P = await (await X(t)).uploadFile({
|
|
178
|
-
Bucket: t.bucket,
|
|
179
|
-
Region: t.region,
|
|
180
|
-
Key: d,
|
|
181
|
-
Body: e,
|
|
182
|
-
SliceSize: 5 * 1024 * 1024,
|
|
183
|
-
onProgress: ({ percent: ce }) => {
|
|
184
|
-
T(n, e, ce * 100);
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
if (!P.Location)
|
|
188
|
-
throw new Error("COS 上传未返回文件地址");
|
|
189
|
-
const K = ie(P.Location), ae = await o, se = I(e, {
|
|
190
|
-
url: K,
|
|
191
|
-
ext: l,
|
|
192
|
-
path: `/${d}`,
|
|
193
|
-
...ae
|
|
194
|
-
});
|
|
195
|
-
return Z({
|
|
196
|
-
file: e,
|
|
197
|
-
fileId: u,
|
|
198
|
-
extension: l,
|
|
199
|
-
objectKey: d,
|
|
200
|
-
objectUrl: K,
|
|
201
|
-
fileData: se
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
async function X(e) {
|
|
205
|
-
const t = await import("cos-js-sdk-v5"), n = Y(t);
|
|
206
|
-
return new n({
|
|
207
|
-
SecretId: e.tmpSecretID,
|
|
208
|
-
SecretKey: e.tmpSecretKey,
|
|
209
|
-
SecurityToken: e.sessionToken,
|
|
210
|
-
StartTime: e.startTime,
|
|
211
|
-
ExpiredTime: e.expiredTime
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
function Y(e) {
|
|
215
|
-
const t = w(e) && "default" in e ? e.default : e;
|
|
216
|
-
if (typeof t != "function")
|
|
217
|
-
throw new Error("COS SDK 加载失败");
|
|
218
|
-
return t;
|
|
219
|
-
}
|
|
220
|
-
async function Z(e) {
|
|
221
|
-
if (!a.baseUrl)
|
|
222
|
-
return e.fileData;
|
|
223
|
-
const t = await $(
|
|
224
|
-
q(a.baseUrl, "ms-attachment/cos/object/add"),
|
|
225
|
-
{
|
|
226
|
-
method: "POST",
|
|
227
|
-
headers: { "Content-Type": "application/json" },
|
|
228
|
-
body: JSON.stringify({
|
|
229
|
-
_appid: R(),
|
|
230
|
-
// The legacy API field name is kept, although the value is a random file identifier.
|
|
231
|
-
fileMd5: e.fileId,
|
|
232
|
-
ext: e.extension,
|
|
233
|
-
size: e.file.size,
|
|
234
|
-
path: `/${e.objectKey}`,
|
|
235
|
-
url: e.objectUrl,
|
|
236
|
-
fileName: e.file.name
|
|
237
|
-
})
|
|
238
|
-
}
|
|
239
|
-
), n = await D(t, "文件元数据保存失败");
|
|
240
|
-
if (!k(n, 200))
|
|
241
|
-
throw new Error("文件元数据保存失败");
|
|
242
|
-
const o = v(re(n.data, "fileURL"));
|
|
243
|
-
return {
|
|
244
|
-
...e.fileData,
|
|
245
|
-
url: o ?? e.objectUrl,
|
|
246
|
-
ext: e.extension
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
async function ee(e, t) {
|
|
250
|
-
const n = a.defaultUploadConfig;
|
|
251
|
-
if (!oe(n))
|
|
252
|
-
throw new Error("defaultUploadConfig is incomplete.");
|
|
253
|
-
const o = new FormData();
|
|
254
|
-
o.append(a.fileType || "file", e);
|
|
255
|
-
const l = await $(n.uploadUrl, {
|
|
256
|
-
method: "POST",
|
|
257
|
-
headers: {
|
|
258
|
-
token: n.token,
|
|
259
|
-
yyid: n.yyid,
|
|
260
|
-
"x-app-channel-id": String(n.appChannelId),
|
|
261
|
-
"x-data-channel-id": String(n.dataChannelId)
|
|
262
|
-
},
|
|
263
|
-
body: o
|
|
264
|
-
}), u = await D(l, "默认直传失败");
|
|
265
|
-
if (!k(u, 2e4))
|
|
266
|
-
throw new Error("默认直传失败");
|
|
267
|
-
return t(100), j(u.data, I(e));
|
|
268
|
-
}
|
|
269
|
-
function z(e) {
|
|
270
|
-
const t = [...p.value, e];
|
|
271
|
-
return p.value = t, s("uploadfiles", e), s("update:overLoaderList", t), e;
|
|
272
|
-
}
|
|
273
|
-
function T(e, t, n) {
|
|
274
|
-
const o = Math.max(0, Math.min(100, Math.round(n)));
|
|
275
|
-
h.value = {
|
|
276
|
-
...h.value,
|
|
277
|
-
[e]: o
|
|
278
|
-
}, s("upload-progress", t, o);
|
|
279
|
-
}
|
|
280
|
-
function N(e) {
|
|
281
|
-
const t = { ...h.value };
|
|
282
|
-
delete t[e], h.value = t;
|
|
283
|
-
}
|
|
284
|
-
function M(e) {
|
|
285
|
-
return `${Date.now()}_${e.name}_${H().slice(0, 12)}`;
|
|
286
|
-
}
|
|
287
|
-
function R() {
|
|
288
|
-
var e;
|
|
289
|
-
return ((e = a.appChanneId) == null ? void 0 : e.trim()) || void 0;
|
|
290
|
-
}
|
|
291
|
-
function I(e, t = {}) {
|
|
292
|
-
return {
|
|
293
|
-
name: e.name,
|
|
294
|
-
origin_name: e.name,
|
|
295
|
-
size: e.size,
|
|
296
|
-
width: 0,
|
|
297
|
-
height: 0,
|
|
298
|
-
...t
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
async function te(e) {
|
|
302
|
-
if (e.type.startsWith("image/"))
|
|
303
|
-
return new Promise((t) => {
|
|
304
|
-
const n = new FileReader();
|
|
305
|
-
n.onerror = () => t(void 0), n.onload = () => {
|
|
306
|
-
if (typeof n.result != "string") {
|
|
307
|
-
t(void 0);
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
const o = new Image();
|
|
311
|
-
o.onload = () => t({
|
|
312
|
-
width: o.naturalWidth,
|
|
313
|
-
height: o.naturalHeight
|
|
314
|
-
}), o.onerror = () => t(void 0), o.src = n.result;
|
|
315
|
-
}, n.readAsDataURL(e);
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
async function $(e, t) {
|
|
319
|
-
const n = globalThis.fetch;
|
|
320
|
-
if (typeof n != "function")
|
|
321
|
-
throw new Error("浏览器不支持 Fetch。");
|
|
322
|
-
const o = await n(e, t);
|
|
323
|
-
if (!o.ok)
|
|
324
|
-
throw new Error(`上传服务请求失败 (${o.status})`);
|
|
325
|
-
return o;
|
|
326
|
-
}
|
|
327
|
-
async function D(e, t) {
|
|
328
|
-
let n;
|
|
329
|
-
try {
|
|
330
|
-
n = await e.json();
|
|
331
|
-
} catch {
|
|
332
|
-
throw new Error(t);
|
|
333
|
-
}
|
|
334
|
-
if (!w(n))
|
|
335
|
-
throw new Error(t);
|
|
336
|
-
return n;
|
|
337
|
-
}
|
|
338
|
-
function k(e, t) {
|
|
339
|
-
const n = e.code;
|
|
340
|
-
return typeof n != "string" && typeof n != "number" ? !1 : String(n) === String(t);
|
|
341
|
-
}
|
|
342
|
-
function ne(e) {
|
|
343
|
-
if (!w(e))
|
|
344
|
-
throw new Error("上传凭证格式无效");
|
|
345
|
-
return {
|
|
346
|
-
tmpSecretID: g(e, ["tmpSecretID", "tmpSecretId", "TmpSecretId"]),
|
|
347
|
-
tmpSecretKey: g(e, ["tmpSecretKey", "TmpSecretKey"]),
|
|
348
|
-
sessionToken: g(e, ["sessionToken", "SessionToken", "token", "Token"]),
|
|
349
|
-
bucket: g(e, ["bucket", "Bucket"]),
|
|
350
|
-
region: g(e, ["region", "Region"]),
|
|
351
|
-
dir: v(e.dir),
|
|
352
|
-
startTime: B(e.startTime ?? e.StartTime),
|
|
353
|
-
expiredTime: B(e.expiredTime ?? e.ExpiredTime)
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
function j(e, t) {
|
|
357
|
-
if (!w(e))
|
|
358
|
-
throw new Error("上传服务未返回文件信息");
|
|
359
|
-
return {
|
|
360
|
-
...t,
|
|
361
|
-
...e
|
|
362
|
-
};
|
|
363
|
-
}
|
|
364
|
-
function oe(e) {
|
|
365
|
-
return !!(e && e.uploadUrl && e.token && e.yyid && e.appChannelId !== void 0 && e.dataChannelId !== void 0);
|
|
366
|
-
}
|
|
367
|
-
function re(e, t) {
|
|
368
|
-
return w(e) ? e[t] : void 0;
|
|
369
|
-
}
|
|
370
|
-
function v(e) {
|
|
371
|
-
return typeof e == "string" && e.trim() ? e : void 0;
|
|
372
|
-
}
|
|
373
|
-
function B(e) {
|
|
374
|
-
if (typeof e == "number" && Number.isFinite(e))
|
|
375
|
-
return e;
|
|
376
|
-
if (typeof e == "string" && e.trim()) {
|
|
377
|
-
const t = Number(e);
|
|
378
|
-
return Number.isFinite(t) ? t : void 0;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
function g(e, t) {
|
|
382
|
-
for (const n of t) {
|
|
383
|
-
const o = v(e[n]);
|
|
384
|
-
if (o)
|
|
385
|
-
return o;
|
|
386
|
-
}
|
|
387
|
-
throw new Error("上传凭证缺少必要字段");
|
|
388
|
-
}
|
|
389
|
-
function ie(e) {
|
|
390
|
-
return /^https?:\/\//i.test(e) ? e : `https://${e.replace(/^\/+/, "")}`;
|
|
391
|
-
}
|
|
392
|
-
function w(e) {
|
|
393
|
-
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
394
|
-
}
|
|
395
|
-
return i({
|
|
396
|
-
triggerUpload: L,
|
|
397
|
-
handleSingleFileUpload: E,
|
|
398
|
-
uploadDefault: x,
|
|
399
|
-
formatFileSize: ge
|
|
400
|
-
}), (e, t) => (O(), A("div", Ce, [
|
|
401
|
-
pe("input", {
|
|
402
|
-
ref_key: "fileInput",
|
|
403
|
-
ref: U,
|
|
404
|
-
class: "wui-upload-cos__input",
|
|
405
|
-
type: "file",
|
|
406
|
-
accept: r.accept,
|
|
407
|
-
multiple: r.multiple,
|
|
408
|
-
onChange: G
|
|
409
|
-
}, null, 40, Te),
|
|
410
|
-
W(e.$slots, "upload-button", {
|
|
411
|
-
triggerUpload: L,
|
|
412
|
-
isUploading: S.value
|
|
413
|
-
}),
|
|
414
|
-
W(e.$slots, "file-list", {
|
|
415
|
-
uploadedFiles: p.value,
|
|
416
|
-
openFile: J,
|
|
417
|
-
progressMap: h.value
|
|
418
|
-
}),
|
|
419
|
-
b.value ? (O(), A("div", be, fe(F.value), 1)) : me("", !0)
|
|
420
|
-
]));
|
|
421
|
-
}
|
|
422
|
-
}), ve = he(Ie, "UploadCos");
|
|
423
|
-
export {
|
|
424
|
-
ve as UploadCos,
|
|
425
|
-
ve as default
|
|
426
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.wui-upload-cos{display:flex;width:fit-content}.wui-upload-cos__input{display:none}.wui-upload-cos__toast{position:fixed;top:200px;left:50%;z-index:9999;max-width:min(360px,calc(100vw - 32px));padding:8px 16px;border-radius:4px;background:#000000b8;color:#fff;font-size:14px;line-height:20px;text-align:center;transform:translate(-50%)}
|
package/dist/upload-cos.umd.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(d,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],a):(d=typeof globalThis<"u"?globalThis:d||self,a(d.ElementCustomUIUploadCos={},d.Vue))})(this,function(d,a){"use strict";const L=new WeakMap;function H(r,i){const c=r,s=i;let l=L.get(r);return l||(l=new Set,L.set(r,l),c.install=S=>{l==null||l.forEach(m=>{S.component(m,r)})}),l.add(s),c}function _(){const r=globalThis.crypto;if(typeof(r==null?void 0:r.randomUUID)=="function")return r.randomUUID().replace(/-/g,"");if(typeof(r==null?void 0:r.getRandomValues)=="function"){const i=new Uint32Array(4);return r.getRandomValues(i),Array.from(i,c=>c.toString(16).padStart(8,"0")).join("")}return`${Date.now().toString(36)}${Math.random().toString(36).slice(2)}`}function J(r){const i=Number.isFinite(r)&&r>0?r:0;return i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(2)} KB`:i<1024*1024*1024?`${(i/(1024*1024)).toFixed(2)} MB`:`${(i/(1024*1024*1024)).toFixed(2)} GB`}function G(r){var c;const i=(c=r.split(".").pop())==null?void 0:c.trim().toLowerCase();return!i||i===r.toLowerCase()?"bin":i.replace(/[^a-z0-9]/g,"")||"bin"}function Q(r,i){const c=Y(r,"easy-oil"),s=_(),l=s.slice(0,12);return{fileId:s,fileName:`${c}_${Date.now()}_${l}.${i}`}}function X(r){if(!r)return"";const i=r.trim().replace(/^\/+/,"").replace(/\/{2,}/g,"/");return i&&!i.endsWith("/")?`${i}/`:i}function x(r,i){const c=i.replace(/^\/+/,""),s=r.replace(/\/+$/,"");return s?`${s}/${c}`:`/${c}`}function Y(r,i){return r.trim().replace(/[\\/\u0000-\u001f]+/g,"-").replace(/\s+/g,"-")||i}const Z={class:"wui-upload-cos"},ee=["accept","multiple"],te={key:0,class:"wui-upload-cos__toast",role:"status"},z=H(a.defineComponent({name:"UploadCos",__name:"UploadCos",props:{appChanneId:{default:""},multiple:{type:Boolean,default:!0},accept:{default:""},baseUrl:{default:""},limit:{default:0},overLoaderList:{default:()=>[]},fileType:{default:"file"},appName:{default:"qingyiweb"},isUseCos:{type:Boolean,default:!0},defaultUploadConfig:{default:()=>({})}},emits:["uploadfiles","errorUpLoad","overLimitTips","update:overLoaderList","upload-progress"],setup(r,{expose:i,emit:c}){const s=r,l=c,S=a.ref(),m=a.ref([]),C=a.ref(!1),M=a.ref(""),I=a.ref(!1),g=a.ref({});let h;a.watch(()=>s.overLoaderList,e=>{m.value=Array.from(e??[])},{immediate:!0}),a.onBeforeUnmount(()=>{h&&clearTimeout(h)});function T(e){M.value=e,I.value=!0,h&&clearTimeout(h),h=setTimeout(()=>{I.value=!1,h=void 0},2e3)}function j(){var e;C.value||(e=S.value)==null||e.click()}function ne(e){if(!(!e.url||typeof window>"u"))try{const t=new URL(e.url,window.location.href);if(!["http:","https:","blob:"].includes(t.protocol))return;const n=window.open(t.href,"_blank","noopener,noreferrer");n&&(n.opener=null)}catch{}}async function oe(e){const t=e.target;if(!(t instanceof HTMLInputElement))return;const n=Array.from(t.files??[]);if(!n.length)return;const o=s.limit>0?Math.max(s.limit-m.value.length,0):n.length,u=s.multiple?o:Math.min(o,1),p=n.slice(0,u);if(s.limit>0&&p.length<n.length&&l("overLimitTips"),!!p.length){C.value=!0;try{let U;if(s.isUseCos)try{U=await P()}catch{T("获取上传凭证失败");return}for(const f of p){if(f.size<=0){T(`文件 ${f.name} 无效,大小为 0`);continue}try{U?await B(f,U):await N(f)}catch{}}}finally{t.value="",C.value=!1}}}async function B(e,t){const n=O(e);b(n,e,0);try{const o=t??await P(),u=await re(e,o,n);return b(n,e,100),R(u)}catch(o){throw l("errorUpLoad",o),T("上传失败"),o}finally{K(n)}}async function N(e){const t=O(e),n=o=>b(t,e,o);n(0);try{const o=await le(e,n);return n(100),R(A(o,$(e)))}catch(o){throw l("errorUpLoad",o),T("上传失败"),o}finally{K(t)}}async function P(){if(!s.baseUrl)throw new Error("baseUrl is required.");const e=await k(x(s.baseUrl,"ms-attachment/cos/getAccessInfo"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({_appid:v()})}),t=await D(e,"获取上传凭证失败");if(!E(t,200))throw new Error("获取上传凭证失败");return ue(t.data)}async function re(e,t,n){const o=ce(e),u=G(e.name),{fileId:p,fileName:U}=Q(s.appName,u),f=`${X(t.dir)}${U}`,W=await(await ie(t)).uploadFile({Bucket:t.bucket,Region:t.region,Key:f,Body:e,SliceSize:5*1024*1024,onProgress:({percent:ge})=>{b(n,e,ge*100)}});if(!W.Location)throw new Error("COS 上传未返回文件地址");const q=fe(W.Location),me=await o,he=$(e,{url:q,ext:u,path:`/${f}`,...me});return se({file:e,fileId:p,extension:u,objectKey:f,objectUrl:q,fileData:he})}async function ie(e){const t=await import("cos-js-sdk-v5"),n=ae(t);return new n({SecretId:e.tmpSecretID,SecretKey:e.tmpSecretKey,SecurityToken:e.sessionToken,StartTime:e.startTime,ExpiredTime:e.expiredTime})}function ae(e){const t=w(e)&&"default"in e?e.default:e;if(typeof t!="function")throw new Error("COS SDK 加载失败");return t}async function se(e){if(!s.baseUrl)return e.fileData;const t=await k(x(s.baseUrl,"ms-attachment/cos/object/add"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({_appid:v(),fileMd5:e.fileId,ext:e.extension,size:e.file.size,path:`/${e.objectKey}`,url:e.objectUrl,fileName:e.file.name})}),n=await D(t,"文件元数据保存失败");if(!E(n,200))throw new Error("文件元数据保存失败");const o=F(pe(n.data,"fileURL"));return{...e.fileData,url:o??e.objectUrl,ext:e.extension}}async function le(e,t){const n=s.defaultUploadConfig;if(!de(n))throw new Error("defaultUploadConfig is incomplete.");const o=new FormData;o.append(s.fileType||"file",e);const u=await k(n.uploadUrl,{method:"POST",headers:{token:n.token,yyid:n.yyid,"x-app-channel-id":String(n.appChannelId),"x-data-channel-id":String(n.dataChannelId)},body:o}),p=await D(u,"默认直传失败");if(!E(p,2e4))throw new Error("默认直传失败");return t(100),A(p.data,$(e))}function R(e){const t=[...m.value,e];return m.value=t,l("uploadfiles",e),l("update:overLoaderList",t),e}function b(e,t,n){const o=Math.max(0,Math.min(100,Math.round(n)));g.value={...g.value,[e]:o},l("upload-progress",t,o)}function K(e){const t={...g.value};delete t[e],g.value=t}function O(e){return`${Date.now()}_${e.name}_${_().slice(0,12)}`}function v(){var e;return((e=s.appChanneId)==null?void 0:e.trim())||void 0}function $(e,t={}){return{name:e.name,origin_name:e.name,size:e.size,width:0,height:0,...t}}async function ce(e){if(e.type.startsWith("image/"))return new Promise(t=>{const n=new FileReader;n.onerror=()=>t(void 0),n.onload=()=>{if(typeof n.result!="string"){t(void 0);return}const o=new Image;o.onload=()=>t({width:o.naturalWidth,height:o.naturalHeight}),o.onerror=()=>t(void 0),o.src=n.result},n.readAsDataURL(e)})}async function k(e,t){const n=globalThis.fetch;if(typeof n!="function")throw new Error("浏览器不支持 Fetch。");const o=await n(e,t);if(!o.ok)throw new Error(`上传服务请求失败 (${o.status})`);return o}async function D(e,t){let n;try{n=await e.json()}catch{throw new Error(t)}if(!w(n))throw new Error(t);return n}function E(e,t){const n=e.code;return typeof n!="string"&&typeof n!="number"?!1:String(n)===String(t)}function ue(e){if(!w(e))throw new Error("上传凭证格式无效");return{tmpSecretID:y(e,["tmpSecretID","tmpSecretId","TmpSecretId"]),tmpSecretKey:y(e,["tmpSecretKey","TmpSecretKey"]),sessionToken:y(e,["sessionToken","SessionToken","token","Token"]),bucket:y(e,["bucket","Bucket"]),region:y(e,["region","Region"]),dir:F(e.dir),startTime:V(e.startTime??e.StartTime),expiredTime:V(e.expiredTime??e.ExpiredTime)}}function A(e,t){if(!w(e))throw new Error("上传服务未返回文件信息");return{...t,...e}}function de(e){return!!(e&&e.uploadUrl&&e.token&&e.yyid&&e.appChannelId!==void 0&&e.dataChannelId!==void 0)}function pe(e,t){return w(e)?e[t]:void 0}function F(e){return typeof e=="string"&&e.trim()?e:void 0}function V(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function y(e,t){for(const n of t){const o=F(e[n]);if(o)return o}throw new Error("上传凭证缺少必要字段")}function fe(e){return/^https?:\/\//i.test(e)?e:`https://${e.replace(/^\/+/,"")}`}function w(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}return i({triggerUpload:j,handleSingleFileUpload:B,uploadDefault:N,formatFileSize:J}),(e,t)=>(a.openBlock(),a.createElementBlock("div",Z,[a.createElementVNode("input",{ref_key:"fileInput",ref:S,class:"wui-upload-cos__input",type:"file",accept:r.accept,multiple:r.multiple,onChange:oe},null,40,ee),a.renderSlot(e.$slots,"upload-button",{triggerUpload:j,isUploading:C.value}),a.renderSlot(e.$slots,"file-list",{uploadedFiles:m.value,openFile:ne,progressMap:g.value}),I.value?(a.openBlock(),a.createElementBlock("div",te,a.toDisplayString(M.value),1)):a.createCommentVNode("",!0)]))}}),"UploadCos");d.UploadCos=z,d.default=z,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/utils/index.d.ts
DELETED
package/dist/utils/is.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Component, Plugin } from 'vue';
|
|
2
|
-
export type SFCWithInstall<T> = T & Plugin;
|
|
3
|
-
/**
|
|
4
|
-
* Adds Vue's plugin install hook to an SFC so it works with both
|
|
5
|
-
* `app.use(Component)` and named imports.
|
|
6
|
-
*/
|
|
7
|
-
export declare function withInstall<T extends Component>(component: T, alias?: string): SFCWithInstall<T>;
|