fix(android): 修复国产手机 WebView 中本地图片/视频选择无效的问题

- 将 .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 提示,避免静默失败
This commit is contained in:
JOJO 2026-06-07 16:56:55 +08:00
parent 5723da8eb1
commit 7c08031413
4 changed files with 25 additions and 3 deletions

View File

@ -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));

View File

@ -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 = '';
}

View File

@ -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 = '';
}

View File

@ -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 {