|
|
@@ -113,6 +113,8 @@ export struct WebDavMainPage {
|
|
|
// 加载账户列表
|
|
|
this.loadAccounts();
|
|
|
|
|
|
+ this.loadFiles()
|
|
|
+
|
|
|
// 订阅WebDAV状态变化
|
|
|
this.webdavManager.subscribe(this.eventHandler);
|
|
|
}
|
|
|
@@ -235,87 +237,7 @@ export struct WebDavMainPage {
|
|
|
this.songs = [];
|
|
|
}
|
|
|
|
|
|
- // 显示添加账户对话框
|
|
|
- private showAddAccountDialog(): void {
|
|
|
- this.accountDialogController = new CustomDialogController({
|
|
|
- builder: WebDavAccountDialog({
|
|
|
- isEditMode: false,
|
|
|
- account: new WebDavAccount(),
|
|
|
- onConfirm: (account: WebDavAccount) => {
|
|
|
- this.webdavManager.insertAccount(
|
|
|
- account.name,
|
|
|
- account.host,
|
|
|
- account.localHost,
|
|
|
- account.isUseLocalHost,
|
|
|
- account.port,
|
|
|
- account.filepath,
|
|
|
- account.lyricFilePath,
|
|
|
- account.uploadFilePath,
|
|
|
- account.imageFilePath,
|
|
|
- account.account,
|
|
|
- account.password,
|
|
|
- account.enableHttps
|
|
|
- ).then(() => {
|
|
|
- promptAction.showToast({ message: '添加成功' });
|
|
|
- }).catch((error: Error) => {
|
|
|
- Logger.error(TAG, '添加账户失败: ' + error.message);
|
|
|
- promptAction.showToast({ message: '添加失败' });
|
|
|
- });
|
|
|
- }
|
|
|
- }),
|
|
|
- autoCancel: true,
|
|
|
- customStyle: true
|
|
|
- });
|
|
|
- this.accountDialogController.open();
|
|
|
- }
|
|
|
|
|
|
- // 显示编辑账户对话框
|
|
|
- private showEditAccountDialog(account: WebDavAccount): void {
|
|
|
- this.accountDialogController = new CustomDialogController({
|
|
|
- builder: WebDavAccountDialog({
|
|
|
- isEditMode: true,
|
|
|
- account: account,
|
|
|
- onConfirm: (updatedAccount: WebDavAccount) => {
|
|
|
- this.webdavManager.editAccount(updatedAccount)
|
|
|
- .then(() => {
|
|
|
- promptAction.showToast({ message: '更新成功' });
|
|
|
- }).catch((error: Error) => {
|
|
|
- Logger.error(TAG, '更新账户失败: ' + error.message);
|
|
|
- promptAction.showToast({ message: '更新失败' });
|
|
|
- });
|
|
|
- }
|
|
|
- }),
|
|
|
- autoCancel: true,
|
|
|
- customStyle: true
|
|
|
- });
|
|
|
- this.accountDialogController.open();
|
|
|
- }
|
|
|
-
|
|
|
- // 显示账户选择对话框
|
|
|
- private showAccountSelectDialog(): void {
|
|
|
- if (this.accounts.length === 0) {
|
|
|
- promptAction.showToast({ message: '没有可用的账户' });
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 构建按钮数组,至少1个,最多6个
|
|
|
- const button1: promptAction.Button = { text: this.accounts[0].name, color: '#000000' };
|
|
|
- const button2: promptAction.Button | undefined = this.accounts.length > 1 ? { text: this.accounts[1].name, color: '#000000' } : undefined;
|
|
|
- const button3: promptAction.Button | undefined = this.accounts.length > 2 ? { text: this.accounts[2].name, color: '#000000' } : undefined;
|
|
|
- const button4: promptAction.Button | undefined = this.accounts.length > 3 ? { text: this.accounts[3].name, color: '#000000' } : undefined;
|
|
|
- const button5: promptAction.Button | undefined = this.accounts.length > 4 ? { text: this.accounts[4].name, color: '#000000' } : undefined;
|
|
|
- const button6: promptAction.Button | undefined = this.accounts.length > 5 ? { text: this.accounts[5].name, color: '#000000' } : undefined;
|
|
|
-
|
|
|
- promptAction.showActionMenu({
|
|
|
- title: '选择账户',
|
|
|
- buttons: [button1, button2, button3, button4, button5, button6]
|
|
|
- }).then((result) => {
|
|
|
- if (result.index >= 0 && result.index < this.accounts.length) {
|
|
|
- this.switchAccount(this.accounts[result.index]);
|
|
|
- promptAction.showToast({ message: '已切换到: ' + this.accounts[result.index].name });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
// 将Song转换为VideoItem
|
|
|
private convertSongToVideoItem(song: Song, index: number): VideoItem {
|
|
|
@@ -469,12 +391,6 @@ export struct WebDavMainPage {
|
|
|
.layoutWeight(1)
|
|
|
.textAlign(TextAlign.Center)
|
|
|
|
|
|
- // 添加账户按钮
|
|
|
- Image($r('app.media.add'))
|
|
|
- .width(24)
|
|
|
- .height(24)
|
|
|
- .margin({ right: 12 })
|
|
|
- .onClick(() => this.showAddAccountDialog())
|
|
|
}
|
|
|
.height(48)
|
|
|
.width('100%')
|
|
|
@@ -522,54 +438,11 @@ export struct WebDavMainPage {
|
|
|
@Builder
|
|
|
buildContentView() {
|
|
|
Column() {
|
|
|
- // 账户选择器
|
|
|
- if (this.accounts.length > 0) {
|
|
|
- Row() {
|
|
|
- Text('当前账户:')
|
|
|
- .fontSize(14)
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
- .margin({ right: 8 })
|
|
|
|
|
|
- Text(this.selectedAccount?.name || '未选择')
|
|
|
- .fontSize(14)
|
|
|
- .fontColor(this.themeColor)
|
|
|
- .layoutWeight(1)
|
|
|
-
|
|
|
- Button('切换', { type: ButtonType.Normal, stateEffect: true })
|
|
|
- .fontSize(12)
|
|
|
- .padding({ left: 12, right: 12, top: 6, bottom: 6 })
|
|
|
- .backgroundColor(this.themeColor)
|
|
|
- .onClick(() => {
|
|
|
- this.showAccountSelectDialog();
|
|
|
- })
|
|
|
-
|
|
|
- Button('编辑', { type: ButtonType.Normal, stateEffect: true })
|
|
|
- .fontSize(12)
|
|
|
- .padding({ left: 12, right: 12, top: 6, bottom: 6 })
|
|
|
- .backgroundColor($r('app.color.input_background'))
|
|
|
- .fontColor($r('app.color.index_tab_font_color'))
|
|
|
- .margin({ left: 8 })
|
|
|
- .onClick(() => {
|
|
|
- if (this.selectedAccount) {
|
|
|
- this.showEditAccountDialog(this.selectedAccount);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- .width('100%')
|
|
|
- .padding(12)
|
|
|
- .backgroundColor($r('app.color.input_background'))
|
|
|
- .borderRadius(8)
|
|
|
- .margin({ left: 12, right: 12, top: 8 })
|
|
|
- }
|
|
|
|
|
|
// 加载按钮和面包屑导航
|
|
|
Column({ space: 8 }) {
|
|
|
Row({ space: 12 }) {
|
|
|
- Button('加载文件列表', { type: ButtonType.Capsule, stateEffect: true })
|
|
|
- .layoutWeight(1)
|
|
|
- .backgroundColor(this.themeColor)
|
|
|
- .enabled(!this.isLoading)
|
|
|
- .onClick(() => this.loadFiles())
|
|
|
|
|
|
// 返回上级按钮
|
|
|
if (this.webdavManager.canGoBack()) {
|