ahaoboy/rcm-tauri

GitHub: ahaoboy/rcm-tauri

基于 Tauri 和 React 构建的 Windows 右键上下文菜单自定义工具,支持 JavaScript 脚本编排命令、远程配置同步及 CSS 主题定制。

Stars: 8 | Forks: 0

# RCM — 右键菜单

RCM Icon

一个可自定义的 Windows 右键上下文菜单,使用 Tauri + React 构建 [rcm-tauri.webm](https://github.com/user-attachments/assets/1b6f95bf-3b49-49bc-95ae-3c2663c3c90c) ## ⚠️ 重要提示 **本项目正在积极开发中,尚未达到生产就绪状态。** - 可能随时发生破坏性更新,恕不另行通知。 - API、配置格式和行为可能会发生变化。 - **请勿在生产环境中使用此软件。** ## 功能 - 替换或增强标准的 Windows 资源管理器上下文菜单。 - 在 Windows 11(紧凑)和 Windows 10(经典)菜单样式之间切换。 - 使用 JavaScript 编写自定义菜单脚本 — 定义你自己的命令、条件和子菜单。 - 远程拉取 — 从 URL 获取 `rcm.js`、`style.css` 和 `rcm.config.json`,以便在多台机器间共享。 - 内置带有语法高亮的配置编辑器,支持实时编辑。 - 可选的菜单图标栏。 - 开机自启。 - 系统托盘图标,便于快速访问设置。 - 支持 深色 / 浅色 主题。 ## 安装说明 1. 前往 [Releases](https://github.com/ahaoboy/rcm-tauri/releases) 页面。 2. 为您的系统下载最新的安装程序(`.msi` 或 `.exe`)。 3. 运行安装程序并按照屏幕上的指示操作。 ## 使用方法 安装后,RCM 图标将出现在您的系统托盘中。请按照以下步骤启用自定义上下文菜单: ### 分步设置 1. **切换到经典样式** - 右键点击 RCM 托盘图标,然后点击 **Classic**。 - 这将启用经典的 Windows 10 上下文菜单样式(这是 shell 扩展在 Windows 11 上运行所必需的)。 2. **注册 shell 扩展** - 在托盘菜单中,点击 **Register**。 - 这将注册 `rcm_com.dll` — 一个用于拦截右键点击事件的 shell 扩展。 3. **启用开机自启(可选)** - 在托盘菜单中点击 **Startup**,将 RCM 添加到您的 Windows 开机启动项中。 - 出现勾号 (✓) 表示已启用。 4. **应用更改** - 点击 **Apply** 重启 Windows 资源管理器并激活 shell 扩展。 - 您的右键菜单现在应该使用了 RCM 样式。 [rcm-tauri.webm](https://github.com/user-attachments/assets/2c2c3a88-bb35-46d6-bea3-8d28bab55541) ## 自定义菜单 RCM 会从可执行文件旁的 `rcm.js` 加载其菜单。您可以编辑此文件,以根据您的工作流定制右键菜单。 ### 工作原理 菜单是一个由包含**项目**的**组**(区块)构成的树状结构。每个项目可以是: - **内置操作**(例如 `open()`、`copy()`、`vscode()`、`terminal()`) - **子菜单**(`{ label: "...", items: [...] }`) - 使用 `action` / `match` 回调定义的**自定义命令** 示例 — 一个极简的 `rcm.js`: ``` import { newMenu, copy, paste, terminal, Menu } from "rcm-kit" export default new Menu( [ { items: [newMenu(), terminal(), { label: "Clipboard", items: [copy(), paste()] }], }, ], [], ) ``` ### 定义自定义命令 使用 `action` 回调来定义您自己的命令: ``` function fsv() { return { key: "fsv", label: "Browse with fsv", action: (props) => { const targets = props.files.length ? props.files.map((f) => f.path) : ["."] return { cmd: "fsv", args: targets, cwd: props.cwd, window: "Visible" } }, } } ``` `props` 对象提供以下属性: | 字段 | 类型 | 描述 | | ----------- | ------------------------------------ | ------------------------------------------------ | | `files` | `{ path: string, isDir: boolean }[]` | 选中的文件(为空表示在空白处点击) | | `cwd` | `string` | 发生右键点击的目录 | | `env` | `Record` | 环境变量(例如 `{ OS: "Windows" }`) | | `admin` | `boolean` | 进程是否以管理员权限运行 | | `lang` | `string` | 系统语言(例如 `"zh"`、`"en"`) | | `clipboard` | `{ has_text, has_image, has_files }` | 剪贴板状态快照 | `action` 的返回值: | 字段 | 类型 | 描述 | | -------- | -------------------------------------------------------- | ------------------ | | `cmd` | `string` | 可执行文件名或路径 | | `args` | `string[]` | 命令行参数 | | `cwd` | `string` | 工作目录 | | `window` | `"Hidden"` / `"Visible"` / `"Minimized"` / `"Maximized"` | 窗口模式 | 使用 `match` 按条件显示项目: ``` { key: "only-for-images", label: "Convert to WebP", match: ({ files }) => files.some(f => /\.(png|jpg)$/i.test(f.path)), action: (props) => ({ cmd: "magick", args: [...], window: "Hidden" }), } ``` ### 远程拉取更新 RCM 可以从远程 URL 获取您的配置文件。请在 `rcm.config.json` 中配置 URL: ``` { // GitHub release URLs (set as defaults when no URLs are configured) "js_url": "https://github.com/ahaoboy/rcm-tauri/releases/latest/download/rcm.js", "css_url": "https://github.com/ahaoboy/rcm-tauri/releases/latest/download/style.css", // config URL is empty by default — set it to pull rcm.config.json updates "config_url": "", } ``` **从托盘拉取:** 打开托盘,点击 **Pull ▸ JS** / **CSS** / **Config** 下载每个文件的最新版本。 **从编辑器拉取:** 打开配置编辑器(托盘 → **Config**),切换到文件标签页,然后点击 **⬇️ Pull**。成功后编辑器会自动重新加载;如果失败,会弹出错误窗口。 ### 配置编辑器 RCM 包含一个内置编辑器,用于编辑 `rcm.js`、`style.css` 和 `rcm.config.json`,并提供语法高亮。 - 通过托盘 → **Config** 打开,或者在命令行运行 `rcm-tauri.exe config`。 - **💾 Save** — 写入文件,并将 CSS 的更改即时广播应用到所有已打开的菜单。 - **⬇️ Pull** — 从配置的远程 URL 下载最新版本。 - **🔄 Reload** — 丢弃未保存的更改并从磁盘重新读取文件。 - **📂 Open** — 使用系统默认编辑器打开文件。 ## 自定义样式 RCM 还支持通过位于可执行文件旁的 `style.css` 进行 CSS 自定义。 ### 工作原理 - 首次启动时,RCM 会将默认的 `style.css` 写入可执行文件所在目录。 - 如果您编辑或替换了 `style.css`,菜单将使用您的版本。 - 使用配置编辑器(**Config** → `style.css` 标签页)或 **Pull ▸ CSS** 来获取远程更新。 - 当您在配置编辑器中保存 `style.css` 时,所有打开的菜单都会立即接收到更新。 - 在托盘菜单中点击 **Reset** 可恢复默认的 `style.css`(同时也会重置 `rcm.config.json` 和 `rcm.js`)。 ### 可自定义内容 CSS 使用以 `--rcm-` 为前缀的设计令牌(自定义属性)。您可以覆盖其中任何一个,在不改动布局规则的情况下更改菜单外观: ``` :root { /* Colors */ --rcm-bg: #fff5f7; /* Menu background */ --rcm-border: #f2c4d0; /* Menu border */ --rcm-text: #b84664; /* Text color */ --rcm-text-disabled: rgba(…); /* Disabled item text */ /* Items */ --rcm-item-hover: #ffe8ef; /* Hover background */ --rcm-item-active: #ffd4e0; /* Active/pressed background */ --rcm-item-height: 32px; /* Row height */ --rcm-item-radius: 10px; /* Corner roundness */ /* Layout */ --rcm-font-family: "Segoe UI Variable", …; --rcm-font-size: 13px; --rcm-icon-size: 18px; --rcm-radius: 12px; /* Menu container roundness */ --rcm-padding: 3px; /* Inner padding */ /* Shadows */ --rcm-shadow: 0 1px 2px rgba(…), …; /* Separator & Ribbon */ --rcm-separator: #f2c4d0; --rcm-ribbon-border: #f2c4d0; /* Arrows & Focus */ --rcm-arrow-color: #e0a0b4; --rcm-accent: #ff85a2; /* Focus ring color */ } ``` 深色模式覆盖使用 `@media (prefers-color-scheme: dark)` 或类选择器 `.rcm-light` / `.rcm-dark`。 ## 社区菜单 以下是一些来自社区示例配置。欢迎通过 PR 提交您的配置! | 菜单 | 预览 | | ------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------- | | [rcm-tauri](https://github.com/ahaoboy/rcm-tauri) · [拉取 URL](https://github.com/ahaoboy/rcm-tauri/releases/latest/download/rcm.js) | default menu | | [rcm-ahaoboy](https://github.com/ahaoboy/rcm-ahaoboy) · [拉取 URL](https://github.com/ahaoboy/rcm-ahaoboy/releases/latest/download/rcm.js) | rcm-ahaoboy |
标签:React, Shell扩展, Syscalls, Tauri, 右键菜单, 数据可视化, 桌面工具, 通知系统