接入移动壳图片导入能力

Expo 壳通过系统相册选择器实现 file.importImage

限制导入图片 MIME 与大小并避免暴露设备本地 URI

H5 facade 将用户取消导入归为无选择回退

更新移动壳依赖、配置校验、测试和架构文档
This commit is contained in:
2026-06-18 03:04:21 +08:00
parent 199f02cf9f
commit 14f838c414
12 changed files with 348 additions and 7 deletions

View File

@@ -129,18 +129,46 @@ for (const snippet of [
}
}
for (const dependency of ['expo-file-system', 'expo-network', 'expo-sharing']) {
for (const dependency of [
'expo-file-system',
'expo-image-picker',
'expo-network',
'expo-sharing',
]) {
if (!packageConfig.dependencies?.[dependency]) {
throw new Error(`mobile shell package missing ${dependency}`);
}
}
const imagePickerPlugin = appConfig.plugins?.find((plugin) =>
Array.isArray(plugin) ? plugin[0] === 'expo-image-picker' : plugin === 'expo-image-picker',
);
if (!imagePickerPlugin) {
throw new Error('mobile shell image picker plugin is missing');
}
if (Array.isArray(imagePickerPlugin)) {
const pluginOptions = imagePickerPlugin[1] ?? {};
if (typeof pluginOptions.photosPermission !== 'string') {
throw new Error('mobile shell image picker photo permission text is missing');
}
if (
pluginOptions.cameraPermission !== false ||
pluginOptions.microphonePermission !== false
) {
throw new Error('mobile shell image picker must not request camera or microphone');
}
}
for (const snippet of [
'file.exportText',
'file.exportImage',
'file.importImage',
'network.status',
'getMobileNetworkStatus',
'Sharing.shareAsync',
'ImagePicker.launchImageLibraryAsync',
'ImagePicker.requestMediaLibraryPermissionsAsync',
'normalizeHostBridgeExportFileName',
'base64Data',
]) {
@@ -172,6 +200,7 @@ for (const capability of [
'clipboard.writeText',
'file.exportText',
'file.exportImage',
'file.importImage',
'haptics.impact',
]) {
if (!mobileCapabilitySet.has(capability)) {