2022-05-01 16:51:52 +09:30
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-05-01 17:01:02 +09:30
|
|
|
_ "embed"
|
2022-05-01 16:51:52 +09:30
|
|
|
"fmt"
|
|
|
|
"github.com/getlantern/systray"
|
|
|
|
"github.com/skratchdot/open-golang/open"
|
|
|
|
"github.com/tardisx/discord-auto-upload/config"
|
|
|
|
daulog "github.com/tardisx/discord-auto-upload/log"
|
|
|
|
"github.com/tardisx/discord-auto-upload/version"
|
|
|
|
)
|
|
|
|
|
2022-05-01 17:39:00 +09:30
|
|
|
//go:generate goversioninfo
|
2022-05-01 17:01:02 +09:30
|
|
|
|
2022-12-05 23:24:27 +10:30
|
|
|
//go:embed dau.ico
|
|
|
|
var appIcon []byte
|
2022-05-01 17:01:02 +09:30
|
|
|
|
2022-05-01 16:51:52 +09:30
|
|
|
func mainloop(c *config.ConfigService) {
|
|
|
|
systray.Run(func() { onReady(c) }, onExit)
|
|
|
|
}
|
|
|
|
|
|
|
|
func onReady(c *config.ConfigService) {
|
|
|
|
|
|
|
|
systray.SetIcon(appIcon)
|
|
|
|
//systray.SetTitle("DAU")
|
|
|
|
systray.SetTooltip(fmt.Sprintf("discord-auto-upload %s", version.CurrentVersion))
|
|
|
|
openApp := systray.AddMenuItem("Open", "Open in web browser")
|
|
|
|
gh := systray.AddMenuItem("Github", "Open project page")
|
2022-05-01 17:01:02 +09:30
|
|
|
discord := systray.AddMenuItem("Discord", "Join us on discord")
|
2022-05-01 16:51:52 +09:30
|
|
|
ghr := systray.AddMenuItem("Release Notes", "Open project release notes")
|
|
|
|
quit := systray.AddMenuItem("Quit", "Quit")
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
<-quit.ClickedCh
|
|
|
|
systray.Quit()
|
|
|
|
}()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-openApp.ClickedCh:
|
|
|
|
openWebBrowser(c.Config.Port)
|
|
|
|
case <-gh.ClickedCh:
|
|
|
|
open.Start("https://github.com/tardisx/discord-auto-upload")
|
|
|
|
case <-ghr.ClickedCh:
|
|
|
|
open.Start(fmt.Sprintf("https://github.com/tardisx/discord-auto-upload/releases/tag/%s", version.CurrentVersion))
|
2022-05-01 17:01:02 +09:30
|
|
|
case <-discord.ClickedCh:
|
|
|
|
open.Start("https://discord.gg/eErG9sntbZ")
|
2022-05-01 16:51:52 +09:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
// Sets the icon of a menu item. Only available on Mac and Windows.
|
|
|
|
// mQuit.SetIcon(icon.Data)
|
|
|
|
}
|
|
|
|
|
|
|
|
func onExit() {
|
|
|
|
// clean up here
|
|
|
|
daulog.Info("quitting on user request")
|
|
|
|
}
|