feat: fix anti-leech is not work on proxy website (#7801)

Refs https://github.com/1Panel-dev/1Panel/issues/7752
This commit is contained in:
zhengkunwang 2025-02-05 18:07:16 +08:00 committed by GitHub
parent 4be9d71edf
commit 74583aa1aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 4 deletions

View file

@ -95,8 +95,10 @@ type IWebsiteService interface {
GetAuthBasics(req request.NginxAuthReq) (res response.NginxAuthRes, err error)
UpdateAuthBasic(req request.NginxAuthUpdate) (err error)
GetAntiLeech(id uint) (*response.NginxAntiLeechRes, error)
UpdateAntiLeech(req request.NginxAntiLeechUpdate) (err error)
OperateRedirect(req request.NginxRedirectReq) (err error)
GetRedirect(id uint) (res []response.NginxRedirectConfig, err error)
UpdateRedirectFile(req request.NginxRedirectUpdate) (err error)
@ -2069,7 +2071,19 @@ func (w WebsiteService) UpdateAntiLeech(req request.NginxAntiLeechUpdate) (err e
}
newBlock.Directives = append(newBlock.Directives, ifDir)
newDirective.Block = newBlock
block.Directives = append(block.Directives, &newDirective)
index := -1
for i, directive := range block.Directives {
if directive.GetName() == "include" {
index = i
break
}
}
if index != -1 {
block.Directives = append(block.Directives[:index], append([]components.IDirective{&newDirective}, block.Directives[index:]...)...)
} else {
block.Directives = append(block.Directives, &newDirective)
}
}
if err = nginx.WriteConfig(nginxFull.SiteConfig.Config, nginx.IndentedStyle); err != nil {

View file

@ -450,17 +450,17 @@ export function getAge(d1: string): string {
let res = '';
if (dayDiff > 0) {
res += String(dayDiff) + i18n.global.t('commons.units.day', dayDiff);
res += String(dayDiff) + ' ' + i18n.global.t('commons.units.day', dayDiff) + ' ';
if (hours <= 0) {
return res;
}
}
if (hours > 0) {
res += String(hours) + i18n.global.t('commons.units.hour', hours);
res += String(hours) + ' ' + i18n.global.t('commons.units.hour', hours) + ' ';
return res;
}
if (minutes > 0) {
res += String(minutes) + i18n.global.t('commons.units.minute', minutes);
res += String(minutes) + ' ' + i18n.global.t('commons.units.minute', minutes);
return res;
}
return i18n.global.t('app.less1Minute');