fix: standardize RunningMode handling between frontend and backend

This commit improves the type consistency between the Rust backend and TypeScript frontend by:

1. Modifying the Rust `get_running_mode()` command to return a String instead of RunningMode enum directly
2. Removing the RunningMode enum and IRunningMode interface from TypeScript types
3. Using string literals for mode comparison in frontend components
4. Standardizing on capitalized mode names (e.g., "Sidecar" instead of "sidecar")

These changes ensure proper serialization/deserialization between backend and frontend,
making the code more maintainable and reducing potential inconsistencies.
This commit is contained in:
Tunglies
2025-03-26 22:04:16 +08:00
parent 6e40dd9862
commit 7ede91599c
7 changed files with 134 additions and 145 deletions

View File

@@ -1,7 +1,5 @@
import dayjs from "dayjs";
import { invoke } from "@tauri-apps/api/core";
import { Notice } from "@/components/base";
import { IRunningMode } from "./types";
export async function copyClashEnv() {
return invoke<void>("copy_clash_env");
@@ -313,7 +311,7 @@ export async function validateScriptFile(filePath: string) {
// 获取当前运行模式
export const getRunningMode = async () => {
return invoke<IRunningMode>("get_running_mode");
return invoke<string>("get_running_mode");
};
// 获取应用运行时间

View File

@@ -806,13 +806,3 @@ interface IWebDavConfig {
username: string;
password: string;
}
export enum RunningMode {
Service = "Service",
Sidecar = "Sidecar",
NotRunning = "NotRunning",
}
export interface IRunningMode {
mode: RunningMode;
}