feat: excel importer

This commit is contained in:
2025-03-10 16:31:08 +07:00
parent 8fbbd7b142
commit 6bf4f1e289
12 changed files with 250 additions and 145 deletions

View File

@@ -1,44 +1,45 @@
package dialogs
import (
"fmt"
"github.com/wailsapp/wails/v3/pkg/application"
)
var currentWindow *application.WebviewWindow
func Init(window *application.WebviewWindow) {
if window == nil {
panic("currentWindow is nil")
}
currentWindow = window
}
func checkInit() {
if currentWindow == nil {
panic("Initialize dialogs package before use")
}
}
func InfoDialog(title string, message string) {
checkInit()
application.InfoDialog().AttachToWindow(currentWindow).SetTitle(title).SetMessage(message).Show()
application.InfoDialog().SetTitle(title).SetMessage(message).Show()
}
func WarningDialog(title string, message string) {
checkInit()
application.WarningDialog().AttachToWindow(currentWindow).SetTitle(title).SetMessage(message).Show()
application.WarningDialog().SetTitle(title).SetMessage(message).Show()
}
func ErrorDialog(title string, message string) {
checkInit()
application.ErrorDialog().AttachToWindow(currentWindow).SetTitle(title).SetMessage(message).Show()
application.ErrorDialog().SetTitle(title).SetMessage(message).Show()
}
func SaveFileDialog(title string, filename string) (string, error) {
checkInit()
selection, err := application.SaveFileDialog().AttachToWindow(currentWindow).SetFilename(filename).PromptForSingleSelection()
selection, err := application.SaveFileDialog().SetFilename(filename).PromptForSingleSelection()
if err != nil {
return "", err
}
return selection, nil
}
func OpenFileDialog(title string) (string, error) {
defer func() {
if r := recover(); r != nil {
fmt.Println("Recovered in f", r)
}
}()
dialog := application.OpenFileDialog()
dialog.SetTitle(title)
dialog.CanChooseDirectories(false)
dialog.AddFilter("Электронные таблицы (.xlsx)", "*.xlsx")
dialog.AddFilter("Электронные таблицы (.xls)", "*.xls")
path, err := dialog.PromptForSingleSelection()
if err != nil {
return "", err
}
return path, nil
}