|
|
@@ -22,6 +22,7 @@ import { RemoteDriveType } from '../common/enums/RemoteDriveType';
|
|
|
import { Utility } from '../common/util/Utility';
|
|
|
import { SettingPage } from './SettingPage';
|
|
|
import { getCloudDiskIcon } from '../dialog/RemoteDriveAccountDialog';
|
|
|
+import { CreateFolderDialog } from '../dialog/CreateFolderDialog';
|
|
|
|
|
|
/**
|
|
|
* 歌单播放事件数据
|
|
|
@@ -865,6 +866,15 @@ export struct WebDavMainPage {
|
|
|
this.navigateToUploadPage();
|
|
|
})
|
|
|
|
|
|
+ MenuItem({
|
|
|
+ symbolStartIcon: new SymbolGlyphModifier($r('sys.symbol.folder_badge_plus')),
|
|
|
+ content: $r('app.string.create_foder')
|
|
|
+ })
|
|
|
+ .onClick(async () => {
|
|
|
+ this.showCreateFolderDialog();
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
}.attributeModifier(new MenuModifier())
|
|
|
}
|
|
|
|
|
|
@@ -1559,4 +1569,99 @@ export struct WebDavMainPage {
|
|
|
this.enterMultiSelect(song);
|
|
|
}))
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // 对话框控制器
|
|
|
+ private createFolderDialogController: CustomDialogController | null = null;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示创建文件夹对话框
|
|
|
+ */
|
|
|
+ private showCreateFolderDialog(): void {
|
|
|
+ if (!this.selectedAccount) {
|
|
|
+ this.getUIContext().getPromptAction().showToast({ message: `请先选择${getRemoteDriveAccountLabel()}` });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取当前主题色
|
|
|
+ const currentThemeColor = this.themeColor;
|
|
|
+
|
|
|
+ // 创建自定义对话框
|
|
|
+ this.createFolderDialogController = new CustomDialogController({
|
|
|
+ builder: CreateFolderDialog({
|
|
|
+ onConfirm: (folderName: string) => {
|
|
|
+ if (folderName.trim().length > 0) {
|
|
|
+ void this.createFolder(folderName.trim());
|
|
|
+ } else {
|
|
|
+ this.getUIContext().getPromptAction().showToast({ message: '文件夹名称不能为空' });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onCancel: () => {
|
|
|
+ // 用户取消创建
|
|
|
+ },
|
|
|
+ initialName: '',
|
|
|
+ themeColor: currentThemeColor
|
|
|
+ }),
|
|
|
+ autoCancel: true,
|
|
|
+ alignment: DialogAlignment.Center,
|
|
|
+ customStyle: false
|
|
|
+ });
|
|
|
+
|
|
|
+ this.createFolderDialogController.open();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建文件夹的实际方法
|
|
|
+ * @param folderName 文件夹名称
|
|
|
+ */
|
|
|
+ private async createFolder(folderName: string): Promise<void> {
|
|
|
+ if (!this.selectedAccount) {
|
|
|
+ this.getUIContext().getPromptAction().showToast({ message: `请先选择${getRemoteDriveAccountLabel()}` });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (folderName.length === 0) {
|
|
|
+ this.getUIContext().getPromptAction().showToast({ message: '文件夹名称不能为空' });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ Logger.info(TAG, `heanup 开始创建文件夹: ${folderName}`);
|
|
|
+
|
|
|
+ // 显示加载状态
|
|
|
+ this.isLoading = true;
|
|
|
+ if(this.selectedAccount.webType==RemoteDriveType.Baidu){
|
|
|
+ // 调用RemoteDriveManager的createBaiduFolder方法
|
|
|
+ const createdPath = await this.webdavManager.createBaiduFolder(this.selectedAccount, folderName);
|
|
|
+
|
|
|
+ // 创建成功后刷新当前目录
|
|
|
+ await this.webdavManager.loadFilesInfoFromAccount(this.selectedAccount, this.webdavManager.currentPath);
|
|
|
+ }else if(this.selectedAccount.webType==RemoteDriveType.WebDav){
|
|
|
+ // 这里帮我实现调用RemoteDriveManager的createWebDavFolder方法
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ this.getUIContext().getPromptAction().showToast({
|
|
|
+ message: `文件夹 "${folderName}" 创建成功`
|
|
|
+ });
|
|
|
+
|
|
|
+ Logger.info(TAG, `heanup 文件夹创建成功`);
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ const err = error as Error;
|
|
|
+ Logger.error(TAG, `heanup 创建文件夹失败: ${err.message}`);
|
|
|
+
|
|
|
+ // 显示具体的错误信息
|
|
|
+ this.getUIContext().getPromptAction().showToast({
|
|
|
+ message: `创建失败: ${err.message}`
|
|
|
+ });
|
|
|
+ } finally {
|
|
|
+ this.isLoading = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|