Merge branches 'master' and 'master' of http://gitea.zianxin.com/zianxin-tec/biz-pc-cloud
This commit is contained in:
commit
89aa679c75
1 file changed
+24
-2
@@ -18,14 +18,36 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
downloadName: "下载",
|
||||
})
|
||||
|
||||
const formatSrc = (src: string, type: "string" | "array" = "string"): string | string[] => {
|
||||
switch (type) {
|
||||
case "string":
|
||||
if (!src.match(/x-oss-process/g)) {
|
||||
return src.split(",")[0]
|
||||
} else {
|
||||
return src.split("?")[0]
|
||||
}
|
||||
case "array":
|
||||
if (!src.match(/x-oss-process/g)) {
|
||||
return src.split(",")
|
||||
} else {
|
||||
return src
|
||||
.split("?")
|
||||
.filter(
|
||||
(item) =>
|
||||
item.endsWith(".jpg") || item.endsWith(".png") || item.endsWith(".gif") || item.endsWith(".jpeg") || item.endsWith(".webp"),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const realSrc = computed(() => {
|
||||
if (!props.src) return ""
|
||||
let real_src = props.src.split(",")[0]
|
||||
let real_src: string = formatSrc(props.src, "string") as string
|
||||
return dispatchUrl(real_src) ?? ""
|
||||
})
|
||||
const realSrcList = computed(() => {
|
||||
if (!props.src) return ""
|
||||
let real_src = props.src.split(",")?.map((v) => dispatchUrl(v))
|
||||
let real_src = (formatSrc(props.src, "array") as string[]).map((v) => dispatchUrl(v))
|
||||
return real_src ?? []
|
||||
})
|
||||
const realWidth = computed(() => (typeof props.width == "string" ? props.width : `${props.width}px`))
|
||||
|
||||
Reference in new issue
Block a user