fix: error
This commit is contained in:
@@ -9,11 +9,11 @@ import {
|
||||
} from 'react-native';
|
||||
import { ThemedView } from '@/components/themed-view';
|
||||
import { ThemedText } from '@/components/themed-text';
|
||||
import { TemplateGeneration, GenerateType } from '@/lib/types/template-run';
|
||||
import { TemplateGeneration } from '@/lib/types/template-run';
|
||||
import { Image } from 'expo-image';
|
||||
import { VideoPlayer } from '@/components/video/video-player';
|
||||
import { useState } from 'react';
|
||||
import * as FileSystem from 'expo-file-system';
|
||||
import { cacheDirectory, documentDirectory, downloadAsync } from 'expo-file-system';
|
||||
import * as MediaLibrary from 'expo-media-library';
|
||||
|
||||
interface ResultDisplayProps {
|
||||
@@ -102,9 +102,14 @@ export function ResultDisplay({
|
||||
}
|
||||
|
||||
// 下载文件
|
||||
const downloadResult = await FileSystem.downloadAsync(
|
||||
const targetDirectory = documentDirectory ?? cacheDirectory;
|
||||
if (!targetDirectory) {
|
||||
throw new Error('无法获取可写入的目录');
|
||||
}
|
||||
|
||||
const downloadResult = await downloadAsync(
|
||||
url,
|
||||
FileSystem.documentDirectory + `generated_${Date.now()}_${index}.${getFileExtension(url)}`
|
||||
`${targetDirectory}generated_${Date.now()}_${index}.${getFileExtension(url)}`
|
||||
);
|
||||
|
||||
// 保存到媒体库
|
||||
@@ -218,9 +223,7 @@ export function ResultDisplay({
|
||||
return (
|
||||
<View key={index} style={styles.textContainer}>
|
||||
<ThemedView style={styles.textBox}>
|
||||
<ThemedText style={styles.textContent}>
|
||||
{url} // 这里假设URL包含文本内容,实际可能需要额外处理
|
||||
</ThemedText>
|
||||
<ThemedText style={styles.textContent}>{url}</ThemedText>
|
||||
</ThemedView>
|
||||
|
||||
<View style={styles.textActions}>
|
||||
@@ -378,7 +381,7 @@ const styles = StyleSheet.create({
|
||||
borderRadius: 12,
|
||||
backgroundColor: '#f0f0f0',
|
||||
},
|
||||
mediaActions: {
|
||||
mediaActions: {
|
||||
flexDirection: 'row',
|
||||
gap: 12,
|
||||
marginTop: 12,
|
||||
@@ -446,4 +449,4 @@ const styles = StyleSheet.create({
|
||||
fontWeight: '600',
|
||||
color: '#4ECDC4',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user