mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 03:07:20 +08:00
feat: 证书支持同时部署多个网站
This commit is contained in:
@@ -59,7 +59,8 @@ func (r *certRepo) Create(req *request.CertCreate) (*biz.Cert, error) {
|
||||
}
|
||||
|
||||
func (r *certRepo) Update(req *request.CertUpdate) error {
|
||||
return app.Orm.Model(&biz.Cert{}).Where("id = ?", req.ID).Updates(&biz.Cert{
|
||||
return app.Orm.Model(&biz.Cert{}).Where("id = ?", req.ID).Select("*").Updates(&biz.Cert{
|
||||
ID: req.ID,
|
||||
AccountID: req.AccountID,
|
||||
WebsiteID: req.WebsiteID,
|
||||
DNSID: req.DNSID,
|
||||
|
||||
@@ -81,7 +81,7 @@ func (r *sshRepo) Update(req *request.SSHUpdate) error {
|
||||
Remark: req.Remark,
|
||||
}
|
||||
|
||||
return app.Orm.Model(ssh).Updates(ssh).Error
|
||||
return app.Orm.Model(ssh).Where("id = ?", req.ID).Select("*").Updates(ssh).Error
|
||||
}
|
||||
|
||||
func (r *sshRepo) Delete(id uint) error {
|
||||
|
||||
@@ -20,10 +20,10 @@ let messageReactive: MessageReactive | null = null
|
||||
|
||||
const updateCertModel = ref<any>({
|
||||
domains: [],
|
||||
dns_id: 0,
|
||||
type: 'P256',
|
||||
dns_id: null,
|
||||
account_id: null,
|
||||
website_id: 0,
|
||||
website_id: null,
|
||||
auto_renew: true
|
||||
})
|
||||
const updateCertModal = ref(false)
|
||||
@@ -35,8 +35,8 @@ const showCertModel = ref<any>({
|
||||
})
|
||||
const deployCertModal = ref(false)
|
||||
const deployCertModel = ref<any>({
|
||||
id: 0,
|
||||
website_id: 0
|
||||
id: null,
|
||||
websites: []
|
||||
})
|
||||
|
||||
const columns: any = [
|
||||
@@ -97,6 +97,9 @@ const columns: any = [
|
||||
resizable: true,
|
||||
ellipsis: { tooltip: true },
|
||||
render(row: any) {
|
||||
if (row.account_id == 0) {
|
||||
return h(NTag, null, { default: () => '无' })
|
||||
}
|
||||
return h(NFlex, null, {
|
||||
default: () => [
|
||||
h(NTag, null, { default: () => (row.account?.email == null ? '无' : row.account.email) }),
|
||||
@@ -255,12 +258,10 @@ const columns: any = [
|
||||
size: 'small',
|
||||
type: 'info',
|
||||
onClick: () => {
|
||||
if (row.website_id != 0) {
|
||||
deployCertModel.value.website_id = row.website_id
|
||||
} else {
|
||||
deployCertModel.value.website_id = 0
|
||||
}
|
||||
deployCertModel.value.id = row.id
|
||||
if (row.website_id != 0) {
|
||||
deployCertModel.value.websites.push(row.website_id)
|
||||
}
|
||||
deployCertModal.value = true
|
||||
}
|
||||
},
|
||||
@@ -318,10 +319,10 @@ const columns: any = [
|
||||
onClick: () => {
|
||||
updateCert.value = row.id
|
||||
updateCertModel.value.domains = row.domains
|
||||
updateCertModel.value.dns_id = row.dns_id
|
||||
updateCertModel.value.type = row.type
|
||||
updateCertModel.value.account_id = row.account_id
|
||||
updateCertModel.value.website_id = row.website_id
|
||||
updateCertModel.value.dns_id = row.dns_id == 0 ? null : row.dns_id
|
||||
updateCertModel.value.account_id = row.account_id == 0 ? null : row.account_id
|
||||
updateCertModel.value.website_id = row.website_id == 0 ? null : row.website_id
|
||||
updateCertModel.value.auto_renew = row.auto_renew
|
||||
updateCertModal.value = true
|
||||
}
|
||||
@@ -399,20 +400,21 @@ const handleUpdateCert = async () => {
|
||||
updateCertModal.value = false
|
||||
onPageChange(1)
|
||||
updateCertModel.value.domains = []
|
||||
updateCertModel.value.dns_id = 0
|
||||
updateCertModel.value.type = 'P256'
|
||||
updateCertModel.value.account_id = 0
|
||||
updateCertModel.value.website_id = 0
|
||||
updateCertModel.value.dns_id = null
|
||||
updateCertModel.value.account_id = null
|
||||
updateCertModel.value.website_id = null
|
||||
updateCertModel.value.auto_renew = true
|
||||
}
|
||||
|
||||
const handleDeployCert = async () => {
|
||||
await cert.deploy(deployCertModel.value.id, deployCertModel.value.website_id)
|
||||
for (const website of deployCertModel.value.websites) {
|
||||
await cert.deploy(deployCertModel.value.id, website)
|
||||
}
|
||||
window.$message.success('部署成功')
|
||||
deployCertModal.value = false
|
||||
deployCertModel.value.id = 0
|
||||
deployCertModel.value.website_id = 0
|
||||
onPageChange(1)
|
||||
deployCertModel.value.id = null
|
||||
deployCertModel.value.websites = []
|
||||
}
|
||||
|
||||
const handleShowModalClose = () => {
|
||||
@@ -519,9 +521,10 @@ onUnmounted(() => {
|
||||
<n-form :model="deployCertModel">
|
||||
<n-form-item path="website_id" label="网站">
|
||||
<n-select
|
||||
v-model:value="deployCertModel.website_id"
|
||||
v-model:value="deployCertModel.websites"
|
||||
placeholder="选择需要部署证书的网站"
|
||||
clearable
|
||||
multiple
|
||||
:options="websites"
|
||||
/>
|
||||
</n-form-item>
|
||||
|
||||
@@ -15,10 +15,10 @@ const { algorithms, websites, accounts, dns } = toRefs(props)
|
||||
|
||||
const model = ref<any>({
|
||||
domains: [],
|
||||
dns_id: 0,
|
||||
dns_id: null,
|
||||
type: 'P256',
|
||||
account_id: null,
|
||||
website_id: 0,
|
||||
website_id: null,
|
||||
auto_renew: true
|
||||
})
|
||||
|
||||
@@ -29,8 +29,8 @@ const handleCreateCert = async () => {
|
||||
model.value.domains = []
|
||||
model.value.dns_id = 0
|
||||
model.value.type = 'P256'
|
||||
model.value.account_id = 0
|
||||
model.value.website_id = 0
|
||||
model.value.account_id = null
|
||||
model.value.website_id = null
|
||||
model.value.auto_renew = true
|
||||
window.$bus.emit('cert:refresh-cert')
|
||||
window.$bus.emit('cert:refresh-async')
|
||||
|
||||
@@ -33,10 +33,6 @@ const getAsyncData = async () => {
|
||||
algorithms.value = algorithmData
|
||||
|
||||
websites.value = []
|
||||
websites.value.push({
|
||||
label: '无',
|
||||
value: 0
|
||||
})
|
||||
app.isInstalled('nginx').then(async (res) => {
|
||||
if (res.data.installed) {
|
||||
const { data: websiteData } = await website.list(1, 10000)
|
||||
@@ -51,10 +47,6 @@ const getAsyncData = async () => {
|
||||
|
||||
const { data: dnsData } = await cert.dns(1, 10000)
|
||||
dns.value = []
|
||||
dns.value.push({
|
||||
label: '无',
|
||||
value: 0
|
||||
})
|
||||
for (const item of dnsData.items) {
|
||||
dns.value.push({
|
||||
label: item.name,
|
||||
|
||||
Reference in New Issue
Block a user