утилиты

main
parent 3834afde74
commit 58027986e6

@ -61,7 +61,7 @@ func (a *App) StartServer(s string) string {
runtime.LogInfo(a.ctx, s)
var server Server
if err := json.Unmarshal([]byte(s), &server); err != nil {
runtime.LogInfo(a.ctx, err.Error())
runtime.LogError(a.ctx, err.Error())
}
runtime.LogInfo(a.ctx, fmt.Sprintf("server: %v", server))
@ -71,3 +71,24 @@ func (a *App) StartServer(s string) string {
return "starting server"
}
func (a *App) Weed() {
os.Chdir("d:\\projects\\sw4-nano\\util")
//s := subprocess.New(".\\"+name+".exe")
cmd := "py scanpics.py"
s := subprocess.New(cmd)
err := s.Exec()
if err != nil {
runtime.LogError(a.ctx, err.Error())
}
runtime.LogInfo(a.ctx, fmt.Sprintf("команда выполнена успешно"))
}
func (a *App) GetStatus() string {
pics, err := os.ReadDir("d:\\pics")
if err != nil {
runtime.LogError(a.ctx, err.Error())
return "error: " + err.Error()
}
return fmt.Sprint(len(pics))
}

@ -1,17 +1,14 @@
<script>
import logo from './assets/images/logo-universal.png'
import {Greet} from '../wailsjs/go/main/App.js'
import {GetStatus, Weed} 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'
// import {BrowserOpenURL} from '../wailsjs/runtime/runtime.js'
let resultText = "Ваше имя 👇"
let name
function greet() {
Greet(name).then(result => resultText = result)
}
let local = servers;
let cnt_pic = "0";
function start_server(server) {
let s = JSON.stringify(server)
@ -19,29 +16,70 @@
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;
});
}
get_status()
</script>
<TailwindCss />
<main 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>
{#each servers as server}
{#each local as server}
<div class="flex justify-between px-4">
<button
class="text-teal-400 hover:text-teal-200 hover:font-semibold cursor-pointer"
class="text-teal-600 hover:text-teal-200 hover:font-normal hover:underline hover:underline-offset-2 cursor-pointer"
on:click={ () => start_server(server)}
>
{server.name}
</button>
<button class="text-neutral-300">
<span class:text-red-300={server.run === "running"}>
{server.run}
</span>
</button>
</div>
{/each}
</main>
</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 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
</button>
<div class="text-neutral-300">
<span>
{cnt_pic}
</span>
</div>
</div>
</div>
<style>
</style>

@ -27,6 +27,13 @@ const servers = [
port: "4323",
run: "idle"
},
{
name: "sw4-nano",
dir: "d:\\projects\\sw4-nano",
cmd: ".\\sw4-nano.exe",
port: "4321",
run: "idle"
},
];
export default servers;

@ -1,6 +1,10 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
export function GetStatus():Promise<string>;
export function Greet(arg1:string):Promise<string>;
export function StartServer(arg1:string):Promise<string>;
export function Weed():Promise<void>;

@ -2,6 +2,10 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
export function GetStatus() {
return window['go']['main']['App']['GetStatus']();
}
export function Greet(arg1) {
return window['go']['main']['App']['Greet'](arg1);
}
@ -9,3 +13,7 @@ export function Greet(arg1) {
export function StartServer(arg1) {
return window['go']['main']['App']['StartServer'](arg1);
}
export function Weed() {
return window['go']['main']['App']['Weed']();
}

Loading…
Cancel
Save