update:修改应用图标,TypeScript改为JavaScript
@ -1,3 +1,8 @@
|
||||
# Windows 静态链接 MSVC 运行时,无需用户安装 VC++ Redistributable
|
||||
[target.x86_64-pc-windows-msvc]
|
||||
rustflags = ["-C", "target-feature=+crt-static"]
|
||||
|
||||
# Cargo 配置
|
||||
[build]
|
||||
# 编译输出目录(减少项目目录占用)
|
||||
target-dir = "E:/rust-target/flash-send"
|
||||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 7.3 KiB |
|
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 87 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 154 KiB |
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 497 B After Width: | Height: | Size: 785 B |
|
Before Width: | Height: | Size: 929 B After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 929 B After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 703 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 929 B After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 6.7 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 881 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 24 KiB |
@ -0,0 +1,89 @@
|
||||
/**
|
||||
* API 模块
|
||||
* 封装所有 Tauri 命令调用
|
||||
*/
|
||||
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
|
||||
/** 发现服务 API */
|
||||
export const discoveryApi = {
|
||||
/** 启动设备发现服务 */
|
||||
start: () => invoke('start_discovery_service'),
|
||||
|
||||
/** 停止设备发现服务 */
|
||||
stop: () => invoke('stop_discovery_service'),
|
||||
|
||||
/** 获取已发现的设备列表 */
|
||||
getDevices: () => invoke('get_discovered_devices'),
|
||||
}
|
||||
|
||||
/** WebSocket API */
|
||||
export const websocketApi = {
|
||||
/** 启动 WebSocket 服务端 */
|
||||
startServer: () => invoke('start_websocket_server'),
|
||||
|
||||
/** 停止 WebSocket 服务端 */
|
||||
stopServer: () => invoke('stop_websocket_server'),
|
||||
|
||||
/** 连接到指定设备 */
|
||||
connect: (deviceId) => invoke('connect_to_peer', { deviceId }),
|
||||
|
||||
/** 断开与指定设备的连接 */
|
||||
disconnect: (deviceId) => invoke('disconnect_from_peer', { deviceId }),
|
||||
}
|
||||
|
||||
/** 聊天 API */
|
||||
export const chatApi = {
|
||||
/** 发送聊天消息 */
|
||||
sendMessage: (deviceId, content, messageType) =>
|
||||
invoke('send_chat_message', { deviceId, content, messageType }),
|
||||
|
||||
/** 获取聊天历史 */
|
||||
getHistory: (deviceId, limit, offset) =>
|
||||
invoke('get_chat_history', { deviceId, limit, offset }),
|
||||
|
||||
/** 删除聊天历史 */
|
||||
deleteHistory: (deviceId) =>
|
||||
invoke('delete_chat_history', { deviceId }),
|
||||
}
|
||||
|
||||
/** 文件传输 API */
|
||||
export const fileApi = {
|
||||
/** 启动 HTTP 服务端 */
|
||||
startServer: () => invoke('start_http_server'),
|
||||
|
||||
/** 停止 HTTP 服务端 */
|
||||
stopServer: () => invoke('stop_http_server'),
|
||||
|
||||
/** 选择要发送的文件 */
|
||||
selectFile: () => invoke('select_file_to_send'),
|
||||
|
||||
/** 发送文件 */
|
||||
sendFile: (deviceId, fileId, filePath) =>
|
||||
invoke('send_file', { deviceId, fileId, filePath }),
|
||||
|
||||
/** 获取传输历史 */
|
||||
getHistory: (deviceId, limit) =>
|
||||
invoke('get_transfer_history', { deviceId, limit }),
|
||||
|
||||
/** 打开文件位置 */
|
||||
openLocation: (path) => invoke('open_file_location', { path }),
|
||||
|
||||
/** 取消传输 */
|
||||
cancelTransfer: (fileId) => invoke('cancel_transfer', { fileId }),
|
||||
}
|
||||
|
||||
/** 配置 API */
|
||||
export const configApi = {
|
||||
/** 获取应用配置 */
|
||||
get: () => invoke('get_app_config'),
|
||||
|
||||
/** 更新设备名称 */
|
||||
updateDeviceName: (name) => invoke('update_device_name', { name }),
|
||||
|
||||
/** 更新下载目录 */
|
||||
updateDownloadDir: (dir) => invoke('update_download_dir', { dir }),
|
||||
|
||||
/** 获取本机设备信息 */
|
||||
getLocalDevice: () => invoke('get_local_device_info'),
|
||||
}
|
||||
@ -1,96 +0,0 @@
|
||||
/**
|
||||
* API 模块
|
||||
* 封装所有 Tauri 命令调用
|
||||
*/
|
||||
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import type {
|
||||
DeviceInfo,
|
||||
ChatMessage,
|
||||
FileTransfer,
|
||||
FileMetadata,
|
||||
AppConfig,
|
||||
} from '@/types'
|
||||
|
||||
/** 发现服务 API */
|
||||
export const discoveryApi = {
|
||||
/** 启动设备发现服务 */
|
||||
start: () => invoke('start_discovery_service'),
|
||||
|
||||
/** 停止设备发现服务 */
|
||||
stop: () => invoke('stop_discovery_service'),
|
||||
|
||||
/** 获取已发现的设备列表 */
|
||||
getDevices: () => invoke<DeviceInfo[]>('get_discovered_devices'),
|
||||
}
|
||||
|
||||
/** WebSocket API */
|
||||
export const websocketApi = {
|
||||
/** 启动 WebSocket 服务端 */
|
||||
startServer: () => invoke('start_websocket_server'),
|
||||
|
||||
/** 停止 WebSocket 服务端 */
|
||||
stopServer: () => invoke('stop_websocket_server'),
|
||||
|
||||
/** 连接到指定设备 */
|
||||
connect: (deviceId: string) => invoke('connect_to_peer', { deviceId }),
|
||||
|
||||
/** 断开与指定设备的连接 */
|
||||
disconnect: (deviceId: string) => invoke('disconnect_from_peer', { deviceId }),
|
||||
}
|
||||
|
||||
/** 聊天 API */
|
||||
export const chatApi = {
|
||||
/** 发送聊天消息 */
|
||||
sendMessage: (deviceId: string, content: string, messageType?: string) =>
|
||||
invoke<ChatMessage>('send_chat_message', { deviceId, content, messageType }),
|
||||
|
||||
/** 获取聊天历史 */
|
||||
getHistory: (deviceId: string, limit?: number, offset?: number) =>
|
||||
invoke<ChatMessage[]>('get_chat_history', { deviceId, limit, offset }),
|
||||
|
||||
/** 删除聊天历史 */
|
||||
deleteHistory: (deviceId: string) =>
|
||||
invoke<number>('delete_chat_history', { deviceId }),
|
||||
}
|
||||
|
||||
/** 文件传输 API */
|
||||
export const fileApi = {
|
||||
/** 启动 HTTP 服务端 */
|
||||
startServer: () => invoke('start_http_server'),
|
||||
|
||||
/** 停止 HTTP 服务端 */
|
||||
stopServer: () => invoke('stop_http_server'),
|
||||
|
||||
/** 选择要发送的文件 */
|
||||
selectFile: () => invoke<FileMetadata | null>('select_file_to_send'),
|
||||
|
||||
/** 发送文件 */
|
||||
sendFile: (deviceId: string, fileId: string, filePath: string) =>
|
||||
invoke<FileTransfer>('send_file', { deviceId, fileId, filePath }),
|
||||
|
||||
/** 获取传输历史 */
|
||||
getHistory: (deviceId: string, limit?: number) =>
|
||||
invoke<FileTransfer[]>('get_transfer_history', { deviceId, limit }),
|
||||
|
||||
/** 打开文件位置 */
|
||||
openLocation: (path: string) => invoke('open_file_location', { path }),
|
||||
|
||||
/** 取消传输 */
|
||||
cancelTransfer: (fileId: string) => invoke('cancel_transfer', { fileId }),
|
||||
}
|
||||
|
||||
/** 配置 API */
|
||||
export const configApi = {
|
||||
/** 获取应用配置 */
|
||||
get: () => invoke<AppConfig>('get_app_config'),
|
||||
|
||||
/** 更新设备名称 */
|
||||
updateDeviceName: (name: string) => invoke('update_device_name', { name }),
|
||||
|
||||
/** 更新下载目录 */
|
||||
updateDownloadDir: (dir: string) => invoke('update_download_dir', { dir }),
|
||||
|
||||
/** 获取本机设备信息 */
|
||||
getLocalDevice: () => invoke<DeviceInfo>('get_local_device_info'),
|
||||
}
|
||||
@ -0,0 +1,110 @@
|
||||
/**
|
||||
* 类型定义模块
|
||||
* JavaScript 版本 - 使用 JSDoc 注释提供类型提示
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {'text' | 'image' | 'file'} DeviceCapability
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} DeviceInfo
|
||||
* @property {string} deviceId
|
||||
* @property {string} deviceName
|
||||
* @property {string} ip
|
||||
* @property {number} wsPort
|
||||
* @property {number} httpPort
|
||||
* @property {boolean} online
|
||||
* @property {DeviceCapability[]} capabilities
|
||||
* @property {number} lastSeen
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {'text' | 'image' | 'file' | 'event' | 'ack' | 'ping' | 'pong'} MessageType
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {'pending' | 'sent' | 'delivered' | 'read' | 'failed'} MessageStatus
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ChatMessage
|
||||
* @property {string} id
|
||||
* @property {MessageType} type
|
||||
* @property {string} content
|
||||
* @property {string} from
|
||||
* @property {string} to
|
||||
* @property {number} timestamp
|
||||
* @property {MessageStatus} status
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {'pending' | 'transferring' | 'completed' | 'failed' | 'cancelled'} TransferStatus
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} FileTransfer
|
||||
* @property {string} fileId
|
||||
* @property {string} name
|
||||
* @property {number} size
|
||||
* @property {number} progress
|
||||
* @property {TransferStatus} status
|
||||
* @property {string} mimeType
|
||||
* @property {string} fromDevice
|
||||
* @property {string} toDevice
|
||||
* @property {string} [localPath]
|
||||
* @property {number} createdAt
|
||||
* @property {number} [completedAt]
|
||||
* @property {number} transferredBytes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} FileMetadata
|
||||
* @property {string} fileId
|
||||
* @property {string} name
|
||||
* @property {number} size
|
||||
* @property {string} mimeType
|
||||
* @property {string} [thumbnail]
|
||||
* @property {string} [path]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} AppConfig
|
||||
* @property {string} deviceId
|
||||
* @property {string} deviceName
|
||||
* @property {number} udpPort
|
||||
* @property {number} wsPort
|
||||
* @property {number} httpPort
|
||||
* @property {string} downloadDir
|
||||
* @property {boolean} autoAcceptFiles
|
||||
* @property {number} maxFileSize
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} TransferProgressEvent
|
||||
* @property {string} fileId
|
||||
* @property {number} progress
|
||||
* @property {number} transferredBytes
|
||||
* @property {number} totalBytes
|
||||
* @property {TransferStatus} status
|
||||
* @property {string} [fileName]
|
||||
* @property {string} [localPath]
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} CommandError
|
||||
* @property {string} code
|
||||
* @property {string} message
|
||||
*/
|
||||
|
||||
/** 事件名称 */
|
||||
export const EventNames = {
|
||||
DEVICE_FOUND: 'device_found',
|
||||
DEVICE_LOST: 'device_lost',
|
||||
MESSAGE_RECEIVED: 'message_received',
|
||||
FILE_RECEIVED: 'file_received',
|
||||
TRANSFER_PROGRESS: 'transfer_progress',
|
||||
WEBSOCKET_CONNECTED: 'websocket_connected',
|
||||
WEBSOCKET_DISCONNECTED: 'websocket_disconnected',
|
||||
MESSAGE_STATUS_UPDATED: 'message_status_updated',
|
||||
}
|
||||
@ -1,106 +0,0 @@
|
||||
/**
|
||||
* 类型定义模块
|
||||
* 定义应用中使用的所有 TypeScript 类型
|
||||
*/
|
||||
|
||||
/** 设备能力 */
|
||||
export type DeviceCapability = 'text' | 'image' | 'file'
|
||||
|
||||
/** 设备信息 */
|
||||
export interface DeviceInfo {
|
||||
deviceId: string
|
||||
deviceName: string
|
||||
ip: string
|
||||
wsPort: number
|
||||
httpPort: number
|
||||
online: boolean
|
||||
capabilities: DeviceCapability[]
|
||||
lastSeen: number
|
||||
}
|
||||
|
||||
/** 消息类型 */
|
||||
export type MessageType = 'text' | 'image' | 'file' | 'event' | 'ack' | 'ping' | 'pong'
|
||||
|
||||
/** 消息状态 */
|
||||
export type MessageStatus = 'pending' | 'sent' | 'delivered' | 'read' | 'failed'
|
||||
|
||||
/** 聊天消息 */
|
||||
export interface ChatMessage {
|
||||
id: string
|
||||
type: MessageType
|
||||
content: string
|
||||
from: string
|
||||
to: string
|
||||
timestamp: number
|
||||
status: MessageStatus
|
||||
}
|
||||
|
||||
/** 文件传输状态 */
|
||||
export type TransferStatus = 'pending' | 'transferring' | 'completed' | 'failed' | 'cancelled'
|
||||
|
||||
/** 文件传输信息 */
|
||||
export interface FileTransfer {
|
||||
fileId: string
|
||||
name: string
|
||||
size: number
|
||||
progress: number
|
||||
status: TransferStatus
|
||||
mimeType: string
|
||||
fromDevice: string
|
||||
toDevice: string
|
||||
localPath?: string
|
||||
createdAt: number
|
||||
completedAt?: number
|
||||
transferredBytes: number
|
||||
}
|
||||
|
||||
/** 文件元数据 */
|
||||
export interface FileMetadata {
|
||||
fileId: string
|
||||
name: string
|
||||
size: number
|
||||
mimeType: string
|
||||
thumbnail?: string
|
||||
path?: string // 文件路径
|
||||
}
|
||||
|
||||
/** 应用配置 */
|
||||
export interface AppConfig {
|
||||
deviceId: string
|
||||
deviceName: string
|
||||
udpPort: number
|
||||
wsPort: number
|
||||
httpPort: number
|
||||
downloadDir: string
|
||||
autoAcceptFiles: boolean
|
||||
maxFileSize: number
|
||||
}
|
||||
|
||||
/** 传输进度事件 */
|
||||
export interface TransferProgressEvent {
|
||||
fileId: string
|
||||
progress: number
|
||||
transferredBytes: number
|
||||
totalBytes: number
|
||||
status: TransferStatus
|
||||
fileName?: string // 文件名(接收方有)
|
||||
localPath?: string // 本地路径(接收方有)
|
||||
}
|
||||
|
||||
/** 命令错误 */
|
||||
export interface CommandError {
|
||||
code: string
|
||||
message: string
|
||||
}
|
||||
|
||||
/** 事件名称 */
|
||||
export const EventNames = {
|
||||
DEVICE_FOUND: 'device_found',
|
||||
DEVICE_LOST: 'device_lost',
|
||||
MESSAGE_RECEIVED: 'message_received',
|
||||
FILE_RECEIVED: 'file_received',
|
||||
TRANSFER_PROGRESS: 'transfer_progress',
|
||||
WEBSOCKET_CONNECTED: 'websocket_connected',
|
||||
WEBSOCKET_DISCONNECTED: 'websocket_disconnected',
|
||||
MESSAGE_STATUS_UPDATED: 'message_status_updated',
|
||||
} as const
|
||||
@ -1,7 +0,0 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
declare module '*.vue' {
|
||||
import type { DefineComponent } from 'vue'
|
||||
const component: DefineComponent<{}, {}, any>
|
||||
export default component
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "preserve",
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@/*": ["src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||