far disks

main
parent 1dae2f7211
commit a0406e5c71

@ -24,6 +24,7 @@ type Server struct {
Run string `json:"run"`
}
// Запускает web-сервер (локальный)
func (s *Server) Start() {
os.Chdir(s.Dir)
//s := subprocess.New(".\\"+name+".exe")
@ -31,18 +32,9 @@ func (s *Server) Start() {
p.ExecAsync()
}
// WindowConfig хранит настройки окна
type WindowConfig struct {
Width int `json:"width"`
Height int `json:"height"`
X int `json:"x"`
Y int `json:"y"`
}
// App struct
type App struct {
ctx context.Context
windowConfig WindowConfig
ctx context.Context
}
// NewApp создает новый экземпляр App
@ -104,11 +96,28 @@ func (a *App) GetDownloads() string {
func (a *App) StartFarDownloads() string {
cmd := `far "D:\soft" "C:\Users\admin\Downloads"`
far := subprocess.New(cmd)
err := far.Exec()
if err != nil {
runtime.LogError(a.ctx, err.Error())
}
runtime.LogInfo(a.ctx, "команда выполнена успешно")
far.ExecAsync()
// runtime.LogInfo(a.ctx, "команда выполнена успешно")
return "ok"
}
// StartFarBooks - запускает far для fb2
func (a *App) StartFarBooks() string {
cmd := `far "D:\books\2\fb2" "D:\books\2\fb2\images"`
far := subprocess.New(cmd)
far.ExecAsync()
alacritty := subprocess.New("alacritty --working-directory D:/books/2/fb2")
alacritty.ExecAsync()
// runtime.LogInfo(a.ctx, "команда выполнена успешно")
return "ok"
}
// StartFarDisks - запускает far для работы с дисками
func (a *App) StartFarDisks() string {
cmd := `far "D:\" "C:\"`
far := subprocess.New(cmd)
far.ExecAsync()
// runtime.LogInfo(a.ctx, "команда выполнена успешно")
return "ok"
}

@ -1,110 +1,103 @@
<script>
import logo from "./assets/images/logo-universal.png";
import {
GetStatus,
Weed,
GetProjects,
StartFar,
GetDisks,
GetDownloads,
StartFarDownloads} 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 disks = [];
let downloads = "";
let cnt_pic = "0";
let normal = true;
let pics = true;
function get_disks() {
console.log("get disks")
GetDisks().then((result) => {
console.log("получена информация о дисках:", result)
disks = result
disks[0].normal = disks[0].Free > 20;
disks[1].normal = disks[1].Free > 50;
})
}
function get_downloads() {
console.log("get downloads")
GetDownloads().then((result) => {
console.log("получена информация о downloads:", result)
downloads = result
})
}
function start_far(project) {
StartFar(project.last_directory_path)
}
function far_downloads() {
StartFarDownloads()
}
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("запрос downloads");
get_downloads()
console.log("запрос дисков");
get_disks()
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();
import logo from "./assets/images/logo-universal.png";
import { GetStatus, Weed, GetProjects,
StartFar, GetDisks, GetDownloads,
StartFarDownloads, StartFarBooks,
StartFarDisks } 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 disks = [];
let downloads = "";
let cnt_pic = "0";
let pics = true;
function get_disks() {
console.log("get disks");
GetDisks().then((result) => {
console.log("получена информация о дисках:", result);
disks = result;
disks[0].normal = disks[0].Free > 20;
disks[1].normal = disks[1].Free > 50;
});
}
function get_downloads() {
console.log("get downloads");
GetDownloads().then((result) => {
console.log("получена информация о downloads:", result);
downloads = result;
});
}
function start_far(project) {
StartFar(project.last_directory_path);
}
function start_server(server) {
const 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("запрос downloads");
get_downloads();
console.log("запрос дисков");
get_disks();
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 />
<div class="container mx-auto pt-4 mb-4">
<div class="disk-panel text-neutral-300">
{#each disks as disk}
<div>
{disk.Name}
<span class={disk.normal ? 'info' : 'danger'}>{disk.Free} Gb</span>
</div>
{/each}
{#each disks as disk}
<div>
{disk.Name}
<a href="#" on:click={StartFarDisks} class={disk.normal ? "info" : "danger"}>
{disk.Free} Gb
</a>
</div>
{/each}
</div>
</div>
@ -112,108 +105,88 @@ get_status();
<h1 class="text-blue-200 text-2xl">СЕРВЕРА</h1>
{#each local as server}
<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_server(server)}
>
<button 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>
<span class:text-red-300={server.run === "running"}>
{server.run}
</span>
</button>
</div>
{/each}
</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">
<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">
<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>
<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 class={pics ? 'warning' : 'info'}>{cnt_pic}</span>
<span class={pics ? "warning" : "info"}>{cnt_pic}</span>
</div>
</div>
<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={far_downloads}
>
Download
</button>
</div>
<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={StartFarDownloads}> Download </button>
<div class="text-neutral-300">
<span class="info">{downloads}</span>
</div>
</div>
</div>
</div>
<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={StartFarBooks}> Books </button>
</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">
<h1 class="text-blue-200 text-2xl">ПРОЕКТЫ</h1>
<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) }
>
<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 class="info"> {project.name} </span>
<span class="info"> {project.name} </span>
</div>
</div>
{/each}
</div>
<!-- панель кнопок -->
<button
<!-- панель кнопок -->
<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="24"
height="24"
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">
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="24" height="24" 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>
.disk-panel {
display: flex;
justify-content: space-around;
}
.info {
color: lightgreen;
}
.danger {
color: red;
}
.warning {
color: orange;
}
.disk-panel {
display: flex;
justify-content: space-around;
}
.info {
color: lightgreen;
}
.danger {
color: red;
}
.warning {
color: orange;
}
</style>

@ -14,6 +14,10 @@ export function Greet(arg1:string):Promise<string>;
export function StartFar(arg1:string):Promise<string>;
export function StartFarBooks():Promise<string>;
export function StartFarDisks():Promise<string>;
export function StartFarDownloads():Promise<string>;
export function StartServer(arg1:string):Promise<string>;

@ -26,6 +26,14 @@ export function StartFar(arg1) {
return window['go']['main']['App']['StartFar'](arg1);
}
export function StartFarBooks() {
return window['go']['main']['App']['StartFarBooks']();
}
export function StartFarDisks() {
return window['go']['main']['App']['StartFarDisks']();
}
export function StartFarDownloads() {
return window['go']['main']['App']['StartFarDownloads']();
}

Loading…
Cancel
Save