From 7c08031413e54376665257402ea9c04ca414543e Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Sun, 7 Jun 2026 16:56:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(android):=20=E4=BF=AE=E5=A4=8D=E5=9B=BD?= =?UTF-8?q?=E4=BA=A7=E6=89=8B=E6=9C=BA=20WebView=20=E4=B8=AD=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E7=89=87/=E8=A7=86=E9=A2=91=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=97=A0=E6=95=88=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 .file-input-hidden 从 display:none 改为 opacity:0 + position:absolute 国产手机(华为/小米/OPPO/vivo)WebView 对 display:none 的 input[type=file] 选择后不会填充 files 属性,导致 change 事件触发但 files 为空 - 在 ImagePicker/VideoPicker 的 change 事件中增加空文件警告日志 - 在 upload.ts handleLocalImageFiles/handleLocalVideoFiles 中增加空文件 时的 Toast 提示,避免静默失败 --- static/src/app/methods/upload.ts | 10 ++++++++++ static/src/components/overlay/ImagePicker.vue | 6 +++++- static/src/components/overlay/VideoPicker.vue | 6 +++++- static/src/styles/components/input/_composer.scss | 6 +++++- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/static/src/app/methods/upload.ts b/static/src/app/methods/upload.ts index ba548862..a08f4fb2 100644 --- a/static/src/app/methods/upload.ts +++ b/static/src/app/methods/upload.ts @@ -78,6 +78,11 @@ export const uploadMethods = { } const list = this.normalizeLocalFiles(files); if (!list.length) { + this.uiPushToast({ + title: '未获取到文件', + message: '系统未返回有效的文件内容,请重试', + type: 'warning' + }); return; } const existingCount = Array.isArray(this.selectedImages) ? this.selectedImages.length : 0; @@ -139,6 +144,11 @@ export const uploadMethods = { } const list = this.normalizeLocalFiles(files); if (!list.length) { + this.uiPushToast({ + title: '未获取到文件', + message: '系统未返回有效的文件内容,请重试', + type: 'warning' + }); return; } const valid = list.filter((file) => this.isVideoFile(file)); diff --git a/static/src/components/overlay/ImagePicker.vue b/static/src/components/overlay/ImagePicker.vue index f58d74f5..59520b52 100644 --- a/static/src/components/overlay/ImagePicker.vue +++ b/static/src/components/overlay/ImagePicker.vue @@ -117,7 +117,11 @@ const triggerLocal = () => { const onLocalChange = (event: Event) => { const target = event.target as HTMLInputElement; - emit('local-files', target?.files || null); + const files = target?.files || null; + if (!files || files.length === 0) { + console.warn('[ImagePicker] change fired but files empty — likely WebView compat issue'); + } + emit('local-files', files); if (target) { target.value = ''; } diff --git a/static/src/components/overlay/VideoPicker.vue b/static/src/components/overlay/VideoPicker.vue index 2626320b..1013c0c1 100644 --- a/static/src/components/overlay/VideoPicker.vue +++ b/static/src/components/overlay/VideoPicker.vue @@ -119,7 +119,11 @@ const triggerLocal = () => { const onLocalChange = (event: Event) => { const target = event.target as HTMLInputElement; - emit('local-files', target?.files || null); + const files = target?.files || null; + if (!files || files.length === 0) { + console.warn('[VideoPicker] change fired but files empty — likely WebView compat issue'); + } + emit('local-files', files); if (target) { target.value = ''; } diff --git a/static/src/styles/components/input/_composer.scss b/static/src/styles/components/input/_composer.scss index 7d2cb6fc..b5e98e32 100644 --- a/static/src/styles/components/input/_composer.scss +++ b/static/src/styles/components/input/_composer.scss @@ -805,7 +805,11 @@ body[data-theme='light'] { } .file-input-hidden { - display: none; + position: absolute; + opacity: 0; + width: 0; + height: 0; + pointer-events: none; } .quick-menu {