fix: 兼容性问题
This commit is contained in:
parent
67f3c0b70e
commit
5e4f9b1292
2
app.json
2
app.json
|
|
@ -21,7 +21,7 @@
|
|||
"edgeToEdgeEnabled": true,
|
||||
"predictiveBackGestureEnabled": false,
|
||||
"package": "com.anonymous.bwexpoappv3",
|
||||
"versionCode": 3
|
||||
"versionCode": 4
|
||||
},
|
||||
"web": {
|
||||
"output": "static",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ThemedView } from '@/components/themed-view';
|
||||
import { getTemplateGeneration } from '@/lib/api/template-runs';
|
||||
import * as Clipboard from 'expo-clipboard';
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { documentDirectory, downloadAsync } from 'expo-file-system/legacy';
|
||||
import * as MediaLibrary from 'expo-media-library';
|
||||
import { router, useLocalSearchParams } from 'expo-router';
|
||||
import { VideoView, useVideoPlayer } from 'expo-video';
|
||||
|
|
@ -85,6 +85,14 @@ function getMediaType(url: string): 'image' | 'video' | 'unknown' {
|
|||
return 'unknown';
|
||||
}
|
||||
|
||||
/**
|
||||
* 安全获取媒体类型,过滤掉 unknown
|
||||
*/
|
||||
function getSafeMediaType(url: string): 'image' | 'video' {
|
||||
const type = getMediaType(url);
|
||||
return type === 'unknown' ? 'image' : type;
|
||||
}
|
||||
|
||||
export default function ResultPage() {
|
||||
const { generationId } = useLocalSearchParams<{ generationId: string }>();
|
||||
const insets = useSafeAreaInsets();
|
||||
|
|
@ -194,11 +202,17 @@ export default function ResultPage() {
|
|||
try {
|
||||
// 生成临时文件名
|
||||
const filename = url.split('/').pop() || `download_${Date.now()}`;
|
||||
const fileUri = `${FileSystem.documentDirectory}${filename}`;
|
||||
|
||||
if (!documentDirectory) {
|
||||
console.error('Document directory not available');
|
||||
continue;
|
||||
}
|
||||
|
||||
const fileUri = `${documentDirectory}${filename}`;
|
||||
|
||||
// 下载文件到本地
|
||||
console.log('Downloading:', url, 'to', fileUri);
|
||||
const downloadResult = await FileSystem.downloadAsync(url, fileUri);
|
||||
const downloadResult = await downloadAsync(url, fileUri);
|
||||
|
||||
if (downloadResult.status === 200) {
|
||||
// 保存到相册
|
||||
|
|
@ -402,7 +416,7 @@ export default function ResultPage() {
|
|||
style={styles.expandButton}
|
||||
onPress={() =>
|
||||
openFullscreen(
|
||||
getMediaType(mediaUrls[currentMediaIndex]),
|
||||
getSafeMediaType(mediaUrls[currentMediaIndex]),
|
||||
mediaUrls[currentMediaIndex]
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue