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

Resources misconception and additional files. #102

Open
SchmidtDawid opened this issue Apr 23, 2022 · 6 comments
Open

Resources misconception and additional files. #102

SchmidtDawid opened this issue Apr 23, 2022 · 6 comments

Comments

@SchmidtDawid
Copy link

SchmidtDawid commented Apr 23, 2022

Hello i made an app with astielectron (without bootstrap) and vue.js. My bundle file looks like that:

{
  "app_name": "Delta Sim Connector",
  "icon_path_windows": "assets/favicon.ico",
  "resources_path": "GUI/dist/"
}

I cant bundle app without resources_path. But when i bundled app with this parameter i still need my folder GUI/dist/ next to my .exe to run. So why i need it? I thought after bundle i will get one working .exe file. Do i not understand something?

Its not big problem for me because i still need for example .dll file and other config files for my app so i am aware of i need more files anyway. An there is my other question.

After bundle i get folder output/windows-amd64 folder with .exe file. Is there any way to just copy for example my .dll file, GUI/dist directory to that directory too? It could be easier to complete all needed files.

I tried with vendor directory, but i thing its another thing i don't fully understand ;)

@asticode
Copy link
Owner

Thing is, using the bundler without the bootstrap means you have to do at least this step manually.

Basically the bundler embed your resources files in the binary, and after starting astilectron you need to disembed those files locally so that they're available to your app.

I thought after bundle i will get one working .exe file

You .exe file will contain your resources files, but you'll still need to copy them locally so that they're available to Electron.

Is there any way to just copy for example my .dll file, GUI/dist directory to that directory too?

You need to replicate your resources path structure (GUI/dist/) in the directory located at a.Paths().DataDirectory() (a being *Astilectron)

@SchmidtDawid
Copy link
Author

SchmidtDawid commented Apr 24, 2022

Ah ok it looks complicated but i hope i can handle it ;). Or maybe ill use bootstrap.

And maybe one more question. I have icon in assets/icon.png for app and for tray. Tray is working good but app icon not. It works when i manually copy it to %appdata%\{MyApp}. What i need to do to copy icon by first execute (i think it will happen then ;))

@asticode
Copy link
Owner

Tray is working good but app icon not

Are you testing on Windows ?

@SchmidtDawid
Copy link
Author

SchmidtDawid commented Apr 24, 2022

Yes on Windows

This is my astielectron init:

a, err = astilectron.New(l, astilectron.Options{
		AppName:            "Delta Sim Connector",
		AppIconDefaultPath: "assets/icon.png",
		BaseDirectoryPath:  "example",
	})
	if err != nil {
		l.Fatal(fmt.Errorf("main: creating astilectron failed: %w", err))
	}

this is my Tray init:

tray = a.NewTray(&astilectron.TrayOptions{
		Image:   astikit.StrPtr("assets/icon.png"),
		Tooltip: astikit.StrPtr("Tray's tooltip"),
	})
	// Create tray
	tray.Create()

And only Tray icon is working. As i said i have to copy app icon manually to (...)AppData\Roaming\Delta Sim Connector which is creating during first execute

@asticode
Copy link
Owner

This is the same problem as for your resources: the icon must be found by Windows locally on the machine. And the path you're providing ("assets/icon.png") is relative to a.Paths().DataDirectory().

Therefore once you use the bootstrap or implement disembedding resources inside the binary, this will work (IF assets/icon.png is the proper relative path)

@SchmidtDawid
Copy link
Author

Yeah i read whole code of bundler and bootstrap and i think i understand what happens now. Thanks for help :)

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