Skip to content

Commit

Permalink
fix: remove deprecated options
Browse files Browse the repository at this point in the history
  • Loading branch information
Gurkengewuerz committed Oct 31, 2023
1 parent e6f5b1b commit 688c19c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.ant-layout-header {
height: 40px;
line-height: 40px;
--wails-draggable: drag
}

.nav-item {
Expand Down
39 changes: 34 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ package main

import (
"embed"
"fmt"
"github.com/Gurkengewuerz/modupdater/backend"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"log"
"net/http"
"os"
"strings"

"github.com/wailsapp/wails/v2/pkg/options/mac"

Expand All @@ -19,6 +24,27 @@ var assets embed.FS
//go:embed build/appicon.png
var icon []byte

type FileLoader struct {
http.Handler
}

func NewFileLoader() *FileLoader {
return &FileLoader{}
}

func (h *FileLoader) ServeHTTP(res http.ResponseWriter, req *http.Request) {
var err error
requestedFilename := strings.TrimPrefix(req.URL.Path, "/")
println("Requesting file:", requestedFilename)
fileData, err := os.ReadFile(requestedFilename)
if err != nil {
res.WriteHeader(http.StatusBadRequest)
res.Write([]byte(fmt.Sprintf("Could not load file %s", requestedFilename)))
}

res.Write(fileData)
}

func main() {
// Create an instance of the app structure
app := backend.NewApp()
Expand All @@ -38,11 +64,14 @@ func main() {
StartHidden: false,
HideWindowOnClose: false,
BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
Assets: assets,
LogLevel: logger.DEBUG,
OnStartup: app.Startup,
OnDomReady: app.DOMReady,
OnShutdown: app.Shutdown,
AssetServer: &assetserver.Options{
Assets: assets,
Handler: NewFileLoader(),
},
LogLevel: logger.DEBUG,
OnStartup: app.Startup,
OnDomReady: app.DOMReady,
OnShutdown: app.Shutdown,
Bind: []interface{}{
app,
},
Expand Down

0 comments on commit 688c19c

Please sign in to comment.