1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

feat: 续签同步应用到网站

This commit is contained in:
zhengkunwang223 2023-01-04 14:26:22 +08:00 committed by zhengkunwang223
parent 75756e8bb7
commit 7f71b5f262
7 changed files with 28 additions and 8 deletions

View File

@ -4,7 +4,7 @@ type WebsiteDnsAccount struct {
BaseModel BaseModel
Name string `gorm:"type:varchar(64);not null" json:"name"` Name string `gorm:"type:varchar(64);not null" json:"name"`
Type string `gorm:"type:varchar(64);not null" json:"type"` Type string `gorm:"type:varchar(64);not null" json:"type"`
Authorization string `gorm:"type:varchar(256);not null" json:"_"` Authorization string `gorm:"type:varchar(256);not null" json:"-"`
} }
func (w WebsiteDnsAccount) TableName() string { func (w WebsiteDnsAccount) TableName() string {

View File

@ -19,6 +19,7 @@ type WebsiteSSL struct {
StartDate time.Time `json:"startDate"` StartDate time.Time `json:"startDate"`
AcmeAccount WebsiteAcmeAccount `json:"acmeAccount"` AcmeAccount WebsiteAcmeAccount `json:"acmeAccount"`
Websites []Website `json:"websites"`
} }
func (w WebsiteSSL) TableName() string { func (w WebsiteSSL) TableName() string {

View File

@ -48,7 +48,7 @@ func (w WebsiteSSLRepo) Page(page, size int, opts ...DBOption) (int64, []model.W
db := getDb(opts...).Model(&model.WebsiteSSL{}) db := getDb(opts...).Model(&model.WebsiteSSL{})
count := int64(0) count := int64(0)
db = db.Count(&count) db = db.Count(&count)
err := db.Limit(size).Offset(size * (page - 1)).Preload("AcmeAccount").Find(&sslList).Error err := db.Limit(size).Offset(size * (page - 1)).Preload("AcmeAccount").Preload("Websites").Find(&sslList).Error
return count, sslList, err return count, sslList, err
} }

View File

@ -169,6 +169,7 @@ export namespace Website {
expireDate: string; expireDate: string;
startDate: string; startDate: string;
provider: string; provider: string;
websites?: Website.Website[];
} }
export interface SSLCreate { export interface SSLCreate {

View File

@ -1002,6 +1002,7 @@ export default {
autoRenew: '自动续签', autoRenew: '自动续签',
autoRenewHelper: '距离到期时间7天自动续签', autoRenewHelper: '距离到期时间7天自动续签',
renewSuccess: '续签成功', renewSuccess: '续签成功',
renewWebsite: '该证书已经和以下网站关联续签会同步应用到这些网站',
}, },
firewall: { firewall: {
ccDeny: 'CC 防护', ccDeny: 'CC 防护',

View File

@ -105,7 +105,7 @@ const buttons = [
return row.provider === 'manual'; return row.provider === 'manual';
}, },
click: function (row: Website.SSL) { click: function (row: Website.SSL) {
openRenewSSL(row.id); openRenewSSL(row.id, row.websites);
}, },
}, },
{ {
@ -141,8 +141,8 @@ const openDnsAccount = () => {
const openSSL = () => { const openSSL = () => {
sslCreateRef.value.acceptParams(); sslCreateRef.value.acceptParams();
}; };
const openRenewSSL = (id: number) => { const openRenewSSL = (id: number, websites: Website.Website[]) => {
renewRef.value.acceptParams(id); renewRef.value.acceptParams({ id: id, websites: websites });
}; };
const openDetail = (id: number) => { const openDetail = (id: number) => {
detailRef.value.acceptParams(id); detailRef.value.acceptParams(id);

View File

@ -8,6 +8,16 @@
:before-close="handleClose" :before-close="handleClose"
> >
<div style="text-align: center"> <div style="text-align: center">
<span>{{ $t('ssl.renewWebsite') }}</span>
<div>
<br />
<span v-if="websites.length > 0">
<span v-for="(website, index) in websites" :key="index">
<el-tag>{{ website.primaryDomain }}</el-tag>
</span>
</span>
</div>
<br />
<span>{{ $t('ssl.renewConfirm') }}</span> <span>{{ $t('ssl.renewConfirm') }}</span>
</div> </div>
<template #footer> <template #footer>
@ -22,25 +32,32 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { Website } from '@/api/interface/Website';
import { RenewSSL } from '@/api/modules/website'; import { RenewSSL } from '@/api/modules/website';
import i18n from '@/lang'; import i18n from '@/lang';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
import { reactive, ref } from 'vue'; import { reactive, ref } from 'vue';
interface RenewProps {
id: number;
websites: Website.Website[];
}
let open = ref(false); let open = ref(false);
let loading = ref(false); let loading = ref(false);
let renewReq = reactive({ let renewReq = reactive({
SSLId: 0, SSLId: 0,
}); });
const em = defineEmits(['close']); const em = defineEmits(['close']);
const handleClose = () => { const handleClose = () => {
open.value = false; open.value = false;
em('close', false); em('close', false);
}; };
const websites = ref([]);
const acceptParams = async (id: number) => { const acceptParams = async (props: RenewProps) => {
renewReq.SSLId = id; renewReq.SSLId = Number(props.id);
websites.value = props.websites;
open.value = true; open.value = true;
}; };