Files
Thing/src/lib/bindings.ts
T
2026-09-15 17:17:16 +08:00

909 lines
40 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// This file has been generated by Tauri Specta. Do not edit this file manually.
import { invoke as __TAURI_INVOKE } from "@tauri-apps/api/core";
/** Commands */
export const commands = {
/** 获取当前应用版本 */
appVersion: () => __TAURI_INVOKE<string>("app_version"),
/** 检查 Gitea 最新 release,返回版本对比与可用资产 */
updateCheck: () => __TAURI_INVOKE<UpdateCheckResult>("update_check"),
/**
* 更新应用本体(安装阶段)。下载由前端下载模块完成,本命令接收已下载的
* 安装包路径(便携版 thing_{v}_x64.exe / 安装版 thing_{v}_x64-setup.exe)。
* 便携版:copy 到临时目录 → update.bat 覆盖重启;
* 安装版:copy 到临时目录 → 提权静默安装 /S。
* 调用返回前会触发应用退出。
*/
updateInstall: (downloadedPath: string) => __TAURI_INVOKE<null>("update_install", { downloadedPath }),
/**
* 应用 ThingHK 内核更新:下载阶段已由下载模块完成,本命令仅做
* need_stop(等待前端停止监控内核并确认)→ 解压 → 替换。
* 进度通过 UPDATE_PROGRESS 事件上报,前端据 need_stop 弹出确认对话框。
*/
updateThinghkApply: (zipPath: string) => __TAURI_INVOKE<null>("update_thinghk_apply", { zipPath }),
/** 前端已停止监控内核,确认继续解压替换(唤醒 need_stop 等待) */
updateThinghkConfirm: () => __TAURI_INVOKE<null>("update_thinghk_confirm"),
/** 取消 ThingHK 内核更新(need_stop 等待阶段有效:唤醒 apply 以「已取消」返回,zip 保留便于重试) */
updateThinghkCancel: () => __TAURI_INVOKE<null>("update_thinghk_cancel"),
proxyActivateProfile: (id: string) => __TAURI_INVOKE<null>("proxy_activate_profile", { id }),
/** 应用内核更新:下载阶段已由下载模块完成,本方法仅做 need_stop → 解压 → 替换。 */
proxyApplyKernelUpdate: (zipPath: string) => __TAURI_INVOKE<KernelInfo>("proxy_apply_kernel_update", { zipPath }),
/** 取消内核下载/安装(设置取消标志,下载循环轮询后中止) */
proxyCancelKernelInstall: () => __TAURI_INVOKE<null>("proxy_cancel_kernel_install"),
proxyCheckKernelUpdate: () => __TAURI_INVOKE<KernelUpdateInfo>("proxy_check_kernel_update"),
proxyClearSystemProxy: () => __TAURI_INVOKE<null>("proxy_clear_system_proxy"),
proxyCloseConnection: (id: string) => __TAURI_INVOKE<null>("proxy_close_connection", { id }),
/**
* 前端确认 mihomo 已停止,唤醒等待中的安装流程继续解压替换。
* (下载阶段允许 mihomo 运行以便走系统代理,解压替换前必须停止 mihomo,否则 exe 被占用)
*/
proxyConfirmInstall: () => __TAURI_INVOKE<null>("proxy_confirm_install"),
proxyDeleteProfile: (id: string) => __TAURI_INVOKE<null>("proxy_delete_profile", { id }),
proxyGetSettings: () => __TAURI_INVOKE<ProxySettings>("proxy_get_settings"),
proxyGetSystemProxy: () => __TAURI_INVOKE<boolean>("proxy_get_system_proxy"),
proxyImportProfile: (url: string, name: string) => __TAURI_INVOKE<ProfileMeta>("proxy_import_profile", { url, name }),
proxyKernelInfo: () => __TAURI_INVOKE<KernelInfo>("proxy_kernel_info"),
proxyRestart: () => __TAURI_INVOKE<ProcessInfo>("proxy_restart"),
proxySaveSettings: (settings: ProxySettings) => __TAURI_INVOKE<null>("proxy_save_settings", { settings }),
proxySelectProxy: (group: string, name: string) => __TAURI_INVOKE<null>("proxy_select_proxy", { group, name }),
proxySetSystemProxy: () => __TAURI_INVOKE<null>("proxy_set_system_proxy"),
proxyStart: () => __TAURI_INVOKE<ProcessInfo>("proxy_start"),
proxyStatus: () => __TAURI_INVOKE<ProxyStatus>("proxy_status"),
proxyStop: () => __TAURI_INVOKE<null>("proxy_stop"),
proxyTraffic: () => __TAURI_INVOKE<TrafficSnapshot>("proxy_traffic"),
proxyTestDelay: (name: string, url: string | null, timeout: number | null) => __TAURI_INVOKE<number>("proxy_test_delay", { name, url, timeout }),
proxyUpdateProfile: (id: string) => __TAURI_INVOKE<ProfileMeta>("proxy_update_profile", { id }),
/** 读取快速面板设置(快捷键等) */
quickpanelGetSettings: () => __TAURI_INVOKE<QuickPanelSettings>("quickpanel_get_settings"),
/**
* 保存快速面板设置;快捷键变化时自动重新注册 + 预创建窗口,
* 索引目录变化时闲时自动重建索引。
*/
quickpanelSaveSettings: (settings: QuickPanelSettings) => __TAURI_INVOKE<null>("quickpanel_save_settings", { settings }),
/** 注册(或切换)快速面板全局快捷键 */
quickpanelRegisterShortcut: (shortcut: string) => __TAURI_INVOKE<null>("quickpanel_register_shortcut", { shortcut }),
/** 注销快速面板全局快捷键 */
quickpanelUnregisterShortcut: () => __TAURI_INVOKE<null>("quickpanel_unregister_shortcut"),
/** 手动触发显示快速面板(供 UI 按钮调用) */
quickpanelShowPopup: () => __TAURI_INVOKE<null>("quickpanel_show_popup"),
/** 隐藏快速面板 */
quickpanelHidePopup: () => __TAURI_INVOKE<null>("quickpanel_hide_popup"),
/** 显示已创建的弹窗窗口(前端 onMounted 后调用) */
quickpanelShowWindow: () => __TAURI_INVOKE<null>("quickpanel_show_window"),
/** 锁定屏幕(Windows: rundll32 user32.dll,LockWorkStationCREATE_NO_WINDOW 避免黑窗) */
quickpanelLockScreen: () => __TAURI_INVOKE<null>("quickpanel_lock_screen"),
/**
* 初始化文件索引数据库(应用启动时调用)。
* 若存在上次构建的索引(last_built_dirs 非空),自动恢复 notify 增量监听,
* 无需重建即可继续自动同步文件变更。
* 若从未构建过(首次运行),闲时自动建立索引,无需用户手动点"构建索引"。
*/
quickpanelInitFileIndex: () => __TAURI_INVOKE<null>("quickpanel_init_file_index"),
/** 构建文件索引(全量重建,阻塞操作建议在 spawn_blocking 调用) */
quickpanelBuildFileIndex: () => __TAURI_INVOKE<number>("quickpanel_build_file_index"),
/** 搜索文件索引(SQLite 查询移出主线程) */
quickpanelSearchFiles: (query: string, limit: number | null) => __TAURI_INVOKE<FileRecord[]>("quickpanel_search_files", { query, limit }),
/** 获取索引状态 */
quickpanelFileIndexStats: () => __TAURI_INVOKE<IndexStats>("quickpanel_file_index_stats"),
/** 扫描已安装应用(遍历开始菜单/桌面/磁盘,移出主线程) */
quickpanelScanApps: () => __TAURI_INVOKE<AppRecord[]>("quickpanel_scan_apps"),
/**
* 获取应用图标(data URL)。命中内存/磁盘缓存时零 Windows API 调用。
* 前端按需为可见项调用,避免一次性加载全部图标。
* 未命中缓存时 SHGetFileInfoW + 编码 + 落盘为阻塞操作,移出主线程。
*/
quickpanelGetAppIcon: (path: string) => __TAURI_INVOKE<string | null>("quickpanel_get_app_icon", { path }),
/** 清理图标缓存(磁盘 + 内存) */
quickpanelClearAppIconCache: () => __TAURI_INVOKE<null>("quickpanel_clear_app_icon_cache"),
/** 在资源管理器中显示文件(选中) */
quickpanelRevealInExplorer: (path: string) => __TAURI_INVOKE<null>("quickpanel_reveal_in_explorer", { path }),
/**
* 用系统默认程序打开文件/文件夹。
* - 目录:explorer.exe 直接打开(修复索引目录点击后未打开的问题)
* - 文件:ShellExecuteW open,无关联应用时自动 fallback 到「打开方式」对话框(verb: openas
*/
quickpanelOpenFile: (path: string) => __TAURI_INVOKE<null>("quickpanel_open_file", { path }),
/** 获取 Windows 常用快捷位置(hosts、回收站、此电脑、用户目录、系统管理工具等) */
quickpanelGetSpecialLocations: () => __TAURI_INVOKE<SpecialLocation[]>("quickpanel_get_special_locations"),
/** 打开快捷位置(kind: file | shell | cmd */
quickpanelOpenSpecial: (kind: string, target: string, args: string[]) => __TAURI_INVOKE<null>("quickpanel_open_special", { kind, target, args }),
/** 删除文件(移到回收站,PowerShell 阻塞等待移出主线程) */
quickpanelDeleteFile: (path: string) => __TAURI_INVOKE<null>("quickpanel_delete_file", { path }),
/**
* 运行自定义命令(执行可执行文件 + 参数)
* .lnk 快捷方式不能直接 spawnos error 193),需通过 cmd /C 启动
*/
quickpanelRunCustomCommand: (command: string, args: string[]) => __TAURI_INVOKE<null>("quickpanel_run_custom_command", { command, args }),
/**
* 运行系统命令(不设置 CREATE_NO_WINDOW,使 cmd/powershell/regedit 等显示自身窗口)
* 适用于内置系统工具:regedit、shutdown、cmd、powershell、taskmgr 等。
* - 控制台类交互程序(cmd/powershell/pwsh)额外设置 CREATE_NEW_CONSOLE
* 否则从 GUI 宿主启动时无可见控制台窗口(表现为"点击没反应")。
* - .msc 控制台文件(如 devmgmt.msc)不可被 CreateProcess 直接执行,
* 改由 mmc 打开(路径解析到 System32,不受当前工作目录影响)。
*/
quickpanelRunSystemCommand: (command: string, args: string[]) => __TAURI_INVOKE<null>("quickpanel_run_system_command", { command, args }),
/** 列出目录下的压缩包文件(供批量解压面板使用)。 */
quickpanelListArchives: (dir: string) => __TAURI_INVOKE<ArchiveInfo[]>("quickpanel_list_archives", { dir }),
/** 列出目录下的全部条目(供批量重命名/删除面板使用,不含子目录递归)。 */
quickpanelListDir: (dir: string) => __TAURI_INVOKE<FileEntry[]>("quickpanel_list_dir", { dir }),
/**
* 批量解压。`files` 为压缩包路径列表,`dest_dir` 为目标目录,
* `password` 为统一解压密码(可空),`into_subfolder` 是否解压到同名子文件夹。
* 每完成一个文件通过 `quickpanel-extract-progress` 事件推送进度。
*/
quickpanelBatchExtract: (files: string[], destDir: string, password: string | null, intoSubfolder: boolean) => __TAURI_INVOKE<ExtractResult[]>("quickpanel_batch_extract", { files, destDir, password, intoSubfolder }),
/**
* 正则批量重命名预览:对每个文件名应用 `pattern → replacement`
* 仅返回有匹配的文件,`newName` 为替换结果。
*/
quickpanelPreviewRename: (files: string[], pattern: string, replacement: string) => __TAURI_INVOKE<RenamePreview[]>("quickpanel_preview_rename", { files, pattern, replacement }),
/** 执行重命名。同一目录下若目标已存在则跳过该项。 */
quickpanelApplyRename: (items: RenameItem[]) => __TAURI_INVOKE<RenameResult[]>("quickpanel_apply_rename", { items }),
/**
* 批量删除文件/目录。`force=false` 时移动至回收站;`force=true` 时先递归清除
* 只读属性再永久删除(可绕过只读/部分占用导致的删除失败,但被其他进程真正
* 锁定的文件仍会失败并返回原因)。
*/
quickpanelDeleteFiles: (paths: string[], force: boolean) => __TAURI_INVOKE<DeleteResult[]>("quickpanel_delete_files", { paths, force }),
/**
* 显示主窗口并强制置为前台。
* Tauri 的 set_focus 在 Windows 上受前台锁定限制,主窗口被其他应用遮挡时无法到前台;
* 改用原生 SetForegroundWindow + BringWindowToTop(模拟 Alt 键重置前台锁定)。
*/
quickpanelFocusMainWindow: () => __TAURI_INVOKE<null>("quickpanel_focus_main_window"),
clipboardGetHistory: (limit: number | null, offset: number | null, kind: string | null) => __TAURI_INVOKE<HistoryPage>("clipboard_get_history", { limit, offset, kind }),
clipboardGetPinned: () => __TAURI_INVOKE<ClipboardItem[]>("clipboard_get_pinned"),
clipboardSearch: (query: string, limit: number | null, offset: number | null) => __TAURI_INVOKE<HistoryPage>("clipboard_search", { query, limit, offset }),
clipboardGetItem: (id: number) => __TAURI_INVOKE<({
/** 文本内容 / 文件列表 JSON */
content: string | null,
/** 图片 PNG base64(仅 image 类型) */
imageBase64: string | null,
}) & (ClipboardItem) | null>("clipboard_get_item", { id }),
/** 获取图片缩略图 PNG base64(弹窗悬停预览用,避免加载全尺寸图片) */
clipboardGetThumb: (id: number) => __TAURI_INVOKE<string | null>("clipboard_get_thumb", { id }),
clipboardSetPinned: (id: number, pinned: boolean) => __TAURI_INVOKE<boolean>("clipboard_set_pinned", { id, pinned }),
clipboardDelete: (id: number) => __TAURI_INVOKE<boolean>("clipboard_delete", { id }),
clipboardClear: () => __TAURI_INVOKE<boolean>("clipboard_clear"),
clipboardCopyBack: (id: number) => __TAURI_INVOKE<null>("clipboard_copy_back", { id }),
clipboardCount: () => __TAURI_INVOKE<number>("clipboard_count"),
clipboardGetSettings: () => __TAURI_INVOKE<ClipboardSettings>("clipboard_get_settings"),
clipboardSaveSettings: (settings: ClipboardSettings) => __TAURI_INVOKE<null>("clipboard_save_settings", { settings }),
clipboardStatus: () => __TAURI_INVOKE<ClipboardStatus>("clipboard_status"),
clipboardStart: () => __TAURI_INVOKE<null>("clipboard_start"),
clipboardStop: () => __TAURI_INVOKE<null>("clipboard_stop"),
/** 注册(或切换)快捷弹窗全局快捷键 */
clipboardRegisterShortcut: (shortcut: string) => __TAURI_INVOKE<null>("clipboard_register_shortcut", { shortcut }),
/** 注销快捷弹窗全局快捷键 */
clipboardUnregisterShortcut: () => __TAURI_INVOKE<null>("clipboard_unregister_shortcut"),
/** 手动触发显示快捷弹窗(供 UI 按钮调用) */
clipboardShowPopup: () => __TAURI_INVOKE<null>("clipboard_show_popup"),
/** 隐藏快捷弹窗 */
clipboardHidePopup: () => __TAURI_INVOKE<null>("clipboard_hide_popup"),
/** 显示已创建的弹窗窗口(前端 onMounted 后调用) */
clipboardShowWindow: () => __TAURI_INVOKE<null>("clipboard_show_window"),
/** 隐藏弹窗并模拟 Ctrl+V 粘贴到原窗口 */
clipboardPasteToTarget: () => __TAURI_INVOKE<null>("clipboard_paste_to_target"),
/** 在弹窗旁显示独立预览窗口(悬停/键盘选中时调用) */
clipboardShowPreview: (id: number) => __TAURI_INVOKE<null>("clipboard_show_preview", { id }),
/** 隐藏独立预览窗口 */
clipboardHidePreview: () => __TAURI_INVOKE<null>("clipboard_hide_preview"),
/**
* 按内容自适应调整预览窗大小(逻辑像素)。前端加载内容(文本测高、图片按宽高比)后调用,
* 窗口贴合内容消除留白;后端按弹窗所在屏工作区钳制并重新对齐弹窗。
* allow_flip:初始落位为 true(优先侧放不下可换侧);放大/还原为 false(保持原侧)。
*/
clipboardResizePreview: (width: number | null, height: number | null, allowFlip: boolean) => __TAURI_INVOKE<null>("clipboard_resize_preview", { width, height, allowFlip }),
/**
* 显示已就绪的预览窗口。前端完成内容加载与 resize 后调用,窗口以最终尺寸出现,
* 消除"先以上次尺寸(可能是放大态大窗)显示再缩回"的闪烁。
*/
clipboardRevealPreview: () => __TAURI_INVOKE<null>("clipboard_reveal_preview"),
/**
* 预览窗交互锁定:前端预览窗收到 mousedown(放大/缩小、复制、选择文本)时调用。
* 此后弹窗+预览不因失焦/鼠标离开而关闭,仅当点击外部或弹窗重新聚焦时退出锁定。
*/
clipboardPreviewInteracted: () => __TAURI_INVOKE<null>("clipboard_preview_interacted"),
/** 获取所有任务 */
downloaderGetTasks: () => __TAURI_INVOKE<DownloadTask[]>("downloader_get_tasks"),
/** 检查 URL 重复性并探测文件信息(添加下载前调用) */
downloaderCheckUrl: (url: string, dir: string | null, headers: { [key in string]: string } | null) => __TAURI_INVOKE<CheckUrlResult>("downloader_check_url", { url, dir, headers }),
/** 添加下载任务 */
downloaderAddTask: (url: string, filename: string | null, dir: string | null, headers: { [key in string]: string } | null, autoRename: boolean | null, onlyFiles: number[] | null) => __TAURI_INVOKE<string>("downloader_add_task", { url, filename, dir, headers, autoRename, onlyFiles }),
/** 暂停任务 */
downloaderPauseTask: (id: string) => __TAURI_INVOKE<null>("downloader_pause_task", { id }),
/** 恢复任务 */
downloaderResumeTask: (id: string) => __TAURI_INVOKE<null>("downloader_resume_task", { id }),
/** 取消任务(置为已取消,清空进度并删除下载文件,但保留记录) */
downloaderCancelTask: (id: string) => __TAURI_INVOKE<null>("downloader_cancel_task", { id }),
/** 重新下载已取消/出错的任务 */
downloaderRedownload: (id: string) => __TAURI_INVOKE<null>("downloader_redownload", { id }),
/** 移除任务 */
downloaderRemoveTask: (id: string, deleteFiles: boolean | null) => __TAURI_INVOKE<null>("downloader_remove_task", { id, deleteFiles }),
/** 获取设置 */
downloaderGetSettings: () => __TAURI_INVOKE<DownloaderSettings>("downloader_get_settings"),
/** 保存设置 */
downloaderSaveSettings: (settings: DownloaderSettings) => __TAURI_INVOKE<null>("downloader_save_settings", { settings }),
/** 用系统资源管理器打开目录 */
downloaderOpenDir: (path: string) => __TAURI_INVOKE<null>("downloader_open_dir", { path }),
/** 用系统默认浏览器打开 URL */
downloaderOpenUrl: (url: string) => __TAURI_INVOKE<null>("downloader_open_url", { url }),
/**
* 将指定 label 的下载窗口显示并强制置为前台。
* Tauri 的 set_focus 在 Windows 上受前台锁定限制(尤其下载窗口由后台进程创建、
* 或创建到非主显示器时更明显),改用原生 SetForegroundWindow + BringWindowToTop
* (模拟 Alt 键重置前台锁定),保证开始/完成下载时窗口能正确定位到前台。
*/
downloaderFocusWindow: (label: string) => __TAURI_INVOKE<null>("downloader_focus_window", { label }),
/** 解析磁力链 / .torrent 文件,返回种子信息(名称 / infohash / 文件列表),供前端做文件勾选 */
downloaderInspect: (input: string) => __TAURI_INVOKE<TorrentInfo>("downloader_inspect", { input }),
/** 磁力任务:元数据解析成功后,用户勾选文件并确认开始下载 */
downloaderSelectBtFiles: (id: string, onlyFiles: number[]) => __TAURI_INVOKE<null>("downloader_select_bt_files", { id, onlyFiles }),
/**
* 查询环境状态(Python / musicdl / FFmpeg / 桥接进程),设置页「环境检查」面板调用。
* 异步命令:子进程探测在阻塞线程池执行,避免冻结主线程/UI。
*/
musicEnvStatus: () => __TAURI_INVOKE<MusicEnvStatus>("music_env_status"),
/** 安装便携 Python + musicdl(幂等),全程推送 music-runtime-install-progress 事件 */
musicInstallRuntime: () => __TAURI_INVOKE<MusicEnvStatus>("music_install_runtime"),
/** 取消便携运行时安装/下载 */
musicCancelRuntimeInstall: () => __TAURI_INVOKE<null>("music_cancel_runtime_install"),
/** 停止桥接进程 */
musicStopBridge: () => __TAURI_INVOKE<null>("music_stop_bridge"),
/** 读取音乐模块设置 */
musicGetSettings: () => __TAURI_INVOKE<MusicSettings>("music_get_settings"),
/**
* 保存音乐模块设置(立即生效)
*
* 飞牛音乐**连接相关字段一律以磁盘为准**,不接受前端传值:
* 连接列表 / 激活连接 / 旧版单连接字段只由 `feiniu_save_connection`、
* `feiniu_activate_connection`、`feiniu_delete_connection`、`feiniu_login`
* 等专用命令维护。
*
* 原因:前端 `musicStore` 只在 init 时读一次整份设置并长期复用快照,
* 若允许它整份回写,删除连接后任意一次设置保存(哪怕是切页触发的)
* 都会把已删除的连接从旧快照里写回来。
*/
musicSaveSettings: (settings: MusicSettings) => __TAURI_INVOKE<null>("music_save_settings", { settings }),
/** 禁用指定窗口(按 label 查找)的显示/隐藏过渡动画,消除覆盖层出现/消失时的缩放动画 */
screenshotDisableTransitions: (label: string) => __TAURI_INVOKE<null>("screenshot_disable_transitions", { label }),
/** 一次 IPC 完成指定窗口的显示与聚焦(截图覆盖层显示关键路径,减少串行往返) */
screenshotShowOverlay: (label: string) => __TAURI_INVOKE<null>("screenshot_show_overlay", { label }),
/** 注册(或切换)截图全局快捷键。传入空字符串则禁用快捷键。 */
screenshotRegisterShortcut: (shortcut: string) => __TAURI_INVOKE<null>("screenshot_register_shortcut", { shortcut }),
/** 注销截图全局快捷键 */
screenshotUnregisterShortcut: () => __TAURI_INVOKE<null>("screenshot_unregister_shortcut"),
/**
* 注册(或切换)贴图全局快捷键。传入空字符串则禁用快捷键。
* 按下时 emit 'screenshot-pin-shortcut',由前端切换贴图窗口显示/隐藏。
*/
screenshotRegisterPinShortcut: (shortcut: string) => __TAURI_INVOKE<null>("screenshot_register_pin_shortcut", { shortcut }),
/** 注销贴图全局快捷键 */
screenshotUnregisterPinShortcut: () => __TAURI_INVOKE<null>("screenshot_unregister_pin_shortcut"),
/**
* 捕获整个虚拟屏(多显示器拼接)存入静态,不做 PNG 编码。
* 同时返回捕获时刻的光标物理坐标(覆盖层据此做初始窗口拾取,省一次 IPC 往返)。
*/
screenshotCaptureFullscreen: () => __TAURI_INVOKE<CaptureStart>("screenshot_capture_fullscreen"),
/** 全屏捕获编码为 PNG base64 并清除(全屏截图直接进编辑器) */
screenshotFullscreenPng: () => __TAURI_INVOKE<CaptureData>("screenshot_fullscreen_png"),
/** 清除静态全屏捕获(覆盖层关闭/取消时释放内存) */
screenshotClearFullscreen: () => __TAURI_INVOKE<null>("screenshot_clear_fullscreen"),
/** 按物理像素坐标裁剪已存储的全屏捕获 */
screenshotCropStored: (x: number, y: number, w: number, h: number) => __TAURI_INVOKE<CaptureData>("screenshot_crop_stored", { x, y, w, h }),
/** 裁剪已存储的全屏捕获并直接写入剪贴板(一次 IPC 完成"裁剪+复制" */
screenshotCropCopyStored: (x: number, y: number, w: number, h: number) => __TAURI_INVOKE<CaptureData>("screenshot_crop_copy_stored", { x, y, w, h }),
/**
* 枚举可拾取的顶层窗口(Z 序顶→底,排除本进程/不可见/工具窗口)。
* 前端在截图开始时缓存列表,鼠标移动时在 JS 侧本地命中测试,消除逐帧 IPC 往返。
*/
screenshotPickList: () => __TAURI_INVOKE<WindowInfo[]>("screenshot_pick_list"),
/** 获取当前鼠标物理屏幕坐标(贴图窗口拖动跟随等场景使用) */
screenshotCursorPos: () => __TAURI_INVOKE<[number, number]>("screenshot_cursor_pos"),
/** 枚举所有可见顶层窗口 */
screenshotEnumWindows: () => __TAURI_INVOKE<WindowInfo[]>("screenshot_enum_windows"),
/** 按 hwnd 捕获指定窗口 */
screenshotCaptureWindow: (hwnd: number) => __TAURI_INVOKE<CaptureData>("screenshot_capture_window", { hwnd }),
/**
* 滚动截图:从窗口当前滚动位置向下拼接到底部,返回超长 PNG。
* `region` 为 Some 时仅在框选区域(屏幕物理坐标)内捕捉,宽 = 选区宽;
* 为 None 时捕捉整个客户区。结束后会把窗口滚回起始位置,不打扰用户。
*/
screenshotScrollCapture: (hwnd: number, region: {
x: number,
y: number,
width: number,
height: number,
} | null) => __TAURI_INVOKE<CaptureData>("screenshot_scroll_capture", { hwnd, region }),
/** 取消滚动截图会话(不导出)。 */
screenshotScrollCancel: () => __TAURI_INVOKE<null>("screenshot_scroll_cancel"),
/** 结束滚动截图会话并导出结果。 */
screenshotScrollFinish: () => __TAURI_INVOKE<null>("screenshot_scroll_finish"),
/**
* 启动滚动截图会话(后台线程持续捕捉拼接,实时推进度事件)。
* `auto = true` 为自动滚动(线程主动下滚拼到底部);`false` 为手动(等用户滚动窗口)。
*/
screenshotScrollStart: (hwnd: number, region: {
x: number,
y: number,
width: number,
height: number,
} | null, auto: boolean) => __TAURI_INVOKE<null>("screenshot_scroll_start", { hwnd, region, auto }),
/**
* 滚动模式遮罩挖孔:在截图覆盖层窗口上挖出选区带的真孔(region = None 时复位整窗)。
*
* Chromium 系浏览器(Edge/Chrome)的窗口遮挡检测会把被完全覆盖的窗口标记为
* occluded 并暂停渲染——滚动截图时覆盖层铺满全屏,网页"看起来完全不滚动"。
* 挖孔后目标窗口仅部分被覆盖,恢复渲染与滚轮响应(详见 capture::set_scroll_hole)。
* 进入滚动模式时带选区调用,会话结束/新一轮截图开始时必须传 None 复位。
*/
screenshotSetScrollHole: (region: {
x: number,
y: number,
width: number,
height: number,
} | null) => __TAURI_INVOKE<null>("screenshot_set_scroll_hole", { region }),
/** 将 PNG base64 写入系统剪贴板(转 CF_DIB */
screenshotCopyImage: (pngBase64: string) => __TAURI_INVOKE<null>("screenshot_copy_image", { pngBase64 }),
/** 将 PNG base64 写入文件 */
screenshotSavePng: (pngBase64: string, path: string) => __TAURI_INVOKE<null>("screenshot_save_png", { pngBase64, path }),
/** 将完整 PNG 写入历史缓存目录,返回文件路径 */
screenshotSaveCache: (pngBase64: string) => __TAURI_INVOKE<string>("screenshot_save_cache", { pngBase64 }),
/** 从历史缓存目录读取 PNG 并返回 base64(点击历史项复制/保存时一次性加载,不常驻内存) */
screenshotLoadCache: (path: string) => __TAURI_INVOKE<string>("screenshot_load_cache", { path }),
/** 删除历史缓存文件(历史项移除/清空时调用,静默忽略不存在文件) */
screenshotDeleteCache: (path: string) => __TAURI_INVOKE<null>("screenshot_delete_cache", { path }),
};
/* Types */
export type AppRecord = {
name: string,
path: string,
};
export type ArchiveInfo = {
name: string,
path: string,
size: number,
};
/** BT 种子内文件条目(多文件任务用;阶段1下载全部文件,但保留列表供 UI 展示) */
export type BtFileInfo = {
/** 文件在种子内的索引 */
index: number,
/** 相对种子根目录的路径(如 "sub/file.mkv" */
path: string,
/** 文件大小(字节) */
size: number,
};
/** 前端可见的捕获数据 */
export type CaptureData = {
pngBase64: string,
width: number,
height: number,
};
/** 截图启动信息:捕获时刻的光标物理坐标(覆盖层据此做初始窗口拾取,省一次 IPC 往返) */
export type CaptureStart = {
cursorX: number,
cursorY: number,
};
/** check_url 命令返回的结果 */
export type CheckUrlResult = {
/** 探测是否成功 */
ok: boolean,
/** 错误信息(探测失败时) */
error: string | null,
/** 文件名(探测成功时) */
filename: string | null,
/** 文件大小(字节) */
totalSize: number | null,
/** 是否支持断点续传 */
supportsResume: boolean,
/** 重复类型 */
duplicate: DuplicateKind,
/** 已存在的任务信息 */
existing: ExistingTaskInfo | null,
};
/** 列表项(不含大字段,用于历史/搜索结果) */
export type ClipboardItem = {
id: number,
kind: string,
preview: string,
size: number,
pinned: boolean,
pinnedOrder: number | null,
createdAt: number,
};
/** 详情(含文本内容或图片 base64) */
export type ClipboardItemDetail = {
/** 文本内容 / 文件列表 JSON */
content: string | null,
/** 图片 PNG base64(仅 image 类型) */
imageBase64: string | null,
} & ClipboardItem;
/** 剪贴板设置(持久化到 clipboard/settings.json */
export type ClipboardSettings = {
/** 监听是否启用 */
enabled?: boolean,
/** 非固定历史最大条数 */
maxItems?: number,
/** 图片大小上限(KB),0 表示不限 */
maxImageKb?: number,
recordText?: boolean,
recordImage?: boolean,
recordFiles?: boolean,
/** 去重(相同内容更新时间而非新增) */
dedup?: boolean,
/** 快捷弹窗全局快捷键(如 "Alt+V",空字符串表示禁用) */
shortcut?: string,
};
export type ClipboardStatus = {
running: boolean,
count: number,
};
/** 自定义命令 */
export type CustomCommand = {
id: string,
title: string,
command: string,
args?: string[],
};
/** 批量删除单个条目的结果。 */
export type DeleteResult = {
name: string,
path: string,
ok: boolean,
error: string,
};
/** 下载任务 */
export type DownloadTask = {
/** 任务 ID(自增 hex 字符串) */
id: string,
/** 下载地址(HTTP URL 或磁力链接) */
url: string,
/** 文件名(HTTP:目标文件名;BT:种子名称) */
filename: string,
/** 保存目录(绝对路径) */
dir: string,
/** 协议类型 */
protocol?: TaskProtocol,
/** BT 种子 infohash(协议=BitTorrent 时存在) */
infoHash?: string | null,
/** BT 种子内文件列表(协议=BitTorrent 时存在) */
btFiles?: BtFileInfo[],
/** BT 元数据是否已解析就绪(异步添加时:后台解析完成前为 false,调度器跳过) */
btMetadataReady?: boolean,
/** 状态 */
status: TaskStatus,
/** 文件总大小(字节),0=未知 */
totalSize: number,
/** 已下载字节 */
completedSize: number,
/** 当前下载速度 bytes/s */
speed: number,
/** 服务器是否支持断点续传 */
supportsResume: boolean,
/** 分段信息 */
segments?: Segment[],
/** 错误信息 */
error?: string | null,
/** 创建时间(Unix 时间戳,毫秒) */
createdAt: number,
/** 自定义请求头(Cookie / Referer 等) */
headers?: { [key in string]: string },
};
/** 下载设置 */
export type DownloaderSettings = {
/** 下载目录 */
downloadDir?: string,
/** 最大同时下载数 */
maxConcurrent?: number,
/** 单任务最大连接数(多线程分段数) */
maxConnections?: number,
/** 断点续传 */
continueDownload?: boolean,
/** 全局速度限制 KB/s0=不限) */
globalSpeedLimit?: number,
/** 扩展 HTTP API 端口 */
extensionPort?: number,
/** 扩展认证密钥(空=不认证) */
extensionSecret?: string,
/** 删除任务时是否同时删除已下载的文件 */
deleteFilesOnRemove?: boolean,
/** 添加下载前检查重复(URL 或文件名重复时询问) */
checkDuplicate?: boolean,
/** 下载是否使用代理:true=尊重系统代理(mihomo 开启系统代理时经其转发),false=强制直连 */
useProxy?: boolean,
/** BitTorrent 上传限速 KB/s0=不限) */
btUploadLimitKb?: number,
/** BitTorrent 下载完成后是否继续做种上传(false=下载完即停止上传) */
btSeedAfterDownload?: boolean,
/** BitTorrent 监听端口(0=自动选择) */
btListenPort?: number,
/** BitTorrent 使用代理下载:开启后自动使用代理模块(mihomo)的 SOCKS5 端口;代理不可用时降级直连 */
btUseProxy?: boolean,
};
/** 重复类型 */
export type DuplicateKind =
/** 无重复 */
"none" |
/** URL 重复(已有相同链接的任务) */
"url" |
/** 文件名重复(已有同名任务下载到同一目录) */
"filename" |
/** 磁盘文件已存在 */
"fileExists";
/** 已存在的任务信息(用于前端展示) */
export type ExistingTaskInfo = {
id: string,
filename: string,
status: TaskStatus,
};
export type ExtractResult = {
name: string,
path: string,
ok: boolean,
error: string,
};
/** 一条飞牛音乐连接(持久化在 `MusicSettings`)。 */
export type FeiniuConnection = {
id: string,
name: string,
/** "lan" | "frp" | "fnconnect"fnconnect 预留) */
kind: string,
/** 服务器地址(http://192.168.x.x:5666 或 https://域名) */
baseUrl: string,
username: string,
token: string,
deviceId: string,
accessCode: string,
/** https 遇到自签证书时忽略校验 */
insecure: boolean,
/** fnconnect 连接的 fnId(如 fnos.net/<id> 或裸 id */
fnId?: string,
/**
* 是否经由 FnConnect 中继链路(`<fnId>.fnos.net`)。
* 中继要求所有请求携带 `Cookie: mode=relay`,否则网关 302 回登录页。
*/
relay?: boolean,
};
export type FileEntry = {
name: string,
path: string,
isDir: boolean,
size: number,
};
/** 单个文件记录(返回给前端) */
export type FileRecord = {
path: string,
name: string,
ext: string,
size: number,
isDir: boolean,
};
/** 历史查询结果(含总数,用于分页) */
export type HistoryPage = {
items: ClipboardItem[],
total: number,
};
/** 索引状态(返回给前端) */
export type IndexStats = {
total: number,
lastBuiltAt: number,
lastBuiltDirs: string[],
};
export type KernelInfo = {
path: string,
exists: boolean,
version: string | null,
};
export type KernelUpdateInfo = {
currentVersion: string | null,
latestVersion: string,
downloadUrl: string,
hasUpdate: boolean,
};
/** 环境状态(返回前端,设置页「环境检查」面板展示) */
export type MusicEnvStatus = {
/** 系统 Python 版本(如 "3.14.5"),无则 None */
python: string | null,
/** python 来源:"system" | "bundled" | "none" */
pythonSource: string,
/** 便携 Python 可执行文件路径(未安装则 None) */
bundledPython: string | null,
/** musicdl 是否可导入 */
musicdlInstalled: boolean,
/** musicdl 版本 */
musicdlVersion: string | null,
/** 本应用锁定的 musicdl 版本(`MUSICDL_VERSION`):是否过期、更新到哪个版本都以它为准 */
musicdlExpected: string,
/**
* 已装 musicdl 是否与锁定版本不一致。
* 未安装时恒为 false(那是「安装」引导的事,不是「更新」)。
*/
musicdlOutdated: boolean,
/** FFmpeg 是否可用(部分音源需要,非必需) */
ffmpeg: string | null,
/** 桥接进程是否在运行 */
bridgeRunning: boolean,
/** 运行时目录({app_data_dir}/music */
runtimeDir: string,
};
/** 音乐模块设置(settings.json 持久化;变更即时生效) */
export type MusicSettings = {
/** 下载保存目录 */
savedir: string,
/** 搜索源(musicdl 客户端名,如 NeteaseMusicClient */
sources: string[],
/** 下载时同步保存歌词 */
lyricDownload: boolean,
/** 下载时同步保存封面 */
coverDownload: boolean,
/** 搜索/下载请求是否走代理模块(mihomo mixed 端口) */
useProxy: boolean,
/** 最大并发下载数 */
maxConcurrent: number,
/** 下载引擎:"musicdl" | "rust"P2 生效) */
downloadEngine: string,
/** 下载时是否弹窗选择音质(默认关;开启后点下载弹出所选歌曲档位并集选择) */
selectQualityOnDownload: boolean,
/** 下载时默认音质:"" 表示最高;否则为搜索音质档位 label(如 "无损"、"320K" */
defaultDownloadQuality: string,
/**
* QQ 音乐 Cookie(可选):用于解析需要登录的歌单(含自己的隐私歌单)与 VIP 音质。
* 传给 musicdl 的 default_search/parse/download_cookies;空=游客身份。
*/
qqCookie?: string,
/** 飞牛音乐(NAS)连接:服务器地址(如 http://192.168.1.10:5666,空=未配置) */
feiniuBaseUrl?: string,
/** 飞牛音乐登录 token(登录成功后保存) */
feiniuToken?: string,
/** 飞牛音乐登录账号(展示 + 重新登录回填用) */
feiniuUsername?: string,
/** 飞牛音乐设备 ID(32 位 hex,登录签名用,一次生成复用) */
feiniuDeviceId?: string,
/** 飞牛音乐访问安全码(可选;仅需访问码的库才填,LAN 通常为空) */
feiniuAccessCode?: string,
/** 飞牛音乐连接列表(多连接:局域网 / FnConnect */
feiniuConnections?: FeiniuConnection[],
/** 当前激活连接的 id */
feiniuActiveId?: string,
/** 本地曲库扫描目录(默认含音乐下载 savedir) */
feiniuLocalDirs?: string[],
/** 播放缓存开关 */
feiniuCacheEnabled?: boolean,
/** 缓存上限(GB */
feiniuCacheMaxGb?: number,
/** 播放模式:"stream" 直连流式 | "cache" 缓存后播放 */
feiniuPlayMode?: string,
/** 飞牛曲库目标目录(NAS 绝对路径,如 vol1/1000/Music;上传到飞牛用) */
feiniuLibraryNasPath?: string,
/** 下载完成后自动上传到飞牛曲库 */
feiniuAutoUpload?: boolean,
};
/** 进程信息(返回给前端) */
export type ProcessInfo = {
id: string,
name: string,
status: ProcessStatus,
pid: number | null,
restartCount: number,
};
/** 进程状态枚举 */
export type ProcessStatus = "running" | "stopped" | "crashed" | "starting";
export type ProfileMeta = {
id?: string,
name?: string,
url?: string,
addedAt?: string,
updatedAt?: string,
size?: number | null,
};
export type ProxySettings = {
mixedPort?: number,
externalController?: string,
secret?: string,
mode?: string,
logLevel?: string,
allowLan?: boolean,
systemProxy?: boolean,
autoStart?: boolean,
autoSystemProxy?: boolean,
currentProfile?: string | null,
profiles?: ProfileMeta[],
autoSwitchEnabled?: boolean,
autoSwitchInterval?: number,
autoSwitchGroup?: string,
autoSwitchRegion?: string,
/**
* 内核下载镜像源列表(前缀拼接到 GitHub URL 前)。
* 空字符串 = 直连 GitHub,其余为镜像站前缀(含尾斜杠)。
*/
kernelMirrors?: string[],
};
export type ProxyStatus = {
running: boolean,
pid: number | null,
restartCount: number,
};
/** 快速面板设置 */
export type QuickPanelSettings = {
/** 全局快捷键(如 "Alt+Space"),空字符串表示不注册。 */
shortcut?: string,
/** 唤起位置:center(鼠标所在显示器中央)| cursor(鼠标位置) */
popupPosition?: string,
/** 默认搜索引擎:google | bing | baidu */
searchEngine?: string,
/** 文件索引目录列表(空列表表示使用默认:桌面/文档/下载) */
indexDirs?: string[],
/** 自定义命令列表 */
customCommands?: CustomCommand[],
};
export type RenameItem = {
path: string,
oldName: string,
newName: string,
};
export type RenamePreview = {
path: string,
oldName: string,
newName: string,
error: string,
};
export type RenameResult = {
oldName: string,
newName: string,
ok: boolean,
error: string,
};
export type ScreenRect = {
x: number,
y: number,
width: number,
height: number,
};
/** 滚动截图区域(屏幕物理像素坐标,通常为覆盖层框选区平移到屏幕) */
export type ScrollRegion = {
x: number,
y: number,
width: number,
height: number,
};
/** 下载分段(多线程 Range 下载 / 断点续传用) */
export type Segment = {
/** 分段索引 */
index: number,
/** 起始字节(含) */
start: number,
/** 结束字节(含) */
end: number,
/** 已下载字节 */
completed: number,
};
/** 快捷位置条目 */
export type SpecialLocation = {
id: string,
title: string,
subtitle: string,
keywords: string[],
/** file: 真实文件/文件夹路径;shell: explorer 打开的 shell 路径;cmd: 可执行命令 */
kind: string,
target: string,
args: string[],
};
/** 任务下载协议类型 */
export type TaskProtocol =
/** HTTP/HTTPS 直链 */
"http" |
/** BitTorrent(磁力链 / .torrent 文件) */
"bittorrent";
/** 任务状态 */
export type TaskStatus =
/** 排队等待(并发数已满) */
"queued" |
/** 下载中 */
"active" |
/** 已暂停 */
"paused" |
/** 已完成 */
"complete" |
/** 错误 */
"error" |
/** 已取消(用户取消:进度与文件已清除,仅保留记录,只能再次下载) */
"cancelled";
/** 种子信息(inspect 解析结果,供命令返回给前端做文件勾选) */
export type TorrentInfo = {
/** 种子名称 */
name: string,
/** infohashhex 小写字符串) */
infoHash: string,
/** 种子内全部文件总大小(字节) */
totalSize: number,
/** 种子内文件列表 */
files: BtFileInfo[],
};
/** 实时流量快照(由 /connections 的会话总量差分得出实时速率) */
export type TrafficSnapshot = {
/** 本次会话累计下载字节数 */
downloadTotal: number,
/** 本次会话累计上传字节数 */
uploadTotal: number,
/** 实时下载速率(字节/秒) */
downloadSpeed: number,
/** 实时上传速率(字节/秒) */
uploadSpeed: number,
/** 当前活跃连接数 */
activeConnections: number,
};
/** release 中的一个资产 */
export type UpdateAsset = {
name: string,
size: number,
browserDownloadUrl: string,
};
/** 检查更新的结果 */
export type UpdateCheckResult = {
currentVersion: string,
latestVersion: string,
hasUpdate: boolean,
/** portable | installed */
installType: string,
releaseName: string,
releaseBody: string,
assets: UpdateAsset[],
};
/** 窗口信息(窗口拾取 / 枚举) */
export type WindowInfo = {
hwnd: number,
title: string,
rect: ScreenRect,
/** DWM 扩展边框矩形(视觉边界,去掉最大化窗口的隐形缩放边框),命中测试用 rect,高亮用 visual_rect */
visualRect: ScreenRect | null,
};