# 主题

A theme changes how VDM looks and keeps everything where it was: the same windows, menus and buttons in the same places, drawn in other colours, shapes and icons. Each theme has a light and a dark side.

## 选择主题

打开**视图 → 主题**，然后点击一个主题：整个窗口会立即改变，无需重启。然后，**视图 → 深色模式支持**和**视图 → 始终为深色**会选择其浅色或深色模式，就像经典外观一样（[深色模式](https://vdm.mikaillab.com/zh-hans/help/getting-started.html#dark-mode)）。

The built-in themes are **Classic** (VDM's own look, the default), **Native** (your system's accent colour and contrast), **High contrast**, and the style themes **Metro**, **Adwaita**, **Breeze**, **Luna**, **Aero**, **Aqua** and **Emerald**, each with its own control shapes and icons, and on Windows its own title bar. [Getting started](https://vdm.mikaillab.com/zh-hans/help/getting-started.html#themes) describes each one; the website's [Themes page](https://vdm.mikaillab.com/themes.html) shows them all, light and dark.

## 主题文件存放位置

Theme files you make or download go in VDM's themes folder. **View → Theme → Open themes folder** opens it (and makes it the first time). It is in VDM's data folder:

| 系统 | 文件夹 |
|---|---|
| Windows | `%APPDATA%\voltdownloadmanager\themes` |
| Linux | `~/.local/share/voltdownloadmanager/themes` |
| macOS | `~/Library/Application Support/voltdownloadmanager/themes` |
| [便携版](https://vdm.mikaillab.com/zh-hans/help/portable.html) | `data\themes`在程序旁边 |

两秒钟内，新文件会显示在**视图 → 主题**中，内置主题下方，带有它自己提供的`name`。编辑文件后，在**视图 → 主题**中再次选择它以查看更改。

主题可以是一个文件（`harbour.toml`），或者当它包含图标时，可以是一个独立的文件夹（`harbour/theme.toml`）。

**View → Theme → Add a theme file…** does it for you: pick a file anywhere, and VDM copies it into the themes folder and uses it at once. A file that isn't a theme stays out, and VDM says why.

## Base16 和 pywal 配色方案

为其他程序制作的配色方案也可以作为主题，无需转换：

- **Base16 方案**，即 `.yaml` 文件，[Base16 和 Base24 方案](https://github.com/tinted-theming/schemes) 均采用此格式：包括经典布局（顶部 `scheme:` 和 `base00` 到 `base0F`）和新布局（`name:` 和 `palette:` 块）。Base24 方案读取其前 16 种颜色。
- **pywal 的 `colors.json`**，或任何符合 pywal 格式的程序文件（wallust 的 pywal 模板）。

通过**视图 → 主题 → 添加主题文件…**添加，或自行放入主题文件夹。它会显示在**视图 → 主题**下，名称为方案名（`name:` 或 `scheme:`；pywal 的方案以壁纸命名）。

**pywal itself:** once `wal` has run, **View → Theme** lists **pywal**, read straight from where pywal writes its colours: `~/.cache/wal/colors.json` (on Windows `%USERPROFILE%\.cache\wal\colors.json`, where winwal and pywal write it; `$PYWAL_CACHE_DIR` or `$XDG_CACHE_HOME/wal` when you set them). Pick it and VDM follows your wallpaper: each time `wal` writes new colours, VDM takes them within two seconds. It looks only at the file's date and size, every two seconds, and only while pywal is the theme. A copy added with **Add a theme file…** keeps the colours it had.

A scheme changes colours only, on the classic look: every window, button and menu stays where it was. A dark scheme makes VDM dark and a light one light, whatever **View → Always dark** says. The scheme's colours go where they mean the same:

| VDM | Base16 | pywal |
|---|---|---|
| 下载列表、文本框和菜单 | `base00`（背景） | `special.background` |
| Windows、对话框、工具栏、菜单栏和列标题 | `base01`（较浅的背景） | 背景向前景靠近一步 |
| 文本 | `base05`（前景） | `special.foreground` |
| 次要文本（大小、备注） | `base04` | `color8` |
| 焦点、默认按钮、复选框、链接、选择和进度条 | `base0D`（蓝色） | `color4` |
| 错误 | `base08`（红色） | `color1` |
| 警告 | `base0A`（黄色） | `color3` |
| 成功、仪表和种子的片段 | `base0B`（绿色） | `color2` |

Borders and the hover and pressed shades are mixed from these, as for a theme file's `[seeds]`. Text stays readable: text and secondary text at 4.5:1 or more against every background they sit on (WCAG AA), the accent at 3:1. A scheme short of that has those colours moved a little darker (lighter on a dark scheme) until they pass; VDM's log says which.

要更改颜色以外的更多内容，请制作一个主题文件，通过其文件名继承该方案并添加您喜欢的内容：

```
name = "Gruvbox, my way"
inherits = "gruvbox-dark-medium"   # gruvbox-dark-medium.yaml, beside it
icons = "accent"

[sizes]
radius = 6
```

`inherits = "pywal"`工作方式相同，也遵循 `wal`。

## 文件

主题是一个小的 [TOML](https://toml.io/) 文本文件（或 JSON，`.json`；或[配色方案](#base16-and-pywal-colour-schemes)，`.yaml`）。它只命名它所更改的内容；所有其他内容都来自它所 `inherits` 的主题：

```
name = "Harbour"
inherits = "classic"
icons = "color"

[seeds.light]
background = "#eef3f6"
surface = "#ffffff"
text = "#11202b"
accent = "#0f6c8c"

[seeds.dark]
background = "#14212a"
surface = "#0e171d"
text = "#e8f0f4"
accent = "#5cc3e6"

[sizes]
radius = 6

[controls]
focus = "ring"
```

- **`name`** — **视图 → 主题**中列出的名称；如果没有，则为文件名。
- **`inherits`** — 您的主题的起始主题：`classic`（如果省略则为默认值）、内置主题的 ID（`metro`、`adwaita`、`breeze`、`luna`、`aero`、`aqua`、`high-contrast`），或同一文件夹中的另一个主题文件，按其不带`.toml`的文件名。一个继承了另一个主题的文件可以反过来被继承；一个主题不能继承自身。
- **`[seeds]`** — a handful of colours (`background`, `surface`, `header`, `text`, `accent`, `selection`, `error`, `warning`, `success`) that VDM spreads over every control. `[seeds.light]` and `[seeds.dark]` give each side its own.
- **`[colors]`** — 两侧的单一颜色角色（例如`window`、`accent`或`"segments.done"`）；**`[light]`**和**`[dark]`**仅在一侧。颜色是`#rrggbb`，或带有透明度的`#rrggbbaa`。文件设置的角色优先于其种子。
- **`[sizes]`** — 圆角半径、边框宽度、字体大小和行高，以像素为单位。
- **`[controls]`** — 文本框、复选框、按钮、进度条、滚动条、列标题、焦点标记和标题栏的形状，以及菜单的字体。
- **`icons`** — `color`、`mono`（一种颜色）或`accent`。
- **`contrast = "high"`** — 在其他颜色之上，加强每个边缘和文本颜色。

Every colour role, size and control style, with what it sets, is listed on the website's [Themes page](https://vdm.mikaillab.com/themes.html#make-your-own) (read from VDM's own code, so it never drifts). The built-in themes are written the same way: [read them on GitHub](https://github.com/mikailhossenimran/voltdownloadmanager/tree/main/crates/app/assets/themes).

A key VDM doesn't know, or a value it can't read, is skipped and written to VDM's log (the `logs` folder beside the themes folder), so a file made for a newer VDM still loads. A file that isn't valid TOML or JSON doesn't load, and the log says why. A file named like a built-in theme (`metro.toml`) is passed over: give yours a name of its own.

### 图标

位于独立文件夹中的主题（`harbour/theme.toml`）可以在`icons/16`和`icons/24`中（对于 PNG 图片，还有`icons/32`和`icons/48`，用于 150% 及以上缩放的屏幕）引入其图标，每个图标都以其显示的内容命名（`tb-add-url.svg`、`cat-music.png`…）。SVG 和 PNG 文件保留其颜色；`-symbolic.svg`和`-symbolic.png`文件，如 GNOME 和 KDE 所命名，采用主题的文本颜色。缺少图标的集合将以经典外观绘制。名称的完整列表在[themeicons.rs](https://github.com/mikailhossenimran/voltdownloadmanager/blob/main/crates/app/src/themeicons.rs)（`NEEDS`）中。

## 制作主题

1. **视图 → 主题 → 打开主题文件夹**，并在其中创建一个新的`.toml`文件（任何文本编辑器）。
2. 从上面的示例开始：更改种子的颜色，然后逐步添加角色和大小。
3. 在**视图 → 主题**中选择它，并查看两侧：**视图 → 始终为深色**的开启和关闭状态。检查文本是否可读，以及焦点标记在两种模式下是否可见。

网站的[主题页面](https://vdm.mikaillab.com/themes.html#ai-prompt)提供了一个您可以提供给 AI 助手的提示，其中包含格式、所有键和规则，以便根据描述为您编写主题。

## 分享

制作了其他人会喜欢的东西？打开一个[拉取请求](https://github.com/mikailhossenimran/voltdownloadmanager/pulls)，将其添加到`crates/app/assets/themes`，并附带：

- 该 `.toml` 文件，以及其图标文件夹（如果有）；
- 主窗口浅色和深色模式的截图；
- a `SOURCES.txt` beside any icons, saying who drew them and under which licence. Icons must be your own or under a licence that lets VDM share them (GPL-3.0), never copied from another program.

不确定？请先在[讨论区](https://github.com/mikailhossenimran/voltdownloadmanager/discussions)中展示。 [CONTRIBUTING.md](https://vdm.mikaillab.com/zh-hans/contributing.html)解释了拉取请求的工作方式。

## 下一步

- [入门 →](https://vdm.mikaillab.com/zh-hans/help/getting-started.html)
- [选项 →](https://vdm.mikaillab.com/zh-hans/help/options.html)

## 相关

- [选项](https://vdm.mikaillab.com/zh-hans/help/options.html)
- [语言](https://vdm.mikaillab.com/zh-hans/help/languages.html)
- [便携模式](https://vdm.mikaillab.com/zh-hans/help/portable.html)
- [键盘快捷方式](https://vdm.mikaillab.com/zh-hans/help/keyboard-shortcuts.html)
- [命令行和自动化](https://vdm.mikaillab.com/zh-hans/help/command-line.html)

[在 GitHub 上编辑此页面](https://github.com/mikailhossenimran/voltdownloadmanager/edit/main/docs/themes.md) [报告此页面的问题](https://github.com/mikailhossenimran/voltdownloadmanager/issues/new?template=website.yml&title=Website%3A%20Themes&page=https%3A//vdm.mikaillab.com/help/themes.html) [页面历史](https://github.com/mikailhossenimran/voltdownloadmanager/commits/main/docs/themes.md)

免费、开源、无广告、无试用版。

[Download Volt Download Manager](https://vdm.mikaillab.com/zh-hans/download.html)
