From c80bc467a41daa6cbae4e5515a300a8ca98cfeaa Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期二, 21 七月 2026 15:44:01 +0800
Subject: [PATCH] 维护
---
unpackage/dist/dev/mp-weixin/components/attachment/index.js | 113 ++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 81 insertions(+), 32 deletions(-)
diff --git a/unpackage/dist/dev/mp-weixin/components/attachment/index.js b/unpackage/dist/dev/mp-weixin/components/attachment/index.js
index 47c3e6d..f95fc2d 100644
--- a/unpackage/dist/dev/mp-weixin/components/attachment/index.js
+++ b/unpackage/dist/dev/mp-weixin/components/attachment/index.js
@@ -17,13 +17,23 @@
files: { type: Array, default: () => [] },
gradesFiles: { type: Array, default: () => [] },
readonly: { type: Boolean, default: false },
- position: { type: Object, default: () => ({ right: "30rpx", bottom: "200rpx" }) },
+ position: {
+ type: Object,
+ default: () => ({ right: "30rpx", bottom: "200rpx" })
+ },
bgColor: { type: String, default: "#67AFAB" },
maxCount: { type: Number, default: 9 },
showGradeSlip: { type: Boolean, default: false },
isGradeRequired: { type: Boolean, default: false }
},
- emits: ["update:files", "update:gradesFiles", "upload", "preview", "upload-grade", "upload-base"],
+ emits: [
+ "update:files",
+ "update:gradesFiles",
+ "upload",
+ "preview",
+ "upload-grade",
+ "upload-base"
+ ],
setup(__props, { expose: __expose, emit: __emit }) {
const userStore = stores_user.useUserStore();
const props = __props;
@@ -33,35 +43,58 @@
const gradeFiles = common_vendor.ref([]);
const showButton = common_vendor.ref(true);
const mainColor = common_vendor.ref("#67AFAB");
- const baseUrlHt = userStore.baseUrlHt;
const currentTab = common_vendor.ref("base");
const blobUrls = common_vendor.ref([]);
+ const getBaseUrlHt = () => {
+ return userStore.baseUrlHt;
+ };
+ const baseUrlHt = getBaseUrlHt();
const currentFileList = common_vendor.computed(() => {
if (!props.showGradeSlip)
return baseFiles.value;
return currentTab.value === "base" ? baseFiles.value : gradeFiles.value;
});
- const totalFileCount = common_vendor.computed(() => baseFiles.value.length + gradeFiles.value.length);
- common_vendor.watch(() => props.files, (newFiles) => {
- baseFiles.value = [...newFiles];
- }, { immediate: true });
- common_vendor.watch(() => props.gradesFiles, (newFiles) => {
- gradeFiles.value = [...newFiles];
- }, { immediate: true });
+ const totalFileCount = common_vendor.computed(
+ () => baseFiles.value.length + gradeFiles.value.length
+ );
+ common_vendor.watch(
+ () => props.files,
+ (newFiles) => {
+ baseFiles.value = [...newFiles];
+ },
+ { immediate: true }
+ );
+ common_vendor.watch(
+ () => props.gradesFiles,
+ (newFiles) => {
+ gradeFiles.value = [...newFiles];
+ },
+ { immediate: true }
+ );
const getFullUrl = (path) => {
if (!path)
return "";
+ if (path.startsWith("blob:") || path.startsWith("file://")) {
+ return path;
+ }
if (path.startsWith("http://") || path.startsWith("https://")) {
- try {
- const url = new URL(path);
- return `${baseUrlHt}${url.pathname}${url.search}${url.hash}`;
- } catch {
- return path;
+ const protocolEnd = path.indexOf("://") + 3;
+ const pathStart = path.indexOf("/", protocolEnd);
+ if (pathStart !== -1) {
+ return `${baseUrlHt}${path.substring(pathStart)}`;
}
+ return baseUrlHt;
}
return `${baseUrlHt}${path.startsWith("/") ? "" : "/"}${path}`;
};
- const supportedImageTypes = ["image/jpeg", "image/png", "image/gif", "image/webp", "image/bmp", "image/svg+xml"];
+ const supportedImageTypes = [
+ "image/jpeg",
+ "image/png",
+ "image/gif",
+ "image/webp",
+ "image/bmp",
+ "image/svg+xml"
+ ];
const onPopupChange = (e) => {
showButton.value = !e.show;
};
@@ -112,7 +145,10 @@
const isGradeTab = props.showGradeSlip && currentTab.value === "grade";
const targetFiles = isGradeTab ? gradeFiles.value : baseFiles.value;
if (targetFiles.length + newFiles.length > props.maxCount) {
- common_vendor.index.showToast({ title: `鏈�澶氬彧鑳戒笂浼�${props.maxCount}涓枃浠禶, icon: "none" });
+ common_vendor.index.showToast({
+ title: `鏈�澶氬彧鑳戒笂浼�${props.maxCount}涓枃浠禶,
+ icon: "none"
+ });
newFiles.forEach((f) => {
if (f.url && f.url.startsWith("blob:"))
URL.revokeObjectURL(f.url);
@@ -133,7 +169,10 @@
success: (res) => {
const remain = props.maxCount - currentFileList.value.length;
if (remain <= 0) {
- common_vendor.index.showToast({ title: `鏈�澶氫笂浼�${props.maxCount}涓枃浠禶, icon: "none" });
+ common_vendor.index.showToast({
+ title: `鏈�澶氫笂浼�${props.maxCount}涓枃浠禶,
+ icon: "none"
+ });
return;
}
if (res.tapIndex === 0) {
@@ -147,7 +186,6 @@
path: file.path,
url: file.path,
uploadPath: file.path,
- // 灏忕▼搴忎复鏃舵枃浠惰矾寰�
type: file.type || "image/jpeg",
size: file.size,
raw: file,
@@ -203,7 +241,9 @@
}
if (file.type && supportedImageTypes.includes(file.type)) {
const allFiles = [...baseFiles.value, ...gradeFiles.value];
- const imageUrls = allFiles.filter((f) => f.type && supportedImageTypes.includes(f.type)).map((f) => f.url.startsWith("blob:") || f.url.startsWith("file://") || f.url.startsWith("/") ? f.url : getFullUrl(f.url));
+ const imageUrls = allFiles.filter((f) => f.type && supportedImageTypes.includes(f.type)).map(
+ (f) => f.url.startsWith("blob:") || f.url.startsWith("file://") || f.url.startsWith("/") ? f.url : getFullUrl(f.url)
+ );
common_vendor.index.previewImage({ urls: imageUrls, current: previewUrl });
} else if (file.type && file.type.includes("pdf")) {
common_vendor.index.downloadFile({
@@ -220,31 +260,34 @@
const uploadFile = (file, type) => {
return new Promise((resolve, reject) => {
const token = common_vendor.index.getStorageSync("token");
- let filePath = file.uploadPath || file.url || file.path;
+ const filePath = file.uploadPath || file.url || file.path;
if (!filePath || typeof filePath !== "string") {
reject(new Error("鏃犳晥鐨勬枃浠惰矾寰�"));
return;
}
- let uploadUrl = "/api/common/upload";
- uploadUrl = "https://opo.qduh.cn/common/upload";
+ const uploadUrl = `${userStore.baseUrlHt}/common/upload`;
common_vendor.index.uploadFile({
url: uploadUrl,
filePath,
name: "file",
- header: { "Authorization": `Bearer ${token}` },
+ header: {
+ Authorization: `Bearer ${token}`
+ },
success: (res) => {
if (res.statusCode === 200) {
try {
const data = JSON.parse(res.data);
- if (data.code === 200)
+ if (data.code === 200) {
resolve({ ...data, fileName: data.fileName });
- else
+ } else {
reject(new Error(data.msg || "涓婁紶澶辫触"));
+ }
} catch {
- reject(new Error("瑙f瀽鍝嶅簲澶辫触"));
+ reject(new Error("鍝嶅簲瑙f瀽澶辫触"));
}
- } else
+ } else {
reject(new Error(`涓婁紶澶辫触锛岀姸鎬佺爜: ${res.statusCode}`));
+ }
},
fail: reject
});
@@ -256,15 +299,21 @@
currentTab.value = "grade";
return;
}
- const totalPending = [...baseFiles.value, ...gradeFiles.value].filter((f) => !f.url || f.status === "pending").length;
+ const totalPending = [...baseFiles.value, ...gradeFiles.value].filter(
+ (f) => !f.url || f.status === "pending"
+ ).length;
if (totalPending === 0) {
common_vendor.index.showToast({ title: "娌℃湁寰呬笂浼犵殑鏂囦欢", icon: "none" });
return;
}
common_vendor.index.showLoading({ title: "涓婁紶涓�", mask: true });
try {
- const pendingBase = baseFiles.value.filter((f) => !f.url || f.status === "pending");
- const pendingGrade = gradeFiles.value.filter((f) => !f.url || f.status === "pending");
+ const pendingBase = baseFiles.value.filter(
+ (f) => !f.url || f.status === "pending"
+ );
+ const pendingGrade = gradeFiles.value.filter(
+ (f) => !f.url || f.status === "pending"
+ );
for (const file of pendingBase) {
try {
file.status = "uploading";
@@ -305,7 +354,7 @@
common_vendor.index.showToast({ title: "涓婁紶瀹屾垚", icon: "success" });
closePopup();
} catch (error) {
- common_vendor.index.__f__("error", "at components/attachment/index.vue:398", "涓婁紶鍑洪敊:", error);
+ common_vendor.index.__f__("error", "at components/attachment/index.vue:609", "涓婁紶鍑洪敊:", error);
common_vendor.index.showToast({ title: "涓婁紶鍑洪敊", icon: "none" });
} finally {
common_vendor.index.hideLoading();
--
Gitblit v1.9.3