diff --git a/backend/app/dto/response/website.go b/backend/app/dto/response/website.go index b80368224..15cc78f85 100644 --- a/backend/app/dto/response/website.go +++ b/backend/app/dto/response/website.go @@ -2,6 +2,7 @@ package response import ( "github.com/1Panel-dev/1Panel/backend/app/model" + "time" ) type WebsiteDTO struct { @@ -11,6 +12,24 @@ type WebsiteDTO struct { SitePath string `json:"sitePath"` AppName string `json:"appName"` RuntimeName string `json:"runtimeName"` + SiteDir string `gorm:"type:varchar;" json:"siteDir"` +} + +type WebsiteRes struct { + ID uint `json:"id"` + CreatedAt time.Time `json:"createdAt"` + Protocol string `json:"protocol"` + PrimaryDomain string `json:"primaryDomain"` + Type string `json:"type"` + Alias string `json:"alias"` + Remark string `json:"remark"` + Status string `json:"status"` + ExpireDate time.Time `json:"expireDate"` + SitePath string `json:"sitePath"` + AppName string `json:"appName"` + RuntimeName string `json:"runtimeName"` + SSLExpireDate time.Time `json:"sslExpireDate"` + SSLStatus string `json:"sslStatus"` } type WebsiteOption struct { diff --git a/backend/app/service/website.go b/backend/app/service/website.go index 35a39ad98..45656a6b7 100644 --- a/backend/app/service/website.go +++ b/backend/app/service/website.go @@ -53,7 +53,7 @@ type WebsiteService struct { } type IWebsiteService interface { - PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteDTO, error) + PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteRes, error) GetWebsites() ([]response.WebsiteDTO, error) CreateWebsite(create request.WebsiteCreate) error OpWebsite(req request.WebsiteOp) error @@ -102,9 +102,9 @@ func NewIWebsiteService() IWebsiteService { return &WebsiteService{} } -func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteDTO, error) { +func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []response.WebsiteRes, error) { var ( - websiteDTOs []response.WebsiteDTO + websiteDTOs []response.WebsiteRes opts []repo.DBOption ) nginxInstall, err := getAppInstallByKey(constant.AppOpenresty) @@ -154,11 +154,22 @@ func (w WebsiteService) PageWebsite(req request.WebsiteSearch) (int64, []respons runtimeName = runtime.Name } sitePath := path.Join(constant.AppInstallDir, constant.AppOpenresty, nginxInstall.Name, "www", "sites", web.Alias) - websiteDTOs = append(websiteDTOs, response.WebsiteDTO{ - Website: web, - AppName: appName, - RuntimeName: runtimeName, - SitePath: sitePath, + + websiteDTOs = append(websiteDTOs, response.WebsiteRes{ + ID: web.ID, + CreatedAt: web.CreatedAt, + Protocol: web.Protocol, + PrimaryDomain: web.PrimaryDomain, + Type: web.Type, + Remark: web.Remark, + Status: web.Status, + Alias: web.Alias, + AppName: appName, + ExpireDate: web.ExpireDate, + SSLExpireDate: web.WebsiteSSL.ExpireDate, + SSLStatus: checkSSLStatus(web.WebsiteSSL.ExpireDate), + RuntimeName: runtimeName, + SitePath: sitePath, }) } return total, websiteDTOs, nil diff --git a/backend/app/service/website_utils.go b/backend/app/service/website_utils.go index bdd76692c..179c7024b 100644 --- a/backend/app/service/website_utils.go +++ b/backend/app/service/website_utils.go @@ -1080,3 +1080,15 @@ func ChangeHSTSConfig(enable bool, nginxInstall model.AppInstall, website model. } return nil } + +func checkSSLStatus(expireDate time.Time) string { + now := time.Now() + daysUntilExpiry := int(expireDate.Sub(now).Hours() / 24) + + if daysUntilExpiry < 0 { + return "danger" + } else if daysUntilExpiry <= 10 { + return "warning" + } + return "success" +} diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts index a34070a10..820fc63e2 100644 --- a/frontend/src/api/interface/website.ts +++ b/frontend/src/api/interface/website.ts @@ -32,6 +32,19 @@ export namespace Website { appName: string; runtimeName: string; } + export interface WebsiteRes extends CommonModel { + protocol: string; + primaryDomain: string; + type: string; + alias: string; + remark: string; + status: string; + expireDate: string; + sitePath: string; + appName: string; + runtimeName: string; + sslExpireDate: Date; + } export interface NewAppInstall { name: string; diff --git a/frontend/src/api/modules/website.ts b/frontend/src/api/modules/website.ts index becc731f1..c30779f02 100644 --- a/frontend/src/api/modules/website.ts +++ b/frontend/src/api/modules/website.ts @@ -7,7 +7,7 @@ import { deepCopy } from '@/utils/util'; import { Base64 } from 'js-base64'; export const SearchWebsites = (req: Website.WebSiteSearch) => { - return http.post>(`/websites/search`, req); + return http.post>(`/websites/search`, req); }; export const ListWebsites = () => { diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 49cefb475..2c04532ad 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -2028,6 +2028,7 @@ const message = { 'Only supports importing local backups, importing backups from other machines may cause recovery failure', ipWebsiteWarn: 'Websites with IP as domain names need to be set as default sites to be accessed normally', hstsHelper: 'Enabling HSTS can increase website security', + sslExpireDate: 'Certificate expiration date', }, php: { short_open_tag: 'Short tag support', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index cacec876f..dadb4396b 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -1888,6 +1888,7 @@ const message = { websiteBackupWarn: '僅支援導入本機備份,導入其他機器備份可能會恢復失敗', ipWebsiteWarn: 'IP 為網域名稱的網站,需要設定為預設網站才能正常存取', hstsHelper: '開啟 HSTS 可以增加網站安全性', + sslExpireDate: '憑證過期時間', }, php: { short_open_tag: '短標簽支持', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index f5f8571f9..14f26a837 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -1890,6 +1890,7 @@ const message = { websiteBackupWarn: '仅支持导入本机备份,导入其他机器备份可能会恢复失败', ipWebsiteWarn: 'IP 为域名的网站,需要设置为默认站点才能正常访问', hstsHelper: '开启 HSTS 可以增加网站安全性', + sslExpireDate: '证书过期时间', }, php: { short_open_tag: '短标签支持', diff --git a/frontend/src/views/website/website/config/basic/https/index.vue b/frontend/src/views/website/website/config/basic/https/index.vue index 316895e95..90e32f56f 100644 --- a/frontend/src/views/website/website/config/basic/https/index.vue +++ b/frontend/src/views/website/website/config/basic/https/index.vue @@ -319,6 +319,7 @@ const submit = async (formEl: FormInstance | undefined) => { const changeEnable = (enable: boolean) => { if (enable) { listSSL(); + form.hsts = true; } if (resData.value.enable && !enable) { ElMessageBox.confirm(i18n.global.t('website.disableHTTPSHelper'), i18n.global.t('website.disableHTTPS'), { diff --git a/frontend/src/views/website/website/index.vue b/frontend/src/views/website/website/index.vue index 17117e58c..36620b3ee 100644 --- a/frontend/src/views/website/website/index.vue +++ b/frontend/src/views/website/website/index.vue @@ -154,6 +154,13 @@ + + +