mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-09-02 01:03:54 +00:00
feat(gui): GUI add support to connect to config server (#1596)
This commit is contained in:
@@ -11,6 +11,7 @@ interface ServiceOptions {
|
||||
rpc_portal: string
|
||||
file_log_level: string
|
||||
file_log_dir: string
|
||||
config_server?: string
|
||||
}
|
||||
|
||||
export type ServiceStatus = "Running" | "Stopped" | "NotInstalled"
|
||||
@@ -67,9 +68,9 @@ export async function getConfig(instanceId: string) {
|
||||
return await invoke<NetworkConfig>('get_config', { instanceId })
|
||||
}
|
||||
|
||||
export async function sendConfigs() {
|
||||
export async function sendConfigs(enabledNetworks: string[]) {
|
||||
let networkList: NetworkConfig[] = JSON.parse(localStorage.getItem('networkList') || '[]');
|
||||
return await invoke('load_configs', { configs: networkList, enabledNetworks: [] })
|
||||
return await invoke('load_configs', { configs: networkList, enabledNetworks })
|
||||
}
|
||||
|
||||
export async function getNetworkMetas(instanceIds: string[]) {
|
||||
@@ -95,3 +96,11 @@ export async function initRpcConnection(url?: string) {
|
||||
export async function isClientRunning() {
|
||||
return await invoke<boolean>('is_client_running')
|
||||
}
|
||||
|
||||
export async function initWebClient(url?: string) {
|
||||
return await invoke('init_web_client', { url })
|
||||
}
|
||||
|
||||
export async function isWebClientConnected() {
|
||||
return await invoke<boolean>('is_web_client_connected')
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
interface NormalMode {
|
||||
import { type } from '@tauri-apps/plugin-os';
|
||||
|
||||
export interface WebClientConfig {
|
||||
config_server_url?: string
|
||||
}
|
||||
|
||||
interface NormalMode extends WebClientConfig {
|
||||
mode: 'normal'
|
||||
}
|
||||
|
||||
export interface ServiceMode {
|
||||
export interface ServiceMode extends WebClientConfig {
|
||||
mode: 'service'
|
||||
config_dir: string
|
||||
rpc_portal: string
|
||||
@@ -19,15 +25,15 @@ export function saveMode(mode: Mode) {
|
||||
localStorage.setItem('app_mode', JSON.stringify(mode))
|
||||
}
|
||||
|
||||
import { type } from '@tauri-apps/plugin-os';
|
||||
|
||||
export function loadMode(): Mode {
|
||||
if (type() === 'android') {
|
||||
return { mode: 'normal' };
|
||||
}
|
||||
const modeStr = localStorage.getItem('app_mode')
|
||||
if (modeStr) {
|
||||
return JSON.parse(modeStr) as Mode
|
||||
let mode = JSON.parse(modeStr) as Mode
|
||||
if (type() === 'android') {
|
||||
return { ...mode, mode: 'normal' }
|
||||
}
|
||||
return mode
|
||||
} else {
|
||||
return { mode: 'normal' }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user