WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit cd0900a

Browse files
committed
添加屏蔽操作
1 parent 65e4260 commit cd0900a

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

controllers/api/BaseController.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import (
2222

2323
type BaseController struct {
2424
beego.Controller
25-
Token string
25+
Token string
26+
Version string
2627
}
2728

2829
type APIResponse struct {
@@ -207,6 +208,7 @@ func (this *BaseController) Prepare() {
207208
}
208209
}
209210
this.Token = this.Ctx.Request.Header.Get("Authorization")
211+
this.Version = this.Ctx.Request.Header.Get("x-version")
210212

211213
if !models.AllowVisitor && this.isLogin() == 0 { // 不允许游客访问,则除了部分涉及登录的API外,一律提示先登录
212214
allowAPIs := map[string]bool{

controllers/api/CommonController.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ func (this *CommonController) SearchBook() {
408408
this.Response(http.StatusBadRequest, messageBadRequest)
409409
}
410410

411+
if models.NewOption().IsResponseEmptyForAPP(this.Version, wd) {
412+
this.Response(http.StatusOK, messageSuccess, map[string]interface{}{"total": 0})
413+
}
414+
411415
var (
412416
page, _ = this.GetInt("page", 1)
413417
size, _ = this.GetInt("size", 10)
@@ -562,9 +566,13 @@ func (this *CommonController) Categories() {
562566
if err != nil {
563567
pid = -1
564568
}
565-
569+
m := models.NewOption()
566570
categories, _ := model.GetCates(pid, 1)
567571
for idx, category := range categories {
572+
if m.IsResponseEmptyForAPP(this.Version, category.Title) {
573+
// 为0,APP端就不会显示该分类
574+
category.Cnt = 0
575+
}
568576
if category.Icon != "" {
569577
if category.Icon == "" {
570578
category.Icon = "/static/images/cate.png"

models/options.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,16 @@ func (m *Option) Init() error {
290290
OptionName: "FORBIDDEN_REFERER",
291291
OptionTitle: "禁止的Referer",
292292
},
293+
{
294+
OptionValue: "",
295+
OptionName: "CheckingAppVersion",
296+
OptionTitle: "审核中的APP版本",
297+
},
298+
{
299+
OptionValue: "Android, 安卓",
300+
OptionName: "CheckingForbidWords",
301+
OptionTitle: "iOS APP提交审核时屏蔽的关键字",
302+
},
293303
{
294304
OptionValue: "1",
295305
OptionName: "DOWNLOAD_INTERVAL",
@@ -311,3 +321,21 @@ func (m *Option) Init() error {
311321
func (m *Option) ForbiddenReferer() []string {
312322
return strings.Split(GetOptionValue("FORBIDDEN_REFERER", ""), "\n")
313323
}
324+
325+
func (m *Option) IsResponseEmptyForAPP(requestVersion, word string) (yes bool) {
326+
version := GetOptionValue("CheckingAppVersion", "")
327+
if version == "" {
328+
return
329+
}
330+
if strings.ToLower(strings.TrimSpace(requestVersion)) == version {
331+
words := strings.Split(GetOptionValue("CheckingForbidWords", ""), ",")
332+
word = strings.ToLower(strings.TrimSpace(word))
333+
for _, item := range words {
334+
item = strings.ToLower(strings.TrimSpace(item))
335+
if strings.Contains(word, item) {
336+
return true
337+
}
338+
}
339+
}
340+
return
341+
}

views/manager/setting.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@
233233
<label>手机APP版本号( <span class="text-muted">应用版本号,必须是整数,用于提示用户升级APP</span> )</label>
234234
<input type="number" name="APP_VERSION" class="form-control" value="{{.APP_VERSION.OptionValue}}">
235235
</div>
236+
<div class="form-group">
237+
<label>App Store审核中的版本( <span class="text-muted">如v1.5.0。iOS APP审核通过后,请务必置空,避免屏蔽的内容无法在APP端显示</span> )</label>
238+
<input type="text" name="CheckingAppVersion" class="form-control" value="{{.CheckingAppVersion.OptionValue}}">
239+
</div>
240+
<div class="form-group">
241+
<label>App Store审核时屏蔽的关键字( <span class="text-muted">多个关键字用英文逗号分隔</span> )</label>
242+
<input type="text" name="CheckingForbidWords" class="form-control" value="{{.CheckingForbidWords.OptionValue}}">
243+
</div>
236244
<div class="form-group">
237245
<label>手机APP下载单页( <span class="text-muted">如果单页链接不为空,则会在导航栏显示APP下载页面</span> )</label>
238246
<input type="text" name="APP_PAGE" class="form-control" value="{{.M_APP_PAGE.OptionValue}}">

0 commit comments

Comments
 (0)