@qynpm/ui 1.1.0 → 1.2.0
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 +4 -4
- package/dist/qy-file-picker/index.cjs +1 -1
- package/dist/qy-file-picker/index.mjs +1 -1
- package/dist/qy-image-upload/index.cjs +2 -2
- package/dist/qy-image-upload/index.mjs +2 -2
- package/dist/qy-upload/index.cjs +1 -1
- package/dist/qy-upload/index.mjs +1 -1
- package/dist/shared/{index-C9AEjhcH.mjs → index-BSHA0cGJ.mjs} +1 -1
- package/dist/shared/index-BoyiE_59.cjs +1 -0
- package/dist/shared/{index-B61qMsVc.cjs → index-DF3BUyOu.cjs} +1 -1
- package/dist/shared/index-DSc98P0J.mjs +957 -0
- package/dist/shared/{index-BjZlBHhd.mjs → index-DlyaXZXS.mjs} +1 -1
- package/dist/shared/{index-Dv56njXo.cjs → index-rP44D5Dd.cjs} +1 -1
- package/package.json +1 -1
- package/qy-upload/index.d.ts +2 -1
- package/dist/shared/index-B7uUS7TF.cjs +0 -1
- package/dist/shared/index-CEt5qI00.mjs +0 -857
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as V, ref as p, computed as w, openBlock as c, createElementBlock as f, normalizeClass as v, createVNode as S, withCtx as z, createElementVNode as h, withModifiers as d, withKeys as y, toDisplayString as U, createCommentVNode as k } from "vue";
|
|
2
|
-
import { U as B } from "./index-
|
|
2
|
+
import { U as B } from "./index-DSc98P0J.mjs";
|
|
3
3
|
import { _ as I } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
4
4
|
const N = /* @__PURE__ */ V({
|
|
5
5
|
name: "QyFilePicker",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const o=require("vue"),L=require("./index-
|
|
1
|
+
"use strict";const o=require("vue"),L=require("./index-BoyiE_59.cjs"),R=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),D=Object.assign({name:"QyImageUpload",inheritAttrs:!1},{__name:"index",props:{modelValue:{type:[String,Array],default:""},api:{type:String,default:"/permission-api/common/uploads"},name:{type:String,default:"files"},disabled:{type:Boolean,default:void 0},multiple:{type:Boolean,default:!1},mode:{type:String,default:"default"},voucher:{type:Boolean,default:!1},fileType:{type:Array,default:()=>[]},fileSize:{type:Number,default:10},isShowTip:{type:Boolean,default:!1},limit:{type:Number,default:void 0},tokenKey:{type:String,default:"Admin-Token"},supportVideo:{type:Boolean,default:!1},size:{type:String,default:"128px"},disableDrag:{type:Boolean,default:!1},showPasteInput:{type:Boolean,default:!0},pastePlaceholder:{type:String,default:"粘贴图片上传"},callBack:{type:Function,default:null},extraData:{type:Object,default:()=>({})},uploadRequest:{type:Function,default:null}},emits:["update:modelValue","change","success","error","remove","updateImg"],setup(p,{expose:f,emit:l}){const t=p,n=l,m=o.useAttrs(),r=o.ref(null),y=["jpg","jpeg","png","gif","bmp","webp"],u=o.computed(()=>t.voucher||t.mode==="voucher"),x=o.computed(()=>Array.isArray(t.modelValue)?t.modelValue.filter(Boolean):t.modelValue?String(t.modelValue).split(",").filter(Boolean):[]),w=o.computed(()=>t.supportVideo?1:u.value?t.limit??30:t.limit??(t.multiple?9:1)),q=o.computed(()=>{var e;return(e=t.fileType)!=null&&e.length?t.fileType:u.value&&!t.supportVideo?y:[]});function h(e){return Array.isArray(e)?e.filter(Boolean):[]}function d(e){const a=h(e);return t.multiple?a:a[0]||""}function P(e){n("update:modelValue",d(e))}function z(e){n("change",d(e==null?void 0:e.files))}function g(e){var k,B;if(typeof e=="string")return e;const a=e||{},c=a.url??a.urls??((k=a.data)==null?void 0:k.url)??((B=a.data)==null?void 0:B.urls)??"";return Array.isArray(c)?c[0]||"":c||""}function F(e){const a=g(e);a&&n("updateImg",a),n("success",s(),e)}function T(e){n("error",e)}function U(e,a){n("remove",e,a)}function v(){var e,a;(a=(e=r.value)==null?void 0:e.openFileDialog)==null||a.call(e)}function _(){var e,a;(a=(e=r.value)==null?void 0:e.clearFiles)==null||a.call(e)}function i(){var e,a;return((a=(e=r.value)==null?void 0:e.getPathList)==null?void 0:a.call(e))||[]}const b=o.computed(()=>i()),V=o.computed(()=>i());function A(){return i()}function s(){const e=i();return t.multiple?e:e[0]||""}f({openFileDialog:v,clearFiles:_,getPathList:i,getFullPathList:A,fullPathList:b,pathList:V,getValue:s});const S={props:t,emit:n,attrs:m,uploadRef:r,voucherImageTypes:y,isVoucherMode:u,modelAsArray:x,uploadLimit:w,effectiveFileType:q,normalizeValue:h,formatValue:d,handleUpdateModelValue:P,handleChange:z,resolveUploadUrl:g,handleSuccess:F,handleError:T,handleRemove:U,openFileDialog:v,clearFiles:_,getPathList:i,fullPathList:b,pathList:V,getFullPathList:A,getValue:s,computed:o.computed,ref:o.ref,useAttrs:o.useAttrs,QyUpload:L.Upload};return Object.defineProperty(S,"__isScriptSetup",{enumerable:!1,value:!0}),S}});function I(p,f,l,t,n,m){return o.openBlock(),o.createBlock(t.QyUpload,o.mergeProps({ref:"uploadRef"},t.attrs,{"model-value":t.modelAsArray,"value-format":"array",api:l.api,name:l.name,multiple:l.multiple,disabled:l.disabled,"file-type":t.effectiveFileType,"file-size":l.fileSize,limit:t.uploadLimit,"is-show-tip":l.isShowTip,"token-key":l.tokenKey,"support-video":l.supportVideo,size:l.size,"disable-drag":l.disableDrag,"call-back":l.callBack,"extra-data":l.extraData,"upload-request":l.uploadRequest,"show-text":!1,"show-paste-input":l.showPasteInput,"paste-placeholder":l.pastePlaceholder,"onUpdate:modelValue":t.handleUpdateModelValue,onChange:t.handleChange,onSuccess:t.handleSuccess,onError:t.handleError,onRemove:t.handleRemove}),null,16,["model-value","api","name","multiple","disabled","file-type","file-size","limit","is-show-tip","token-key","support-video","size","disable-drag","call-back","extra-data","upload-request","show-paste-input","paste-placeholder"])}const j=R._export_sfc(D,[["render",I],["__file","/home/runner/work/qy-component/qy-component/packages/ui/lib/qy-image-upload/index.vue"]]);exports.Component=j;
|
package/package.json
CHANGED
package/qy-upload/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
Plugin
|
|
5
5
|
} from 'vue'
|
|
6
6
|
|
|
7
|
-
export type QyUploadVariant = 'media-card' | 'file-list'
|
|
7
|
+
export type QyUploadVariant = 'media-card' | 'attachment-card' | 'file-list'
|
|
8
8
|
export type QyUploadValueFormat = 'object' | 'array' | 'string'
|
|
9
9
|
export type QyUploadInvalidCode = 'extension' | 'size'
|
|
10
10
|
|
|
@@ -81,6 +81,7 @@ export type QyUploadEmits = {
|
|
|
81
81
|
error: (error: unknown) => void
|
|
82
82
|
remove: (file: unknown, files: unknown[]) => void
|
|
83
83
|
invalid: (detail: QyUploadInvalidDetail) => void
|
|
84
|
+
preview: (file: { url: string; name: string }) => void
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
declare const QyUpload: DefineComponent<
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const B=require("element-plus"),t=require("vue"),_e=require("@element-plus/icons-vue"),m=require("element-plus"),Xe=require("./js.cookie-BmJmHEx1.cjs"),He=require("./_plugin-vue_export-helper-BHFhmbuH.cjs"),Je="Admin-Token";function Fe(D=Je){return Xe.api.get(D)}const Qe=Object.assign({name:"QyUpload"},{__name:"index",props:{modelValue:{type:[Object,Array,String],default:void 0},selectedFiles:{type:Array,default:()=>[]},autoUpload:{type:Boolean,default:!0},variant:{type:String,default:"media-card"},defaultValue:{type:Object,default:()=>({files:"",text:""})},valueFormat:{type:String,default:"object"},showText:{type:Boolean,default:!0},showPasteInput:{type:Boolean,default:!1},pastePlaceholder:{type:String,default:"输入文字"},multiple:{type:Boolean,default:!0},disabled:{type:Boolean,default:void 0},fileType:{type:Array,default:()=>[]},fileSize:{type:Number,default:10},limit:{type:Number,default:9},isShowTip:{type:Boolean,default:!1},api:{type:String,default:"/permission-api/common/uploads"},name:{type:String,default:"file"},tokenKey:{type:String,default:"Admin-Token"},supportVideo:{type:Boolean,default:!1},size:{type:String,default:"default"},disableDrag:{type:Boolean,default:!1},callBack:{type:Function,default:null},extraData:{type:Object,default:()=>({})},uploadRequest:{type:Function,default:null}},emits:["update:modelValue","update:selectedFiles","selectedFilesChange","change","success","error","remove","invalid"],setup(D,{expose:r,emit:f}){const l=D,p=f,ne=t.ref(null),N=t.ref(null),E=t.ref(null),s=t.ref([]),L=t.ref(null),O=t.ref(null),x=new Map,k=new WeakMap;let g=Date.now(),M=!1;const K=t.ref(!1),W=t.ref([]),ae=t.ref(0),ie=t.ref(!1),oe=t.ref(""),re=t.ref(""),T=new Set,U=new Map;function S(e){T.delete(e)&&URL.revokeObjectURL(e)}function X(){for(const e of T)S(e)}function q(e){const n=U.get(e);n&&(U.delete(e),n.close())}function H(){for(const e of U.keys())q(e)}function J(e){var n;(n=x.get(e))==null||n()}function Q(){for(const e of x.values())e()}const P=t.ref(!1),V=t.ref(""),Ce=t.ref(!1);t.onMounted(()=>{l.modelValue!==void 0||!l.autoUpload||Y(l.defaultValue)});const Be=t.computed(()=>({large:"160px",default:"140px",small:"80px"})[l.size]??l.size),h=m.useFormDisabled(),De=t.computed(()=>s.value.some(e=>e.status==="uploading")),Ne=t.computed(()=>l.variant==="file-list"||l.supportVideo?"text":"picture-card"),se=t.computed(()=>l.supportVideo?1:!l.autoUpload&&!l.multiple?2:l.limit),Me=t.computed(()=>{var e;return l.isShowTip&&(l.fileSize||((e=b.value)==null?void 0:e.length))}),b=t.computed(()=>{var e;return(e=l.fileType)!=null&&e.length?l.fileType.map(n=>String(n).trim().replace(/^\./,"").toLowerCase()).filter(Boolean):l.variant==="file-list"?[]:l.supportVideo?["mp4","mov","avi"]:["jpg","jpeg","png","gif","webp"]}),j=t.computed(()=>{if(!l.autoUpload&&!l.multiple)return!1;const e=l.supportVideo?1:l.limit;return s.value.length>=e}),Te=t.computed(()=>b.value.map(e=>`.${e}`).join(",")),Se=t.computed(()=>({"qy-upload--reached-limit":j.value,"qy-upload--disabled":h.value,"qy-upload--video":l.supportVideo,"qy-upload--without-text":!l.showText&&!l.showPasteInput}));t.watch(V,()=>{M||F()}),t.watch(()=>l.modelValue,e=>{l.autoUpload&&e!==void 0&&Y(e)},{immediate:!0,deep:!0}),t.watch(()=>[l.autoUpload,l.selectedFiles],([e,n])=>{e||(s.value=_(n))},{immediate:!0,deep:!0});function G(e){return Array.isArray(e)?e.filter(Boolean):e?String(e).split(",").filter(Boolean):[]}function ue(e){return Array.isArray(e)?{files:e,text:""}:typeof e=="string"?{files:G(e),text:""}:e&&typeof e=="object"?{files:G(e.files),text:e.text??""}:{files:[],text:""}}function de(e=[]){return e.map((n,a)=>({name:String(n).split("/").pop()||`file-${a}`,url:n,status:"success",uid:m.genFileId()}))}function _(e=[]){return e.filter(Boolean).map((n,a)=>{const i=t.toRaw(n);return{name:i.name,raw:i,status:"ready",uid:ce(i,a)}})}function ce(e,n){if(e.uid!=null)return e.uid;const a=k.get(e);return a??(g+=n+1,k.set(e,g),g)}function I(e=s.value){return e.map(n=>{const a=n.raw??(n instanceof File?n:null);return a?t.toRaw(a):null}).filter(Boolean)}function R(e){p("update:selectedFiles",e),p("selectedFilesChange",e)}function qe(e,n){if(l.autoUpload)return;const a=e==null?void 0:e.raw;if(a&&!z(a)){s.value=_(l.selectedFiles);return}const i=I(n);a&&!i.includes(a)&&i.push(a);const o=l.multiple?i:i.slice(-1);s.value=_(o),R(o)}function fe(e){const n=new Set(e.map(i=>i.url)),a=s.value.filter(i=>(i.status==="ready"||i.status==="uploading")&&!n.has(i.url));return[...e,...a]}function Y(e){const n=ue(e);M=!0,V.value=n.text,s.value=fe(de(n.files)),t.nextTick(()=>{M=!1})}function Z(e){return l.valueFormat==="array"?e.files:l.valueFormat==="string"?e.files.join(","):e}function Re(){var e;(e=L.value)==null||e.focus()}function Ee(e){e.target.value=""}function F(e){const i={files:(e??s.value).filter(o=>o.status==="success"&&o.url).map(o=>o.url),text:V.value};p("update:modelValue",Z(i)),p("change",i),l.callBack&&l.callBack(i)}function Le(e,n){if(q(e.uid),J(e.uid),S(e.url),!l.autoUpload){const a=I(n);s.value=_(a),R(a),p("remove",e,n);return}F(n),p("remove",e,n)}function $(e){var a;const n=(e==null?void 0:e.name)||"";return n.includes(".")&&((a=n.split(".").pop())==null?void 0:a.toLowerCase())||""}function ee(e){var o,d,u;const n=((d=(o=e==null?void 0:e.type)==null?void 0:o.toLowerCase)==null?void 0:d.call(o))||"",a={"image/jpeg":["jpg","jpeg"],"image/png":["png"],"image/gif":["gif"],"image/bmp":["bmp"],"image/webp":["webp"],"video/mp4":["mp4"],"video/quicktime":["mov"],"video/x-msvideo":["avi"],"video/webm":["webm"]};if(a[n])return a[n];const i=(u=n.split("/")[1])==null?void 0:u.split("+")[0];return i?[i]:[]}function pe(e){if(!b.value.length)return!0;const n=$(e),a=ee(e);return[n,...a].some(i=>b.value.includes(i))}function z(e){if(l.fileSize>0&&e.size>l.fileSize*1024*1024){const a={code:"size",file:e,message:`文件大小不能超过${l.fileSize}M`};return m.ElMessage.warning(a.message),p("invalid",a),!1}if(!pe(e)){const a={code:"extension",file:e,message:`格式不支持,仅允许: ${b.value.join("/")}`};return m.ElMessage.warning(a.message),p("invalid",a),!1}return!0}async function me(e,n,a,i,o){const d=te(e),u={close:()=>i.close()};U.set(o,u);const y=()=>U.get(o)===u;try{const c=await l.uploadRequest({file:e,formData:d,api:l.api,name:l.name,tokenKey:l.tokenKey,extraData:l.extraData});if(!y())return;const C=ge(c);if(!C){const w=new Error("上传失败,未返回文件地址");m.ElMessage.error(w.message),p("error",w),a==null||a(w);return}m.ElMessage.success("上传成功"),n==null||n({...typeof c=="object"&&c?c:{},url:C})}catch(c){if(!y())return;m.ElMessage.error("上传失败"),p("error",c),a==null||a(c)}finally{y()&&q(o)}}function te(e){const n=new FormData;return n.append(l.name,e),l.extraData&&Object.entries(l.extraData).forEach(([a,i])=>n.append(a,i)),n}function ge(e){var i,o;if(typeof e=="string")return e;const n=e||{},a=n.urls??n.url??((i=n.data)==null?void 0:i.urls)??((o=n.data)==null?void 0:o.url)??"";return Array.isArray(a)?a[0]||"":a||""}function le(e,n,a,i,o=e.uid){const d=m.ElLoading.service({target:N.value,text:"上传中",background:"rgba(255,255,255,0.7)"});if(l.uploadRequest){me(e,a,i,d,o);return}const u=l.api.startsWith("http")?l.api:window.location.origin+l.api.replace(/^([^/])/,"/$1"),y=te(e),c=new XMLHttpRequest;let C=!1;const w=()=>C?!1:(C=!0,x.delete(o),d.close(),!0);x.set(o,()=>{w()&&c.abort()}),c.onabort=w,c.open("POST",u);const Ue=Fe(l.tokenKey);Ue&&c.setRequestHeader("Authorization",`Bearer ${Ue}`),c.upload.onprogress=v=>{!C&&v.total>0&&(n==null||n({percent:v.loaded/v.total*100}))},c.onload=()=>{if(w()){if(c.status<200||c.status>=300){const v=`上传失败 (HTTP ${c.status})`;m.ElMessage.error(v),p("error",{msg:v,status:c.status}),i==null||i(new Error(v));return}try{const v=JSON.parse(c.responseText);v.code===200&&v.urls?(m.ElMessage.success("上传成功"),a==null||a({...v,url:v.urls})):(m.ElMessage.error(v.msg||"上传失败"),p("error",v),i==null||i(v))}catch{m.ElMessage.error("上传失败,响应格式错误"),p("error",new Error("Response parse error")),i==null||i(new Error("Response parse error"))}}},c.onerror=()=>{w()&&(m.ElMessage.error("上传失败,网络异常"),p("error",new Error("Network error")),i==null||i(new Error("Network error")))},c.send(y)}function ve(e){return h.value?!1:z(e)}function ye(e,n){const a=s.value.find(i=>{var o;return i.uid===(e==null?void 0:e.uid)||((o=i.raw)==null?void 0:o.uid)===(e==null?void 0:e.uid)});a&&(a.url=n,a.status="success")}function Pe(e){le(e.file,e.onProgress,n=>{ye(e.file,n.url),e.onSuccess(n),F(),p("success",n)},n=>e.onError(n))}function je(e){var i;if(!e.url)return;const n=((i=e.url.split(".").pop())==null?void 0:i.toLowerCase())||"";if(["mp4","mov","avi","webm"].includes(n)){oe.value=e.url,re.value=e.name||"视频预览",ie.value=!0;return}const a=s.value.filter(o=>{var d;return o.status==="success"&&o.url&&!["mp4","mov","avi","webm"].includes((d=o.url.split(".").pop())==null?void 0:d.toLowerCase())});W.value=a.map(o=>o.url),ae.value=a.findIndex(o=>o.uid===e.uid)||0,K.value=!0}function Ie(){K.value=!1,W.value=[]}function he(e,n){if(e.name&&$(e))return e;const a=ee(e).find(i=>b.value.includes(i));return a?new File([e],`paste-${Date.now()+n}.${a}`,{type:e.type,lastModified:e.lastModified}):e}function A(e){if(!l.autoUpload){const n=I(),a=e.filter(o=>z(o));if(!a.length)return;const i=l.multiple?[...n,...a].slice(0,l.limit):a.slice(-1);s.value=_(i),R(i);return}for(let n=0;n<e.length&&!(s.value.length>=se.value);n++){const a=he(e[n],n);if(!ve(a))continue;const i=m.genFileId(),o=URL.createObjectURL(a);T.add(o),s.value.push({uid:i,name:a.name||`file-${i}`,status:"uploading",percentage:0,url:o}),le(a,d=>{const u=s.value.find(y=>y.uid===i);u&&(u.percentage=d.percent)},d=>{const u=s.value.find(y=>y.uid===i);u&&(u.url!==d.url&&S(u.url),u.status="success",u.url=d.url,F(),p("success",d))},()=>xe(i),i)}}function ze(e){const n=e.target,a=Array.from(n.files||[]);if(n.value="",h.value||!a.length)return;const i=l.supportVideo||!l.multiple?a.slice(0,1):a;A(i)}function we(e){const n=Array.from((e==null?void 0:e.files)||[]).filter(d=>{var u;return(u=d.type)==null?void 0:u.startsWith("image/")});if(n.length)return n;const a=e==null?void 0:e.items;if(!a)return[];const i=[],o=new Set;for(let d=0;d<a.length;d++){const u=a[d];if(u.kind==="file"&&u.type.startsWith("image/")){const y=u.getAsFile();y&&!o.has(y)&&(o.add(y),i.push(y))}}return i}function Ae(e){if(h.value)return;const n=we(e.clipboardData);n.length&&(e.preventDefault(),A(n))}function Oe(){h.value||l.disableDrag||(P.value=!0)}function Ke(){P.value=!1}function We(e){var a;if(P.value=!1,h.value||l.disableDrag||j.value)return;const n=Array.from(((a=e.dataTransfer)==null?void 0:a.files)||[]);n.length&&A(n)}function xe(e){q(e),J(e);const n=s.value.findIndex(a=>a.uid===e);n!==-1&&(S(s.value[n].url),s.value.splice(n,1))}t.onBeforeUnmount(()=>{H(),Q(),X()});function Ve(){var e;h.value||j.value||(e=E.value)==null||e.click()}function be(){var e;H(),Q();for(const n of s.value)(e=n.url)!=null&&e.startsWith("blob:")&&T.add(n.url);X(),s.value=[],V.value="",R([]),l.autoUpload&&F()}r({openFileDialog:Ve,getPathList:()=>s.value.filter(e=>e.status==="success").map(e=>e.url),clearFiles:be,getValue:()=>({files:s.value.filter(e=>e.status==="success"&&e.url).map(e=>e.url),text:V.value}),getModelValue:()=>Z({files:s.value.filter(e=>e.status==="success"&&e.url).map(e=>e.url),text:V.value})});const ke={props:l,emit:p,uploadRef:ne,rootRef:N,nativeInputRef:E,fileList:s,inputRef:L,pasteInputRef:O,pendingXhrs:x,selectedFileUids:k,get selectedFileUid(){return g},set selectedFileUid(e){g=e},get syncingFromValue(){return M},set syncingFromValue(e){M=e},viewerVisible:K,viewerUrlList:W,viewerIndex:ae,videoVisible:ie,videoUrl:oe,videoTitle:re,objectUrls:T,pendingCustomUploads:U,releaseObjectUrl:S,releaseObjectUrls:X,cancelCustomUpload:q,cancelCustomUploads:H,cancelXhr:J,cancelXhrs:Q,isDragOver:P,localText:V,textExpanded:Ce,sizeValue:Be,isUploadDisabled:h,isUploading:De,uploadListType:Ne,effectiveLimit:se,shouldShowTip:Me,allowedExtensions:b,isReachedLimit:j,acceptAttr:Te,uploadClasses:Se,normalizeFilesInput:G,parseValue:ue,createFileList:de,createSelectedFileList:_,getSelectedFileUid:ce,getSelectedRawFiles:I,emitSelectedFiles:R,handleFileChange:qe,mergePendingFileList:fe,syncValueToState:Y,formatModelValue:Z,focusTextarea:Re,clearPasteInput:Ee,handleSyncValue:F,handleRemove:Le,getFileNameExtension:$,getMimeExtensions:ee,isAllowedFileType:pe,validateFile:z,uploadViaCustomRequest:me,createUploadFormData:te,resolveUploadUrl:ge,uploadViaXhr:le,handleBeforeUpload:ve,applyUploadResultToFile:ye,handleCustomUpload:Pe,handlePreview:je,closeViewer:Ie,createNamedPasteFile:he,uploadFiles:A,handleNativeInputChange:ze,collectImageFilesFromClipboard:we,handlePaste:Ae,handleDragOver:Oe,handleDragLeave:Ke,handleDrop:We,handleRemoveByUid:xe,openFileDialog:Ve,clearFiles:be,ref:t.ref,computed:t.computed,watch:t.watch,onMounted:t.onMounted,onBeforeUnmount:t.onBeforeUnmount,nextTick:t.nextTick,toRaw:t.toRaw,get Plus(){return _e.Plus},get InfoFilled(){return _e.InfoFilled},get ElMessage(){return m.ElMessage},get ElLoading(){return m.ElLoading},get genFileId(){return m.genFileId},get useFormDisabled(){return m.useFormDisabled},get getToken(){return Fe}};return Object.defineProperty(ke,"__isScriptSetup",{enumerable:!1,value:!0}),ke}}),Ge=["accept","multiple","disabled"],Ye=["disabled"],Ze={class:"qy-upload__hint"},$e=["placeholder","disabled"],et=["src"],tt={key:1,class:"qy-upload__tip"},lt={class:"error"},nt={class:"error"};function at(D,r,f,l,p,ne){var k;const N=B.ElIcon,E=B.ElInput,s=B.ElPopover,L=B.ElUpload,O=B.ElImageViewer,x=B.ElDialog;return t.openBlock(),t.createElementBlock("div",{ref:"rootRef",class:t.normalizeClass(["qy-upload",l.uploadClasses]),style:t.normalizeStyle({"--qy-upload-size":l.sizeValue})},[t.createElementVNode("input",{ref:"nativeInputRef",class:"qy-upload__native-input",type:"file",accept:l.acceptAttr,multiple:f.supportVideo?!1:f.multiple,disabled:l.isUploadDisabled,onChange:l.handleNativeInputChange},null,40,Ge),t.createVNode(L,{ref:"uploadRef","file-list":l.fileList,"onUpdate:fileList":r[7]||(r[7]=g=>l.fileList=g),action:"#",multiple:f.supportVideo?!1:f.multiple,limit:l.effectiveLimit,"auto-upload":f.autoUpload,"list-type":l.uploadListType,accept:l.acceptAttr,disabled:l.isUploadDisabled,"http-request":l.handleCustomUpload,"before-upload":l.handleBeforeUpload,"on-change":l.handleFileChange,"on-preview":l.handlePreview,"on-remove":l.handleRemove},t.createSlots({default:t.withCtx(()=>[f.variant!=="file-list"&&!l.isReachedLimit?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["qy-upload__trigger",{"is-dragover":l.isDragOver}]),onPaste:l.handlePaste,onDragover:t.withModifiers(l.handleDragOver,["prevent"]),onDragleave:t.withModifiers(l.handleDragLeave,["prevent"]),onDrop:t.withModifiers(l.handleDrop,["prevent"])},[t.createVNode(N,{class:"qy-upload__icon"},{default:t.withCtx(()=>[t.createVNode(l.Plus)]),_:1}),f.supportVideo?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[r[10]||(r[10]=t.createElementVNode("span",{class:"qy-upload__label"},"点击上传视频",-1)),t.createElementVNode("span",Ze,"支持 "+t.toDisplayString(l.allowedExtensions.join(" / "))+",不超过 "+t.toDisplayString(f.fileSize)+"MB",1)],64)):t.createCommentVNode("v-if",!0),t.createCommentVNode(" 文字输入框:可通过 showText 关闭,凭证上传这类纯图片场景不需要展示 "),f.showText?(t.openBlock(),t.createElementBlock("div",{key:1,class:"qy-upload__text",onClick:r[4]||(r[4]=t.withModifiers(()=>{},["stop"])),onPaste:t.withModifiers(l.handlePaste,["stop"])},[t.createVNode(s,{visible:l.textExpanded,"onUpdate:visible":r[3]||(r[3]=g=>l.textExpanded=g),placement:"bottom-start",width:220,trigger:"click","popper-class":"qy-upload__text-popover",onAfterEnter:l.focusTextarea},{reference:t.withCtx(()=>[t.createElementVNode("div",{class:t.normalizeClass(["qy-upload__text-preview",{"is-placeholder":!l.localText}])},t.toDisplayString(l.localText||f.pastePlaceholder),3)]),default:t.withCtx(()=>[t.createVNode(E,{ref:"inputRef",modelValue:l.localText,"onUpdate:modelValue":r[1]||(r[1]=g=>l.localText=g),type:"textarea",autosize:{minRows:2,maxRows:5},placeholder:f.pastePlaceholder,disabled:l.isUploadDisabled,onBlur:r[2]||(r[2]=g=>l.textExpanded=!1),onPaste:t.withModifiers(l.handlePaste,["stop"])},null,8,["modelValue","placeholder","disabled"])]),_:1},8,["visible"])],32)):f.showPasteInput?(t.openBlock(),t.createElementBlock(t.Fragment,{key:2},[t.createCommentVNode(" 纯粘贴入口:不保存文字,只提供一个可聚焦区域承接 Ctrl+V 图片 "),t.createElementVNode("div",{class:"qy-upload__text",onClick:r[6]||(r[6]=t.withModifiers(()=>{},["stop"])),onPaste:t.withModifiers(l.handlePaste,["stop"])},[t.createElementVNode("input",{ref:"pasteInputRef",class:"qy-upload__paste-input",placeholder:f.pastePlaceholder,disabled:l.isUploadDisabled,onPaste:t.withModifiers(l.handlePaste,["stop"]),onInput:l.clearPasteInput,onClick:r[5]||(r[5]=t.withModifiers(()=>{},["stop"]))},null,40,$e)],32)],2112)):t.createCommentVNode("v-if",!0)],34)):t.createCommentVNode("v-if",!0)]),_:2},[f.variant==="file-list"?{name:"trigger",fn:t.withCtx(()=>[t.createElementVNode("div",{class:"qy-upload__file-trigger",onClick:r[0]||(r[0]=t.withModifiers(()=>{},["stop"])),onDragover:t.withModifiers(l.handleDragOver,["prevent"]),onDragleave:t.withModifiers(l.handleDragLeave,["prevent"]),onDrop:t.withModifiers(l.handleDrop,["prevent"])},[t.renderSlot(D.$slots,"trigger",{open:l.openFileDialog,disabled:l.isUploadDisabled,uploading:l.isUploading},()=>[t.createElementVNode("button",{class:"qy-upload__file-button",type:"button",disabled:l.isUploadDisabled,onClick:l.openFileDialog}," 选择文件 ",8,Ye)],!0)],32)]),key:"0"}:void 0]),1032,["file-list","multiple","limit","auto-upload","list-type","accept","disabled"]),l.viewerVisible?(t.openBlock(),t.createBlock(O,{key:0,"url-list":l.viewerUrlList,"initial-index":l.viewerIndex,onClose:l.closeViewer},null,8,["url-list","initial-index"])):t.createCommentVNode("v-if",!0),t.createCommentVNode(" 视频预览弹窗 "),t.createVNode(x,{modelValue:l.videoVisible,"onUpdate:modelValue":r[8]||(r[8]=g=>l.videoVisible=g),title:l.videoTitle,width:"640px","append-to-body":"","destroy-on-close":"",onClose:r[9]||(r[9]=g=>l.videoVisible=!1)},{default:t.withCtx(()=>[l.videoVisible?(t.openBlock(),t.createElementBlock("video",{key:0,src:l.videoUrl,controls:"",autoplay:"",style:{width:"100%","max-height":"400px","border-radius":"4px"}},null,8,et)):t.createCommentVNode("v-if",!0)]),_:1},8,["modelValue","title"]),l.shouldShowTip?(t.openBlock(),t.createElementBlock("div",tt,[t.createVNode(N,null,{default:t.withCtx(()=>[t.createVNode(l.InfoFilled)]),_:1}),t.createElementVNode("span",null,[r[13]||(r[13]=t.createTextVNode(" 请上传 ",-1)),f.fileSize?(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[r[11]||(r[11]=t.createTextVNode("大小不超过 ",-1)),t.createElementVNode("b",lt,t.toDisplayString(f.fileSize)+"MB",1)],64)):t.createCommentVNode("v-if",!0),(k=l.allowedExtensions)!=null&&k.length?(t.openBlock(),t.createElementBlock(t.Fragment,{key:1},[r[12]||(r[12]=t.createTextVNode(",格式为 ",-1)),t.createElementVNode("b",nt,t.toDisplayString(l.allowedExtensions.join("/")),1)],64)):t.createCommentVNode("v-if",!0),r[14]||(r[14]=t.createTextVNode(" 的文件。 ",-1))])])):t.createCommentVNode("v-if",!0)],6)}const it=He._export_sfc(Qe,[["render",at],["__scopeId","data-v-61da1df2"],["__file","/home/runner/work/qy-component/qy-component/packages/ui/lib/upload/index.vue"]]);exports.Upload=it;
|