fix(platform): improve web compatibility and optimize module loading
Refactor core services and components to prevent runtime errors on web platforms and optimize build environment. - Update `Dockerfile.web` to use Node 25 for the build stage. - Implement lazy loading for `expo-media-library` and `expo-file-system` in `ImageGallery` to prevent crashes on web where these native modules are unavailable. - Refactor `CallKeepServiceImpl` to use dynamic imports for `expo-callkit-telecom`, ensuring the service remains compatible with web environments.
This commit is contained in:
@@ -30,8 +30,6 @@ import Animated, {
|
||||
} from 'react-native-reanimated';
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import { MaterialCommunityIcons } from '@expo/vector-icons';
|
||||
import * as MediaLibrary from 'expo-media-library';
|
||||
import { File, Paths } from 'expo-file-system';
|
||||
import { spacing, borderRadius, fontSizes } from '../../theme';
|
||||
import { blurActiveElement } from '../../infrastructure/platform';
|
||||
|
||||
@@ -203,7 +201,10 @@ export const ImageGallery: React.FC<ImageGalleryProps> = ({
|
||||
|
||||
// 保存图片到本地相册
|
||||
const handleSaveImage = useCallback(async () => {
|
||||
if (!currentImage || saving) return;
|
||||
if (!currentImage || saving || Platform.OS === 'web') return;
|
||||
|
||||
const MediaLibrary = require('expo-media-library') as typeof import('expo-media-library');
|
||||
const { File, Paths } = require('expo-file-system') as typeof import('expo-file-system');
|
||||
|
||||
const { status } = await MediaLibrary.requestPermissionsAsync();
|
||||
if (status !== 'granted') {
|
||||
|
||||
Reference in New Issue
Block a user