fix headers
This commit is contained in:
2025-10-24 19:49:50 +08:00
parent 009d21e42d
commit bfd65d8b82

View File

@@ -10,8 +10,11 @@
<div v-if="validated && !uploading" class="fab-select"> <div v-if="validated && !uploading" class="fab-select">
<button @click="autoOpenFileInput" class="select-trigger" aria-label="Select Photos">Add</button> <button @click="autoOpenFileInput" class="select-trigger" aria-label="Select Photos">Add</button>
</div> </div>
<input type="file" @change="onFileChange" multiple accept="image/*,.png,.jpg,.jpeg,.gif,.bmp,.webp,.heic,.heif,.tif,.tiff" ref="fileInput" style="display: none" /> <input type="file" @change="onFileChange" multiple
<p class="status note" v-if="nonPreviewCount > 0">Selected {{ nonPreviewCount }} images are not previewable (still uploadable).</p> accept="image/*,.png,.jpg,.jpeg,.gif,.bmp,.webp,.heic,.heif,.tif,.tiff" ref="fileInput"
style="display: none"/>
<p class="status note" v-if="nonPreviewCount > 0">Selected {{ nonPreviewCount }} images are not previewable (still
uploadable).</p>
<div v-if="loading" class="screen-mask" role="status" aria-live="polite"> <div v-if="loading" class="screen-mask" role="status" aria-live="polite">
<div class="mask-content">Loading...</div> <div class="mask-content">Loading...</div>
</div> </div>
@@ -157,8 +160,16 @@ export default {
const cleanBase = (baseUrl || '').replace(/\/+$/, ''); const cleanBase = (baseUrl || '').replace(/\/+$/, '');
const endpoint = `${cleanBase}/kiosk-upload/upload`; const endpoint = `${cleanBase}/kiosk-upload/upload`;
const headers = {
'tenant-id': '000000'
// 注意:不要手动设置 'Content-Type',因为使用 FormData 时浏览器会自动设置正确的 boundary
};
fetch(endpoint, { method: 'POST', body: formData }) fetch(endpoint, {
method: 'POST',
body: formData,
headers: headers
})
.then((res) => { .then((res) => {
if (!res.ok) throw new Error(`HTTP ${res.status}`); if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json().catch(() => ({})); return res.json().catch(() => ({}));
@@ -351,6 +362,7 @@ export default {
border: none; border: none;
border-radius: 999px; border-radius: 999px;
} }
.error-toast { .error-toast {
position: fixed; position: fixed;
top: 16px; top: 16px;
@@ -370,5 +382,9 @@ export default {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.error-toast span { margin-left: 4px; opacity: 0.9; }
.error-toast span {
margin-left: 4px;
opacity: 0.9;
}
</style> </style>