upload-jh #7

Merged
txcjh merged 13 commits from upload-jh into upload 2025-07-17 15:55:28 +08:00
5 changed files with 45 additions and 14 deletions
Showing only changes of commit 49012df68e - Show all commits

View File

@ -49,7 +49,7 @@
"plugins": [
"expo-router",
"expo-secure-store", [
"expo-background-fetch",
"expo-background-task",
{
"minimumInterval": 15
}

View File

@ -101,7 +101,7 @@ export default function HomeScreen() {
isLoggedIn ? <MemoList /> :
<View className="flex-1 bg-bgPrimary px-[1rem] h-screen overflow-auto py-[2rem] " style={{ paddingTop: insets.top + 48 }}>
{/* 标题区域 */}
<View className="items-start mb-10 w-full px-5">
<View className="items-center mb-10 w-full px-5">
<Text className="text-white text-3xl font-bold mb-3 text-left">
{t('auth.welcomeAwaken.awaken', { ns: 'login' })}
{"\n"}

View File

@ -1,5 +1,35 @@
/**
* @file backgroundUploader.ts
* @description
* Expo React Native
*
* 使
*
* @features
* - 后台任务处理: 利用 `expo-task-manager` `expo-background-fetch`
* 15使退
* - 媒体文件检索: 使用 `expo-media-library` 访
* EXIF GPS位置
* - :
* - 图片压缩: 通过 `expo-image-manipulator`
* - HEIC 格式转换: 自动将苹果设备上常见的 HEIC/HEIF JPEG
* - 视频缩略图: 提取视频的第一帧作为预览图进行上传
* - 高效并发上传: 使用 `p-limit` 10
* - 手动触发机制: 提供 `triggerManualUpload`
*
* @workflow
* 1. 触发: 上传流程可以通过两种方式启动
* 2. 查询媒体文件: 根据指定的日期范围
* 3. ():
* a. 权限检查: 确保应用拥有访问媒体库的权限
* b. 上传原始文件: 首先上传完整分辨率的原始文件 HEIC URL
* XMLHttpRequest
* c. 上传派生文件: 接着
* d. 关联素材: 当原始文件和派生文件/API将两者进行关联
* 4. 完成: 所有文件处理完毕后
*/
import { fetchApi } from '@/lib/server-api-util';
import * as BackgroundFetch from 'expo-background-fetch';
import * as BackgroundFetch from 'expo-background-task';
import * as FileSystem from 'expo-file-system';
import * as ImageManipulator from 'expo-image-manipulator';
import * as MediaLibrary from 'expo-media-library';
@ -8,6 +38,7 @@ import pLimit from 'p-limit';
import { Alert } from 'react-native';
import { transformData } from '../utils/objectFlat';
type ExtendedAsset = MediaLibrary.Asset & {
exif?: Record<string, any>;
};
@ -524,7 +555,7 @@ TaskManager.defineTask(BACKGROUND_UPLOAD_TASK, async () => {
if (media.length === 0) {
console.log('No media files to upload');
return BackgroundFetch.BackgroundFetchResult.NoData;
return BackgroundFetch.BackgroundTaskResult.Success;
}
// 处理媒体文件上传
@ -534,11 +565,11 @@ TaskManager.defineTask(BACKGROUND_UPLOAD_TASK, async () => {
console.log(`Background upload completed. Success: ${successCount}/${results.length}`);
return successCount > 0
? BackgroundFetch.BackgroundFetchResult.NewData
: BackgroundFetch.BackgroundFetchResult.NoData;
? BackgroundFetch.BackgroundTaskResult.Success
: BackgroundFetch.BackgroundTaskResult.Failed;
} catch (error) {
console.error('Background task error:', error);
return BackgroundFetch.BackgroundFetchResult.Failed;
return BackgroundFetch.BackgroundTaskResult.Failed;
}
});

10
package-lock.json generated
View File

@ -16,7 +16,7 @@
"@types/react-redux": "^7.1.34",
"expo": "~53.0.12",
"expo-audio": "~0.4.7",
"expo-background-fetch": "^13.1.6",
"expo-background-task": "^0.2.8",
"expo-blur": "~14.1.5",
"expo-clipboard": "~7.1.5",
"expo-constants": "~17.1.6",
@ -7801,10 +7801,10 @@
"react-native": "*"
}
},
"node_modules/expo-background-fetch": {
"version": "13.1.6",
"resolved": "https://registry.npmjs.org/expo-background-fetch/-/expo-background-fetch-13.1.6.tgz",
"integrity": "sha512-hl4kR32DaxoHFYqNsILLZG2mWssCkUb4wnEAHtDGmpxUP4SCnJILcAn99J6AGDFUw5lF6FXNZZCXNfcrFioO4Q==",
"node_modules/expo-background-task": {
"version": "0.2.8",
"resolved": "http://192.168.31.115:8081/repository/npm/expo-background-task/-/expo-background-task-0.2.8.tgz",
"integrity": "sha512-dePyskpmyDZeOtbr9vWFh+Nrse0TvF6YitJqnKcd+3P7pDMiDr1V2aT6zHdNOc5iV9vPaDJoH/zdmlarp1uHMQ==",
"license": "MIT",
"dependencies": {
"expo-task-manager": "~13.1.6"

View File

@ -21,7 +21,7 @@
"@types/react-redux": "^7.1.34",
"expo": "~53.0.12",
"expo-audio": "~0.4.7",
"expo-background-fetch": "^13.1.6",
"expo-background-task": "^0.2.8",
"expo-blur": "~14.1.5",
"expo-constants": "~17.1.6",
"expo-dev-client": "~5.2.1",
@ -92,4 +92,4 @@
}
}
}
}
}