Added the backup feature

This commit is contained in:
2025-07-17 00:12:00 +08:00
parent b4b0ad9bba
commit 9fff7bcfca
39 changed files with 1876 additions and 1018 deletions

View File

@@ -50,7 +50,6 @@ func (ds *DialogService) SelectDirectory() (string, error) {
// 对话框文本配置
Title: "Select Directory",
Message: "Select the folder where you want to store your app data",
ButtonText: "Select",
// 不设置过滤器,因为我们选择目录
@@ -69,3 +68,44 @@ func (ds *DialogService) SelectDirectory() (string, error) {
}
return path, nil
}
// SelectFile 打开文件选择对话框
func (ds *DialogService) SelectFile() (string, error) {
dialog := application.OpenFileDialog()
dialog.SetOptions(&application.OpenFileDialogOptions{
// 目录选择配置
CanChooseDirectories: false, // 允许选择目录
CanChooseFiles: true, // 不允许选择文件
CanCreateDirectories: true, // 允许创建新目录
AllowsMultipleSelection: false, // 单选模式
// 显示配置
ShowHiddenFiles: true, // 不显示隐藏文件
HideExtension: false, // 不隐藏扩展名
CanSelectHiddenExtension: false, // 不允许选择隐藏扩展名
TreatsFilePackagesAsDirectories: false, // 不将文件包当作目录处理
AllowsOtherFileTypes: false, // 不允许其他文件类型
// 系统配置
ResolvesAliases: true, // 解析别名/快捷方式
// 对话框文本配置
Title: "Select File",
ButtonText: "Select File",
// 不设置过滤器,因为我们选择目录
Filters: nil,
// 不指定默认目录,让系统决定
Directory: "",
// 绑定到主窗口
Window: ds.window,
})
path, err := dialog.PromptForSingleSelection()
if err != nil {
return "", err
}
return path, nil
}