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 cnt_pic = "0"; let projects = [];
let cnt_pic = "0";
function start_server(server) {
let s = JSON.stringify(server) function start_far(project) {
console.log(s) StartFar(project.last_directory_path)
StartServer(s).then(result => { }
resultText = result
console.log(resultText) function start_server(server) {
server.run = "running" let s = JSON.stringify(server);
local = local; console.log(s);
}) StartServer(s).then((result) => {
} resultText = result;
console.log(resultText);
function weed() { server.run = "running";
// console.log("weed"); local = local;
Weed().then(() => { });
get_status() }
})
} function weed() {
// console.log("weed");
function get_status(){ Weed().then(() => {
console.log("запрос статуса") get_status();
GetStatus().then((result) => { });
console.log("result:", result) }
cnt_pic = result;
// сразу сбросим признак работающего сервера function get_status() {
local = local.map ( server => { console.log("запрос статуса");
server.run = "idle" GetStatus().then((result) => {
return server console.log("result:", result);
}) cnt_pic = result;
}); // сразу сбросим признак работающего сервера
local = local.map((server) => {
console.log("запрос проектов") server.run = "idle";
GetProjects().then((result) => { return server;
console.log("projects:", result) });
}); });
}
console.log("запрос проектов");
get_status() GetProjects().then((result) => {
console.log("projects:", result);
projects = result;
});
}
get_status();
</script> </script>
<TailwindCss /> <TailwindCss />
@ -69,53 +75,72 @@
</button> </button>
</div> </div>
{/each} {/each}
</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>
<div class="flex flex-col h-full justify-between">
<div class="h-24">
<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={weed}
>
Weed (python)
</button>
<div class="text-neutral-300">
<span>
{cnt_pic}
</span>
</div>
</div>
</div>
</div> </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>
<div class="flex flex-col h-full justify-between"> {#each projects as project}
<div class="h-24"> <div class="flex justify-between px-4">
<div class="flex justify-between px-4"> <button
<button class="text-teal-600 hover:text-teal-200 hover:font-normal hover:underline hover:underline-offset-2 cursor-pointer"
class="text-teal-600 hover:text-teal-200 hover:font-normal hover:underline hover:underline-offset-2 cursor-pointer" on:click={ () => start_far(project) }
on:click={weed} >
> {project.last_directory}
Weed (python) </button>
</button>
<div class="text-neutral-300">
<div class="text-neutral-300"> <span> {project.name} </span>
<span> </div>
{cnt_pic}
</span>
</div>
</div>
</div>
</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 bg-slate-700 hover:bg-slate-500
bg-slate-700 hover:bg-slate-500 p-2 rounded-full">
p-2 rounded-full"> <svg
<svg xmlns="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg" width="36"
width="36" height="36"
height="36" viewBox="0 0 24 24"
viewBox="0 0 24 24" fill="none"
fill="none" stroke="currentColor"
stroke="currentColor" stroke-width="3"
stroke-width="3" stroke-linecap="round"
stroke-linecap="round" stroke-linejoin="round"
stroke-linejoin="round" class="feather feather-refresh-ccw cursor-pointer">
class="feather feather-refresh-ccw cursor-pointer"> <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