From e5555efb7939b834a5030d94050a458b688f04e9 Mon Sep 17 00:00:00 2001 From: chenxing Date: Fri, 16 Oct 2026 00:04:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(p93):=20=E9=99=84=E4=BB=B6/=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E5=9B=9E=E6=98=BE=20URL=20=E7=94=A8=E9=94=99=E6=8C=82?= =?UTF-8?q?=E8=BD=BD=E7=82=B9=E2=80=94=E2=80=94/static/*=20404=EF=BC=8C?= =?UTF-8?q?=E5=BA=94=E4=B8=BA=20{ctx}/upload/*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 160 演练实测(honor_student 证书图片上传后):/static/form/** 404(146B)、 /form-center/upload/form/** 200 且字节数一致——/static 是平台主题通道保留前缀, 附件实际挂载在 {ctx}/upload/(Caddy 静态路由 + 后端 upload 映射)。 - 修复两处 URL 构建:fields/image/pc.vue 回显 img src → `${serviceHost}/upload/{key}`; AnswerValueView.vue fileLinks 前缀 → `${serviceHost}/upload/`(serviceHost 空=dev 同源相对,vite 代理补 /upload → localhost:8086)。 - 附带发现记 P92:字段级 maxSize 仅前端 beforeUpload 拦截,/api/form/upload 对 5.7MB 文件返回成功(上传端点不感知表单 schema 的字段约束)——裁决口径见报告。 验证:vue-tsc --noEmit 干净;vite build 通过。160 端回显修复随下次部署生效。 --- src/components/answer/AnswerValueView.vue | 6 ++++-- src/components/fields/image/pc.vue | 8 +++++++- vite.config.ts | 5 +++++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/answer/AnswerValueView.vue b/src/components/answer/AnswerValueView.vue index f2d3ddf..6b5af66 100644 --- a/src/components/answer/AnswerValueView.vue +++ b/src/components/answer/AnswerValueView.vue @@ -51,10 +51,12 @@ interface GroupView { const schemaFields = computed(() => flattenFields(props.groups)); -/** 附件地址由渲染期拼(值里只存相对 key,绝对 URL 不进答卷——契约 §3、方案 §4.3②) */ +/** 附件地址由渲染期拼(值里只存相对 key,绝对 URL 不进答卷——契约 §3、方案 §4.3②)。 + * P93:挂载点是 {ctx}/upload/*(Caddy 静态路由 + 后端 upload 映射),不是 /static/* + * ——/static 是平台主题通道的保留前缀,160 实测 /static/form/** 404、/{ctx}/upload/** 200。 */ function fileLinks(value: unknown): FileLink[] { if (!isFileArray(value)) return []; - const prefix = `${conf.serviceHost || ""}/static/`; + const prefix = `${conf.serviceHost || ""}/upload/`; return (value as FileValue[]).map((f) => ({ name: String(f.fileName ?? f.key ?? ""), url: prefix + String(f.key ?? "") diff --git a/src/components/fields/image/pc.vue b/src/components/fields/image/pc.vue index 27f3500..9032695 100644 --- a/src/components/fields/image/pc.vue +++ b/src/components/fields/image/pc.vue @@ -8,6 +8,10 @@ import type { FieldWidgetProps } from "../types"; import type { FileValue } from "@/types/formSchema"; import { Upload } from "view-ui-plus"; import { alovaInstance } from "@/utils/alova/alova-iview"; +import conf from "@/assets/config/host.config"; + +/** 附件回显基址:{ctx}/upload/(P93);serviceHost 空(dev 同源)时走 /upload 相对路径 */ +const fileBase = `${conf.serviceHost || ""}/upload`; const props = withDefaults(defineProps
- + +
×
{ target: "http://localhost:8086", changeOrigin: true, }, + // 附件/图片回显同源代理(P93:URL={serviceHost}/upload/{key},dev 下 serviceHost 空) + "/upload": { + target: "http://localhost:8086", + changeOrigin: true, + }, // 主题通道本地联调:dev 下 loader 走同源相对,manifest/CSS 经此代理到中央通道。 // 联调本地通道源:YschTheme 侧 npm run serve:static(默认 9527),再用 // YH_THEME_PROXY_TARGET=http://localhost:9527 覆盖本 target