u
This commit is contained in:
1 parent
422d206bd6
commit
a4bd92264d
108 files changed
+16862
-35
No files matched your search
@@ -203,7 +203,6 @@ export function getFileExtension(fileName) {
|
||||
return fileExt;
|
||||
}
|
||||
|
||||
|
||||
export function downloadOssZip(files, fileName = "文件合集", callback) {
|
||||
const zip = new JSZip();
|
||||
const addedFiles = new Set();
|
||||
@@ -424,8 +423,35 @@ export function buildPublicUrl(filePath) {
|
||||
return joinUrl(baseUrl, "/static/file", filePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从完整 URL 中提取 filePath
|
||||
* @param fullUrl 完整访问地址
|
||||
* @returns filePath
|
||||
*/
|
||||
export function extractFilePath(fullUrl) {
|
||||
if (!fullUrl) return "";
|
||||
|
||||
const baseUrl = import.meta.env.PUBLIC_API_BASE_URL || "";
|
||||
|
||||
// 去掉 baseUrl
|
||||
let path = fullUrl.startsWith(baseUrl) ? fullUrl.slice(baseUrl.length) : fullUrl;
|
||||
|
||||
// 去掉 /static/file 前缀
|
||||
const prefix = "/static/file";
|
||||
if (path.startsWith(prefix)) {
|
||||
path = path.slice(prefix.length);
|
||||
}
|
||||
|
||||
// 去掉开头的 /
|
||||
if (path.startsWith("/")) {
|
||||
path = path.slice(1);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
export function getFileBlob(path) {
|
||||
const fullUrl = buildPublicUrl(path)
|
||||
const fullUrl = buildPublicUrl(path);
|
||||
|
||||
return fetch(fullUrl).then((response) => {
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in new issue
Block a user