mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 07:57:21 +08:00
feat: 优化证书列表账号显示
This commit is contained in:
@@ -85,16 +85,16 @@ func (r certAccountRepo) Create(req *request.CertAccountCreate) (*biz.CertAccoun
|
||||
case "sslcom":
|
||||
client, err = acme.NewRegisterAccount(context.Background(), account.Email, acme.CASSLcom, &acme.EAB{KeyID: account.Kid, MACKey: account.HmacEncoded}, acme.KeyType(account.KeyType))
|
||||
default:
|
||||
return nil, errors.New("CA 提供商不支持")
|
||||
return nil, errors.New("unsupported CA")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("注册账号失败:%v", err)
|
||||
return nil, fmt.Errorf("failed to register account: %v", err)
|
||||
}
|
||||
|
||||
privateKey, err := cert.EncodeKey(client.Account.PrivateKey)
|
||||
if err != nil {
|
||||
return nil, errors.New("获取私钥失败")
|
||||
return nil, errors.New("failed to get private key")
|
||||
}
|
||||
account.PrivateKey = string(privateKey)
|
||||
|
||||
@@ -144,16 +144,16 @@ func (r certAccountRepo) Update(req *request.CertAccountUpdate) error {
|
||||
case "sslcom":
|
||||
client, err = acme.NewRegisterAccount(context.Background(), account.Email, acme.CASSLcom, &acme.EAB{KeyID: account.Kid, MACKey: account.HmacEncoded}, acme.KeyType(account.KeyType))
|
||||
default:
|
||||
return errors.New("CA 提供商不支持")
|
||||
return errors.New("unsupported CA")
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return errors.New("向 CA 注册账号失败,请检查参数是否正确")
|
||||
return errors.New("failed to register account")
|
||||
}
|
||||
|
||||
privateKey, err := cert.EncodeKey(client.Account.PrivateKey)
|
||||
if err != nil {
|
||||
return errors.New("获取私钥失败")
|
||||
return errors.New("failed to get private key")
|
||||
}
|
||||
account.PrivateKey = string(privateKey)
|
||||
|
||||
@@ -177,13 +177,13 @@ func (r certAccountRepo) getGoogleEAB() (*acme.EAB, error) {
|
||||
client.SetTimeout(5 * time.Second)
|
||||
client.SetRetryCount(2)
|
||||
|
||||
resp, err := client.R().SetResult(&data{}).Get("https://panel.haozi.net/api/acme/googleEAB")
|
||||
resp, err := client.R().SetResult(&data{}).Get("https://gts.rat.dev/eab")
|
||||
if err != nil || !resp.IsSuccess() {
|
||||
return &acme.EAB{}, errors.New("获取Google EAB失败")
|
||||
return &acme.EAB{}, fmt.Errorf("failed to get Google EAB: %v", err)
|
||||
}
|
||||
eab := resp.Result().(*data)
|
||||
if eab.Message != "success" {
|
||||
return &acme.EAB{}, errors.New("获取Google EAB失败")
|
||||
return &acme.EAB{}, fmt.Errorf("failed to get Google EAB: %s", eab.Message)
|
||||
}
|
||||
|
||||
return &acme.EAB{KeyID: eab.Data.KeyId, MACKey: eab.Data.MacKey}, nil
|
||||
@@ -204,11 +204,11 @@ func (r certAccountRepo) getZeroSSLEAB(email string) (*acme.EAB, error) {
|
||||
"email": email,
|
||||
}).SetResult(&data{}).Post("https://api.zerossl.com/acme/eab-credentials-email")
|
||||
if err != nil || !resp.IsSuccess() {
|
||||
return &acme.EAB{}, errors.New("获取ZeroSSL EAB失败")
|
||||
return &acme.EAB{}, fmt.Errorf("failed to get ZeroSSL EAB: %v", err)
|
||||
}
|
||||
eab := resp.Result().(*data)
|
||||
if !eab.Success {
|
||||
return &acme.EAB{}, errors.New("获取ZeroSSL EAB失败")
|
||||
return &acme.EAB{}, fmt.Errorf("failed to get ZeroSSL EAB")
|
||||
}
|
||||
|
||||
return &acme.EAB{KeyID: eab.EabKid, MACKey: eab.EabHmacKey}, nil
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import Editor from '@guolao/vue-monaco-editor'
|
||||
import { NButton, NDataTable, NPopconfirm, NSpace, NSwitch, NTable, NTag } from 'naive-ui'
|
||||
import { NButton, NDataTable, NFlex, NPopconfirm, NSpace, NSwitch, NTable, NTag } from 'naive-ui'
|
||||
|
||||
import cert from '@/api/panel/cert'
|
||||
import type { Cert } from '@/views/cert/types'
|
||||
@@ -9,10 +9,11 @@ const props = defineProps({
|
||||
algorithms: Array<any>,
|
||||
websites: Array<any>,
|
||||
accounts: Array<any>,
|
||||
dns: Array<any>
|
||||
dns: Array<any>,
|
||||
caProviders: Array<any>
|
||||
})
|
||||
|
||||
const { algorithms, websites, accounts, dns } = toRefs(props)
|
||||
const { algorithms, websites, accounts, dns, caProviders } = toRefs(props)
|
||||
|
||||
let messageReactive: any
|
||||
|
||||
@@ -91,20 +92,19 @@ const columns: any = [
|
||||
{
|
||||
title: '关联账号',
|
||||
key: 'account_id',
|
||||
minWidth: 150,
|
||||
minWidth: 400,
|
||||
resizable: true,
|
||||
ellipsis: { tooltip: true },
|
||||
render(row: any) {
|
||||
return h(
|
||||
NTag,
|
||||
{
|
||||
type: row.account == null ? 'error' : 'success',
|
||||
bordered: false
|
||||
},
|
||||
{
|
||||
default: () => (row.account?.email == null ? '无' : row.account.email)
|
||||
}
|
||||
)
|
||||
return h(NFlex, null, {
|
||||
default: () => [
|
||||
h(NTag, null, { default: () => (row.account?.email == null ? '无' : row.account.email) }),
|
||||
h(NTag, null, {
|
||||
default: () =>
|
||||
caProviders?.value?.find((item: any) => item.value === row.account?.ca)?.label
|
||||
})
|
||||
]
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -436,7 +436,7 @@ onUnmounted(() => {
|
||||
<n-data-table
|
||||
striped
|
||||
remote
|
||||
:scroll-x="1000"
|
||||
:scroll-x="1400"
|
||||
:loading="false"
|
||||
:columns="columns"
|
||||
:data="data"
|
||||
|
||||
@@ -106,7 +106,13 @@ onUnmounted(() => {
|
||||
</template>
|
||||
<n-tabs v-model:value="currentTab" type="line" animated>
|
||||
<n-tab-pane name="cert" tab="证书列表">
|
||||
<cert-view :accounts="accounts" :algorithms="algorithms" :websites="websites" :dns="dns" />
|
||||
<cert-view
|
||||
:accounts="accounts"
|
||||
:algorithms="algorithms"
|
||||
:websites="websites"
|
||||
:dns="dns"
|
||||
:ca-providers="caProviders"
|
||||
/>
|
||||
</n-tab-pane>
|
||||
<n-tab-pane name="user" tab="账号列表">
|
||||
<account-view :ca-providers="caProviders" :algorithms="algorithms" />
|
||||
|
||||
Reference in New Issue
Block a user