Skip to content

Commit 558ccc8

Browse files
committed
APP链接跳转
1 parent b2d2677 commit 558ccc8

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

change.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
## v2.2 升级日志
3434

3535
- [x] 使用`go mod`方式管理程序的包依赖(建议二次开发的朋友把go开发环境升级到支持`go mod`的go版本)
36-
- [x] APP下载单页管理
37-
- [x] 书籍信息设置页,支持增加文字广告功能
36+
- [x] APP下载单页配置管理
37+
- [x] 书籍信息设置页,支持增加文字广告功能,并增加 APP 跳转页
3838
- [x] 电子书是否登录才能下载
3939
- [x] 移动端横幅尺寸控制(由于移动端横幅展示,为了不使横幅变形,以及能够灵活控制移动端横幅宽高比例显示)
4040
- [x] 支持`项目设置`给项目内容增加全局文字小广告功能,比如添加原作者赞助二维码链接或者是原作者实体书购买地址等,以便支持开源作者

controllers/StaticController.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"strings"
88
"time"
99

10+
"github.com/TruthHun/BookStack/models"
11+
1012
"github.com/TruthHun/BookStack/models/store"
1113
"github.com/TruthHun/BookStack/utils"
1214
"github.com/astaxie/beego"
@@ -16,6 +18,14 @@ type StaticController struct {
1618
beego.Controller
1719
}
1820

21+
func (this *StaticController) APP() {
22+
link := strings.TrimSpace(models.GetOptionValue("APP_PAGE", ""))
23+
if link != "" {
24+
this.Redirect(link, 302)
25+
}
26+
this.Abort("404")
27+
}
28+
1929
//静态文件,这个加在路由的最后
2030
func (this *StaticController) StaticFile() {
2131
file := this.GetString(":splat")

routers/web.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77

88
func webRouter() {
99
beego.Router("/", &controllers.CateController{}, "get:Index")
10+
beego.Router("/app", &controllers.StaticController{}, "get:APP")
1011
beego.Router("/cate", &controllers.CateController{}, "get:List")
1112
//beego.Router("/", &controllers.HomeController{}, "*:Index")
1213
beego.Router("/explore", &controllers.HomeController{}, "*:Index")

views/widgets/header.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
<li><a href="https://www.bookstack.cn/read/help/opensource.md" title="BookStack开源" target="_blank"><i class="fa fa-code"></i> 开源</a></li>
2222
{{end}}
2323
{{if .APP_PAGE}}
24-
<li><a href="{{.APP_PAGE}}" title="手机APP下载" target="_blank"><i class="fa fa-paper-plane-o"></i> APP下载</a></li>
24+
{{/* "/app" 会自动根据后台配置的APP单页地址跳转过去 */}}
25+
<li><a href="/app" title="手机APP下载" target="_blank"><i class="fa fa-paper-plane-o"></i> APP下载</a></li>
2526
{{end}}
2627
{{if gt .Member.MemberId 0}}
2728
<li>
@@ -81,7 +82,8 @@
8182
<li class="hidden-sm"><a href="https://www.bookstack.cn/read/help/opensource.md" title="BookStack开源" target="_blank"><i class="fa fa-code"></i> 开源</a></li>
8283
{{end}}
8384
{{if .APP_PAGE}}
84-
<li><a href="{{.APP_PAGE}}" title="手机APP下载" target="_blank"><i class="fa fa-paper-plane-o"></i> APP下载</a></li>
85+
{{/* "/app" 会自动根据后台配置的APP单页地址跳转过去 */}}
86+
<li><a href="/app" title="手机APP下载" target="_blank"><i class="fa fa-paper-plane-o"></i> APP下载</a></li>
8587
{{end}}
8688
{{if .IsSearch}}
8789
<li class="active">

0 commit comments

Comments
 (0)