mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 15:29:26 +00:00
Refactor: Moved Go app to the root and fixed links.
This commit is contained in:
parent
d1de67910d
commit
7157d43168
28 changed files with 100 additions and 164 deletions
|
|
@ -1,64 +0,0 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"be/app/helper"
|
||||
"os"
|
||||
|
||||
"github.com/getlantern/systray"
|
||||
)
|
||||
|
||||
func InitSystray() {
|
||||
go func() {
|
||||
systray.Run(OnReady, OnExit)
|
||||
}()
|
||||
}
|
||||
|
||||
func OnReady() {
|
||||
systray.SetIcon(getIcon("favicon.ico"))
|
||||
systray.SetTitle("Macrame")
|
||||
systray.SetTooltip("Macrame - Server")
|
||||
|
||||
ip, err := GetServerIp()
|
||||
|
||||
if err == nil {
|
||||
systray.AddMenuItem("IP: "+ip+":"+helper.EnvGet("MCRM__PORT"), "Server IP")
|
||||
}
|
||||
|
||||
systray.AddSeparator()
|
||||
|
||||
addMCRMItem("Dashboard", "/")
|
||||
addMCRMItem("Panels", "/panels")
|
||||
addMCRMItem("Macros", "/macros")
|
||||
addMCRMItem("Devices", "/devices")
|
||||
|
||||
systray.AddSeparator()
|
||||
|
||||
mQuit := systray.AddMenuItem("Quit Macrame", "Quit Macrame")
|
||||
go func() {
|
||||
<-mQuit.ClickedCh
|
||||
os.Exit(0)
|
||||
}()
|
||||
}
|
||||
|
||||
func addMCRMItem(name, urlPath string) {
|
||||
m := systray.AddMenuItem(name, name)
|
||||
|
||||
go func() {
|
||||
<-m.ClickedCh
|
||||
helper.OpenBrowser("http://localhost:" + helper.EnvGet("MCRM__PORT") + urlPath)
|
||||
}()
|
||||
}
|
||||
|
||||
func OnExit() {
|
||||
systray.Quit()
|
||||
}
|
||||
|
||||
func getIcon(path string) []byte {
|
||||
icon, err := os.ReadFile(path)
|
||||
|
||||
if err != nil {
|
||||
MCRMLog("getIcon Error: ", err)
|
||||
}
|
||||
|
||||
return icon
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue