-
This commit is contained in:
211
ui/app.slint
Normal file
211
ui/app.slint
Normal file
@@ -0,0 +1,211 @@
|
||||
import { Theme } from "./theme/theme.slint";
|
||||
import { AppSidebar, NavItem } from "./components/app-sidebar.slint";
|
||||
import { StatusState } from "./components/status-indicator.slint";
|
||||
import { HomePage } from "./pages/home.slint";
|
||||
import { ProfilesPage, ProfileData } from "./pages/profiles.slint";
|
||||
import { ProxiesPage, ProxyGroup, ProxyNode } from "./pages/proxies.slint";
|
||||
import { LogsPage, LogEntry } from "./pages/logs.slint";
|
||||
import { ConnectionsPage, Connection } from "./pages/connections.slint";
|
||||
import { SettingsPage } from "./pages/settings.slint";
|
||||
|
||||
export component App inherits Window {
|
||||
title: "Clash Manager";
|
||||
preferred-width: 1200px;
|
||||
preferred-height: 800px;
|
||||
background: Theme.colors.background;
|
||||
|
||||
// Navigation state
|
||||
in-out property <int> current-page: 0;
|
||||
|
||||
// Mihomo status
|
||||
in-out property <StatusState> mihomo-status: StatusState.stopped;
|
||||
in-out property <bool> mihomo-loading: false;
|
||||
|
||||
// Home page data
|
||||
in-out property <string> profile-name: "NanoCloud";
|
||||
in-out property <string> profile-node: "Free-Japan1-Ver.7";
|
||||
in-out property <float> profile-usage: 1.26;
|
||||
in-out property <float> profile-total: 100;
|
||||
in-out property <string> profile-expiry: "2025-11-11";
|
||||
in-out property <string> profile-updated: "2025-10-12 10:05";
|
||||
in-out property <string> location-ip: "47.238.198.100";
|
||||
in-out property <string> location-region: "Japan · Tokyo";
|
||||
in-out property <bool> tun-mode-enabled: false;
|
||||
in-out property <bool> system-proxy-enabled: false;
|
||||
in-out property <int> proxy-port: 7890;
|
||||
|
||||
// Profiles page data
|
||||
in-out property <[ProfileData]> profiles: [];
|
||||
in-out property <string> selected-profile-id: "";
|
||||
|
||||
// Proxies page data
|
||||
in-out property <[ProxyGroup]> proxy-groups: [];
|
||||
in-out property <int> proxy-mode: 0;
|
||||
in-out property <string> selected-proxy: "";
|
||||
|
||||
// Logs page data
|
||||
in-out property <[LogEntry]> mihomo-logs: [];
|
||||
in-out property <[LogEntry]> app-logs: [];
|
||||
in-out property <int> log-tab: 0;
|
||||
|
||||
// Connections page data
|
||||
in-out property <[Connection]> connections: [];
|
||||
|
||||
// Settings page data
|
||||
in-out property <bool> auto-start: false;
|
||||
in-out property <bool> silent-start: false;
|
||||
in-out property <bool> clash-core: false;
|
||||
in-out property <bool> allow-lan: false;
|
||||
in-out property <bool> ipv6: false;
|
||||
in-out property <bool> unified-delay: false;
|
||||
in-out property <int> log-level-index: 1;
|
||||
in-out property <string> app-dir: "C:/Program Files/Clash";
|
||||
in-out property <string> config-dir: "C:/Users/User/.config/clash";
|
||||
in-out property <string> core-dir: "C:/Program Files/Clash/core";
|
||||
in-out property <string> app-version: "1.0.0";
|
||||
|
||||
// Callbacks
|
||||
callback navigate(int);
|
||||
callback toggle-mihomo();
|
||||
callback refresh-profile();
|
||||
callback toggle-tun-mode(bool);
|
||||
callback toggle-system-proxy(bool);
|
||||
callback open-port-settings();
|
||||
callback add-profile();
|
||||
callback refresh-all-profiles();
|
||||
callback select-profile(string);
|
||||
callback edit-profile(string);
|
||||
callback delete-profile(string);
|
||||
callback refresh-single-profile(string);
|
||||
callback proxy-mode-changed(int);
|
||||
callback proxy-group-toggled(int, bool);
|
||||
callback proxy-selected(string);
|
||||
callback log-tab-changed(int);
|
||||
callback toggle-auto-start(bool);
|
||||
callback toggle-silent-start(bool);
|
||||
callback toggle-clash-core(bool);
|
||||
callback toggle-allow-lan(bool);
|
||||
callback toggle-ipv6(bool);
|
||||
callback toggle-unified-delay(bool);
|
||||
callback log-level-changed(int);
|
||||
callback open-tun-config();
|
||||
callback open-directory(string);
|
||||
|
||||
HorizontalLayout {
|
||||
// Sidebar
|
||||
AppSidebar {
|
||||
nav-items: [
|
||||
{ title: "Home", icon: "🏠" },
|
||||
{ title: "Proxies", icon: "🌐" },
|
||||
{ title: "Profiles", icon: "📋" },
|
||||
{ title: "Connections", icon: "🔗" },
|
||||
{ title: "Logs", icon: "📝" },
|
||||
{ title: "Settings", icon: "⚙" },
|
||||
];
|
||||
current-page: root.current-page;
|
||||
mihomo-status: root.mihomo-status;
|
||||
mihomo-loading: root.mihomo-loading;
|
||||
|
||||
navigate(index) => {
|
||||
root.current-page = index;
|
||||
root.navigate(index);
|
||||
}
|
||||
|
||||
toggle-mihomo => {
|
||||
root.toggle-mihomo();
|
||||
}
|
||||
}
|
||||
|
||||
// Content Area
|
||||
Rectangle {
|
||||
background: Theme.colors.background;
|
||||
|
||||
// Home Page
|
||||
if root.current-page == 0: HomePage {
|
||||
profile-name: root.profile-name;
|
||||
profile-node: root.profile-node;
|
||||
usage: root.profile-usage;
|
||||
total: root.profile-total;
|
||||
expiry: root.profile-expiry;
|
||||
updated: root.profile-updated;
|
||||
location-ip: root.location-ip;
|
||||
location-region: root.location-region;
|
||||
tun-mode-enabled: root.tun-mode-enabled;
|
||||
system-proxy-enabled: root.system-proxy-enabled;
|
||||
proxy-port: root.proxy-port;
|
||||
|
||||
refresh-profile => { root.refresh-profile(); }
|
||||
toggle-tun-mode(enabled) => { root.toggle-tun-mode(enabled); }
|
||||
toggle-system-proxy(enabled) => { root.toggle-system-proxy(enabled); }
|
||||
open-port-settings => { root.open-port-settings(); }
|
||||
}
|
||||
|
||||
// Proxies Page
|
||||
if root.current-page == 1: ProxiesPage {
|
||||
proxy-groups: root.proxy-groups;
|
||||
current-mode: root.proxy-mode;
|
||||
selected-proxy: root.selected-proxy;
|
||||
|
||||
mode-changed(mode) => { root.proxy-mode-changed(mode); }
|
||||
group-toggled(index, expanded) => { root.proxy-group-toggled(index, expanded); }
|
||||
proxy-selected(name) => { root.proxy-selected(name); }
|
||||
}
|
||||
|
||||
// Profiles Page
|
||||
if root.current-page == 2: ProfilesPage {
|
||||
profiles: root.profiles;
|
||||
selected-profile-id: root.selected-profile-id;
|
||||
|
||||
adrofile => { root.add-profile(); }
|
||||
refresh-all => { root.refresh-all-profiles(); }
|
||||
select-profile(id) => { root.select-profile(id); }
|
||||
edit-profile(id) => { root.edit-profile(id); }
|
||||
delete-profile(id) => { root.delete-profile(id); }
|
||||
refresh-profile(id) => { root.refresh-single-profile(id); }
|
||||
}
|
||||
|
||||
// Connections Page
|
||||
if root.current-page == 3: ConnectionsPage {
|
||||
connections: root.connections;
|
||||
}
|
||||
|
||||
// Logs Page
|
||||
if root.current-page == 4: LogsPage {
|
||||
mihomo-logs: root.mihomo-logs;
|
||||
app-logs: root.app-logs;
|
||||
current-tab: root.log-tab;
|
||||
|
||||
tab-changed(index) => { root.log-tab-changed(index); }
|
||||
}
|
||||
|
||||
// Settings Page
|
||||
if root.current-page == 5: SettingsPage {
|
||||
auto-start: root.auto-start;
|
||||
silent-start: root.silent-start;
|
||||
clash-core: root.clash-core;
|
||||
tun-mode: root.tun-mode-enabled;
|
||||
allow-lan: root.allow-lan;
|
||||
ipv6: root.ipv6;
|
||||
unified-delay: root.unified-delay;
|
||||
log-level-index: root.log-level-index;
|
||||
proxy-port: root.proxy-port;
|
||||
app-dir: root.app-dir;
|
||||
config-dir: root.config-dir;
|
||||
core-dir: root.core-dir;
|
||||
app-version: root.app-version;
|
||||
|
||||
toggle-auto-start(enabled) => { root.toggle-auto-start(enabled); }
|
||||
toggle-silent-start(enabled) => { root.toggle-silent-start(enabled); }
|
||||
toggle-clash-core(enabled) => { root.toggle-clash-core(enabled); }
|
||||
toggle-tun-mode(enabled) => { root.toggle-tun-mode(enabled); }
|
||||
toggle-allow-lan(enabled) => { root.toggle-allow-lan(enabled); }
|
||||
toggle-ipv6(enabled) => { root.toggle-ipv6(enabled); }
|
||||
toggle-unified-delay(enabled) => { root.toggle-unified-delay(enabled); }
|
||||
log-level-changed(index) => { root.log-level-changed(index); }
|
||||
open-port-settings => { root.open-port-settings(); }
|
||||
open-tun-config => { root.open-tun-config(); }
|
||||
open-directory(dir) => { root.open-directory(dir); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user