liuxiaole 1 nedēļu atpakaļ
vecāks
revīzija
20070f23a7

+ 108 - 0
src/api/modules/aiImageUpload.ts

@@ -280,6 +280,112 @@ export async function moderateImage(params: ModerateImageParams = {}): Promise<a
   return body;
 }
 
+export interface ModerateVideoParams {
+  /** 本地视频文件(Web);与 uni 的 filePath 二选一或同时有远端字段 */
+  file?: File | null;
+  filePath?: string;
+  path?: string;
+  /** 服务端视频地址,无 Tus 时可传空字符串 */
+  video_path?: string;
+  /** 标题/简介等 */
+  text?: string;
+  /** 远程 http(s) 视频地址 */
+  video_url?: string;
+}
+
+/**
+ * 上传视频并进入审核:POST `/api/v1/video/submit`,multipart/form-data(与 Apifox 一致)
+ * 字段:`file`(可选,二进制)+ `video_path` / `video_url` / `text`(可选)
+ * 服务基址:`BASE_AI_MODERATE_URL`(默认 https://verify.ailien.shop:8444)
+ */
+export async function moderateVideo(params: ModerateVideoParams = {}): Promise<any> {
+  const fd = new FormData();
+  fd.append("video_path", String(params.video_path ?? ""));
+  fd.append("text", String(params.text ?? ""));
+  fd.append("video_url", String(params.video_url ?? ""));
+
+  const file = params.file ?? null;
+  if (file) {
+    fd.append("file", file, file.name);
+  }
+
+  const res = await fetch(`${BASE_AI_MODERATE_URL}/api/v1/video/submit`, {
+    method: "POST",
+    headers: {
+      Authorization: authHeader()
+    },
+    body: fd
+  });
+
+  let body: any = null;
+  const ct = res.headers.get("content-type") || "";
+  if (ct.includes("application/json")) {
+    try {
+      body = await res.json();
+    } catch {
+      body = null;
+    }
+  } else {
+    const t = await res.text();
+    try {
+      body = t ? JSON.parse(t) : null;
+    } catch {
+      body = { raw: t };
+    }
+  }
+
+  if (res.status < 200 || res.status >= 300) {
+    throw new Error(`视频审核提交失败(${res.status})`);
+  }
+  if (body && typeof body === "object" && body.code !== undefined && body.code !== 200 && body.code !== 0) {
+    throw new Error(body.msg || body.message || "视频审核提交失败");
+  }
+  return body;
+}
+
+/**
+ * 查询视频异步审核结果:GET `/api/v1/video/status/{task_id}`
+ * @param data.task_id 或传入字符串即 task_id
+ */
+export async function getVideoModerateResult(data: { task_id?: string } | string): Promise<any> {
+  const taskId = typeof data === "string" ? data : String(data?.task_id ?? "").trim();
+  if (!taskId) {
+    throw new Error("缺少 task_id");
+  }
+
+  const res = await fetch(`${BASE_AI_MODERATE_URL}/api/v1/video/status/${encodeURIComponent(taskId)}`, {
+    method: "GET",
+    headers: {
+      Authorization: authHeader()
+    }
+  });
+
+  let body: any = null;
+  const ct = res.headers.get("content-type") || "";
+  if (ct.includes("application/json")) {
+    try {
+      body = await res.json();
+    } catch {
+      body = null;
+    }
+  } else {
+    const t = await res.text();
+    try {
+      body = t ? JSON.parse(t) : null;
+    } catch {
+      body = { raw: t };
+    }
+  }
+
+  if (res.status < 200 || res.status >= 300) {
+    throw new Error(`查询视频审核状态失败(${res.status})`);
+  }
+  if (body && typeof body === "object" && body.code !== undefined && body.code !== 200 && body.code !== 0) {
+    throw new Error(body.msg || body.message || "查询视频审核状态失败");
+  }
+  return body;
+}
+
 export interface UploadFileViaAiOptions {
   /** 0~100 */
   onProgress?: (progress: number) => void;
@@ -419,6 +525,8 @@ export const aiImageApi = {
   deleteUploadSession,
   finalizeUploadSession,
   moderateImage,
+  moderateVideo,
+  getVideoModerateResult,
   uploadFileViaAi,
   uploadFilesViaAi
 };

+ 0 - 1
src/views/storeDecoration/businessHours/index.vue

@@ -232,7 +232,6 @@ function getListTitle(item: NormalHoursItem | SpecialHoursItem, type: 1 | 2) {
   if (type === 1) {
     const n = item as NormalHoursItem;
     const sorted = [...n.days].sort((a, b) => a - b);
-    if (sorted.length === 7) return "周一至周日";
     return sorted
       .map(d => weekDays.find(w => w.value === d)?.label)
       .filter(Boolean)