refactor: 删除部分多余的代码和注释

This commit is contained in:
mofeng-git
2026-05-01 17:31:04 +08:00
parent 74035f8e12
commit d8e7de74a6
165 changed files with 2960 additions and 9917 deletions

View File

@@ -19,6 +19,7 @@ import type {
MsdConfigUpdate,
AtxConfig,
AtxConfigUpdate,
AtxDevices,
AudioConfig,
AudioConfigUpdate,
ExtensionsStatus,
@@ -36,7 +37,6 @@ import type {
import { request } from './request'
// ===== 全局配置 API =====
export const configApi = {
/**
* 获取完整配置
@@ -44,7 +44,6 @@ export const configApi = {
getAll: () => request<AppConfig>('/config'),
}
// ===== Auth 配置 API =====
export const authConfigApi = {
/**
* 获取认证配置
@@ -62,7 +61,6 @@ export const authConfigApi = {
}),
}
// ===== Video 配置 API =====
export const videoConfigApi = {
/**
* 获取视频配置
@@ -80,7 +78,6 @@ export const videoConfigApi = {
}),
}
// ===== Stream 配置 API =====
export const streamConfigApi = {
/**
* 获取流配置
@@ -98,7 +95,6 @@ export const streamConfigApi = {
}),
}
// ===== HID 配置 API =====
export const hidConfigApi = {
/**
* 获取 HID 配置
@@ -116,7 +112,6 @@ export const hidConfigApi = {
}),
}
// ===== MSD 配置 API =====
export const msdConfigApi = {
/**
* 获取 MSD 配置
@@ -134,9 +129,6 @@ export const msdConfigApi = {
}),
}
// ===== ATX 配置 API =====
import type { AtxDevices } from '@/types/generated'
export interface WolHistoryEntry {
mac_address: string
updated_at: number
@@ -185,7 +177,6 @@ export const atxConfigApi = {
request<WolHistoryResponse>(`/atx/wol/history?limit=${Math.max(1, Math.min(50, limit))}`),
}
// ===== Audio 配置 API =====
export const audioConfigApi = {
/**
* 获取音频配置
@@ -203,7 +194,6 @@ export const audioConfigApi = {
}),
}
// ===== Extensions API =====
export const extensionsApi = {
/**
* 获取所有扩展状态
@@ -265,8 +255,6 @@ export const extensionsApi = {
}),
}
// ===== RustDesk 配置 API =====
/** RustDesk 配置响应 */
export interface RustDeskConfigResponse {
enabled: boolean
@@ -342,8 +330,6 @@ export const rustdeskConfigApi = {
}),
}
// ===== RTSP 配置 API =====
export type RtspCodec = 'h264' | 'h265'
export interface RtspConfigResponse {
@@ -385,9 +371,6 @@ export const rtspConfigApi = {
getStatus: () => request<RtspStatusResponse>('/config/rtsp/status'),
}
// ===== Web 服务器配置 API =====
// `/config/web` 使用 `WebConfigResponse` / `WebConfigUpdate`(由 typeshare 自 Rust 生成)。
/** REST `/config/web` 响应(`WebConfigResponse` 别名,兼容旧命名) */
export type WebConfig = WebConfigResponse
@@ -409,8 +392,6 @@ export const webConfigApi = {
}),
}
// ===== 系统控制 API =====
export const systemApi = {
/**
* 重启系统

View File

@@ -1,11 +1,9 @@
// API client for One-KVM backend
import { request, ApiError } from './request'
import type { CanonicalKey } from '@/types/generated'
import { useHidWebSocket, type HidKeyboardEvent, type HidMouseEvent } from '@/composables/useHidWebSocket'
const API_BASE = '/api'
// Auth API
export const authApi = {
login: (username: string, password: string) =>
request<{ success: boolean; message?: string }>(
@@ -36,7 +34,6 @@ export const authApi = {
}),
}
// System API
export interface NetworkAddress {
interface: string
ip: string
@@ -149,7 +146,6 @@ export const updateApi = {
request<UpdateStatusResponse>('/update/status'),
}
// Stream API
export interface VideoCodecInfo {
id: string
name: string
@@ -271,7 +267,6 @@ export const streamApi = {
}),
}
// WebRTC API
export interface IceCandidate {
candidate: string
sdpMid?: string
@@ -317,15 +312,9 @@ export const webrtcApi = {
request<{ ice_servers: IceServerConfig[]; mdns_mode: string }>('/webrtc/ice-servers'),
}
// HID API
// Import HID WebSocket composable
import { useHidWebSocket, type HidKeyboardEvent, type HidMouseEvent } from '@/composables/useHidWebSocket'
// Create shared HID WebSocket instance
const hidWs = useHidWebSocket()
let hidWsInitialized = false
// Initialize HID WebSocket connection
async function ensureHidConnection() {
if (!hidWsInitialized) {
hidWsInitialized = true
@@ -333,7 +322,6 @@ async function ensureHidConnection() {
}
}
// Map button string to number
function mapButton(button?: 'left' | 'right' | 'middle'): number | undefined {
if (!button) return undefined
const buttonMap = { left: 0, middle: 1, right: 2 }
@@ -403,7 +391,6 @@ export const hidApi = {
scroll?: number | null
}) => {
await ensureHidConnection()
// Ensure all values are properly typed (convert null to undefined)
const event: HidMouseEvent = {
type: data.type === 'move_abs' ? 'moveabs' : data.type,
x: data.x ?? undefined,
@@ -424,13 +411,11 @@ export const hidApi = {
return { success: true }
},
// WebSocket connection management
connectWebSocket: () => hidWs.connect(),
disconnectWebSocket: () => hidWs.disconnect(),
isWebSocketConnected: () => hidWs.connected.value,
}
// ATX API
export const atxApi = {
status: () =>
request<{
@@ -448,7 +433,6 @@ export const atxApi = {
}),
}
// MSD API
export interface MsdImage {
id: string
name: string
@@ -485,7 +469,6 @@ export const msdApi = {
}
}>('/msd/status'),
// Image management
listImages: () => request<MsdImage[]>('/msd/images'),
uploadImage: async (file: File, onProgress?: (progress: number) => void) => {
@@ -528,7 +511,6 @@ export const msdApi = {
disconnect: () =>
request<{ success: boolean }>('/msd/disconnect', { method: 'POST' }),
// Virtual drive
driveInfo: () =>
request<{
size: number
@@ -590,7 +572,6 @@ export const msdApi = {
method: 'POST',
}),
// Download from URL
downloadFromUrl: (url: string, filename?: string) =>
request<{
download_id: string
@@ -632,7 +613,6 @@ function sortSerialDevices(serialDevices: SerialDeviceOption[]): SerialDeviceOpt
})
}
// Config API
/** @deprecated 使用域特定 API(videoConfigApi, hidConfigApi 等)替代 */
export const configApi = {
get: () => request<Record<string, unknown>>('/config'),
@@ -683,7 +663,6 @@ export const configApi = {
},
}
// 导出新的域分离配置 API
export {
authConfigApi,
videoConfigApi,
@@ -707,7 +686,6 @@ export {
type WebConfigUpdate,
} from './config'
// 导出生成的类型
export type {
AppConfig,
AuthConfig,
@@ -730,7 +708,6 @@ export type {
BitratePreset,
} from '@/types/generated'
// Audio API
export const audioApi = {
status: () =>
request<{
@@ -765,7 +742,6 @@ export const audioApi = {
}),
}
// USB API
export interface UsbDeviceInfo {
bus_num: number
dev_num: number