Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

windows does not display #104

Open
liuhedong opened this issue Dec 28, 2022 · 6 comments
Open

windows does not display #104

liuhedong opened this issue Dec 28, 2022 · 6 comments

Comments

@liuhedong
Copy link

1: Windows 10 can be compiled and run on the local device. Copy the exe to other devices to run as an administrator. You can see it in the task manager, but the program is not displayed.
Other devices: windows10 and windows7
astilectron: 0.55.0
electron: 11.4.3

{
"app_name": "ceshi",
"icon_path_darwin": "resources/icon.icns",
"icon_path_linux": "resources/icon.png",
"icon_path_windows": "resources/icon.ico"
}

2: Adding a signature still doesn't work

@asticode
Copy link
Owner

Did you add a proper logger using this option ? If not, could you add it ?

Once you've done it, could you open the exe in the terminal and paste logs output here?

@liuhedong
Copy link
Author

package main

import (
"fmt"
"log"

"net/http"

"github.com/asticode/go-astikit"
"github.com/asticode/go-astilectron"

)

func main() {
http.HandleFunc("/", func(wr http.ResponseWriter, r *http.Request) {
wr.Write([]byte(<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes" /> <title>test</title> </head> <body> <div id="app">test test test</div> </body> </html>))
})
go http.ListenAndServe("127.0.0.1:8858", nil)

// Set logger
l := log.New(log.Writer(), log.Prefix(), log.Flags())

// Create astilectron
a, err := astilectron.New(l, astilectron.Options{
	AppName: "test",
	//BaseDirectoryPath: "example",
})
if err != nil {
	l.Fatal(fmt.Errorf("main: creating astilectron failed: %w", err))
}
defer a.Close()

// Handle signals
a.HandleSignals()

// Start
if err = a.Start(); err != nil {
	l.Fatal(fmt.Errorf("main: starting astilectron failed: %w", err))
}

// New window
var w *astilectron.Window
if w, err = a.NewWindow("http://127.0.0.1:8858", &astilectron.WindowOptions{
	Center:    astikit.BoolPtr(true),
	Width:     astikit.IntPtr(500),
	Height:    astikit.IntPtr(300),
	Resizable: astikit.BoolPtr(false),
}); err != nil {
	l.Fatal(fmt.Errorf("main: new window failed: %w", err))
}

// Create windows
if err = w.Create(); err != nil {
	l.Fatal(fmt.Errorf("main: creating window failed: %w", err))
}

a.Wait()

}

{
"app_name": "test",
"icon_path_darwin": "resources/icon.icns",
"icon_path_linux": "resources/icon.png",
"icon_path_windows": "resources/icon.ico"
}

delete windows.syso
delete bind_windows_amd64.go

C:\Users\liuhedong\go\example.com\test>astilectron-bundler cc
2022/12/29 20:22:35 Removing C:\Users\liuhedong\AppData\Local\Temp\astibundler\cache

C:\Users\liuhedong\go\example.com\test>astilectron-bundler
2022/12/29 20:22:39 Bundling for environment windows/amd64
2022/12/29 20:22:39 Binding data
2022/12/29 20:22:39 Removing C:\Users\liuhedong\AppData\Local\Temp\astibundler\bind
2022/12/29 20:22:39 Creating C:\Users\liuhedong\AppData\Local\Temp\astibundler\bind
2022/12/29 20:22:39 Creating C:\Users\liuhedong\AppData\Local\Temp\astibundler\bind\vendor_astilectron_bundler
2022/12/29 20:22:39 Creating C:\Users\liuhedong\AppData\Local\Temp\astibundler\cache
2022/12/29 20:22:39 Downloading https://github.com/asticode/astilectron/archive/v0.55.0.zip into C:\Users\liuhedong\AppData\Local\Temp\astibundler\cache\astilectron-0.55.0.zip
2022/12/29 20:22:39 astikit: sending GET request to https://github.com/asticode/astilectron/archive/v0.55.0.zip (1/1)
2022/12/29 20:22:41 Copying C:\Users\liuhedong\AppData\Local\Temp\astibundler\cache\astilectron-0.55.0.zip to C:\Users\liuhedong\AppData\Local\Temp\astibundler\bind\vendor_astilectron_bundler\astilectron.zip
2022/12/29 20:22:41 Downloading https://github.com/electron/electron/releases/download/v11.4.3/electron-v11.4.3-win32-x64.zip into C:\Users\liuhedong\AppData\Local\Temp\astibundler\cache\electron-windows-amd64-11.4.3.zip
2022/12/29 20:22:41 astikit: sending GET request to https://github.com/electron/electron/releases/download/v11.4.3/electron-v11.4.3-win32-x64.zip (1/1)
2022/12/29 20:26:22 Copying C:\Users\liuhedong\AppData\Local\Temp\astibundler\cache\electron-windows-amd64-11.4.3.zip to C:\Users\liuhedong\AppData\Local\Temp\astibundler\bind\vendor_astilectron_bundler\electron.zip
2022/12/29 20:26:22 Creating C:\Users\liuhedong\AppData\Local\Temp\astibundler\bind\resources
2022/12/29 20:26:22 Copying C:\Users\liuhedong\go\example.com\test\resources to C:\Users\liuhedong\AppData\Local\Temp\astibundler\bind\resources
2022/12/29 20:26:22 Generating C:\Users\liuhedong\go\example.com\test\bind_windows_amd64.go
2022/12/29 20:26:26 Running rsrc for icon C:\Users\liuhedong\go\example.com\test\resources\icon.ico into C:\Users\liuhedong\go\example.com\test\windows.syso
2022/12/29 20:26:26 Removing C:\Users\liuhedong\go\example.com\test\output\windows-amd64
2022/12/29 20:26:26 Creating C:\Users\liuhedong\go\example.com\test\output\windows-amd64
2022/12/29 20:26:26 Building for os windows and arch amd64 astilectron: 0.55.0 electron: 11.4.3
2022/12/29 20:26:26 Executing go build -ldflags -H "windowsgui" -X "main.AppName=test" -X "main.BuiltAt=2022-12-29 20:26:26.0654017 +0800 +08 m=+226.224113101" -X "main.VersionAstilectron=0.55.0" -X "main.VersionElectron=11.4.3" -o C:\Users\liuhedong\go\example.com\test\output\windows-amd64\binary .
2022/12/29 20:26:56 Moving C:\Users\liuhedong\go\example.com\test\output\windows-amd64\binary to C:\Users\liuhedong\go\example.com\test\output\windows-amd64\test.exe

@asticode
Copy link
Owner

What logs do you see when you run test.exe through the terminal ?

@liuhedong
Copy link
Author

liuhedong commented Dec 29, 2022

Found it, in the C:\Users\liuhedong\AppData\Roaming\test\vendor directory, electron-windows-amd64-v11.4.3.zip cannot be downloaded.

@liuhedong
Copy link
Author

The compilation includes electron, why do you need to download it?

@asticode
Copy link
Owner

Since you're using the bundler, you should use the bootstrap (check out the demo). In the code you've shared, you're not using the bootstrap, therefore bundler will be useless since it will download vendors every time.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants