|
|
@@ -6,6 +6,7 @@ import { RemoteDriveManagerStates } from '../common/enums/RemoteDriveManagerStat
|
|
|
import Logger from '../common/util/Logger';
|
|
|
import { router } from '@kit.ArkUI';
|
|
|
import { CommonConstants } from '../common/constants/CommonConstants';
|
|
|
+import { Constants } from '../Constants';
|
|
|
import { picker } from '@kit.CoreFileKit';
|
|
|
import { BusinessError } from '@kit.BasicServicesKit';
|
|
|
import { fileUri } from '@kit.CoreFileKit';
|
|
|
@@ -300,7 +301,7 @@ export struct UploadMusicPage {
|
|
|
const documentSelectOptions = new picker.DocumentSelectOptions();
|
|
|
|
|
|
// 设置音频文件过滤器
|
|
|
- documentSelectOptions.fileSuffixFilters = CommonConstants.AUDIO_EXTENSIONS;
|
|
|
+ documentSelectOptions.fileSuffixFilters = Constants.AUDIO_EXTENSIONS;
|
|
|
|
|
|
// 支持多选
|
|
|
documentSelectOptions.maxSelectNumber = 100;
|
|
|
@@ -478,13 +479,31 @@ export struct UploadMusicPage {
|
|
|
// 构建VideoItem列表
|
|
|
const songs: VideoItem[] = [];
|
|
|
for (let i = 0; i < this.selectedFiles.length; i++) {
|
|
|
- const fileUri = this.selectedFiles[i];
|
|
|
- const fileName = this.selectedFileNames[i];
|
|
|
+ const selectedUri = this.selectedFiles[i];
|
|
|
+ let displayName = this.selectedFileNames[i];
|
|
|
+ let resolvedPath = '';
|
|
|
+
|
|
|
+ try {
|
|
|
+ const fileUriObj = new fileUri.FileUri(selectedUri);
|
|
|
+ resolvedPath = fileUriObj.path || '';
|
|
|
+ if (!displayName) {
|
|
|
+ displayName = fileUriObj.name || selectedUri;
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ const err = error as Error;
|
|
|
+ Logger.error(TAG, `解析文件路径失败: ${err.message}`);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!resolvedPath) {
|
|
|
+ Logger.error(TAG, `无法获取本地路径,跳过文件: ${selectedUri}`);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
const videoItem = new VideoItem(
|
|
|
- fileName,
|
|
|
- fileUri,
|
|
|
- fileUri,
|
|
|
+ displayName,
|
|
|
+ selectedUri,
|
|
|
+ resolvedPath,
|
|
|
CommonConstants.TYPE_LOCAL,
|
|
|
0,
|
|
|
'',
|
|
|
@@ -493,14 +512,20 @@ export struct UploadMusicPage {
|
|
|
undefined,
|
|
|
undefined,
|
|
|
undefined,
|
|
|
- fileName
|
|
|
+ displayName
|
|
|
);
|
|
|
|
|
|
songs.push(videoItem);
|
|
|
}
|
|
|
|
|
|
- // 添加到上传队列
|
|
|
- this.webdavManager.addToUploadQueue(songs, this.selectedAccount);
|
|
|
+ if (songs.length === 0) {
|
|
|
+ Logger.warn(TAG, '未找到可上传的有效文件,取消任务');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加到上传队列,传递用户选择的上传路径
|
|
|
+ Logger.info(TAG, `使用上传路径: ${this.uploadPath}`);
|
|
|
+ this.webdavManager.addToUploadQueue(songs, this.selectedAccount, this.uploadPath);
|
|
|
this.totalUploadCount = songs.length;
|
|
|
this.uploadedCount = 0;
|
|
|
|
|
|
@@ -546,95 +571,93 @@ export struct UploadMusicPage {
|
|
|
*/
|
|
|
@Builder
|
|
|
UploadProgressView() {
|
|
|
- if (!this.isUploading || !this.currentTask) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- Column() {
|
|
|
- Text('上传进度')
|
|
|
- .fontSize(16)
|
|
|
- .fontWeight(FontWeight.Medium)
|
|
|
- .fontColor(this.isDarkMode ? '#E5FFFFFF' : '#E5000000')
|
|
|
- .margin({ bottom: 12 })
|
|
|
- .alignSelf(ItemAlign.Start)
|
|
|
+ if (this.isUploading && this.currentTask) {
|
|
|
+ Column() {
|
|
|
+ Text('上传进度')
|
|
|
+ .fontSize(16)
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor(this.isDarkMode ? '#E5FFFFFF' : '#E5000000')
|
|
|
+ .margin({ bottom: 12 })
|
|
|
+ .alignSelf(ItemAlign.Start)
|
|
|
|
|
|
- // 当前文件名
|
|
|
- Text(`当前文件: ${this.currentTask.name}`)
|
|
|
- .fontSize(14)
|
|
|
- .fontColor(this.isDarkMode ? '#99FFFFFF' : '#99000000')
|
|
|
- .margin({ bottom: 8 })
|
|
|
- .maxLines(1)
|
|
|
- .textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
+ // 当前文件名
|
|
|
+ Text(`当前文件: ${this.currentTask.name}`)
|
|
|
+ .fontSize(14)
|
|
|
+ .fontColor(this.isDarkMode ? '#99FFFFFF' : '#99000000')
|
|
|
+ .margin({ bottom: 8 })
|
|
|
+ .maxLines(1)
|
|
|
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
|
|
|
+
|
|
|
+ // 进度条
|
|
|
+ Progress({ value: this.uploadProgress, total: 100, type: ProgressType.Linear })
|
|
|
+ .width('100%')
|
|
|
+ .color(this.themeColor)
|
|
|
+ .backgroundColor(this.isDarkMode ? '#33FFFFFF' : '#19000000')
|
|
|
+ .margin({ bottom: 8 })
|
|
|
+
|
|
|
+ // 进度百分比和速度信息行
|
|
|
+ Row() {
|
|
|
+ Text(`${this.uploadProgress}%`)
|
|
|
+ .fontSize(14)
|
|
|
+ .fontWeight(FontWeight.Medium)
|
|
|
+ .fontColor(this.themeColor)
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
|
- // 进度条
|
|
|
- Progress({ value: this.uploadProgress, total: 100, type: ProgressType.Linear })
|
|
|
+ Text(`${this.uploadSpeed}`)
|
|
|
+ .fontSize(14)
|
|
|
+ .fontColor(this.isDarkMode ? '#66FFFFFF' : '#66000000')
|
|
|
+ }
|
|
|
.width('100%')
|
|
|
- .color(this.themeColor)
|
|
|
- .backgroundColor(this.isDarkMode ? '#33FFFFFF' : '#19000000')
|
|
|
.margin({ bottom: 8 })
|
|
|
|
|
|
- // 进度百分比和速度信息行
|
|
|
- Row() {
|
|
|
- Text(`${this.uploadProgress}%`)
|
|
|
- .fontSize(14)
|
|
|
- .fontWeight(FontWeight.Medium)
|
|
|
- .fontColor(this.themeColor)
|
|
|
- .layoutWeight(1)
|
|
|
-
|
|
|
- Text(`${this.uploadSpeed}`)
|
|
|
+ // 已上传数量
|
|
|
+ Text(`已上传: ${this.uploadedCount}/${this.totalUploadCount}`)
|
|
|
.fontSize(14)
|
|
|
- .fontColor(this.isDarkMode ? '#66FFFFFF' : '#66000000')
|
|
|
- }
|
|
|
- .width('100%')
|
|
|
- .margin({ bottom: 8 })
|
|
|
-
|
|
|
- // 已上传数量
|
|
|
- Text(`已上传: ${this.uploadedCount}/${this.totalUploadCount}`)
|
|
|
- .fontSize(14)
|
|
|
- .fontColor(this.isDarkMode ? '#99FFFFFF' : '#99000000')
|
|
|
- .margin({ bottom: 16 })
|
|
|
+ .fontColor(this.isDarkMode ? '#99FFFFFF' : '#99000000')
|
|
|
+ .margin({ bottom: 16 })
|
|
|
|
|
|
- // 控制按钮
|
|
|
- Row({ space: 12 }) {
|
|
|
- Button(this.webdavManager.isPauseUpload ? '恢复' : '暂停')
|
|
|
- .fontSize(14)
|
|
|
- .height(44)
|
|
|
- .layoutWeight(1)
|
|
|
- .backgroundColor(this.themeColor)
|
|
|
- .fontColor('#FFFFFF')
|
|
|
- .borderRadius(8)
|
|
|
- .onClick(() => {
|
|
|
- if (this.webdavManager.isPauseUpload) {
|
|
|
- this.resumeUpload();
|
|
|
- } else {
|
|
|
- this.pauseUpload();
|
|
|
- }
|
|
|
- })
|
|
|
+ // 控制按钮
|
|
|
+ Row({ space: 12 }) {
|
|
|
+ Button(this.webdavManager.isPauseUpload ? '恢复' : '暂停')
|
|
|
+ .fontSize(14)
|
|
|
+ .height(44)
|
|
|
+ .layoutWeight(1)
|
|
|
+ .backgroundColor(this.themeColor)
|
|
|
+ .fontColor('#FFFFFF')
|
|
|
+ .borderRadius(8)
|
|
|
+ .onClick(() => {
|
|
|
+ if (this.webdavManager.isPauseUpload) {
|
|
|
+ this.resumeUpload();
|
|
|
+ } else {
|
|
|
+ this.pauseUpload();
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
- Button('取消')
|
|
|
- .fontSize(14)
|
|
|
- .height(44)
|
|
|
- .layoutWeight(1)
|
|
|
- .backgroundColor(this.isDarkMode ? '#D94838' : '#E84026')
|
|
|
- .fontColor('#FFFFFF')
|
|
|
- .borderRadius(8)
|
|
|
- .onClick(() => {
|
|
|
- this.cancelUpload();
|
|
|
- })
|
|
|
+ Button('取消')
|
|
|
+ .fontSize(14)
|
|
|
+ .height(44)
|
|
|
+ .layoutWeight(1)
|
|
|
+ .backgroundColor(this.isDarkMode ? '#D94838' : '#E84026')
|
|
|
+ .fontColor('#FFFFFF')
|
|
|
+ .borderRadius(8)
|
|
|
+ .onClick(() => {
|
|
|
+ this.cancelUpload();
|
|
|
+ })
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
}
|
|
|
.width('100%')
|
|
|
+ .padding(16)
|
|
|
+ .backgroundColor(this.isDarkMode ? '#23272E' : '#FFFFFF')
|
|
|
+ .borderRadius(12)
|
|
|
+ .shadow({
|
|
|
+ radius: this.isDarkMode ? 8 : 12,
|
|
|
+ color: this.isDarkMode ? '#0C000000' : '#19000000',
|
|
|
+ offsetX: 0,
|
|
|
+ offsetY: 2
|
|
|
+ })
|
|
|
+ .margin({ bottom: 16 })
|
|
|
}
|
|
|
- .width('100%')
|
|
|
- .padding(16)
|
|
|
- .backgroundColor(this.isDarkMode ? '#23272E' : '#FFFFFF')
|
|
|
- .borderRadius(12)
|
|
|
- .shadow({
|
|
|
- radius: this.isDarkMode ? 8 : 12,
|
|
|
- color: this.isDarkMode ? '#0C000000' : '#19000000',
|
|
|
- offsetX: 0,
|
|
|
- offsetY: 2
|
|
|
- })
|
|
|
- .margin({ bottom: 16 })
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -1057,7 +1080,7 @@ export struct UploadMusicPage {
|
|
|
.backgroundColor(this.isDarkMode ? '#23272E' : '#FFFFFF')
|
|
|
}
|
|
|
.width('90%')
|
|
|
- .maxWidth(600)
|
|
|
+ .constraintSize({ maxWidth: 600 })
|
|
|
.backgroundColor(this.isDarkMode ? '#191A1C' : '#FFFFFF')
|
|
|
.borderRadius(16)
|
|
|
.shadow({
|
|
|
@@ -1257,7 +1280,7 @@ export struct UploadMusicPage {
|
|
|
}, (fileName: string, index: number) => `${index}-${fileName}`)
|
|
|
}
|
|
|
.width('100%')
|
|
|
- .maxHeight(300)
|
|
|
+ .constraintSize({ maxHeight: 300 })
|
|
|
.divider({
|
|
|
strokeWidth: 1,
|
|
|
color: this.isDarkMode ? '#19FFFFFF' : '#0C000000'
|