Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds frontend support for a Virtual Host management feature in the OpenList admin panel. It introduces a new CRUD interface (list, add, edit, delete) for virtual hosts, following the same patterns established by the existing Metas, Shares, and Storages management pages. Virtual hosts allow mapping a domain to an internal OpenList path, with an optional Web Hosting mode for serving static HTML files directly.
Changes:
- Added a new
VirtualHostTypeScript interface and registered it in the type exports. - Created two new management pages (
VirtualHosts.tsxfor listing andAddOrEdit.tsxfor creating/editing virtual hosts), following existing CRUD page conventions. - Integrated the virtual hosts section into the admin side menu, route configuration, and English language translations.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/types/virtual_host.ts |
New VirtualHost interface definition with id, enabled, domain, path, and web_hosting fields. |
src/types/index.ts |
Re-exports the new VirtualHost type. |
src/pages/manage/virtual_hosts/VirtualHosts.tsx |
List page for virtual hosts with refresh, add, edit, and delete actions. |
src/pages/manage/virtual_hosts/AddOrEdit.tsx |
Add/Edit form for virtual hosts with enabled switch, domain input, path chooser, and web hosting toggle. |
src/pages/manage/sidemenu_items.tsx |
Adds "Virtual Hosts" entry to the admin side menu with a globe icon. |
src/pages/manage/routes.tsx |
Registers add and edit routes for virtual hosts. |
src/lang/en/virtual_hosts.json |
English translation strings for virtual host form labels and help text. |
src/lang/en/manage.json |
Adds "Virtual Hosts" label for the side menu. |
src/lang/en/entry.ts |
Registers the new virtual_hosts translation module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <VStack w="$full" alignItems="start" spacing="$4"> | ||
| <Heading>{t(`global.${id ? "edit" : "add"}`)}</Heading> | ||
|
|
||
| {/* 启用开关 */} |
There was a problem hiding this comment.
These section-label comments are in Chinese (启用开关, 域名, 路径, Web 托管开关), while the rest of the codebase uses English for all comments. For consistency, these should be in English (e.g., Enabled switch, Domain, Path, Web Hosting switch), or simply removed since the labels and FormLabel text already make the sections self-documenting.
Description / 描述
实现虚拟主机(Virtual Host)功能的完整支持,包含两种工作模式:
模式一:路径重映射(Enabled,Web Hosting 关闭)
将指定域名的访问路径透明映射到后端真实路径,实现"伪静态"效果:
http://example.com/,地址栏保持不变,面包屑显示🏠Home//api/fs/list、/api/fs/get)自动将请求路径映射到vhost.Path(如/123pan/Downloads)/p/、/d/)自动去掉 vhost 路径前缀,保持前端路径一致性,避免路径重复叠加模式二:Web Hosting(Enabled + Web Hosting 开启)
将指定域名作为静态网站托管,直接返回
index.html等静态文件内容:forceContentTypeWriter包装器强制覆盖响应头中的Content-Type,确保 HTML 文件在浏览器中正确渲染而非触发下载Motivation and Context / 背景
原有虚拟主机功能存在以下问题:
too many redirects错误history.replaceState注入脚本修改地址栏,不符合"伪静态"语义Content-Type覆盖了正确的 MIME 类型,导致index.html被当作application/octet-stream下载internalfs.Get/Link时,context 中缺少用户信息/p/链接经过中间件再次映射后路径翻倍How Has This Been Tested? / 测试
localhost,映射路径/123pan/Downloadshttp://localhost:5244/,验证:http://localhost:5244/不变 ✅🏠Home/✅/123pan/Downloads的内容 ✅/subdir,文件列表正确显示/123pan/Downloads/subdir的内容 ✅/p/filename,不含 vhost 路径前缀 ✅index.html到映射路径:Checklist / 检查清单
我已阅读 CONTRIBUTING 文档。
go fmtor prettier.我已使用
go fmt或 prettier 格式化提交的代码。我已为此 PR 添加了适当的标签(如无权限或需要的标签不存在,请在描述中说明,管理员将后续处理)。
我已在适当情况下使用"Request review"功能请求相关代码作者进行审查。
我已相应更新了相关仓库(若适用)。