diff --git a/css.go b/css.go new file mode 100644 index 0000000..78ad8e3 --- /dev/null +++ b/css.go @@ -0,0 +1,38 @@ +package main + +import ( + //"os" +) + +const css = ` +body { + background-color: #222; + color: #aaa; + font-size: 1rem; + font-family: "Source Sans Pro", 'JetBrains Mono', 'Fira Code', "Segoe UI" +} + +.main-title { + color: teal; + margin-top: 0; + text-align: center; +} + +.container { + display: flex; + margin-left: 8px; + margin-right: 8px; + justify-content: space-between; +} + +.server { + color: darkcyan; + cursor: pointer; +} + +.server:hover { + text-decoration: underline; + color: cyan; +} + +` diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..7196dbc --- /dev/null +++ b/go.mod @@ -0,0 +1,8 @@ +module servers + +go 1.22.0 + +require ( + github.com/estebangarcia21/subprocess v0.0.0-20230526204252-a1a6de4773be + github.com/webview/webview_go v0.0.0-20230901181450-5a14030a9070 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e6edc39 --- /dev/null +++ b/go.sum @@ -0,0 +1,4 @@ +github.com/estebangarcia21/subprocess v0.0.0-20230526204252-a1a6de4773be h1:Mf6Xc0DgENbsDgKn10KNCNmW9FYSTcMr2bFsJ9uzvX0= +github.com/estebangarcia21/subprocess v0.0.0-20230526204252-a1a6de4773be/go.mod h1:PlHe6+WP6t7m4ghYrX6GBzB0KZLdOKWz2Ih3h0nusAY= +github.com/webview/webview_go v0.0.0-20230901181450-5a14030a9070 h1:imZLWyo1ondeQjqfb/eHuYgFiOAYg6ugSMCnGfPTPmg= +github.com/webview/webview_go v0.0.0-20230901181450-5a14030a9070/go.mod h1:yE65LFCeWf4kyWD5re+h4XNvOHJEXOCOuJZ4v8l5sgk= diff --git a/html.go b/html.go new file mode 100644 index 0000000..227ec43 --- /dev/null +++ b/html.go @@ -0,0 +1,26 @@ +package main + +const html = ` +

Сервера

+ +
+
books-web
+
3000
+
+ +
+
nano-tw
+
4321
+
+ +
+
trans-web
+
4322
+
+ +
+
stem
+
4323
+
+ +` \ No newline at end of file diff --git a/icons8_Discord_Partner_Server_Owner_Badge.ico b/icons8_Discord_Partner_Server_Owner_Badge.ico new file mode 100644 index 0000000..5607d32 Binary files /dev/null and b/icons8_Discord_Partner_Server_Owner_Badge.ico differ diff --git a/js.go b/js.go new file mode 100644 index 0000000..5e8bd89 --- /dev/null +++ b/js.go @@ -0,0 +1,18 @@ +package main + +import ( + //"os" +) + +const js = ` + +function start_server(name){ + const e = document.getElementById(name) + e.innerHTML = "работает.." + let result = server(name) +} + +window.onload = function() { + noop(); +} +` diff --git a/main.go b/main.go new file mode 100644 index 0000000..346dd69 --- /dev/null +++ b/main.go @@ -0,0 +1,54 @@ +package main + +import ( + "log" + "os" + "fmt" + webview "github.com/webview/webview_go" + "github.com/estebangarcia21/subprocess" +) + +func startServer(name string) { + os.Chdir("d:\\projects\\" + name); + s := subprocess.New(".\\"+name+".exe") + s.ExecAsync() +} + +const mainhtml = ` + + + + + + %s + + ` + +func main() { + w := webview.New(false) + defer w.Destroy() + w.SetTitle("Сервера") + w.SetSize(280, 320, webview.HintNone) + //w.SetHtml("Thanks for using webview!") + //w.SetHtml(`test`) + + // Регистрируем функцию JavaScript для прослушивания события от веб-страницы + w.Bind("noop", func() string { + log.Println("hello") + return "hello" + }) + + w.Bind("server", func(name string) string { + log.Printf("start server: %s", name) + startServer(name) + return "start" + }) + + // Загружаем HTML-страницу с JavaScript кодом, который будет отправлять сообщения + resulthtml := fmt.Sprintf(mainhtml, css, html, js) + w.SetHtml(resulthtml) + //w.Navigate("http://localhost:9999") + + // Запускаем цикл событий окна браузера + w.Run() +}