在文件/文件夹的右键菜单中添加了一个新的 "publish" 项。点击后会打开一个指定的发布页面,并将当前文件的路径和类型作为参数传递。
filebrowser config set --branding.publishURL "https://sys.\$current_hostname/publish/pub.html"filebrowser config init --branding.publishURL "https://sys.\$current_hostname/publish/pub.html"在 config.json 中设置:
{
"branding": {
"publishURL": "https://sys.$current_hostname/publish/pub.html"
}
}$current_hostname: 会被替换为当前的主机名- 最终URL示例:
https://sys.example.com/publish/pub.html?path=/path/to/file&type=file
path: 选中文件/文件夹的完整路径type: 项目类型,值为file或folder
- constants.ts: 添加了
publishURL常量,从后端window.FileBrowser.PublishURL获取 - FileListing.vue:
- 在
headerButtons中添加publish权限检查(单选时可用) - 在右键菜单中添加 "Publish" 项
- 实现
publish()函数处理发布逻辑
- 在
- i18n: 使用现有的 "publish" 翻译
- settings/branding.go: 在
Branding结构体中添加PublishURL字段 - http/static.go: 在
handleWithStaticData函数中将PublishURL注入到前端 - cmd/config.go: 添加
branding.publishURL配置选项,支持设置和显示
发布功能在以下条件下可用:
- 有且仅有一个文件/文件夹被选中
filebrowser config set --branding.publishURL "https://publish.example.com/pub.html"结果:点击文件 /documents/report.pdf 会打开
https://publish.example.com/pub.html?path=/documents/report.pdf&type=file
filebrowser config set --branding.publishURL "https://sys.\$current_hostname/publish/pub.html"如果访问地址是 file.example.com,点击文件会打开:
https://sys.example.com/publish/pub.html?path=/documents/report.pdf&type=file