main
parent f14ef27b93
commit 54439a870e

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"io/fs" "io/fs"
"os" "os"
//"path/filepath" //"path/filepath"
//"time" //"time"
@ -53,7 +54,8 @@ func NewApp() *App {
// startup вызывается при запуске приложения // startup вызывается при запуске приложения
func (a *App) startup(ctx context.Context) { func (a *App) startup(ctx context.Context) {
a.ctx = ctx a.ctx = ctx
runtime.WindowSetTitle(ctx, "v1.0.1") runtime.WindowSetTitle(ctx, "v1.0.2")
runtime.WindowSetPosition(ctx, 1500, 80)
} }
// GetProjects возвращает список последних проектов // GetProjects возвращает список последних проектов
@ -92,6 +94,19 @@ func (a *App) StartServer(s string) string {
return "starting server" return "starting server"
} }
// StartServer - запускает сервер на выполнение
func (a *App) StartFar(s string) string {
runtime.LogInfo(a.ctx, s)
cmd := fmt.Sprintf("far \"%s\" \"%s\"", s, s)
far := subprocess.New(cmd)
err := far.Exec()
if err != nil {
runtime.LogError(a.ctx, err.Error())
}
runtime.LogInfo(a.ctx, fmt.Sprintf("команда выполнена успешно"))
return "ok"
}
func (a *App) Weed() { func (a *App) Weed() {
os.Chdir("d:\\projects\\nano\\sw4-nano\\util") os.Chdir("d:\\projects\\nano\\sw4-nano\\util")
//s := subprocess.New(".\\"+name+".exe") //s := subprocess.New(".\\"+name+".exe")
@ -101,7 +116,7 @@ func (a *App) Weed() {
if err != nil { if err != nil {
runtime.LogError(a.ctx, err.Error()) runtime.LogError(a.ctx, err.Error())
} }
runtime.LogInfo(a.ctx, fmt.Sprintf("команда выполнена успешно")) runtime.LogInfo(a.ctx, "команда выполнена успешно")
} }
func getCountPics(dir string) int { func getCountPics(dir string) int {

@ -1,52 +1,58 @@
<script> <script>
import logo from './assets/images/logo-universal.png' import logo from "./assets/images/logo-universal.png";
import {GetStatus, Weed, GetProjects} from '../wailsjs/go/main/App.js' import { GetStatus, Weed, GetProjects, StartFar } from "../wailsjs/go/main/App.js";
import {StartServer} from '../wailsjs/go/main/App.js' import { StartServer } from "../wailsjs/go/main/App.js";
import TailwindCss from './TailwindCSS.svelte'; import TailwindCss from "./TailwindCSS.svelte";
import servers from './servers.js'; import servers from "./servers.js";
// import {BrowserOpenURL} from '../wailsjs/runtime/runtime.js' // import {BrowserOpenURL} from '../wailsjs/runtime/runtime.js'
let resultText = "Ваше имя 👇" let resultText = "Ваше имя 👇";
let local = servers; let local = servers;
let projects = [];
let cnt_pic = "0"; let cnt_pic = "0";
function start_far(project) {
StartFar(project.last_directory_path)
}
function start_server(server) { function start_server(server) {
let s = JSON.stringify(server) let s = JSON.stringify(server);
console.log(s) console.log(s);
StartServer(s).then(result => { StartServer(s).then((result) => {
resultText = result resultText = result;
console.log(resultText) console.log(resultText);
server.run = "running" server.run = "running";
local = local; local = local;
}) });
} }
function weed() { function weed() {
// console.log("weed"); // console.log("weed");
Weed().then(() => { Weed().then(() => {
get_status() get_status();
}) });
} }
function get_status() { function get_status() {
console.log("запрос статуса") console.log("запрос статуса");
GetStatus().then((result) => { GetStatus().then((result) => {
console.log("result:", result) console.log("result:", result);
cnt_pic = result; cnt_pic = result;
// сразу сбросим признак работающего сервера // сразу сбросим признак работающего сервера
local = local.map ( server => { local = local.map((server) => {
server.run = "idle" server.run = "idle";
return server return server;
}) });
}); });
console.log("запрос проектов") console.log("запрос проектов");
GetProjects().then((result) => { GetProjects().then((result) => {
console.log("projects:", result) console.log("projects:", result);
projects = result;
}); });
} }
get_status() get_status();
</script> </script>
<TailwindCss /> <TailwindCss />
@ -71,7 +77,7 @@
{/each} {/each}
</div> </div>
<hr class="mb-2 mx-4 text-slate-600"> <hr class="mb-2 mx-4 text-slate-600"/>
<div class="container mx-auto pt-4 mb-8"> <div class="container mx-auto pt-4 mb-8">
<h1 class="text-blue-200 text-2xl">УТИЛИТЫ</h1> <h1 class="text-blue-200 text-2xl">УТИЛИТЫ</h1>
@ -93,9 +99,29 @@
</div> </div>
</div> </div>
</div> </div>
</div>
<!-- панель кнопок --> <hr class="mb-2 mx-4 text-slate-600"/>
<div class="container mx-auto pt-4 mb-8">
<h1 class="text-blue-200 text-2xl">ПРОЕКТЫ</h1>
{#each projects as project}
<div class="flex justify-between px-4">
<button
class="text-teal-600 hover:text-teal-200 hover:font-normal hover:underline hover:underline-offset-2 cursor-pointer"
on:click={ () => start_far(project) }
>
{project.last_directory}
</button>
<div class="text-neutral-300">
<span> {project.name} </span>
</div>
</div>
{/each}
</div>
<!-- панель кнопок -->
<button <button
on:click={get_status} on:click={get_status}
class="absolute right-4 bottom-4 class="absolute right-4 bottom-4
@ -115,7 +141,6 @@
<polyline points="1 4 1 10 7 10"></polyline><polyline points="23 20 23 14 17 14"></polyline><path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"></path> <polyline points="1 4 1 10 7 10"></polyline><polyline points="23 20 23 14 17 14"></polyline><path d="M20.49 9A9 9 0 0 0 5.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 0 1 3.51 15"></path>
</svg> </svg>
</button> </button>
</div>
<style> <style>
</style> </style>

@ -8,6 +8,8 @@ export function GetStatus():Promise<string>;
export function Greet(arg1:string):Promise<string>; export function Greet(arg1:string):Promise<string>;
export function StartFar(arg1:string):Promise<string>;
export function StartServer(arg1:string):Promise<string>; export function StartServer(arg1:string):Promise<string>;
export function Weed():Promise<void>; export function Weed():Promise<void>;

@ -14,6 +14,10 @@ export function Greet(arg1) {
return window['go']['main']['App']['Greet'](arg1); return window['go']['main']['App']['Greet'](arg1);
} }
export function StartFar(arg1) {
return window['go']['main']['App']['StartFar'](arg1);
}
export function StartServer(arg1) { export function StartServer(arg1) {
return window['go']['main']['App']['StartServer'](arg1); return window['go']['main']['App']['StartServer'](arg1);
} }

@ -21,7 +21,7 @@ func main() {
err := wails.Run(&options.App{ err := wails.Run(&options.App{
Title: "server", Title: "server",
Width: 300, Width: 300,
Height: 918, Height: 800,
MinWidth: 200, MinWidth: 200,
MinHeight: 400, MinHeight: 400,
// Frameless: true, // Frameless: true,

Loading…
Cancel
Save