diff --git a/entry/src/main/ets/pages/ResumableFileTransfer.ets b/entry/src/main/ets/pages/ResumableFileTransfer.ets index 1a333122721d27063b4d83db6701a6820be29105..422331363b952029d7b7eee177d8c8938fde3d99 100644 --- a/entry/src/main/ets/pages/ResumableFileTransfer.ets +++ b/entry/src/main/ets/pages/ResumableFileTransfer.ets @@ -15,7 +15,7 @@ import { rcp } from '@kit.RemoteCommunicationKit'; import { fileIo } from '@kit.CoreFileKit'; -import { promptAction } from '@kit.ArkUI'; + import { CustomListItem } from '../components/CustomList'; import { SelectionList } from '../components/SelectionList'; import { getFileList, ResumableDownloadManager } from '../service/FileRequest'; @@ -24,6 +24,8 @@ import { getAlbumAsset } from '../utils/LocalFileUtil'; import { ProgressBtn } from '../components/ProgressButton'; import { getProgressPercent, showSuccessMessage } from '../utils/CommonUtil'; +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); +let promptAction = uiContext!.getPromptAction()!; @Component export struct ResumableFileTransfer { @Consume navPageInfos: NavPathStack; diff --git a/entry/src/main/ets/utils/CommonUtil.ets b/entry/src/main/ets/utils/CommonUtil.ets index 3195f48a591b8a83e040a3a436bae704b7c932e1..c890022d9269b9d134400a5e7e2e2b7e41051959 100644 --- a/entry/src/main/ets/utils/CommonUtil.ets +++ b/entry/src/main/ets/utils/CommonUtil.ets @@ -12,11 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * 最佳实践:基于RCP的文件上传与下载 - */ -import { promptAction } from '@kit.ArkUI'; + const uiContext: UIContext | undefined = AppStorage.get('uiContext'); +let promptAction = uiContext!.getPromptAction()!; export function getChunkRanges(totalSize: number, chunkSize: number): number[][] { const chunkCount = Math.ceil(totalSize / chunkSize); diff --git a/entry/src/main/ets/utils/LocalFileUtil.ets b/entry/src/main/ets/utils/LocalFileUtil.ets index 22b71c9a9f45984de7710a5a4a0e6f6ab4199e11..d42f50df4803eb42ac471fa133c2a077f1d6166b 100644 --- a/entry/src/main/ets/utils/LocalFileUtil.ets +++ b/entry/src/main/ets/utils/LocalFileUtil.ets @@ -21,6 +21,9 @@ import { imageExtensions } from '../constants/Constants'; const uiContext: UIContext | undefined = AppStorage.get('uiContext'); let context = uiContext!.getHostContext()!; +const uiContext: UIContext | undefined = AppStorage.get('uiContext'); +let context = uiContext!.getHostContext()!; + export function getSandboxPath(path: string) { return `${context.filesDir}/${path}`; } @@ -35,8 +38,8 @@ export function copyFileSync(srcPath: string, destPath: string) { function getPhotoType(fileNameExtension: string) { return imageExtensions.includes(fileNameExtension) ? - photoAccessHelper.PhotoType.IMAGE : - photoAccessHelper.PhotoType.VIDEO; + photoAccessHelper.PhotoType.IMAGE : + photoAccessHelper.PhotoType.VIDEO; } export async function getAlbumAsset(fileNameExtension: string) { @@ -55,7 +58,9 @@ export async function saveImageToAlbum(sandboxPath: string) { const uri: string = fileUri.getUriFromPath(sandboxPath); const desFileUris: string[] = await phAccessHelper.showAssetsCreationDialog([uri], [photoCreationConfig]); const filePath = desFileUris[0]; - if (!filePath) throw new Error('photo assets permission denied'); + if (!filePath) { + throw new Error('photo assets permission denied'); + } copyFileSync(sandboxPath, filePath); return filePath; } @@ -78,4 +83,4 @@ export async function selectImagesFromAlbum(maxNumber: number = 1): Promise