diff --git a/internal/web/actions/default/servers/certs/selectPopup.go b/internal/web/actions/default/servers/certs/selectPopup.go index e9c323dd..a2d90b86 100644 --- a/internal/web/actions/default/servers/certs/selectPopup.go +++ b/internal/web/actions/default/servers/certs/selectPopup.go @@ -2,11 +2,14 @@ package certs import ( "encoding/json" + "github.com/TeaOSLab/EdgeAdmin/internal/utils/numberutils" "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/sslconfigs" + "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/maps" timeutil "github.com/iwind/TeaGo/utils/time" + "strings" "time" ) @@ -20,10 +23,17 @@ func (this *SelectPopupAction) Init() { } func (this *SelectPopupAction) RunGet(params struct { - ViewSize string + ViewSize string + SelectedCertIds string }) { // TODO 支持关键词搜索 - // TODO 列出常用的证书供用户选择 + // TODO 列出常用和最新的证书供用户选择 + + // 已经选择的证书 + selectedCertIds := []string{} + if len(params.SelectedCertIds) > 0 { + selectedCertIds = strings.Split(params.SelectedCertIds, ",") + } if len(params.ViewSize) == 0 { params.ViewSize = "normal" @@ -67,6 +77,7 @@ func (this *SelectPopupAction) RunGet(params struct { "isExpired": nowTime > certConfig.TimeEndAt, "isAvailable": nowTime <= certConfig.TimeEndAt, "countServers": countServersResp.Count, + "isSelected": lists.ContainsString(selectedCertIds, numberutils.FormatInt64(certConfig.Id)), }) } this.Data["certInfos"] = certMaps diff --git a/web/public/js/components/server/ssl-config-box.js b/web/public/js/components/server/ssl-config-box.js index 2dc5f682..c81c54cc 100644 --- a/web/public/js/components/server/ssl-config-box.js +++ b/web/public/js/components/server/ssl-config-box.js @@ -95,7 +95,13 @@ Vue.component("ssl-config-box", { // 选择证书 selectCert: function () { let that = this - teaweb.popup("/servers/certs/selectPopup", { + let selectedCertIds = [] + if (this.policy != null && this.policy.certs.length > 0) { + this.policy.certs.forEach(function (cert) { + selectedCertIds.push(cert.id.toString()) + }) + } + teaweb.popup("/servers/certs/selectPopup?selectedCertIds=" + selectedCertIds, { width: "50em", height: "30em", callback: function (resp) { diff --git a/web/views/@default/servers/certs/selectPopup.html b/web/views/@default/servers/certs/selectPopup.html index 627f0ae4..b49cf57f 100644 --- a/web/views/@default/servers/certs/selectPopup.html +++ b/web/views/@default/servers/certs/selectPopup.html @@ -35,7 +35,8 @@ 有效中 - 选择 + 选择 + 已选