SwitchHosts README

The project's README from github.com/oldj/SwitchHosts. As one markdown file: README.md.

Special thanks to:
Warp sponsorship

Warp, the intelligent terminal for developers

Available for MacOS, Linux, & Windows


SwitchHosts

Homepage: https://switchhosts.vercel.app

SwitchHosts is an App for managing hosts file, it is based on Tauri, React, Jotai, Mantine, etc.

Screenshot

SwitchHosts screenshot

Features

Install

Download

You can download the source code and build it yourself, or download the built version from following links:

You can also install the built version using the package manager Chocolatey:

choco install switchhosts

Backup

SwitchHosts stores data at ~/.SwitchHosts (Or folder .SwitchHosts under the current user's home path on Windows). In the v5 data layout:

For a complete manual backup, copy the whole ~/.SwitchHosts folder. The in-app export creates a hosts data backup JSON; it does not include preferences or histories.

Develop and build

Prerequisites

Development

Build and package

# development
npm run tauri:dev

# production build
npm run tauri:build

SwitchHosts is a free and open source software, it is released under the Apache License.

SwitchHosts (oldj/SwitchHosts)

Searching Database…

这是什么东西?SwitchHosts 是一款免费开源的桌面应用,用来管理 hosts 文件:可以保存多份 hosts 配置方案,在主窗口或系统托盘里一键切换。
它是桌面应用,还是我加到项目里的库?它是一个独立的桌面应用,基于 Tauri 构建,界面用了 React、Jotai 和 Mantine——它常驻系统托盘,负责管理系统的 hosts 文件。没有什么需要加到项目里的东西。
我的电脑上还需要装别的东西才能运行吗?不需要额外装任何东西——下载下来的应用是自包含的。Node.js、Rust 和 Tauri 的系统依赖只有从源码构建时才需要。
如果我导出 hosts 数据,导出的内容是完整的吗?不是——应用内的导出只是一份 hosts 数据的 JSON,不包含偏好设置和历史记录。想完整备份的话,请把整个 ~/.SwitchHosts 文件夹复制一份。
哪些系统上可以运行它?Windows、macOS 和 Linux,全部来自同一套 Tauri 代码;安装包在 GitHub releases 页面上,Windows 还提供 Chocolatey 包。
SwitchHosts 把我的 hosts 数据存在哪里?存在本地 ~/.SwitchHosts 文件夹里(Windows 上是用户主目录下的 .SwitchHosts):manifest.json 存 hosts 树结构,entries/ 存内容,trashcan.json 存已删除的条目。
使用它是免费的吗?是的——它是基于 Apache 2.0 许可证发布的免费开源软件。
除了切换配置方案的开关,它还能做什么?能做的不少:hosts 文件语法高亮、跨条目查找和替换、远程 hosts 手动或定时刷新、导入导出(包括从 URL 备份)、带恢复功能的回收站,还有本地 HTTP API。
在它里面编辑 hosts 文件是什么体验?就像用代码编辑器一样:hosts 条目有语法高亮和查找替换功能,由 CodeMirror 提供,它是这个应用的依赖之一。
可以自动化操作吗,比如用脚本触发切换?偏好设置里有本地 HTTP API 和应用后命令(post-apply commands)功能,所以你可以暴露一个 HTTP 端点,并在 hosts 条目应用之后执行命令。
应用是用 TypeScript 写的,为什么构建还需要 Rust?界面部分是 TypeScript/React,但桌面外壳是 Tauri,它的原生后端是 src-tauri 里的 Rust 代码——这就是为什么 Node.js 和 Rust 都是构建的前提条件。
Creator
oldj
Size
36.5 MB
Stars
27.3K
Age
15y
Commits · 90 Days