mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2026-04-28 17:15:18 +08:00
优化代码
This commit is contained in:
@@ -36,5 +36,5 @@ func (this *DownloadCertAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
this.AddHeader("Content-Disposition", "attachment; filename=\"cert-"+strconv.FormatInt(params.CertId, 10)+".pem\";")
|
||||
this.Write(certConfig.CertData)
|
||||
_, _ = this.Write(certConfig.CertData)
|
||||
}
|
||||
|
||||
@@ -36,5 +36,5 @@ func (this *DownloadKeyAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
this.AddHeader("Content-Disposition", "attachment; filename=\"key-"+strconv.FormatInt(params.CertId, 10)+".pem\";")
|
||||
this.Write(certConfig.KeyData)
|
||||
_, _ = this.Write(certConfig.KeyData)
|
||||
}
|
||||
|
||||
@@ -50,12 +50,12 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
this.Data["user"] = userMap
|
||||
|
||||
var countAll = int64(0)
|
||||
var countCA = int64(0)
|
||||
var countAvailable = int64(0)
|
||||
var countExpired = int64(0)
|
||||
var count7Days = int64(0)
|
||||
var count30Days = int64(0)
|
||||
var countAll int64
|
||||
var countCA int64
|
||||
var countAvailable int64
|
||||
var countExpired int64
|
||||
var count7Days int64
|
||||
var count30Days int64
|
||||
|
||||
// 计算数量
|
||||
{
|
||||
|
||||
@@ -172,6 +172,11 @@ func (this *SelectPopupAction) RunGet(params struct {
|
||||
})
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
if listResp == nil {
|
||||
this.ErrorPage(errors.New("'listResp' should not be nil"))
|
||||
return
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package certs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
@@ -120,7 +121,7 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
|
||||
// 校验
|
||||
certConfig.IsCA = params.IsCA
|
||||
err = certConfig.Init(nil)
|
||||
err = certConfig.Init(context.TODO())
|
||||
if err != nil {
|
||||
if params.IsCA {
|
||||
this.Fail("证书校验错误:" + err.Error())
|
||||
|
||||
@@ -4,6 +4,7 @@ package certs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
@@ -156,7 +157,7 @@ func (this *UploadBatchPopupAction) RunPost(params struct {
|
||||
CertData: certData,
|
||||
KeyData: keyData,
|
||||
}
|
||||
err := certConfig.Init(nil)
|
||||
err := certConfig.Init(context.TODO())
|
||||
if err != nil {
|
||||
this.Fail("证书验证失败:" + err.Error())
|
||||
return
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package certs
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
|
||||
@@ -60,8 +61,8 @@ func (this *UploadPopupAction) RunPost(params struct {
|
||||
Field("name", params.Name).
|
||||
Require("请输入证书说明")
|
||||
|
||||
var certData = []byte{}
|
||||
var keyData = []byte{}
|
||||
var certData []byte
|
||||
var keyData []byte
|
||||
|
||||
if params.TextMode {
|
||||
if len(params.CertText) == 0 {
|
||||
@@ -104,7 +105,7 @@ func (this *UploadPopupAction) RunPost(params struct {
|
||||
CertData: certData,
|
||||
KeyData: keyData,
|
||||
}
|
||||
err := certConfig.Init(nil)
|
||||
err := certConfig.Init(context.TODO())
|
||||
if err != nil {
|
||||
if params.IsCA {
|
||||
this.Fail("证书校验错误:" + err.Error())
|
||||
|
||||
@@ -35,5 +35,5 @@ func (this *ViewCertAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Write(certConfig.CertData)
|
||||
_, _ = this.Write(certConfig.CertData)
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func (this *ViewKeyAction) RunGet(params struct {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Write(certConfig.KeyData)
|
||||
_, _ = this.Write(certConfig.KeyData)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user