|
@@ -148,7 +148,7 @@ import { ElLoading, ElMessage } from "element-plus";
|
|
|
import { getStoreHeadImg, saveStoreHeadImg } from "@/api/modules/storeDecoration";
|
|
import { getStoreHeadImg, saveStoreHeadImg } from "@/api/modules/storeDecoration";
|
|
|
import { getDetail } from "@/api/modules/homeEntry";
|
|
import { getDetail } from "@/api/modules/homeEntry";
|
|
|
import { localGet } from "@/utils";
|
|
import { localGet } from "@/utils";
|
|
|
-import { uploadFilesToOss } from "@/api/upload.js";
|
|
|
|
|
|
|
+import { uploadFilesToOss, isUploadUserCancelledError, isUploadApiErrorAlreadyMessaged } from "@/api/upload.js";
|
|
|
import { getCoverAuditData } from "@/api/modules/coverAudit";
|
|
import { getCoverAuditData } from "@/api/modules/coverAudit";
|
|
|
import previewDemoImg from "@/assets/images/uDianShiImg4.svg";
|
|
import previewDemoImg from "@/assets/images/uDianShiImg4.svg";
|
|
|
|
|
|
|
@@ -335,9 +335,9 @@ function onCoverVideoPreviewClosed() {
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 与 App `checkImageCompliance` 中封面分支一致:`getCoverAuditData({ url })`,
|
|
* 与 App `checkImageCompliance` 中封面分支一致:`getCoverAuditData({ url })`,
|
|
|
- * code 成功且非 `overall_match === false` 视为通过。
|
|
|
|
|
|
|
+ * code 成功且非 `overall_match === false` 视为通过。仅在页面层弹一次 toast,此处不调用 ElMessage。
|
|
|
*/
|
|
*/
|
|
|
-async function validateUploadedCover(url: string): Promise<boolean> {
|
|
|
|
|
|
|
+async function runCoverComplianceAudit(url: string): Promise<{ ok: true } | { ok: false; message: string }> {
|
|
|
try {
|
|
try {
|
|
|
const res = (await getCoverAuditData({ url })) as {
|
|
const res = (await getCoverAuditData({ url })) as {
|
|
|
code?: number | string;
|
|
code?: number | string;
|
|
@@ -348,22 +348,19 @@ async function validateUploadedCover(url: string): Promise<boolean> {
|
|
|
const c = res.code;
|
|
const c = res.code;
|
|
|
const okCode = c === 200 || c === 0 || c === "200" || c === "0";
|
|
const okCode = c === 200 || c === 0 || c === "200" || c === "0";
|
|
|
if (!okCode) {
|
|
if (!okCode) {
|
|
|
- ElMessage.error(String(res.msg || res.message || "素材合规性检查失败"));
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ return { ok: false, message: String(res.msg || res.message || "素材合规性检查失败") };
|
|
|
}
|
|
}
|
|
|
const d = res.data;
|
|
const d = res.data;
|
|
|
if (d && d.overall_match === false) {
|
|
if (d && d.overall_match === false) {
|
|
|
- ElMessage.error(String(d.match_reason || "素材不符合规范,请重新上传"));
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ return { ok: false, message: String(d.match_reason || "素材不符合规范,请重新上传") };
|
|
|
}
|
|
}
|
|
|
- return true;
|
|
|
|
|
|
|
+ return { ok: true };
|
|
|
} catch (e: unknown) {
|
|
} catch (e: unknown) {
|
|
|
const msg =
|
|
const msg =
|
|
|
typeof e === "object" && e && "message" in e && typeof (e as { message?: unknown }).message === "string"
|
|
typeof e === "object" && e && "message" in e && typeof (e as { message?: unknown }).message === "string"
|
|
|
? String((e as Error).message)
|
|
? String((e as Error).message)
|
|
|
: "素材合规性检查失败,请重试";
|
|
: "素材合规性检查失败,请重试";
|
|
|
- ElMessage.error(msg);
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ return { ok: false, message: msg };
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -403,8 +400,11 @@ async function ingestPickedFile(file: File): Promise<boolean> {
|
|
|
background: "rgba(0, 0, 0, 0.35)"
|
|
background: "rgba(0, 0, 0, 0.35)"
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- const pass = await validateUploadedCover(url);
|
|
|
|
|
- if (!pass) return false;
|
|
|
|
|
|
|
+ const audit = await runCoverComplianceAudit(url);
|
|
|
|
|
+ if (!audit.ok) {
|
|
|
|
|
+ ElMessage.error(audit.message);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
let posterUrl = "";
|
|
let posterUrl = "";
|
|
|
if (isVideo) {
|
|
if (isVideo) {
|
|
@@ -420,6 +420,12 @@ async function ingestPickedFile(file: File): Promise<boolean> {
|
|
|
ElMessage.success("已上传并通过合规校验,请点击保存写入门店");
|
|
ElMessage.success("已上传并通过合规校验,请点击保存写入门店");
|
|
|
return true;
|
|
return true;
|
|
|
} catch (e: unknown) {
|
|
} catch (e: unknown) {
|
|
|
|
|
+ if (isUploadUserCancelledError(e)) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (isUploadApiErrorAlreadyMessaged(e)) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
const msg =
|
|
const msg =
|
|
|
typeof e === "object" && e && "message" in e && typeof (e as { message?: unknown }).message === "string"
|
|
typeof e === "object" && e && "message" in e && typeof (e as { message?: unknown }).message === "string"
|
|
|
? String((e as Error).message)
|
|
? String((e as Error).message)
|