ahaoboy/rcm-tauri
GitHub: ahaoboy/rcm-tauri
基于 Tauri 和 React 构建的 Windows 右键上下文菜单自定义工具,支持 JavaScript 脚本编排命令、远程配置同步及 CSS 主题定制。
Stars: 8 | Forks: 0
# RCM — 右键菜单
` | 环境变量(例如 `{ 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) |
|
| [rcm-ahaoboy](https://github.com/ahaoboy/rcm-ahaoboy) · [拉取 URL](https://github.com/ahaoboy/rcm-ahaoboy/releases/latest/download/rcm.js) |
|
标签:React, Shell扩展, Syscalls, Tauri, 右键菜单, 数据可视化, 桌面工具, 通知系统