|
|
@@ -129,12 +129,11 @@
|
|
|
<script setup lang="ts">
|
|
|
import { ref, computed, onMounted } from "vue";
|
|
|
import { ArrowRight, Plus, InfoFilled, View, Delete } from "@element-plus/icons-vue";
|
|
|
-import { ElLoading, ElMessage } from "element-plus";
|
|
|
+import { ElMessage } from "element-plus";
|
|
|
import { getStoreHeadImg, saveStoreHeadImg } from "@/api/modules/storeDecoration";
|
|
|
import { getDetail } from "@/api/modules/homeEntry";
|
|
|
import { localGet } from "@/utils";
|
|
|
import { uploadFilesToOss, isUploadUserCancelledError, isUploadApiErrorAlreadyMessaged } from "@/api/upload.js";
|
|
|
-import { getCoverAuditData } from "@/api/modules/coverAudit";
|
|
|
import previewDemoImg from "@/assets/images/uDianShiImg4.svg";
|
|
|
import PcImagePreviewViewer from "@/components/pcMediaPreview/PcImagePreviewViewer.vue";
|
|
|
import PcVideoPreviewDialog from "@/components/pcMediaPreview/PcVideoPreviewDialog.vue";
|
|
|
@@ -320,37 +319,6 @@ function onCoverVideoPreviewClosed() {
|
|
|
previewTarget.value = null;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 与 App `checkImageCompliance` 中封面分支一致:`getCoverAuditData({ url })`,
|
|
|
- * code 成功且非 `overall_match === false` 视为通过。仅在页面层弹一次 toast,此处不调用 ElMessage。
|
|
|
- */
|
|
|
-async function runCoverComplianceAudit(url: string): Promise<{ ok: true } | { ok: false; message: string }> {
|
|
|
- try {
|
|
|
- const res = (await getCoverAuditData({ url })) as {
|
|
|
- code?: number | string;
|
|
|
- msg?: string;
|
|
|
- message?: string;
|
|
|
- data?: { overall_match?: boolean; match_reason?: string };
|
|
|
- };
|
|
|
- const c = res.code;
|
|
|
- const okCode = c === 200 || c === 0 || c === "200" || c === "0";
|
|
|
- if (!okCode) {
|
|
|
- return { ok: false, message: String(res.msg || res.message || "素材合规性检查失败") };
|
|
|
- }
|
|
|
- const d = res.data;
|
|
|
- if (d && d.overall_match === false) {
|
|
|
- return { ok: false, message: String(d.match_reason || "素材不符合规范,请重新上传") };
|
|
|
- }
|
|
|
- return { ok: true };
|
|
|
- } catch (e: unknown) {
|
|
|
- const msg =
|
|
|
- typeof e === "object" && e && "message" in e && typeof (e as { message?: unknown }).message === "string"
|
|
|
- ? String((e as Error).message)
|
|
|
- : "素材合规性检查失败,请重试";
|
|
|
- return { ok: false, message: msg };
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
async function ingestPickedFile(file: File): Promise<boolean> {
|
|
|
const name = String(file.name || "").toLowerCase();
|
|
|
const type = String(file.type || "");
|
|
|
@@ -372,27 +340,14 @@ async function ingestPickedFile(file: File): Promise<boolean> {
|
|
|
}
|
|
|
|
|
|
uploading.value = true;
|
|
|
- let auditLoading;
|
|
|
try {
|
|
|
const urls = await uploadFilesToOss([file], isVideo ? "video" : "image", {
|
|
|
- /** 保留全局 PopupLoading 进度;上传完成不 toast,审核通过后再提示 */
|
|
|
+ /** 保留全局 PopupLoading 进度;上传完成不 toast,由本页统一提示(上传服务已含合规校验) */
|
|
|
uploadSuccessMessage: null
|
|
|
});
|
|
|
const url = urls[0];
|
|
|
if (!url) throw new Error("上传成功但未返回地址");
|
|
|
|
|
|
- auditLoading = ElLoading.service({
|
|
|
- lock: true,
|
|
|
- text: "素材合规校验中…",
|
|
|
- background: "rgba(0, 0, 0, 0.35)"
|
|
|
- });
|
|
|
-
|
|
|
- const audit = await runCoverComplianceAudit(url);
|
|
|
- if (!audit.ok) {
|
|
|
- ElMessage.error(audit.message);
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
let posterUrl = "";
|
|
|
if (isVideo) {
|
|
|
posterUrl = tryOssVideoSnapshotCoverUrl(url);
|
|
|
@@ -404,7 +359,7 @@ async function ingestPickedFile(file: File): Promise<boolean> {
|
|
|
isVideo,
|
|
|
...(posterUrl ? { posterUrl } : {})
|
|
|
};
|
|
|
- ElMessage.success("已上传并通过合规校验,请点击保存写入门店");
|
|
|
+ ElMessage.success("上传成功");
|
|
|
return true;
|
|
|
} catch (e: unknown) {
|
|
|
if (isUploadUserCancelledError(e)) {
|
|
|
@@ -420,7 +375,6 @@ async function ingestPickedFile(file: File): Promise<boolean> {
|
|
|
ElMessage.error(msg);
|
|
|
return false;
|
|
|
} finally {
|
|
|
- auditLoading?.close();
|
|
|
uploading.value = false;
|
|
|
}
|
|
|
}
|