fix(p93): 附件/图片回显 URL 用错挂载点——/static/* 404,应为 {ctx}/upload/*
build / build (push) Successful in 1m47s
build / build (push) Successful in 1m47s
- 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 端回显修复随下次部署生效。
This commit is contained in:
@@ -51,10 +51,12 @@ interface GroupView {
|
|||||||
|
|
||||||
const schemaFields = computed<DesignField[]>(() => flattenFields(props.groups));
|
const schemaFields = computed<DesignField[]>(() => 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[] {
|
function fileLinks(value: unknown): FileLink[] {
|
||||||
if (!isFileArray(value)) return [];
|
if (!isFileArray(value)) return [];
|
||||||
const prefix = `${conf.serviceHost || ""}/static/`;
|
const prefix = `${conf.serviceHost || ""}/upload/`;
|
||||||
return (value as FileValue[]).map((f) => ({
|
return (value as FileValue[]).map((f) => ({
|
||||||
name: String(f.fileName ?? f.key ?? ""),
|
name: String(f.fileName ?? f.key ?? ""),
|
||||||
url: prefix + String(f.key ?? "")
|
url: prefix + String(f.key ?? "")
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import type { FieldWidgetProps } from "../types";
|
|||||||
import type { FileValue } from "@/types/formSchema";
|
import type { FileValue } from "@/types/formSchema";
|
||||||
import { Upload } from "view-ui-plus";
|
import { Upload } from "view-ui-plus";
|
||||||
import { alovaInstance } from "@/utils/alova/alova-iview";
|
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<FieldWidgetProps & {
|
const props = withDefaults(defineProps<FieldWidgetProps & {
|
||||||
modelValue?: FileValue[];
|
modelValue?: FileValue[];
|
||||||
@@ -76,7 +80,9 @@ function handleRemove(index: number) {
|
|||||||
<div class="attach">
|
<div class="attach">
|
||||||
<div class="image-list">
|
<div class="image-list">
|
||||||
<div v-for="(item, idx) in fileList" :key="item.id" class="image-item">
|
<div v-for="(item, idx) in fileList" :key="item.id" class="image-item">
|
||||||
<img :src="`/static/${item.key}`" :alt="item.fileName" class="image-preview" />
|
<!-- P93:回显挂载点={serviceHost}/upload/{key}(160 实测 /static/form/** 404,
|
||||||
|
/static 是平台主题通道保留前缀;serviceHost 空时走同源相对,dev 需 vite /upload 代理) -->
|
||||||
|
<img :src="`${fileBase}/${item.key}`" :alt="item.fileName" class="image-preview" />
|
||||||
<div v-if="!readonly" class="image-remove" @click="handleRemove(idx)">×</div>
|
<div v-if="!readonly" class="image-remove" @click="handleRemove(idx)">×</div>
|
||||||
</div>
|
</div>
|
||||||
<Upload v-if="!readonly" :before-upload="beforeUpload" :handle-upload="handleUpload" :accept="accept"
|
<Upload v-if="!readonly" :before-upload="beforeUpload" :handle-upload="handleUpload" :accept="accept"
|
||||||
|
|||||||
@@ -99,6 +99,11 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|||||||
target: "http://localhost:8086",
|
target: "http://localhost:8086",
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
},
|
},
|
||||||
|
// 附件/图片回显同源代理(P93:URL={serviceHost}/upload/{key},dev 下 serviceHost 空)
|
||||||
|
"/upload": {
|
||||||
|
target: "http://localhost:8086",
|
||||||
|
changeOrigin: true,
|
||||||
|
},
|
||||||
// 主题通道本地联调:dev 下 loader 走同源相对,manifest/CSS 经此代理到中央通道。
|
// 主题通道本地联调:dev 下 loader 走同源相对,manifest/CSS 经此代理到中央通道。
|
||||||
// 联调本地通道源:YschTheme 侧 npm run serve:static(默认 9527),再用
|
// 联调本地通道源:YschTheme 侧 npm run serve:static(默认 9527),再用
|
||||||
// YH_THEME_PROXY_TARGET=http://localhost:9527 覆盖本 target
|
// YH_THEME_PROXY_TARGET=http://localhost:9527 覆盖本 target
|
||||||
|
|||||||
Reference in New Issue
Block a user