diff --git a/app.go b/app.go index 1723e20..83b71d9 100644 --- a/app.go +++ b/app.go @@ -6,6 +6,7 @@ import ( "fmt" "io/fs" "os" + //"path/filepath" //"time" @@ -53,7 +54,8 @@ func NewApp() *App { // startup вызывается при запуске приложения func (a *App) startup(ctx context.Context) { a.ctx = ctx - runtime.WindowSetTitle(ctx, "v1.0.1") + runtime.WindowSetTitle(ctx, "v1.0.2") + runtime.WindowSetPosition(ctx, 1500, 80) } // GetProjects возвращает список последних проектов @@ -92,6 +94,19 @@ func (a *App) StartServer(s string) string { 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() { os.Chdir("d:\\projects\\nano\\sw4-nano\\util") //s := subprocess.New(".\\"+name+".exe") @@ -101,7 +116,7 @@ func (a *App) Weed() { if err != nil { runtime.LogError(a.ctx, err.Error()) } - runtime.LogInfo(a.ctx, fmt.Sprintf("команда выполнена успешно")) + runtime.LogInfo(a.ctx, "команда выполнена успешно") } func getCountPics(dir string) int { diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index b655f80..39162b5 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -1,52 +1,58 @@ <script> - import logo from './assets/images/logo-universal.png' - import {GetStatus, Weed, GetProjects} from '../wailsjs/go/main/App.js' - import {StartServer} from '../wailsjs/go/main/App.js' - import TailwindCss from './TailwindCSS.svelte'; - import servers from './servers.js'; - // import {BrowserOpenURL} from '../wailsjs/runtime/runtime.js' - - let resultText = "Ваше имя 👇" - let local = servers; - let cnt_pic = "0"; - - function start_server(server) { - let s = JSON.stringify(server) - console.log(s) - StartServer(s).then(result => { - resultText = result - console.log(resultText) - server.run = "running" - local = local; - }) - } - - function weed() { - // console.log("weed"); - Weed().then(() => { - get_status() - }) - } - - function get_status(){ - console.log("запрос статуса") - GetStatus().then((result) => { - console.log("result:", result) - cnt_pic = result; - // сразу сбросим признак работающего сервера - local = local.map ( server => { - server.run = "idle" - return server - }) - }); - - console.log("запрос проектов") - GetProjects().then((result) => { - console.log("projects:", result) - }); - } - - get_status() +import logo from "./assets/images/logo-universal.png"; +import { GetStatus, Weed, GetProjects, StartFar } from "../wailsjs/go/main/App.js"; +import { StartServer } from "../wailsjs/go/main/App.js"; +import TailwindCss from "./TailwindCSS.svelte"; +import servers from "./servers.js"; +// import {BrowserOpenURL} from '../wailsjs/runtime/runtime.js' + +let resultText = "Ваше имя 👇"; +let local = servers; +let projects = []; +let cnt_pic = "0"; + +function start_far(project) { + StartFar(project.last_directory_path) +} + +function start_server(server) { + let s = JSON.stringify(server); + console.log(s); + StartServer(s).then((result) => { + resultText = result; + console.log(resultText); + server.run = "running"; + local = local; + }); +} + +function weed() { + // console.log("weed"); + Weed().then(() => { + get_status(); + }); +} + +function get_status() { + console.log("запрос статуса"); + GetStatus().then((result) => { + console.log("result:", result); + cnt_pic = result; + // сразу сбросим признак работающего сервера + local = local.map((server) => { + server.run = "idle"; + return server; + }); + }); + + console.log("запрос проектов"); + GetProjects().then((result) => { + console.log("projects:", result); + projects = result; + }); +} + +get_status(); </script> <TailwindCss /> @@ -69,53 +75,72 @@ </button> </div> {/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> - <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> +<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 - on:click={get_status} - class="absolute right-4 bottom-4 - bg-slate-700 hover:bg-slate-500 - p-2 rounded-full"> - <svg - xmlns="http://www.w3.org/2000/svg" - width="36" - height="36" - viewBox="0 0 24 24" - fill="none" - stroke="currentColor" - stroke-width="3" - stroke-linecap="round" - stroke-linejoin="round" - 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> - </svg> - </button> - </div> +<!-- панель кнопок --> +<button + on:click={get_status} + class="absolute right-4 bottom-4 + bg-slate-700 hover:bg-slate-500 + p-2 rounded-full"> + <svg + xmlns="http://www.w3.org/2000/svg" + width="36" + height="36" + viewBox="0 0 24 24" + fill="none" + stroke="currentColor" + stroke-width="3" + stroke-linecap="round" + stroke-linejoin="round" + 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> + </svg> +</button> <style> </style> diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts index e5c9337..468a314 100644 --- a/frontend/wailsjs/go/main/App.d.ts +++ b/frontend/wailsjs/go/main/App.d.ts @@ -8,6 +8,8 @@ export function GetStatus():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 Weed():Promise<void>; diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js index 7816e82..9869d7e 100644 --- a/frontend/wailsjs/go/main/App.js +++ b/frontend/wailsjs/go/main/App.js @@ -14,6 +14,10 @@ export function Greet(arg1) { return window['go']['main']['App']['Greet'](arg1); } +export function StartFar(arg1) { + return window['go']['main']['App']['StartFar'](arg1); +} + export function StartServer(arg1) { return window['go']['main']['App']['StartServer'](arg1); } diff --git a/main.go b/main.go index 96827e3..d94d8d9 100644 --- a/main.go +++ b/main.go @@ -21,7 +21,7 @@ func main() { err := wails.Run(&options.App{ Title: "server", Width: 300, - Height: 918, + Height: 800, MinWidth: 200, MinHeight: 400, // Frameless: true,