完善证书管理与初始化流程
This commit is contained in:
1 parent
07636abe44
commit
c74372284a
84 files changed
+10151
-3502
No files matched your search
@@ -0,0 +1,474 @@
|
||||
.page-shell {
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
padding: 42px 28px 70px;
|
||||
}
|
||||
.topbar,
|
||||
.panel-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
}
|
||||
.topbar-actions,
|
||||
.row-actions,
|
||||
.modal-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
.topbar-actions {
|
||||
flex-wrap: wrap;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.eyebrow {
|
||||
margin: 0 0 9px;
|
||||
color: #687792;
|
||||
font-size: 11px;
|
||||
font-weight: 800;
|
||||
letter-spacing: 0.15em;
|
||||
}
|
||||
h1,
|
||||
h2,
|
||||
p {
|
||||
margin-top: 0;
|
||||
}
|
||||
h1 {
|
||||
margin-bottom: 0;
|
||||
font-size: clamp(30px, 5vw, 52px);
|
||||
letter-spacing: -0.05em;
|
||||
}
|
||||
h2 {
|
||||
margin-bottom: 10px;
|
||||
font-size: clamp(24px, 4vw, 38px);
|
||||
letter-spacing: -0.04em;
|
||||
}
|
||||
.secondary-button {
|
||||
border: 1px solid #d5ddea;
|
||||
border-radius: 12px;
|
||||
background: #fff;
|
||||
color: #32405a;
|
||||
padding: 11px 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
.primary-button {
|
||||
border: 1px solid #315aaa;
|
||||
border-radius: 12px;
|
||||
background: #315aaa;
|
||||
color: #fff;
|
||||
padding: 11px 16px;
|
||||
font-weight: 800;
|
||||
box-shadow: 0 8px 18px rgba(49, 90, 170, 0.18);
|
||||
}
|
||||
.primary-button:disabled,
|
||||
.secondary-button:disabled {
|
||||
cursor: wait;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.hero-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 250px;
|
||||
margin: 36px 0 18px;
|
||||
padding: 36px 42px;
|
||||
border-radius: 28px;
|
||||
color: #fff;
|
||||
background: linear-gradient(120deg, #182b5b, #315aaa);
|
||||
box-shadow: 0 20px 45px rgba(42, 75, 145, 0.2);
|
||||
}
|
||||
.hero-card p {
|
||||
max-width: 650px;
|
||||
margin-bottom: 0;
|
||||
color: #d5e1ff;
|
||||
line-height: 1.8;
|
||||
}
|
||||
.status-label {
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
}
|
||||
.status-dot {
|
||||
display: inline-block;
|
||||
width: 9px;
|
||||
height: 9px;
|
||||
margin-right: 8px;
|
||||
border-radius: 50%;
|
||||
background: #ffba58;
|
||||
}
|
||||
.status-dot.online {
|
||||
background: #5ee0a0;
|
||||
box-shadow: 0 0 0 5px rgba(94, 224, 160, 0.15);
|
||||
}
|
||||
.hero-mark {
|
||||
display: block;
|
||||
width: 138px;
|
||||
height: 138px;
|
||||
object-fit: contain;
|
||||
filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.18));
|
||||
}
|
||||
.error-banner,
|
||||
.notice-banner {
|
||||
margin: 18px 0;
|
||||
padding: 14px 18px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.error-banner {
|
||||
border: 1px solid #f0c4c4;
|
||||
color: #9c3b3b;
|
||||
background: #fff2f2;
|
||||
}
|
||||
.notice-banner {
|
||||
border: 1px solid #bfe7d1;
|
||||
color: #24734b;
|
||||
background: #effbf4;
|
||||
}
|
||||
.metrics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 14px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.metric-card,
|
||||
.panel {
|
||||
border: 1px solid #e2e8f2;
|
||||
border-radius: 20px;
|
||||
background: rgba(255, 255, 255, 0.86);
|
||||
box-shadow: 0 10px 30px rgba(31, 50, 87, 0.04);
|
||||
}
|
||||
.metric-card {
|
||||
padding: 22px;
|
||||
}
|
||||
.metric-card span,
|
||||
.domain-row span,
|
||||
.muted {
|
||||
color: #7a879d;
|
||||
font-size: 13px;
|
||||
}
|
||||
.metric-card strong {
|
||||
display: block;
|
||||
margin-top: 13px;
|
||||
font-size: 28px;
|
||||
}
|
||||
.panel {
|
||||
padding: 28px;
|
||||
}
|
||||
.server-panel {
|
||||
margin-top: 18px;
|
||||
}
|
||||
.panel-heading {
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
.panel-heading h2 {
|
||||
margin-bottom: 0;
|
||||
font-size: 26px;
|
||||
}
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 52px 10px;
|
||||
color: #7a879d;
|
||||
text-align: center;
|
||||
}
|
||||
.empty-state strong {
|
||||
color: #32405a;
|
||||
font-size: 17px;
|
||||
}
|
||||
code {
|
||||
padding: 2px 6px;
|
||||
border-radius: 6px;
|
||||
background: #eef2f8;
|
||||
font-family: Consolas, monospace;
|
||||
}
|
||||
.domain-list {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
.domain-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||
align-items: center;
|
||||
gap: 22px;
|
||||
padding: 17px 18px;
|
||||
border: 1px solid #edf0f5;
|
||||
border-radius: 13px;
|
||||
}
|
||||
.domain-row strong,
|
||||
.domain-row span {
|
||||
display: block;
|
||||
}
|
||||
.domain-title-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
.domain-title-line strong {
|
||||
margin-bottom: 0;
|
||||
font-size: 17px;
|
||||
}
|
||||
.domain-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px 16px;
|
||||
margin-top: 9px;
|
||||
}
|
||||
.domain-meta span,
|
||||
.domain-expiry span {
|
||||
color: #7a879d;
|
||||
font-size: 12px;
|
||||
}
|
||||
.domain-expiry {
|
||||
min-width: 105px;
|
||||
text-align: right;
|
||||
}
|
||||
.domain-expiry strong {
|
||||
margin-bottom: 5px;
|
||||
font-size: 13px;
|
||||
}
|
||||
.text-button {
|
||||
padding: 5px 3px;
|
||||
border: 0;
|
||||
color: #315aaa;
|
||||
background: transparent;
|
||||
font-weight: 800;
|
||||
}
|
||||
.danger-text {
|
||||
color: #ba5555;
|
||||
}
|
||||
.tag {
|
||||
padding: 5px 10px;
|
||||
border-radius: 99px;
|
||||
background: #fff3d8;
|
||||
color: #9b6a1a !important;
|
||||
font-size: 12px !important;
|
||||
}
|
||||
.tag.success {
|
||||
background: #e7f8ee;
|
||||
color: #24734b !important;
|
||||
}
|
||||
.tag.danger {
|
||||
background: #fff0f0;
|
||||
color: #ba5555 !important;
|
||||
}
|
||||
.modal-backdrop {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 10;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 20px;
|
||||
background: rgba(18, 31, 58, 0.45);
|
||||
}
|
||||
.modal-card {
|
||||
width: min(100%, 560px);
|
||||
max-height: calc(100vh - 40px);
|
||||
overflow: auto;
|
||||
padding: 30px;
|
||||
border: 1px solid #e2e8f2;
|
||||
border-radius: 22px;
|
||||
background: #fff;
|
||||
box-shadow: 0 24px 70px rgba(19, 38, 79, 0.25);
|
||||
}
|
||||
.modal-heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.modal-heading h2 {
|
||||
margin-bottom: 0;
|
||||
font-size: 28px;
|
||||
}
|
||||
.close-button {
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border: 0;
|
||||
border-radius: 10px;
|
||||
color: #687792;
|
||||
background: #f1f4f8;
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
}
|
||||
.field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
margin-bottom: 17px;
|
||||
color: #32405a;
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
}
|
||||
.field small,
|
||||
.switch-field small {
|
||||
margin-left: 5px;
|
||||
color: #8995a8;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.field input,
|
||||
.field select,
|
||||
.field textarea {
|
||||
width: 100%;
|
||||
border: 1px solid #d8e0eb;
|
||||
border-radius: 10px;
|
||||
outline: 0;
|
||||
padding: 11px 12px;
|
||||
color: #172033;
|
||||
background: #fbfcfe;
|
||||
font: inherit;
|
||||
font-weight: 500;
|
||||
}
|
||||
.field textarea {
|
||||
resize: vertical;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.field input:focus,
|
||||
.field select:focus,
|
||||
.field textarea:focus {
|
||||
border-color: #4f7ed5;
|
||||
box-shadow: 0 0 0 3px rgba(79, 126, 213, 0.12);
|
||||
}
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 14px;
|
||||
}
|
||||
.switch-field {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 10px;
|
||||
margin: 4px 0 20px;
|
||||
color: #32405a;
|
||||
font-size: 13px;
|
||||
}
|
||||
.switch-field input {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
accent-color: #315aaa;
|
||||
}
|
||||
.switch-field strong,
|
||||
.switch-field small {
|
||||
display: block;
|
||||
}
|
||||
.switch-field small {
|
||||
margin: 5px 0 0;
|
||||
}
|
||||
.server-picker {
|
||||
margin: 4px 0 20px;
|
||||
padding: 15px;
|
||||
border: 1px solid #e2e8f2;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.server-picker legend {
|
||||
padding: 0 5px;
|
||||
color: #32405a;
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
}
|
||||
.server-option {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 9px;
|
||||
padding: 9px 4px;
|
||||
color: #32405a;
|
||||
font-size: 13px;
|
||||
}
|
||||
.server-option input {
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
accent-color: #315aaa;
|
||||
}
|
||||
.server-option strong,
|
||||
.server-option small {
|
||||
display: block;
|
||||
}
|
||||
.server-option small {
|
||||
margin-top: 4px;
|
||||
color: #8995a8;
|
||||
font-size: 11px;
|
||||
}
|
||||
.form-error {
|
||||
margin: 0 0 16px;
|
||||
color: #ba5555;
|
||||
font-size: 13px;
|
||||
}
|
||||
.field-hint {
|
||||
margin: -4px 0 17px;
|
||||
color: #6d7b91;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.security-hint {
|
||||
margin: -2px 0 16px;
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
color: #315b48;
|
||||
background: #eef9f3;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.key-fingerprint {
|
||||
overflow-wrap: anywhere;
|
||||
font-family: Consolas, monospace;
|
||||
}
|
||||
.modal-actions {
|
||||
justify-content: flex-end;
|
||||
padding-top: 5px;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.page-shell {
|
||||
padding: 26px 16px 48px;
|
||||
}
|
||||
.topbar {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
.topbar-actions {
|
||||
width: 100%;
|
||||
justify-content: stretch;
|
||||
}
|
||||
.topbar-actions button {
|
||||
flex: 1 1 calc(50% - 10px);
|
||||
}
|
||||
.hero-card {
|
||||
align-items: flex-start;
|
||||
padding: 28px;
|
||||
}
|
||||
.hero-mark {
|
||||
display: none;
|
||||
}
|
||||
.metrics-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
.panel {
|
||||
padding: 20px;
|
||||
}
|
||||
.panel-heading {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
.domain-row {
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 14px;
|
||||
}
|
||||
.domain-expiry {
|
||||
text-align: left;
|
||||
}
|
||||
.row-actions {
|
||||
grid-column: 1 / -1;
|
||||
justify-content: flex-end;
|
||||
border-top: 1px solid #edf0f5;
|
||||
padding-top: 10px;
|
||||
}
|
||||
.modal-card {
|
||||
padding: 22px;
|
||||
}
|
||||
.form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,482 @@
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
|
||||
export function useDashboard() {
|
||||
const scertLogo = "/Scert.png";
|
||||
|
||||
const status = ref(null);
|
||||
const domains = ref([]);
|
||||
const servers = ref([]);
|
||||
const sshKeys = ref([]);
|
||||
const domainServers = ref({});
|
||||
const loading = ref(true);
|
||||
const saving = ref(false);
|
||||
const error = ref("");
|
||||
const notice = ref("");
|
||||
const formError = ref("");
|
||||
const showForm = ref(false);
|
||||
const editingId = ref("");
|
||||
const showServerForm = ref(false);
|
||||
const serverEditingId = ref("");
|
||||
const serverSaving = ref(false);
|
||||
const serverFormError = ref("");
|
||||
const showSSHKeyForm = ref(false);
|
||||
const sshKeySaving = ref(false);
|
||||
const sshKeyFormError = ref("");
|
||||
|
||||
const certificateTypeLabels = {
|
||||
single: "单域名",
|
||||
wildcard: "泛域名",
|
||||
san: "SAN 多域名",
|
||||
};
|
||||
const domainStatusLabels = {
|
||||
pending: "等待申请",
|
||||
active: "正常",
|
||||
error: "错误",
|
||||
};
|
||||
const httpsModeLabels = { direct: "核心服务 HTTPS", proxy: "反向代理 HTTPS" };
|
||||
const environmentLabels = { staging: "测试环境", production: "生产环境" };
|
||||
const webServerLabels = {
|
||||
nginx: "Nginx",
|
||||
caddy: "Caddy",
|
||||
apache: "Apache",
|
||||
custom: "自定义网站服务",
|
||||
};
|
||||
const dnsProviders = [
|
||||
{ value: "cloudflare", label: "Cloudflare" },
|
||||
{ value: "aliyun", label: "阿里云 DNS" },
|
||||
{ value: "dnspod", label: "DNSPod" },
|
||||
{ value: "cname", label: "CNAME 委派" },
|
||||
{ value: "huaweicloud", label: "华为云" },
|
||||
{ value: "tencentcloud", label: "腾讯云" },
|
||||
{ value: "route53", label: "AWS Route 53" },
|
||||
{ value: "googlecloud", label: "Google Cloud DNS" },
|
||||
{ value: "other", label: "其他服务商" },
|
||||
];
|
||||
|
||||
const isEditing = computed(() => Boolean(editingId.value));
|
||||
const formTitle = computed(() =>
|
||||
isEditing.value ? "编辑域名配置" : "添加托管域名",
|
||||
);
|
||||
|
||||
const defaultCertificatePath = "/ssl/{域名}/{证书类型}/cert.pem";
|
||||
const defaultCertificateChainPath = "/ssl/{域名}/{证书类型}/fullchain.pem";
|
||||
const defaultPrivateKeyPath = "/ssl/{域名}/{证书类型}/key.pem";
|
||||
|
||||
const form = ref(createEmptyForm());
|
||||
const serverForm = ref(createEmptyServerForm());
|
||||
const sshKeyForm = ref(createEmptySSHKeyForm());
|
||||
|
||||
function createEmptyForm() {
|
||||
return {
|
||||
name: "",
|
||||
certificate_type: "single",
|
||||
sans: "",
|
||||
auto_renew: true,
|
||||
acme_environment: "staging",
|
||||
dns_provider: "",
|
||||
server_ids: [],
|
||||
};
|
||||
}
|
||||
|
||||
function createEmptyServerForm() {
|
||||
return {
|
||||
name: "",
|
||||
address: "",
|
||||
port: 22,
|
||||
username: "",
|
||||
private_key_ref: "",
|
||||
host_key_fingerprint: "",
|
||||
certificate_path: defaultCertificatePath,
|
||||
private_key_path: defaultPrivateKeyPath,
|
||||
certificate_chain_path: defaultCertificateChainPath,
|
||||
web_server: "nginx",
|
||||
reload_command: "",
|
||||
server_ids: [],
|
||||
};
|
||||
}
|
||||
|
||||
function createEmptySSHKeyForm() {
|
||||
return { name: "", private_key: "", passphrase: "" };
|
||||
}
|
||||
|
||||
function displayLabel(labels, value) {
|
||||
return labels[value] || (value ? "未知" : "—");
|
||||
}
|
||||
|
||||
function formatDate(value) {
|
||||
if (!value) return "尚未签发";
|
||||
return new Intl.DateTimeFormat("zh-CN", {
|
||||
dateStyle: "medium",
|
||||
timeZone: "Asia/Shanghai",
|
||||
}).format(new Date(value));
|
||||
}
|
||||
|
||||
function daysRemaining(value) {
|
||||
if (!value) return "待申请";
|
||||
const days = Math.ceil((new Date(value).getTime() - Date.now()) / 86400000);
|
||||
return days >= 0 ? `剩余 ${days} 天` : `已过期 ${Math.abs(days)} 天`;
|
||||
}
|
||||
|
||||
function statusClass(value) {
|
||||
return value === "active"
|
||||
? "success"
|
||||
: value === "error"
|
||||
? "danger"
|
||||
: "warning";
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
editingId.value = "";
|
||||
form.value = createEmptyForm();
|
||||
formError.value = "";
|
||||
showForm.value = true;
|
||||
}
|
||||
|
||||
function openEdit(item) {
|
||||
editingId.value = item.id;
|
||||
form.value = {
|
||||
name: item.name,
|
||||
certificate_type: item.certificate_type,
|
||||
sans: (item.sans || []).filter((name) => name !== item.name).join("\n"),
|
||||
auto_renew: item.auto_renew !== false,
|
||||
acme_environment: item.acme_environment || "staging",
|
||||
dns_provider: item.dns_provider || "",
|
||||
server_ids: (domainServers.value[item.id] || []).map(
|
||||
(server) => server.id,
|
||||
),
|
||||
};
|
||||
formError.value = "";
|
||||
showForm.value = true;
|
||||
}
|
||||
|
||||
function closeForm() {
|
||||
if (!saving.value) showForm.value = false;
|
||||
}
|
||||
|
||||
function openServerCreate() {
|
||||
serverEditingId.value = "";
|
||||
serverForm.value = createEmptyServerForm();
|
||||
serverFormError.value = "";
|
||||
showServerForm.value = true;
|
||||
}
|
||||
|
||||
function openServerEdit(item) {
|
||||
serverEditingId.value = item.id;
|
||||
serverForm.value = {
|
||||
...item,
|
||||
reload_command: (item.reload_command || []).join("\n"),
|
||||
server_ids: [],
|
||||
};
|
||||
serverFormError.value = "";
|
||||
showServerForm.value = true;
|
||||
}
|
||||
|
||||
function closeServerForm() {
|
||||
if (!serverSaving.value) showServerForm.value = false;
|
||||
}
|
||||
|
||||
function openSSHKeyCreate() {
|
||||
sshKeyForm.value = createEmptySSHKeyForm();
|
||||
sshKeyFormError.value = "";
|
||||
showSSHKeyForm.value = true;
|
||||
}
|
||||
|
||||
function closeSSHKeyForm() {
|
||||
if (sshKeySaving.value) return;
|
||||
sshKeyForm.value = createEmptySSHKeyForm();
|
||||
sshKeyFormError.value = "";
|
||||
showSSHKeyForm.value = false;
|
||||
}
|
||||
|
||||
async function saveSSHKey() {
|
||||
sshKeyFormError.value = "";
|
||||
sshKeySaving.value = true;
|
||||
try {
|
||||
const response = await fetch("/api/v1/ssh-keys", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(sshKeyForm.value),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "保存 SSH 私钥失败");
|
||||
sshKeyForm.value = createEmptySSHKeyForm();
|
||||
showSSHKeyForm.value = false;
|
||||
notice.value = "SSH 私钥已加密保存";
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
sshKeyFormError.value = err.message || "保存 SSH 私钥失败";
|
||||
} finally {
|
||||
sshKeySaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteSSHKey(item) {
|
||||
if (
|
||||
!window.confirm(
|
||||
`确定删除 SSH 私钥“${item.name}”吗?正在被服务器使用的私钥无法删除。`,
|
||||
)
|
||||
)
|
||||
return;
|
||||
try {
|
||||
const response = await fetch(`/api/v1/ssh-keys/${item.id}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "删除 SSH 私钥失败");
|
||||
notice.value = "SSH 私钥已删除";
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
error.value = err.message || "删除 SSH 私钥失败";
|
||||
}
|
||||
}
|
||||
|
||||
function parseCommand(value) {
|
||||
return value
|
||||
.split(/\n/)
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
async function saveServer() {
|
||||
serverFormError.value = "";
|
||||
serverSaving.value = true;
|
||||
try {
|
||||
const payload = {
|
||||
name: serverForm.value.name,
|
||||
address: serverForm.value.address,
|
||||
port: Number(serverForm.value.port),
|
||||
username: serverForm.value.username,
|
||||
private_key_ref: serverForm.value.private_key_ref,
|
||||
host_key_fingerprint: serverForm.value.host_key_fingerprint,
|
||||
certificate_path: serverForm.value.certificate_path,
|
||||
private_key_path: serverForm.value.private_key_path,
|
||||
certificate_chain_path: serverForm.value.certificate_chain_path,
|
||||
web_server: serverForm.value.web_server,
|
||||
reload_command: parseCommand(serverForm.value.reload_command),
|
||||
};
|
||||
const path = serverEditingId.value
|
||||
? `/api/v1/servers/${serverEditingId.value}`
|
||||
: "/api/v1/servers";
|
||||
const response = await fetch(path, {
|
||||
method: serverEditingId.value ? "PUT" : "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "保存服务器失败");
|
||||
showServerForm.value = false;
|
||||
notice.value = serverEditingId.value
|
||||
? "服务器配置已更新"
|
||||
: "服务器已添加";
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
serverFormError.value = err.message || "保存服务器失败";
|
||||
} finally {
|
||||
serverSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteServer(item) {
|
||||
if (!window.confirm(`确定删除服务器“${item.name}”吗?关联域名也会解除。`))
|
||||
return;
|
||||
try {
|
||||
const response = await fetch(`/api/v1/servers/${item.id}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "删除服务器失败");
|
||||
notice.value = "服务器已删除";
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
error.value = err.message || "删除服务器失败";
|
||||
}
|
||||
}
|
||||
|
||||
async function saveDomainServers(domainId, serverIds) {
|
||||
const response = await fetch(`/api/v1/domains/${domainId}/servers`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ server_ids: serverIds }),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "保存域名服务器关联失败");
|
||||
domainServers.value = {
|
||||
...domainServers.value,
|
||||
[domainId]: result.items || [],
|
||||
};
|
||||
}
|
||||
|
||||
function parseSANs(value) {
|
||||
return value
|
||||
.split(/[\n,,]/)
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
async function saveDomain() {
|
||||
formError.value = "";
|
||||
notice.value = "";
|
||||
if (!form.value.name.trim()) {
|
||||
formError.value = "请输入主域名";
|
||||
return;
|
||||
}
|
||||
if (
|
||||
form.value.certificate_type === "san" &&
|
||||
parseSANs(form.value.sans).length === 0
|
||||
) {
|
||||
formError.value = "SAN 证书至少需要填写一个附加域名";
|
||||
return;
|
||||
}
|
||||
saving.value = true;
|
||||
try {
|
||||
const payload = {
|
||||
name: form.value.name,
|
||||
certificate_type: form.value.certificate_type,
|
||||
sans: parseSANs(form.value.sans),
|
||||
auto_renew: form.value.auto_renew,
|
||||
acme_environment: form.value.acme_environment,
|
||||
dns_provider: form.value.dns_provider,
|
||||
};
|
||||
const path = isEditing.value
|
||||
? `/api/v1/domains/${editingId.value}`
|
||||
: "/api/v1/domains";
|
||||
const response = await fetch(path, {
|
||||
method: isEditing.value ? "PUT" : "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "保存域名失败");
|
||||
await saveDomainServers(result.id, form.value.server_ids);
|
||||
showForm.value = false;
|
||||
notice.value = isEditing.value
|
||||
? "域名配置已更新"
|
||||
: "域名已添加,等待申请证书";
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
formError.value = err.message || "保存域名失败";
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteDomain(item) {
|
||||
if (
|
||||
!window.confirm(
|
||||
`确定删除域名“${item.name}”吗?删除前请确认没有正在执行的任务。`,
|
||||
)
|
||||
)
|
||||
return;
|
||||
error.value = "";
|
||||
notice.value = "";
|
||||
try {
|
||||
const response = await fetch(`/api/v1/domains/${item.id}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
if (!response.ok) {
|
||||
const result = await response.json().catch(() => ({}));
|
||||
throw new Error(result.error || "删除域名失败");
|
||||
}
|
||||
notice.value = "域名已删除";
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
error.value = err.message || "删除域名失败";
|
||||
}
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
loading.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const [statusResponse, domainResponse, serverResponse, sshKeyResponse] =
|
||||
await Promise.all([
|
||||
fetch("/api/v1/status"),
|
||||
fetch("/api/v1/domains"),
|
||||
fetch("/api/v1/servers"),
|
||||
fetch("/api/v1/ssh-keys"),
|
||||
]);
|
||||
if (
|
||||
!statusResponse.ok ||
|
||||
!domainResponse.ok ||
|
||||
!serverResponse.ok ||
|
||||
!sshKeyResponse.ok
|
||||
)
|
||||
throw new Error("服务接口返回失败");
|
||||
status.value = await statusResponse.json();
|
||||
domains.value = (await domainResponse.json()).items || [];
|
||||
servers.value = (await serverResponse.json()).items || [];
|
||||
sshKeys.value = (await sshKeyResponse.json()).items || [];
|
||||
const associations = await Promise.all(
|
||||
domains.value.map(async (item) => {
|
||||
const response = await fetch(`/api/v1/domains/${item.id}/servers`);
|
||||
return [
|
||||
item.id,
|
||||
response.ok ? (await response.json()).items || [] : [],
|
||||
];
|
||||
}),
|
||||
);
|
||||
domainServers.value = Object.fromEntries(associations);
|
||||
} catch {
|
||||
error.value = "无法连接核心服务,请先启动 scert serve";
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadData);
|
||||
|
||||
return {
|
||||
scertLogo,
|
||||
status,
|
||||
domains,
|
||||
servers,
|
||||
sshKeys,
|
||||
domainServers,
|
||||
loading,
|
||||
saving,
|
||||
error,
|
||||
notice,
|
||||
formError,
|
||||
showForm,
|
||||
editingId,
|
||||
showServerForm,
|
||||
serverEditingId,
|
||||
serverSaving,
|
||||
serverFormError,
|
||||
showSSHKeyForm,
|
||||
sshKeySaving,
|
||||
sshKeyFormError,
|
||||
certificateTypeLabels,
|
||||
domainStatusLabels,
|
||||
httpsModeLabels,
|
||||
environmentLabels,
|
||||
webServerLabels,
|
||||
isEditing,
|
||||
formTitle,
|
||||
form,
|
||||
serverForm,
|
||||
sshKeyForm,
|
||||
defaultCertificatePath,
|
||||
defaultCertificateChainPath,
|
||||
defaultPrivateKeyPath,
|
||||
openCreate,
|
||||
openEdit,
|
||||
closeForm,
|
||||
openServerCreate,
|
||||
openServerEdit,
|
||||
closeServerForm,
|
||||
openSSHKeyCreate,
|
||||
closeSSHKeyForm,
|
||||
saveSSHKey,
|
||||
deleteSSHKey,
|
||||
saveServer,
|
||||
deleteServer,
|
||||
saveDomain,
|
||||
deleteDomain,
|
||||
loadData,
|
||||
displayLabel,
|
||||
formatDate,
|
||||
daysRemaining,
|
||||
statusClass,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,655 @@
|
||||
<script setup>
|
||||
import { useDashboard } from "./Dashboard.js";
|
||||
|
||||
const {
|
||||
scertLogo,
|
||||
status,
|
||||
domains,
|
||||
servers,
|
||||
sshKeys,
|
||||
domainServers,
|
||||
loading,
|
||||
saving,
|
||||
error,
|
||||
notice,
|
||||
formError,
|
||||
showForm,
|
||||
editingId,
|
||||
showServerForm,
|
||||
serverEditingId,
|
||||
serverSaving,
|
||||
serverFormError,
|
||||
showSSHKeyForm,
|
||||
sshKeySaving,
|
||||
sshKeyFormError,
|
||||
certificateTypeLabels,
|
||||
domainStatusLabels,
|
||||
httpsModeLabels,
|
||||
environmentLabels,
|
||||
webServerLabels,
|
||||
isEditing,
|
||||
formTitle,
|
||||
form,
|
||||
serverForm,
|
||||
sshKeyForm,
|
||||
defaultCertificatePath,
|
||||
defaultCertificateChainPath,
|
||||
defaultPrivateKeyPath,
|
||||
openCreate,
|
||||
openEdit,
|
||||
closeForm,
|
||||
openServerCreate,
|
||||
openServerEdit,
|
||||
closeServerForm,
|
||||
openSSHKeyCreate,
|
||||
closeSSHKeyForm,
|
||||
saveSSHKey,
|
||||
deleteSSHKey,
|
||||
saveServer,
|
||||
deleteServer,
|
||||
saveDomain,
|
||||
deleteDomain,
|
||||
loadData,
|
||||
displayLabel,
|
||||
formatDate,
|
||||
daysRemaining,
|
||||
statusClass,
|
||||
} = useDashboard();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="page-shell">
|
||||
<header class="topbar">
|
||||
<div>
|
||||
<p class="eyebrow">SCERT / SSL 证书管理</p>
|
||||
<h1>证书管理总览</h1>
|
||||
</div>
|
||||
<div class="topbar-actions">
|
||||
<button class="secondary-button" type="button" @click="loadData">
|
||||
刷新状态
|
||||
</button>
|
||||
<button
|
||||
class="secondary-button"
|
||||
type="button"
|
||||
@click="openSSHKeyCreate"
|
||||
>
|
||||
添加 SSH 私钥
|
||||
</button>
|
||||
<button
|
||||
class="secondary-button"
|
||||
type="button"
|
||||
@click="openServerCreate"
|
||||
>
|
||||
添加服务器
|
||||
</button>
|
||||
<button class="primary-button" type="button" @click="openCreate">
|
||||
添加域名
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<section class="hero-card">
|
||||
<div>
|
||||
<span class="status-dot" :class="{ online: status }"></span>
|
||||
<span class="status-label">{{
|
||||
status ? "核心服务运行中" : "等待连接核心服务"
|
||||
}}</span>
|
||||
<h2>让证书续期和部署变得可追踪</h2>
|
||||
<p>
|
||||
统一管理单域名、泛域名和 SAN 证书,后续将接入 lego、DNS
|
||||
验证与远程部署流程。
|
||||
</p>
|
||||
</div>
|
||||
<img class="hero-mark" :src="scertLogo" alt="Scert 标志" />
|
||||
</section>
|
||||
|
||||
<p v-if="error" class="error-banner">{{ error }}</p>
|
||||
<p v-if="notice" class="notice-banner">{{ notice }}</p>
|
||||
|
||||
<section class="metrics-grid">
|
||||
<article class="metric-card">
|
||||
<span>服务版本</span><strong>{{ status?.version || "—" }}</strong>
|
||||
</article>
|
||||
<article class="metric-card">
|
||||
<span>数据库</span
|
||||
><strong>{{
|
||||
displayLabel(
|
||||
{ sqlite: "SQLite", mysql: "MySQL" },
|
||||
status?.database_driver,
|
||||
)
|
||||
}}</strong>
|
||||
</article>
|
||||
<article class="metric-card">
|
||||
<span>HTTPS 模式</span
|
||||
><strong>{{
|
||||
displayLabel(httpsModeLabels, status?.https_mode)
|
||||
}}</strong>
|
||||
</article>
|
||||
<article class="metric-card">
|
||||
<span>托管域名</span><strong>{{ domains.length }}</strong>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<p class="eyebrow">域名配置</p>
|
||||
<h2>托管域名</h2>
|
||||
</div>
|
||||
<span class="muted">共 {{ domains.length }} 个配置</span>
|
||||
</div>
|
||||
<div v-if="loading" class="empty-state">正在读取域名状态……</div>
|
||||
<div v-else-if="domains.length === 0" class="empty-state">
|
||||
<strong>还没有托管域名</strong>
|
||||
<span>添加第一个域名,开始管理证书申请和自动续期。</span>
|
||||
<button class="primary-button" type="button" @click="openCreate">
|
||||
添加托管域名
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="domain-list">
|
||||
<article v-for="item in domains" :key="item.id" class="domain-row">
|
||||
<div class="domain-main">
|
||||
<div class="domain-title-line">
|
||||
<strong>{{ item.name }}</strong
|
||||
><span class="tag" :class="statusClass(item.status)">{{
|
||||
displayLabel(domainStatusLabels, item.status)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="domain-meta">
|
||||
<span>{{
|
||||
displayLabel(certificateTypeLabels, item.certificate_type)
|
||||
}}</span>
|
||||
<span>{{
|
||||
displayLabel(environmentLabels, item.acme_environment)
|
||||
}}</span>
|
||||
<span>{{
|
||||
item.auto_renew ? "自动续期已开启" : "自动续期已关闭"
|
||||
}}</span>
|
||||
<span>{{ (item.sans || []).length }} 个证书标识</span>
|
||||
<span
|
||||
>部署服务器:{{
|
||||
(domainServers[item.id] || [])
|
||||
.map((server) => server.name)
|
||||
.join("、") || "未配置"
|
||||
}}</span
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div class="domain-expiry">
|
||||
<strong>{{ daysRemaining(item.expires_at) }}</strong
|
||||
><span>{{ formatDate(item.expires_at) }}</span>
|
||||
</div>
|
||||
<div class="row-actions">
|
||||
<button class="text-button" type="button" @click="openEdit(item)">
|
||||
编辑</button
|
||||
><button
|
||||
class="text-button danger-text"
|
||||
type="button"
|
||||
@click="deleteDomain(item)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel server-panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<p class="eyebrow">安全凭据</p>
|
||||
<h2>SSH 私钥</h2>
|
||||
</div>
|
||||
<span class="muted">共 {{ sshKeys.length }} 个加密引用</span>
|
||||
</div>
|
||||
<div v-if="sshKeys.length === 0" class="empty-state">
|
||||
<strong>还没有 SSH 私钥</strong
|
||||
><span>私钥会加密保存,页面和接口只显示算法、指纹与安全引用。</span
|
||||
><button class="primary-button" type="button" @click="openSSHKeyCreate">
|
||||
添加 SSH 私钥
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="domain-list">
|
||||
<article v-for="item in sshKeys" :key="item.id" class="domain-row">
|
||||
<div class="domain-main">
|
||||
<div class="domain-title-line">
|
||||
<strong>{{ item.name }}</strong
|
||||
><span class="tag success">{{ item.algorithm }}</span>
|
||||
</div>
|
||||
<div class="domain-meta">
|
||||
<span class="key-fingerprint"
|
||||
>公钥指纹:{{ item.fingerprint }}</span
|
||||
><span>更新时间:{{ formatDate(item.updated_at) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-actions">
|
||||
<button
|
||||
class="text-button danger-text"
|
||||
type="button"
|
||||
@click="deleteSSHKey(item)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel server-panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<p class="eyebrow">远程部署</p>
|
||||
<h2>部署服务器</h2>
|
||||
</div>
|
||||
<span class="muted">共 {{ servers.length }} 台配置</span>
|
||||
</div>
|
||||
<div v-if="servers.length === 0" class="empty-state">
|
||||
<strong>还没有部署服务器</strong
|
||||
><span>添加 SSH 服务器后,证书申请成功可自动部署。</span
|
||||
><button class="primary-button" type="button" @click="openServerCreate">
|
||||
添加部署服务器
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="domain-list">
|
||||
<article v-for="item in servers" :key="item.id" class="domain-row">
|
||||
<div class="domain-main">
|
||||
<div class="domain-title-line">
|
||||
<strong>{{ item.name }}</strong
|
||||
><span class="tag">{{ displayLabel(webServerLabels, item.web_server) }}</span>
|
||||
</div>
|
||||
<div class="domain-meta">
|
||||
<span>{{ item.username }}@{{ item.address }}:{{ item.port }}</span
|
||||
><span>私钥引用已配置</span
|
||||
><span>指纹:{{ item.host_key_fingerprint }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-actions">
|
||||
<button
|
||||
class="text-button"
|
||||
type="button"
|
||||
@click="openServerEdit(item)"
|
||||
>
|
||||
编辑</button
|
||||
><button
|
||||
class="text-button danger-text"
|
||||
type="button"
|
||||
@click="deleteServer(item)"
|
||||
>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div v-if="showForm" class="modal-backdrop" @click.self="closeForm">
|
||||
<section
|
||||
class="modal-card"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-label="formTitle"
|
||||
>
|
||||
<div class="modal-heading">
|
||||
<div>
|
||||
<p class="eyebrow">域名配置</p>
|
||||
<h2>{{ formTitle }}</h2>
|
||||
</div>
|
||||
<button
|
||||
class="close-button"
|
||||
type="button"
|
||||
aria-label="关闭"
|
||||
@click="closeForm"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<form @submit.prevent="saveDomain">
|
||||
<label class="field" for="domain-name"
|
||||
><span>主域名</span
|
||||
><input
|
||||
id="domain-name"
|
||||
name="name"
|
||||
v-model="form.name"
|
||||
type="text"
|
||||
placeholder="例如 example.com"
|
||||
autocomplete="off"
|
||||
/></label>
|
||||
<label class="field" for="certificate-type"
|
||||
><span>证书类型</span
|
||||
><select
|
||||
id="certificate-type"
|
||||
name="certificate_type"
|
||||
v-model="form.certificate_type"
|
||||
>
|
||||
<option value="single">单域名</option>
|
||||
<option value="wildcard">泛域名</option>
|
||||
<option value="san">SAN 多域名</option>
|
||||
</select></label
|
||||
>
|
||||
<label
|
||||
v-if="form.certificate_type === 'san'"
|
||||
class="field"
|
||||
for="domain-sans"
|
||||
><span>附加域名 <small>每行一个,也支持逗号分隔</small></span
|
||||
><textarea
|
||||
id="domain-sans"
|
||||
name="sans"
|
||||
v-model="form.sans"
|
||||
rows="4"
|
||||
placeholder="www.example.com api.example.com"
|
||||
></textarea>
|
||||
</label>
|
||||
<div class="form-grid">
|
||||
<label class="field" for="acme-environment"
|
||||
><span>ACME 环境</span
|
||||
><select
|
||||
id="acme-environment"
|
||||
name="acme_environment"
|
||||
v-model="form.acme_environment"
|
||||
>
|
||||
<option value="staging">测试环境</option>
|
||||
<option value="production">生产环境</option>
|
||||
</select></label
|
||||
>
|
||||
<label class="field" for="dns-provider"
|
||||
><span>DNS 验证服务商</span
|
||||
><select
|
||||
id="dns-provider"
|
||||
name="dns_provider"
|
||||
v-model="form.dns_provider"
|
||||
>
|
||||
<option value="">暂不选择</option>
|
||||
<option
|
||||
v-for="provider in dnsProviders"
|
||||
:key="provider.value"
|
||||
:value="provider.value"
|
||||
>
|
||||
{{ provider.label }}
|
||||
</option>
|
||||
</select></label
|
||||
>
|
||||
</div>
|
||||
<label class="switch-field" for="auto-renew"
|
||||
><input
|
||||
id="auto-renew"
|
||||
name="auto_renew"
|
||||
v-model="form.auto_renew"
|
||||
type="checkbox"
|
||||
/><span
|
||||
><strong>启用自动续期</strong
|
||||
><small>证书剩余有效期达到阈值时自动创建续期任务</small></span
|
||||
></label
|
||||
>
|
||||
<fieldset class="server-picker">
|
||||
<legend>关联部署服务器</legend>
|
||||
<label
|
||||
v-for="server in servers"
|
||||
:key="server.id"
|
||||
class="server-option"
|
||||
><input
|
||||
v-model="form.server_ids"
|
||||
type="checkbox"
|
||||
:value="server.id"
|
||||
/><span
|
||||
><strong>{{ server.name }}</strong
|
||||
><small
|
||||
>{{ server.address }} ·
|
||||
{{ displayLabel(webServerLabels, server.web_server) }}</small
|
||||
></span
|
||||
></label
|
||||
>
|
||||
<p v-if="servers.length === 0" class="muted">
|
||||
暂无服务器配置,可先保存域名后添加服务器。
|
||||
</p>
|
||||
</fieldset>
|
||||
<p v-if="formError" class="form-error">{{ formError }}</p>
|
||||
<div class="modal-actions">
|
||||
<button
|
||||
class="secondary-button"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
@click="closeForm"
|
||||
>
|
||||
取消</button
|
||||
><button class="primary-button" type="submit" :disabled="saving">
|
||||
{{ saving ? "保存中……" : "保存配置" }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="showServerForm"
|
||||
class="modal-backdrop"
|
||||
@click.self="closeServerForm"
|
||||
>
|
||||
<section
|
||||
class="modal-card server-modal"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="服务器配置"
|
||||
>
|
||||
<div class="modal-heading">
|
||||
<div>
|
||||
<p class="eyebrow">远程部署</p>
|
||||
<h2>{{ serverEditingId ? "编辑部署服务器" : "添加部署服务器" }}</h2>
|
||||
</div>
|
||||
<button
|
||||
class="close-button"
|
||||
type="button"
|
||||
aria-label="关闭"
|
||||
@click="closeServerForm"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<form @submit.prevent="saveServer">
|
||||
<div class="form-grid">
|
||||
<label class="field"
|
||||
><span>服务器名称</span
|
||||
><input
|
||||
v-model="serverForm.name"
|
||||
required
|
||||
type="text"
|
||||
placeholder="例如生产 Nginx" /></label
|
||||
><label class="field"
|
||||
><span>网站服务</span
|
||||
><select v-model="serverForm.web_server">
|
||||
<option value="nginx">Nginx</option>
|
||||
<option value="caddy">Caddy</option>
|
||||
<option value="apache">Apache</option>
|
||||
<option value="custom">自定义</option>
|
||||
</select></label
|
||||
>
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<label class="field"
|
||||
><span>服务器地址</span
|
||||
><input
|
||||
v-model="serverForm.address"
|
||||
required
|
||||
type="text"
|
||||
placeholder="IP 或主机名" /></label
|
||||
><label class="field"
|
||||
><span>SSH 端口</span
|
||||
><input
|
||||
v-model.number="serverForm.port"
|
||||
required
|
||||
type="number"
|
||||
min="1"
|
||||
max="65535"
|
||||
/></label>
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<label class="field"
|
||||
><span>SSH 用户</span
|
||||
><input
|
||||
v-model="serverForm.username"
|
||||
required
|
||||
type="text" /></label
|
||||
><label class="field"
|
||||
><span>SSH 私钥</span
|
||||
><select v-model="serverForm.private_key_ref" required>
|
||||
<option value="">请选择已加密保存的私钥</option>
|
||||
<option
|
||||
v-for="key in sshKeys"
|
||||
:key="key.id"
|
||||
:value="key.reference"
|
||||
>
|
||||
{{ key.name }} · {{ key.algorithm }}
|
||||
</option></select
|
||||
><small v-if="sshKeys.length === 0"
|
||||
>请先关闭窗口并添加 SSH 私钥。</small
|
||||
></label
|
||||
>
|
||||
</div>
|
||||
<label class="field"
|
||||
><span>SSH 主机 SHA256 指纹</span
|
||||
><input
|
||||
v-model="serverForm.host_key_fingerprint"
|
||||
required
|
||||
type="text"
|
||||
placeholder="SHA256:..."
|
||||
/></label>
|
||||
<label class="field"
|
||||
><span>远程证书路径</span
|
||||
><input
|
||||
v-model="serverForm.certificate_path"
|
||||
required
|
||||
type="text"
|
||||
:placeholder="defaultCertificatePath"
|
||||
/></label>
|
||||
<label class="field"
|
||||
><span>远程完整证书链路径</span
|
||||
><input
|
||||
v-model="serverForm.certificate_chain_path"
|
||||
required
|
||||
type="text"
|
||||
:placeholder="defaultCertificateChainPath"
|
||||
/></label>
|
||||
<label class="field"
|
||||
><span>远程私钥路径</span
|
||||
><input
|
||||
v-model="serverForm.private_key_path"
|
||||
required
|
||||
type="text"
|
||||
:placeholder="defaultPrivateKeyPath"
|
||||
/></label>
|
||||
<p class="field-hint">
|
||||
保存的是路径模板,部署时会将 {域名} 和 {证书类型}
|
||||
替换为实际值。证书类型目录固定为 single、wildcard 或 san。
|
||||
</p>
|
||||
<label class="field"
|
||||
><span
|
||||
>自定义重载命令
|
||||
<small>每行一个参数;留空使用网站服务默认命令</small></span
|
||||
><textarea
|
||||
v-model="serverForm.reload_command"
|
||||
rows="3"
|
||||
placeholder="nginx -s reload"
|
||||
></textarea>
|
||||
</label>
|
||||
<p v-if="serverFormError" class="form-error">{{ serverFormError }}</p>
|
||||
<div class="modal-actions">
|
||||
<button
|
||||
class="secondary-button"
|
||||
type="button"
|
||||
:disabled="serverSaving"
|
||||
@click="closeServerForm"
|
||||
>
|
||||
取消</button
|
||||
><button
|
||||
class="primary-button"
|
||||
type="submit"
|
||||
:disabled="serverSaving"
|
||||
>
|
||||
{{ serverSaving ? "保存中……" : "保存服务器" }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="showSSHKeyForm"
|
||||
class="modal-backdrop"
|
||||
@click.self="closeSSHKeyForm"
|
||||
>
|
||||
<section
|
||||
class="modal-card"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="添加 SSH 私钥"
|
||||
>
|
||||
<div class="modal-heading">
|
||||
<div>
|
||||
<p class="eyebrow">安全凭据</p>
|
||||
<h2>添加 SSH 私钥</h2>
|
||||
</div>
|
||||
<button
|
||||
class="close-button"
|
||||
type="button"
|
||||
aria-label="关闭"
|
||||
@click="closeSSHKeyForm"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
<form @submit.prevent="saveSSHKey">
|
||||
<label class="field"
|
||||
><span>私钥名称</span
|
||||
><input
|
||||
v-model="sshKeyForm.name"
|
||||
required
|
||||
type="text"
|
||||
maxlength="128"
|
||||
placeholder="例如生产环境部署私钥"
|
||||
autocomplete="off"
|
||||
/></label>
|
||||
<label class="field"
|
||||
><span
|
||||
>私钥内容
|
||||
<small>支持 RSA、ECDSA、Ed25519 和 OpenSSH 私钥</small></span
|
||||
><textarea
|
||||
v-model="sshKeyForm.private_key"
|
||||
required
|
||||
rows="11"
|
||||
spellcheck="false"
|
||||
placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
|
||||
></textarea>
|
||||
</label>
|
||||
<label class="field"
|
||||
><span>私钥口令 <small>未加密私钥请留空</small></span
|
||||
><input
|
||||
v-model="sshKeyForm.passphrase"
|
||||
type="password"
|
||||
maxlength="4096"
|
||||
autocomplete="new-password"
|
||||
/></label>
|
||||
<p class="security-hint">
|
||||
保存后私钥和口令只进入本机加密敏感信息存储,后续接口不会返回明文。
|
||||
</p>
|
||||
<p v-if="sshKeyFormError" class="form-error">{{ sshKeyFormError }}</p>
|
||||
<div class="modal-actions">
|
||||
<button
|
||||
class="secondary-button"
|
||||
type="button"
|
||||
:disabled="sshKeySaving"
|
||||
@click="closeSSHKeyForm"
|
||||
>
|
||||
取消</button
|
||||
><button
|
||||
class="primary-button"
|
||||
type="submit"
|
||||
:disabled="sshKeySaving"
|
||||
>
|
||||
{{ sshKeySaving ? "加密保存中……" : "加密保存" }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
<style scoped src="./Dashboard.css"></style>
|
||||
@@ -0,0 +1,33 @@
|
||||
.login-card {
|
||||
max-width: 470px;
|
||||
}
|
||||
|
||||
.login-card .access-card-header {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
|
||||
.login-next-step {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.login-account {
|
||||
margin: 0;
|
||||
color: #4d76b7;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.login-stage-title {
|
||||
margin: 0;
|
||||
color: #172033;
|
||||
font-size: 20px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.login-success {
|
||||
margin: 0;
|
||||
color: #1e8b63;
|
||||
font-size: 14px;
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
const roleLabels = {
|
||||
super_admin: "\u8d85\u7ea7\u7ba1\u7406\u5458",
|
||||
admin: "\u7ba1\u7406\u5458",
|
||||
user: "\u666e\u901a\u7528\u6237",
|
||||
};
|
||||
|
||||
export function useLogin() {
|
||||
const identifier = ref("");
|
||||
const password = ref("");
|
||||
const remember = ref(false);
|
||||
const submitting = ref(false);
|
||||
const error = ref("");
|
||||
const stage = ref("credentials");
|
||||
const accountRole = ref("");
|
||||
const accountName = ref("");
|
||||
|
||||
const identifierLabel = "\u7528\u6237\u540d\u6216\u90ae\u7bb1";
|
||||
const identifierPlaceholder = "\u8bf7\u8f93\u5165\u7528\u6237\u540d\u6216\u7ed1\u5b9a\u90ae\u7bb1";
|
||||
const stageTitle = computed(() => {
|
||||
if (stage.value === "totp") return "\u4e24\u6b65\u9a8c\u8bc1";
|
||||
if (stage.value === "external_email") return "\u90ae\u7bb1\u9a8c\u8bc1";
|
||||
if (stage.value === "complete") {
|
||||
return `${roleLabels[accountRole.value] || "\u7528\u6237"}\u767b\u5f55\u6210\u529f`;
|
||||
}
|
||||
return "\u7ba1\u7406\u5458\u767b\u5f55";
|
||||
});
|
||||
const stageMessage = computed(() => {
|
||||
if (stage.value === "totp") return "\u8be5\u8d26\u6237\u8fd8\u9700\u5b8c\u6210\u4e24\u6b65\u9a8c\u8bc1\u3002";
|
||||
if (stage.value === "external_email") return "\u8be5\u8d26\u6237\u8fd8\u9700\u5b8c\u6210\u7b2c\u4e09\u65b9\u90ae\u7bb1\u9a8c\u8bc1\u3002";
|
||||
if (stage.value === "complete") return "\u6b63\u5728\u8fdb\u5165 Scert \u7ba1\u7406\u540e\u53f0\u3002";
|
||||
return "\u8bf7\u8f93\u5165\u7528\u6237\u540d\u6216\u90ae\u7bb1\u3002\u8d26\u6237\u6743\u9650\u7531\u670d\u52a1\u7aef\u81ea\u52a8\u8bc6\u522b\u3002";
|
||||
});
|
||||
|
||||
function resetStage() {
|
||||
stage.value = "credentials";
|
||||
accountRole.value = "";
|
||||
accountName.value = "";
|
||||
error.value = "";
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (submitting.value || stage.value !== "credentials") return;
|
||||
error.value = "";
|
||||
if (!identifier.value.trim()) {
|
||||
error.value = "\u8bf7\u8f93\u5165\u7528\u6237\u540d\u6216\u90ae\u7bb1\u3002";
|
||||
return;
|
||||
}
|
||||
if (!password.value) {
|
||||
error.value = "\u8bf7\u8f93\u5165\u5bc6\u7801\u3002";
|
||||
return;
|
||||
}
|
||||
|
||||
submitting.value = true;
|
||||
try {
|
||||
const response = await fetch("/api/v1/auth/login", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
credentials: "include",
|
||||
body: JSON.stringify({
|
||||
identifier: identifier.value.trim(),
|
||||
password: password.value,
|
||||
remember: remember.value,
|
||||
}),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
throw new Error(result.error || "\u767b\u5f55\u5931\u8d25\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5");
|
||||
}
|
||||
|
||||
accountRole.value = result.role || "";
|
||||
accountName.value = result.account || "";
|
||||
stage.value = result.next_step || "complete";
|
||||
if (stage.value === "complete") {
|
||||
window.setTimeout(() => window.location.assign("/"), 600);
|
||||
}
|
||||
} catch (err) {
|
||||
error.value = err.message || "\u767b\u5f55\u5931\u8d25\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5";
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
identifier,
|
||||
password,
|
||||
remember,
|
||||
submitting,
|
||||
error,
|
||||
stage,
|
||||
accountName,
|
||||
identifierLabel,
|
||||
identifierPlaceholder,
|
||||
stageTitle,
|
||||
stageMessage,
|
||||
resetStage,
|
||||
submit,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<script setup>
|
||||
import AccessShell from "../components/AccessShell/AccessShell.vue";
|
||||
import { useLogin } from "./Login.js";
|
||||
|
||||
const {
|
||||
identifier,
|
||||
password,
|
||||
remember,
|
||||
submitting,
|
||||
error,
|
||||
stage,
|
||||
accountName,
|
||||
identifierLabel,
|
||||
identifierPlaceholder,
|
||||
stageTitle,
|
||||
stageMessage,
|
||||
resetStage,
|
||||
submit,
|
||||
} = useLogin();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccessShell variant="compact" aria-label="Scert 管理员登录">
|
||||
<template #brand>
|
||||
<img class="access-logo" src="/Scert.png" alt="Scert 标志" />
|
||||
<p class="access-eyebrow">SCERT 管理后台</p>
|
||||
<h1 class="access-brand-title">统一证书管理服务</h1>
|
||||
<p class="access-brand-description">
|
||||
集中管理域名证书、自动续期,并安全部署到关联服务器。
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<section class="access-card login-card">
|
||||
<header class="access-card-header">
|
||||
<p class="access-eyebrow">安全访问</p>
|
||||
<h2 class="access-card-title">管理员登录</h2>
|
||||
<p class="access-card-description">请输入管理员账号,进入 Scert 管理后台。</p>
|
||||
</header>
|
||||
|
||||
<section v-if="stage === 'credentials'">
|
||||
<form class="access-form" @submit.prevent="submit">
|
||||
<label class="access-field">
|
||||
<span>{{ identifierLabel }}</span>
|
||||
<input
|
||||
id="login-identifier"
|
||||
name="identifier"
|
||||
v-model.trim="identifier"
|
||||
type="text"
|
||||
autocomplete="username"
|
||||
:placeholder="identifierPlaceholder"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="access-field">
|
||||
<span>密码</span>
|
||||
<input
|
||||
id="login-password"
|
||||
name="password"
|
||||
v-model="password"
|
||||
type="password"
|
||||
autocomplete="current-password"
|
||||
placeholder="请输入管理员密码"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<div class="access-options">
|
||||
<label class="access-check">
|
||||
<input
|
||||
id="remember-login"
|
||||
name="remember"
|
||||
v-model="remember"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>记住登录状态</span>
|
||||
</label>
|
||||
<a class="access-link" href="/password-reset">忘记密码</a>
|
||||
</div>
|
||||
|
||||
<p v-if="error" class="access-error">{{ error }}</p>
|
||||
<button class="access-submit" type="submit" :disabled="submitting">
|
||||
{{ submitting ? "正在登录……" : "登录" }}
|
||||
</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section v-else class="login-next-step" aria-live="polite">
|
||||
<p class="login-account">登录账户:{{ accountName }}</p>
|
||||
<p class="login-stage-title">{{ stageTitle }}</p>
|
||||
<p v-if="stage === 'complete'" class="login-success">{{ stageMessage }}</p>
|
||||
<p v-else class="access-error">{{ stageMessage }}</p>
|
||||
<button class="access-submit" type="button" @click="resetStage">返回登录</button>
|
||||
</section>
|
||||
</section>
|
||||
</AccessShell>
|
||||
</template>
|
||||
|
||||
<style src="./Login.css"></style>
|
||||
@@ -0,0 +1,3 @@
|
||||
.password-reset-card {
|
||||
max-width: 470px;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
export function usePasswordReset() {
|
||||
const username = ref("");
|
||||
const password = ref("");
|
||||
const confirmPassword = ref("");
|
||||
const message = ref("");
|
||||
const error = ref("");
|
||||
|
||||
function submit() {
|
||||
message.value = "";
|
||||
error.value = "";
|
||||
if (password.value.length < 8) {
|
||||
error.value = "新密码至少需要 8 个字符。";
|
||||
return;
|
||||
}
|
||||
if (password.value !== confirmPassword.value) {
|
||||
error.value = "两次输入的新密码不一致。";
|
||||
return;
|
||||
}
|
||||
error.value = "普通管理员密码重置接口尚未接入,请联系超级管理员处理。";
|
||||
}
|
||||
|
||||
return {
|
||||
username,
|
||||
password,
|
||||
confirmPassword,
|
||||
message,
|
||||
error,
|
||||
submit,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
<script setup>
|
||||
import AccessShell from "../components/AccessShell/AccessShell.vue";
|
||||
import { usePasswordReset } from "./PasswordReset.js";
|
||||
|
||||
const {
|
||||
username,
|
||||
password,
|
||||
confirmPassword,
|
||||
message,
|
||||
error,
|
||||
submit,
|
||||
} = usePasswordReset();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccessShell variant="compact" aria-label="Scert 管理员密码重置">
|
||||
<template #brand>
|
||||
<img class="access-logo" src="/Scert.png" alt="Scert 标志" />
|
||||
<p class="access-eyebrow">SCERT 安全中心</p>
|
||||
<h1 class="access-brand-title">保护管理后台安全</h1>
|
||||
<p class="access-brand-description">
|
||||
密码重置入口仅用于已接入认证流程的管理员账号。
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<section class="access-card password-reset-card">
|
||||
<header class="access-card-header">
|
||||
<p class="access-eyebrow">账户安全</p>
|
||||
<h2 class="access-card-title">密码重置</h2>
|
||||
<p class="access-card-description">填写账号和新密码,提交密码重置申请。</p>
|
||||
</header>
|
||||
|
||||
<form class="access-form" @submit.prevent="submit">
|
||||
<label class="access-field">
|
||||
<span>管理员账号</span>
|
||||
<input
|
||||
id="reset-username"
|
||||
name="username"
|
||||
v-model.trim="username"
|
||||
type="text"
|
||||
autocomplete="username"
|
||||
placeholder="请输入管理员账号"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="access-field">
|
||||
<span>新密码</span>
|
||||
<input
|
||||
id="reset-password"
|
||||
name="password"
|
||||
v-model="password"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="至少 8 个字符"
|
||||
minlength="8"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="access-field">
|
||||
<span>确认新密码</span>
|
||||
<input
|
||||
id="reset-confirm-password"
|
||||
name="confirm_password"
|
||||
v-model="confirmPassword"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="请再次输入新密码"
|
||||
minlength="8"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<p v-if="message" class="access-message">{{ message }}</p>
|
||||
<p v-if="error" class="access-error">{{ error }}</p>
|
||||
<button class="access-submit" type="submit">提交重置申请</button>
|
||||
</form>
|
||||
|
||||
<a class="access-return" href="/login">返回登录</a>
|
||||
</section>
|
||||
</AccessShell>
|
||||
</template>
|
||||
|
||||
<style src="./PasswordReset.css"></style>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,379 @@
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
|
||||
|
||||
export function useSetupWizard(props, emit) {
|
||||
const scertLogo = "/Scert.png";
|
||||
|
||||
const submitting = ref(false);
|
||||
const error = ref("");
|
||||
const resultMessage = ref("");
|
||||
const dnsCatalogLoading = ref(true);
|
||||
const dnsCatalogError = ref("");
|
||||
const dnsTesting = ref(false);
|
||||
const dnsTestError = ref("");
|
||||
const dnsProviders = ref([]);
|
||||
const dnsCredentials = ref({});
|
||||
const dnsTestDomain = ref(props.status.web_hostname || "");
|
||||
const dnsVerification = ref(null);
|
||||
const verificationClock = ref(Date.now());
|
||||
const currentStep = ref(1);
|
||||
let verificationTimer;
|
||||
const targetType = ref(props.status.web_public_ip ? "ip" : "hostname");
|
||||
const form = ref({
|
||||
admin_username: "",
|
||||
admin_email: "",
|
||||
admin_password: "",
|
||||
confirm_password: "",
|
||||
server_port: props.status.server_port || 8080,
|
||||
email_provider: "",
|
||||
email_endpoint: "",
|
||||
recipients: "",
|
||||
dns_provider: props.status.dns_provider || "cloudflare",
|
||||
certificate_root: props.status.certificate_root || "",
|
||||
web_hostname: props.status.web_hostname || "",
|
||||
web_public_ip: props.status.web_public_ip || "",
|
||||
web_enabled: props.status.web_enabled !== false,
|
||||
https_mode: props.status.https_mode || "direct",
|
||||
});
|
||||
|
||||
const targetLabel = computed(() =>
|
||||
targetType.value === "hostname" ? "管理页面域名" : "公网 IP 地址",
|
||||
);
|
||||
const resetURLPreview = computed(() => {
|
||||
const rawHost =
|
||||
targetType.value === "hostname"
|
||||
? form.value.web_hostname
|
||||
: form.value.web_public_ip;
|
||||
const host = String(rawHost || "")
|
||||
.trim()
|
||||
.replace(/^\[|\]$/g, "");
|
||||
if (!host) return "完成域名或公网 IP 配置后自动生成";
|
||||
const displayHost = host.includes(":") ? `[${host}]` : host;
|
||||
return `https://${displayHost}/reset`;
|
||||
});
|
||||
const selectedDNSProvider = computed(
|
||||
() =>
|
||||
dnsProviders.value.find(
|
||||
(provider) => provider.id === form.value.dns_provider,
|
||||
) || null,
|
||||
);
|
||||
const dnsVerificationValid = computed(() => {
|
||||
verificationClock.value;
|
||||
if (
|
||||
!dnsVerification.value?.verification_token ||
|
||||
!dnsVerification.value?.credential_ref
|
||||
)
|
||||
return false;
|
||||
return new Date(dnsVerification.value.expires_at).getTime() > Date.now();
|
||||
});
|
||||
|
||||
function invalidateDNSVerification() {
|
||||
dnsVerification.value = null;
|
||||
dnsTestError.value = "";
|
||||
}
|
||||
|
||||
function formatVerificationExpiry(value) {
|
||||
if (!value) return "";
|
||||
return new Intl.DateTimeFormat("zh-CN", {
|
||||
dateStyle: "medium",
|
||||
timeStyle: "medium",
|
||||
timeZone: "Asia/Shanghai",
|
||||
}).format(new Date(value));
|
||||
}
|
||||
|
||||
async function loadDNSProviders() {
|
||||
dnsCatalogLoading.value = true;
|
||||
dnsCatalogError.value = "";
|
||||
try {
|
||||
const response = await fetch("/api/v1/setup/dns/providers");
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok)
|
||||
throw new Error(result.error || "读取 DNS 服务商列表失败");
|
||||
dnsProviders.value = Array.isArray(result.items) ? result.items : [];
|
||||
if (
|
||||
!dnsProviders.value.some(
|
||||
(provider) => provider.id === form.value.dns_provider,
|
||||
)
|
||||
) {
|
||||
form.value.dns_provider =
|
||||
dnsProviders.value.find((provider) => provider.available)?.id || "";
|
||||
}
|
||||
} catch (err) {
|
||||
dnsCatalogError.value = err.message || "读取 DNS 服务商列表失败";
|
||||
} finally {
|
||||
dnsCatalogLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function credentialPayload() {
|
||||
const payload = {};
|
||||
for (const field of selectedDNSProvider.value?.credential_fields || []) {
|
||||
const value = String(dnsCredentials.value[field.name] || "").trim();
|
||||
if (value) payload[field.name] = value;
|
||||
}
|
||||
return payload;
|
||||
}
|
||||
|
||||
async function testDNS() {
|
||||
dnsTestError.value = "";
|
||||
resultMessage.value = "";
|
||||
invalidateDNSVerification();
|
||||
const provider = selectedDNSProvider.value;
|
||||
if (!provider) {
|
||||
dnsTestError.value = "请选择 DNS 服务商。";
|
||||
return;
|
||||
}
|
||||
if (!provider.available) {
|
||||
dnsTestError.value = "该 DNS 服务商在线验证适配器尚未开放。";
|
||||
return;
|
||||
}
|
||||
const testDomain = dnsTestDomain.value.trim();
|
||||
if (!testDomain) {
|
||||
dnsTestError.value = "请填写 DNS 权限测试域名。";
|
||||
return;
|
||||
}
|
||||
for (const field of provider.credential_fields || []) {
|
||||
if (
|
||||
field.required &&
|
||||
!String(dnsCredentials.value[field.name] || "").trim()
|
||||
) {
|
||||
dnsTestError.value = `请填写${field.label}。`;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
dnsTesting.value = true;
|
||||
try {
|
||||
const response = await fetch("/api/v1/setup/dns/test", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
provider: provider.id,
|
||||
test_domain: testDomain,
|
||||
credentials: credentialPayload(),
|
||||
}),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "DNS API 在线验证失败");
|
||||
dnsVerification.value = result;
|
||||
} catch (err) {
|
||||
dnsTestError.value = err.message || "DNS API 在线验证失败";
|
||||
} finally {
|
||||
dnsTesting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function validateCurrentStep() {
|
||||
error.value = "";
|
||||
resultMessage.value = "";
|
||||
|
||||
if (currentStep.value === 1) {
|
||||
if (!form.value.admin_username.trim()) {
|
||||
error.value = "请输入超级管理员用户名。";
|
||||
return false;
|
||||
}
|
||||
if (!form.value.admin_email.trim()) {
|
||||
error.value = "请输入超级管理员绑定邮箱。";
|
||||
return false;
|
||||
}
|
||||
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(form.value.admin_email.trim())) {
|
||||
error.value = "请输入合法的超级管理员绑定邮箱。";
|
||||
return false;
|
||||
}
|
||||
if (form.value.admin_password.length < 8) {
|
||||
error.value = "超级管理员密码至少需要 8 个字符。";
|
||||
return false;
|
||||
}
|
||||
if (form.value.admin_password !== form.value.confirm_password) {
|
||||
error.value = "两次输入的超级管理员密码不一致。";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentStep.value === 2) {
|
||||
const port = Number(form.value.server_port);
|
||||
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
||||
error.value = "请输入 1 至 65535 之间的主服务端口。";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentStep.value === 3) {
|
||||
const provider = selectedDNSProvider.value;
|
||||
if (!provider) {
|
||||
error.value = "请选择 DNS 服务商。";
|
||||
return false;
|
||||
}
|
||||
if (!provider.available) {
|
||||
error.value = "该 DNS 服务商在线验证适配器尚未开放。";
|
||||
return false;
|
||||
}
|
||||
if (!dnsTestDomain.value.trim()) {
|
||||
error.value = "请填写 DNS 权限测试域名。";
|
||||
return false;
|
||||
}
|
||||
for (const field of provider.credential_fields || []) {
|
||||
if (
|
||||
field.required &&
|
||||
!String(dnsCredentials.value[field.name] || "").trim()
|
||||
) {
|
||||
error.value = `请填写${field.label}。`;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!dnsVerificationValid.value) {
|
||||
error.value = "请先完成 DNS API 在线验证。";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentStep.value === 4) {
|
||||
const hostname =
|
||||
targetType.value === "hostname" ? form.value.web_hostname.trim() : "";
|
||||
const publicIP =
|
||||
targetType.value === "ip" ? form.value.web_public_ip.trim() : "";
|
||||
if (!hostname && !publicIP) {
|
||||
error.value = `请填写${targetLabel.value}。`;
|
||||
return false;
|
||||
}
|
||||
if (!form.value.certificate_root.trim()) {
|
||||
error.value = "请填写证书部署根目录。";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function nextStep() {
|
||||
if (!validateCurrentStep()) return;
|
||||
if (currentStep.value < 4) currentStep.value += 1;
|
||||
}
|
||||
|
||||
function previousStep() {
|
||||
error.value = "";
|
||||
resultMessage.value = "";
|
||||
if (currentStep.value > 1) currentStep.value -= 1;
|
||||
}
|
||||
|
||||
function handleSubmit() {
|
||||
if (currentStep.value < 4) {
|
||||
nextStep();
|
||||
return;
|
||||
}
|
||||
submit();
|
||||
}
|
||||
|
||||
function recipients() {
|
||||
return form.value.recipients
|
||||
.split(/[\n,,]/)
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
error.value = "";
|
||||
resultMessage.value = "";
|
||||
if (form.value.admin_password.length < 8) {
|
||||
error.value = "超级管理员密码至少需要 8 个字符。";
|
||||
return;
|
||||
}
|
||||
if (form.value.admin_password !== form.value.confirm_password) {
|
||||
error.value = "两次输入的超级管理员密码不一致。";
|
||||
return;
|
||||
}
|
||||
if (!dnsVerificationValid.value) {
|
||||
error.value = "必须先完成 DNS API 在线验证;验证结果已过期时请重新测试。";
|
||||
return;
|
||||
}
|
||||
const hostname =
|
||||
targetType.value === "hostname" ? form.value.web_hostname.trim() : "";
|
||||
const publicIP =
|
||||
targetType.value === "ip" ? form.value.web_public_ip.trim() : "";
|
||||
if (!hostname && !publicIP) {
|
||||
error.value = `请填写${targetLabel.value}。`;
|
||||
return;
|
||||
}
|
||||
|
||||
submitting.value = true;
|
||||
try {
|
||||
const response = await fetch("/api/v1/setup", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
admin_username: form.value.admin_username,
|
||||
admin_email: form.value.admin_email,
|
||||
admin_password: form.value.admin_password,
|
||||
server_port: Number(form.value.server_port),
|
||||
email_provider: form.value.email_provider,
|
||||
email_endpoint: form.value.email_endpoint,
|
||||
recipients: recipients(),
|
||||
dns_provider: form.value.dns_provider,
|
||||
dns_credential_ref: dnsVerification.value.credential_ref,
|
||||
dns_verification_token: dnsVerification.value.verification_token,
|
||||
dns_test_domain: dnsTestDomain.value.trim(),
|
||||
certificate_root: form.value.certificate_root,
|
||||
web_hostname: hostname,
|
||||
web_public_ip: publicIP,
|
||||
web_enabled: form.value.web_enabled,
|
||||
https_mode: form.value.https_mode,
|
||||
}),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "保存初始化配置失败");
|
||||
resultMessage.value = result.message || "初始化配置已保存。";
|
||||
emit("initialized", result);
|
||||
} catch (err) {
|
||||
error.value = err.message || "保存初始化配置失败";
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => form.value.dns_provider,
|
||||
() => {
|
||||
dnsCredentials.value = {};
|
||||
invalidateDNSVerification();
|
||||
},
|
||||
);
|
||||
|
||||
watch(dnsCredentials, invalidateDNSVerification, { deep: true });
|
||||
watch(dnsTestDomain, invalidateDNSVerification);
|
||||
|
||||
onMounted(() => {
|
||||
loadDNSProviders();
|
||||
verificationTimer = window.setInterval(() => {
|
||||
verificationClock.value = Date.now();
|
||||
}, 30000);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (verificationTimer) window.clearInterval(verificationTimer);
|
||||
});
|
||||
|
||||
return {
|
||||
scertLogo,
|
||||
submitting,
|
||||
error,
|
||||
resultMessage,
|
||||
dnsCatalogLoading,
|
||||
dnsCatalogError,
|
||||
dnsTesting,
|
||||
dnsTestError,
|
||||
dnsProviders,
|
||||
dnsCredentials,
|
||||
dnsTestDomain,
|
||||
dnsVerification,
|
||||
currentStep,
|
||||
targetType,
|
||||
form,
|
||||
targetLabel,
|
||||
resetURLPreview,
|
||||
selectedDNSProvider,
|
||||
dnsVerificationValid,
|
||||
formatVerificationExpiry,
|
||||
testDNS,
|
||||
handleSubmit,
|
||||
previousStep,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,421 @@
|
||||
<script setup>
|
||||
import { useSetupWizard } from "./SetupWizard.js";
|
||||
import AccessShell from "../components/AccessShell/AccessShell.vue";
|
||||
|
||||
const props = defineProps({
|
||||
status: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["initialized"]);
|
||||
|
||||
const {
|
||||
scertLogo,
|
||||
submitting,
|
||||
error,
|
||||
resultMessage,
|
||||
dnsCatalogLoading,
|
||||
dnsCatalogError,
|
||||
dnsTesting,
|
||||
dnsTestError,
|
||||
dnsProviders,
|
||||
dnsCredentials,
|
||||
dnsTestDomain,
|
||||
dnsVerification,
|
||||
currentStep,
|
||||
targetType,
|
||||
form,
|
||||
targetLabel,
|
||||
resetURLPreview,
|
||||
selectedDNSProvider,
|
||||
dnsVerificationValid,
|
||||
formatVerificationExpiry,
|
||||
testDNS,
|
||||
handleSubmit,
|
||||
previousStep,
|
||||
} = useSetupWizard(props, emit);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccessShell variant="setup" aria-label="Scert 初始化向导">
|
||||
<template #brand>
|
||||
<img class="access-logo" :src="scertLogo" alt="Scert 标志" />
|
||||
<p class="access-eyebrow">SCERT 首次运行</p>
|
||||
<h1 class="access-brand-title">配置证书管理服务</h1>
|
||||
<p class="access-brand-description">
|
||||
Scert 与 Scert-admin 共享本次配置。完成初始化后,即可通过管理页面统一管理证书。
|
||||
</p>
|
||||
<div class="warning-card">
|
||||
<strong>初始化提示</strong>
|
||||
<span
|
||||
>请先完成 DNS API 在线验证。证书签发和 HTTPS
|
||||
切换将在后续任务中执行,本页不会伪报申请成功。</span
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<section class="setup-card">
|
||||
<header>
|
||||
<div>
|
||||
<p class="setup-eyebrow">初始化向导</p>
|
||||
<h2>基础配置</h2>
|
||||
</div>
|
||||
<span class="local-badge">仅限本机</span>
|
||||
</header>
|
||||
|
||||
<nav class="setup-progress" aria-label="初始化步骤">
|
||||
<span
|
||||
class="progress-step"
|
||||
:class="{ active: currentStep === 1, complete: currentStep > 1 }"
|
||||
><b>1</b><strong>管理员</strong><small>账号安全</small></span
|
||||
>
|
||||
<i aria-hidden="true"></i>
|
||||
<span
|
||||
class="progress-step"
|
||||
:class="{ active: currentStep === 2, complete: currentStep > 2 }"
|
||||
><b>2</b><strong>服务通知</strong><small>端口与邮件</small></span
|
||||
>
|
||||
<i aria-hidden="true"></i>
|
||||
<span
|
||||
class="progress-step"
|
||||
:class="{ active: currentStep === 3, complete: currentStep > 3 }"
|
||||
><b>3</b><strong>DNS 验证</strong><small>权限测试</small></span
|
||||
>
|
||||
<i aria-hidden="true"></i>
|
||||
<span class="progress-step" :class="{ active: currentStep === 4 }"
|
||||
><b>4</b><strong>管理页面证书</strong><small>访问方式</small></span
|
||||
>
|
||||
</nav>
|
||||
|
||||
<form
|
||||
id="setup-form"
|
||||
name="setup_form"
|
||||
class="setup-form"
|
||||
@submit.prevent="handleSubmit"
|
||||
>
|
||||
<div class="setup-step-grid">
|
||||
<fieldset v-if="currentStep === 1" class="setup-step-card">
|
||||
<legend><span>01</span>超级管理员</legend>
|
||||
<div class="setup-grid two-columns">
|
||||
<label
|
||||
><span>用户名</span
|
||||
><input
|
||||
id="admin-username"
|
||||
name="admin_username"
|
||||
v-model.trim="form.admin_username"
|
||||
required
|
||||
autocomplete="username"
|
||||
placeholder="例如 scert-admin"
|
||||
/></label>
|
||||
<label
|
||||
><span>绑定邮箱</span
|
||||
><input
|
||||
id="admin-email"
|
||||
name="admin_email"
|
||||
v-model.trim="form.admin_email"
|
||||
required
|
||||
type="email"
|
||||
autocomplete="email"
|
||||
placeholder="用于登录和安全通知"
|
||||
/></label>
|
||||
<label
|
||||
><span>密码</span
|
||||
><input
|
||||
id="admin-password"
|
||||
name="admin_password"
|
||||
v-model="form.admin_password"
|
||||
required
|
||||
minlength="8"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="至少 8 个字符"
|
||||
/></label>
|
||||
<label
|
||||
><span>确认密码</span
|
||||
><input
|
||||
id="confirm-password"
|
||||
name="confirm_password"
|
||||
v-model="form.confirm_password"
|
||||
required
|
||||
minlength="8"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="再次输入密码"
|
||||
/></label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset v-if="currentStep === 2" class="setup-step-card">
|
||||
<legend><span>02</span>服务与通知</legend>
|
||||
<div class="setup-grid two-columns">
|
||||
<label
|
||||
><span>Scert 主服务端口</span
|
||||
><input
|
||||
id="server-port"
|
||||
name="server_port"
|
||||
v-model.number="form.server_port"
|
||||
required
|
||||
min="1"
|
||||
max="65535"
|
||||
type="number"
|
||||
/></label>
|
||||
<label
|
||||
><span>第三方邮箱服务标识</span
|
||||
><input
|
||||
id="email-provider"
|
||||
name="email_provider"
|
||||
v-model.trim="form.email_provider"
|
||||
placeholder="例如 company-mail-api"
|
||||
/></label>
|
||||
<label
|
||||
><span>邮件 API 地址</span
|
||||
><input
|
||||
id="email-endpoint"
|
||||
name="email_endpoint"
|
||||
v-model.trim="form.email_endpoint"
|
||||
type="url"
|
||||
placeholder="https://mail.example.com/send"
|
||||
/></label>
|
||||
</div>
|
||||
<div class="provider-description reset-preview">
|
||||
<strong>密码重置地址</strong><span>{{ resetURLPreview }}</span
|
||||
><span
|
||||
>无需配置独立端口;只有手动启动 Scert-admin
|
||||
后,此地址才会临时可用。</span
|
||||
>
|
||||
</div>
|
||||
<label
|
||||
><span>通知收件人</span
|
||||
><input
|
||||
id="recipients"
|
||||
name="recipients"
|
||||
v-model="form.recipients"
|
||||
placeholder="多个地址使用逗号分隔"
|
||||
/></label>
|
||||
</fieldset>
|
||||
|
||||
<fieldset v-if="currentStep === 3" class="setup-step-card">
|
||||
<legend><span>03</span>DNS 验证</legend>
|
||||
<div class="setup-grid two-columns">
|
||||
<label
|
||||
><span>DNS 服务商</span
|
||||
><select
|
||||
id="dns-provider"
|
||||
name="dns_provider"
|
||||
v-model="form.dns_provider"
|
||||
required
|
||||
:disabled="dnsCatalogLoading"
|
||||
>
|
||||
<option v-if="dnsCatalogLoading" value="">
|
||||
正在读取服务商……
|
||||
</option>
|
||||
<option
|
||||
v-for="provider in dnsProviders"
|
||||
:key="provider.id"
|
||||
:value="provider.id"
|
||||
>
|
||||
{{ provider.name
|
||||
}}{{ provider.available ? "" : "(适配器待开放)" }}
|
||||
</option>
|
||||
</select></label
|
||||
>
|
||||
<label
|
||||
><span>DNS 权限测试域名</span
|
||||
><input
|
||||
id="dns-test-domain"
|
||||
name="dns_test_domain"
|
||||
v-model.trim="dnsTestDomain"
|
||||
required
|
||||
placeholder="例如 example.com"
|
||||
/><small
|
||||
>使用域名时可填写管理页面域名;使用公网 IP
|
||||
时必须另填一个由当前 DNS 账号管理的域名。</small
|
||||
></label
|
||||
>
|
||||
</div>
|
||||
<p v-if="dnsCatalogError" class="inline-error">
|
||||
{{ dnsCatalogError }}
|
||||
</p>
|
||||
<div
|
||||
v-if="selectedDNSProvider"
|
||||
class="provider-description"
|
||||
:class="{ unavailable: !selectedDNSProvider.available }"
|
||||
>
|
||||
<strong>{{
|
||||
selectedDNSProvider.available
|
||||
? "在线验证可用"
|
||||
: "当前仅提供字段模型"
|
||||
}}</strong>
|
||||
<span>{{ selectedDNSProvider.description }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="selectedDNSProvider"
|
||||
class="setup-grid two-columns credential-grid"
|
||||
>
|
||||
<label
|
||||
v-for="field in selectedDNSProvider.credential_fields"
|
||||
:key="field.name"
|
||||
>
|
||||
<span
|
||||
>{{ field.label
|
||||
}}{{ field.required ? "(必填)" : "(可选)" }}</span
|
||||
>
|
||||
<textarea
|
||||
v-if="field.name.includes('json')"
|
||||
:id="`dns-credential-${field.name}`"
|
||||
:name="`dns_credential_${field.name}`"
|
||||
v-model="dnsCredentials[field.name]"
|
||||
:required="field.required"
|
||||
:placeholder="field.placeholder"
|
||||
rows="4"
|
||||
autocomplete="off"
|
||||
></textarea>
|
||||
<input
|
||||
v-else
|
||||
:id="`dns-credential-${field.name}`"
|
||||
:name="`dns_credential_${field.name}`"
|
||||
v-model="dnsCredentials[field.name]"
|
||||
:required="field.required"
|
||||
:type="field.secret ? 'password' : 'text'"
|
||||
:placeholder="field.placeholder"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div class="dns-test-actions">
|
||||
<button
|
||||
class="dns-test-button"
|
||||
type="button"
|
||||
:disabled="
|
||||
dnsTesting ||
|
||||
dnsCatalogLoading ||
|
||||
!selectedDNSProvider?.available
|
||||
"
|
||||
@click="testDNS"
|
||||
>
|
||||
{{ dnsTesting ? "正在创建并清理测试记录……" : "测试 DNS API" }}
|
||||
</button>
|
||||
<span
|
||||
>测试会临时创建 DNS-01 TXT
|
||||
记录并自动清理,明文凭据不会写入普通配置文件。</span
|
||||
>
|
||||
</div>
|
||||
<p v-if="dnsTestError" class="inline-error">{{ dnsTestError }}</p>
|
||||
<div v-if="dnsVerificationValid" class="dns-verification-success">
|
||||
<strong>DNS API 在线验证通过</strong>
|
||||
<span
|
||||
>凭据已加密保存,本次验证结果有效至
|
||||
{{
|
||||
formatVerificationExpiry(dnsVerification.expires_at)
|
||||
}}。修改服务商、测试域名或凭据后需要重新测试。</span
|
||||
>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset v-if="currentStep === 4" class="setup-step-card">
|
||||
<legend><span>04</span>管理页面与证书目录</legend>
|
||||
<div class="target-switch">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: targetType === 'hostname' }"
|
||||
@click="targetType = 'hostname'"
|
||||
>
|
||||
使用域名</button
|
||||
><button
|
||||
type="button"
|
||||
:class="{ active: targetType === 'ip' }"
|
||||
@click="targetType = 'ip'"
|
||||
>
|
||||
使用公网 IP
|
||||
</button>
|
||||
</div>
|
||||
<div class="setup-grid two-columns">
|
||||
<label v-if="targetType === 'hostname'"
|
||||
><span>管理页面域名</span
|
||||
><input
|
||||
id="web-hostname"
|
||||
name="web_hostname"
|
||||
v-model.trim="form.web_hostname"
|
||||
required
|
||||
placeholder="scert.example.com"
|
||||
/></label>
|
||||
<label v-else
|
||||
><span>公网 IP 地址</span
|
||||
><input
|
||||
id="web-public-ip"
|
||||
name="web_public_ip"
|
||||
v-model.trim="form.web_public_ip"
|
||||
required
|
||||
placeholder="203.0.113.10"
|
||||
/></label>
|
||||
<label
|
||||
><span>证书部署根目录</span
|
||||
><input
|
||||
id="certificate-root"
|
||||
name="certificate_root"
|
||||
v-model.trim="form.certificate_root"
|
||||
required
|
||||
/></label>
|
||||
<label
|
||||
><span>HTTPS 模式</span
|
||||
><select
|
||||
id="https-mode"
|
||||
name="https_mode"
|
||||
v-model="form.https_mode"
|
||||
>
|
||||
<option value="direct">默认:核心服务直接终止 HTTPS</option>
|
||||
<option value="proxy">
|
||||
高级:Nginx/Caddy 终止公网 HTTPS
|
||||
</option>
|
||||
</select></label
|
||||
>
|
||||
</div>
|
||||
<label class="confirm-row"
|
||||
><input
|
||||
id="web-enabled"
|
||||
name="web_enabled"
|
||||
v-model="form.web_enabled"
|
||||
type="checkbox"
|
||||
/><span
|
||||
><strong>初始化完成后开启管理页面</strong
|
||||
><small
|
||||
>桌面端可通过此开关决定是否启用浏览器管理页面。</small
|
||||
></span
|
||||
></label
|
||||
>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
<p v-if="error" class="setup-error">{{ error }}</p>
|
||||
<p v-if="resultMessage" class="setup-success">{{ resultMessage }}</p>
|
||||
<footer>
|
||||
<span
|
||||
>初始化程序将自动配置本机防火墙;云安全组只需放行主服务端口。配置完成前仅保存在内存中。</span
|
||||
>
|
||||
<div class="wizard-actions">
|
||||
<button
|
||||
v-if="currentStep > 1"
|
||||
class="back-button"
|
||||
type="button"
|
||||
@click="previousStep"
|
||||
>
|
||||
上一步</button
|
||||
><button type="submit" :disabled="submitting || dnsTesting">
|
||||
{{
|
||||
currentStep < 4
|
||||
? "下一步"
|
||||
: submitting
|
||||
? "正在保存……"
|
||||
: "完成初始化"
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</footer>
|
||||
</form>
|
||||
</section>
|
||||
</AccessShell>
|
||||
</template>
|
||||
|
||||
<style scoped src="./SetupWizard.css"></style>
|
||||
@@ -0,0 +1,52 @@
|
||||
.super-admin-reset-card {
|
||||
width: min(100%, 520px);
|
||||
max-width: 520px;
|
||||
}
|
||||
|
||||
.reset-success-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 20;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background: rgba(17, 36, 78, 0.38);
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
.reset-success-dialog {
|
||||
width: min(100%, 390px);
|
||||
padding: 34px 30px 30px;
|
||||
border: 1px solid #d7e5f7;
|
||||
border-radius: 22px;
|
||||
background: #ffffff;
|
||||
color: #172033;
|
||||
box-shadow: 0 24px 60px rgba(17, 36, 78, 0.24);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.reset-success-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
margin: 0 auto 18px;
|
||||
border-radius: 50%;
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, #3d83d8, #2455a0);
|
||||
font-size: 27px;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.reset-success-dialog h2 {
|
||||
margin: 0 0 12px;
|
||||
color: #172033;
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.reset-success-dialog p {
|
||||
margin: 6px 0;
|
||||
color: #607391;
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
import { onBeforeUnmount, onMounted, ref } from "vue";
|
||||
|
||||
function readResetMessage(html) {
|
||||
const documentNode = new DOMParser().parseFromString(html, "text/html");
|
||||
const notice = documentNode.querySelector(".notice");
|
||||
return notice?.textContent?.trim() || "重置请求未成功,请检查一次性校验码。";
|
||||
}
|
||||
|
||||
export function useSuperAdminReset() {
|
||||
const verificationCode = ref("");
|
||||
const password = ref("");
|
||||
const confirmPassword = ref("");
|
||||
const csrfToken = ref("");
|
||||
const message = ref("");
|
||||
const error = ref("");
|
||||
const loading = ref(true);
|
||||
const submitting = ref(false);
|
||||
const success = ref(false);
|
||||
const redirectSeconds = ref(3);
|
||||
let redirectTimer;
|
||||
|
||||
async function loadSession() {
|
||||
loading.value = true;
|
||||
error.value = "";
|
||||
try {
|
||||
const response = await fetch("/reset", {
|
||||
credentials: "same-origin",
|
||||
cache: "no-store",
|
||||
headers: {
|
||||
Accept: "application/x-scert-reset-bootstrap",
|
||||
},
|
||||
});
|
||||
const html = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error("当前重置入口未开启,请先启动 Scert-admin。");
|
||||
}
|
||||
const documentNode = new DOMParser().parseFromString(html, "text/html");
|
||||
csrfToken.value = documentNode.querySelector(
|
||||
'input[name="csrf_token"]',
|
||||
)?.value || "";
|
||||
if (!csrfToken.value) {
|
||||
throw new Error("未能获取本次重置授权,请重新打开页面。");
|
||||
}
|
||||
} catch (loadError) {
|
||||
error.value = loadError.message || "无法获取重置授权,请稍后重试。";
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function validate() {
|
||||
if (!verificationCode.value.trim()) {
|
||||
return "请输入一次性校验码。";
|
||||
}
|
||||
if (password.value.length < 8) {
|
||||
return "新密码至少需要 8 个字符。";
|
||||
}
|
||||
if (password.value !== confirmPassword.value) {
|
||||
return "两次输入的新密码不一致。";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (submitting.value || success.value) {
|
||||
return;
|
||||
}
|
||||
message.value = "";
|
||||
error.value = validate();
|
||||
if (error.value) {
|
||||
return;
|
||||
}
|
||||
if (!csrfToken.value) {
|
||||
error.value = "本次重置授权已失效,请重新打开页面。";
|
||||
return;
|
||||
}
|
||||
|
||||
submitting.value = true;
|
||||
try {
|
||||
const form = new URLSearchParams({
|
||||
csrf_token: csrfToken.value,
|
||||
reset_code: verificationCode.value.trim(),
|
||||
new_password: password.value,
|
||||
confirm_password: confirmPassword.value,
|
||||
});
|
||||
const response = await fetch("/reset", {
|
||||
method: "POST",
|
||||
credentials: "same-origin",
|
||||
headers: {
|
||||
Accept: "text/html",
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
body: form,
|
||||
});
|
||||
const responseBody = await response.text();
|
||||
if (!response.ok) {
|
||||
throw new Error(readResetMessage(responseBody));
|
||||
}
|
||||
|
||||
csrfToken.value = "";
|
||||
verificationCode.value = "";
|
||||
password.value = "";
|
||||
confirmPassword.value = "";
|
||||
success.value = true;
|
||||
redirectSeconds.value = 3;
|
||||
redirectTimer = window.setInterval(() => {
|
||||
redirectSeconds.value -= 1;
|
||||
if (redirectSeconds.value <= 0) {
|
||||
window.clearInterval(redirectTimer);
|
||||
window.location.href = "/login";
|
||||
}
|
||||
}, 1000);
|
||||
} catch (submitError) {
|
||||
error.value = submitError.message || "密码重置失败,请稍后重试。";
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(loadSession);
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (redirectTimer) {
|
||||
window.clearInterval(redirectTimer);
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
verificationCode,
|
||||
password,
|
||||
confirmPassword,
|
||||
message,
|
||||
error,
|
||||
loading,
|
||||
submitting,
|
||||
success,
|
||||
redirectSeconds,
|
||||
submit,
|
||||
loadSession,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<script setup>
|
||||
import AccessShell from "../components/AccessShell/AccessShell.vue";
|
||||
import { useSuperAdminReset } from "./SuperAdminReset.js";
|
||||
|
||||
const {
|
||||
verificationCode,
|
||||
password,
|
||||
confirmPassword,
|
||||
message,
|
||||
error,
|
||||
loading,
|
||||
submitting,
|
||||
success,
|
||||
redirectSeconds,
|
||||
submit,
|
||||
loadSession,
|
||||
} = useSuperAdminReset();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccessShell variant="compact" aria-label="Scert 超级管理员密码重置">
|
||||
<template #brand>
|
||||
<img class="access-logo" src="/Scert.png" alt="Scert 标志" />
|
||||
<p class="access-eyebrow">SCERT-ADMIN 安全入口</p>
|
||||
<h1 class="access-brand-title">超级管理员密码重置</h1>
|
||||
<p class="access-brand-description">
|
||||
此入口仅配合部署主机上的临时管理服务使用,不提供公开常驻访问。
|
||||
</p>
|
||||
</template>
|
||||
|
||||
<section class="access-card super-admin-reset-card">
|
||||
<header class="access-card-header">
|
||||
<p class="access-eyebrow">临时授权</p>
|
||||
<h2 class="access-card-title">确认安全重置</h2>
|
||||
<p class="access-card-description">
|
||||
请输入一次性校验码和新的超级管理员密码。
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<form class="access-form" @submit.prevent="submit">
|
||||
<label class="access-field">
|
||||
<span>一次性校验码</span>
|
||||
<input
|
||||
id="verification-code"
|
||||
name="verification_code"
|
||||
v-model.trim="verificationCode"
|
||||
type="text"
|
||||
autocomplete="one-time-code"
|
||||
placeholder="请输入一次性校验码"
|
||||
:disabled="loading || submitting || success"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="access-field">
|
||||
<span>新密码</span>
|
||||
<input
|
||||
id="super-admin-password"
|
||||
name="password"
|
||||
v-model="password"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="至少 8 个字符"
|
||||
minlength="8"
|
||||
:disabled="loading || submitting || success"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<label class="access-field">
|
||||
<span>确认新密码</span>
|
||||
<input
|
||||
id="super-admin-confirm-password"
|
||||
name="confirm_password"
|
||||
v-model="confirmPassword"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="请再次输入新密码"
|
||||
minlength="8"
|
||||
:disabled="loading || submitting || success"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
<p v-if="loading" class="access-message">正在验证本次重置入口……</p>
|
||||
<p v-if="message" class="access-message">{{ message }}</p>
|
||||
<p v-if="error" class="access-error">{{ error }}</p>
|
||||
<button
|
||||
class="access-submit"
|
||||
type="submit"
|
||||
:disabled="loading || submitting || success"
|
||||
>
|
||||
{{ submitting ? "正在提交" : "确认重置" }}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<p class="access-note">
|
||||
本页面仅在 Scert-admin 临时启用后使用。提交成功后,本次授权会立即销毁且不可再次使用。
|
||||
</p>
|
||||
<a class="access-return" href="/login">返回登录</a>
|
||||
</section>
|
||||
|
||||
<div v-if="success" class="reset-success-overlay" role="dialog" aria-modal="true">
|
||||
<div class="reset-success-dialog">
|
||||
<div class="reset-success-icon" aria-hidden="true">✓</div>
|
||||
<h2>密码重置成功</h2>
|
||||
<p>本次重置授权已销毁。</p>
|
||||
<p>{{ redirectSeconds }} 秒后返回登录页面。</p>
|
||||
</div>
|
||||
</div>
|
||||
</AccessShell>
|
||||
</template>
|
||||
|
||||
<style src="./SuperAdminReset.css"></style>
|
||||
@@ -0,0 +1,397 @@
|
||||
.access-shell {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: min(calc(100% - 48px), 1120px);
|
||||
height: min(680px, calc(100dvh - 48px));
|
||||
min-height: 520px;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1.58fr);
|
||||
overflow: hidden;
|
||||
transform: translate(-50%, -50%);
|
||||
border: 1px solid rgba(213, 224, 239, 0.95);
|
||||
border-radius: 28px;
|
||||
background: #ffffff;
|
||||
color: #172033;
|
||||
box-shadow: 0 28px 80px rgba(35, 67, 116, 0.17);
|
||||
}
|
||||
|
||||
.access-shell--setup {
|
||||
width: min(calc(100% - 48px), 1360px);
|
||||
height: min(760px, calc(100dvh - 40px));
|
||||
min-height: 600px;
|
||||
}
|
||||
|
||||
.access-shell--compact {
|
||||
width: min(calc(100% - 48px), 1040px);
|
||||
height: min(640px, calc(100dvh - 48px));
|
||||
}
|
||||
|
||||
.access-brand {
|
||||
position: relative;
|
||||
isolation: isolate;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: #ffffff;
|
||||
background:
|
||||
radial-gradient(
|
||||
circle at 18% 12%,
|
||||
rgba(119, 168, 255, 0.58),
|
||||
transparent 34%
|
||||
),
|
||||
linear-gradient(148deg, #11244e 0%, #244c92 60%, #326cc0 100%);
|
||||
}
|
||||
|
||||
.access-brand::before,
|
||||
.access-brand::after {
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
display: block;
|
||||
border-radius: 50%;
|
||||
content: "";
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.access-brand::before {
|
||||
top: -145px;
|
||||
right: -120px;
|
||||
width: 350px;
|
||||
height: 350px;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.access-brand::after {
|
||||
bottom: -190px;
|
||||
left: -150px;
|
||||
width: 410px;
|
||||
height: 410px;
|
||||
background: rgba(4, 18, 54, 0.25);
|
||||
}
|
||||
|
||||
.access-brand-content {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
padding: clamp(22px, 1.8vw, 30px) clamp(10px, 1.2vw, 18px);
|
||||
}
|
||||
|
||||
.access-logo {
|
||||
display: block;
|
||||
width: clamp(68px, 7vw, 94px);
|
||||
height: clamp(68px, 7vw, 94px);
|
||||
margin-bottom: 22px;
|
||||
object-fit: contain;
|
||||
filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.2));
|
||||
}
|
||||
|
||||
.access-eyebrow {
|
||||
margin: 0 0 8px;
|
||||
color: #bed5ff;
|
||||
font-size: 11px;
|
||||
font-weight: 900;
|
||||
letter-spacing: 0.14em;
|
||||
}
|
||||
|
||||
.access-brand-title {
|
||||
max-width: 100%;
|
||||
margin: 0 0 14px;
|
||||
color: #ffffff;
|
||||
font-size: clamp(18px, 1.45vw, 24px);
|
||||
letter-spacing: -0.08em;
|
||||
line-height: 1.16;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.access-brand-description {
|
||||
max-width: 470px;
|
||||
margin: 0;
|
||||
color: #dce8fb;
|
||||
font-size: 13px;
|
||||
line-height: 1.75;
|
||||
}
|
||||
|
||||
.access-panel {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
background: linear-gradient(145deg, #ffffff 0%, #f8fbff 100%);
|
||||
}
|
||||
|
||||
.access-panel-inner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: clamp(30px, 4vw, 58px);
|
||||
}
|
||||
|
||||
.access-shell--setup .access-panel-inner {
|
||||
align-items: stretch;
|
||||
padding: clamp(22px, 2.7vw, 42px);
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.access-shell,
|
||||
.access-shell--setup,
|
||||
.access-shell--compact {
|
||||
width: min(calc(100% - 24px), 760px);
|
||||
height: calc(100dvh - 24px);
|
||||
min-height: 0;
|
||||
grid-template-columns: 1fr;
|
||||
grid-template-rows: 120px minmax(0, 1fr);
|
||||
border-radius: 22px;
|
||||
}
|
||||
|
||||
.access-brand-content {
|
||||
display: grid;
|
||||
grid-template-columns: auto minmax(0, 1fr);
|
||||
align-content: center;
|
||||
align-items: center;
|
||||
column-gap: 18px;
|
||||
padding: 16px 20px;
|
||||
}
|
||||
|
||||
.access-logo,
|
||||
.access-brand-content > img:first-child {
|
||||
grid-row: 1 / span 3;
|
||||
width: 68px;
|
||||
height: 68px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.access-brand-title {
|
||||
max-width: 100%;
|
||||
margin-bottom: 3px;
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
.access-brand-description {
|
||||
max-width: 100%;
|
||||
font-size: 10px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.access-eyebrow {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.access-panel-inner,
|
||||
.access-shell--setup .access-panel-inner {
|
||||
padding: 18px 22px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.access-shell,
|
||||
.access-shell--setup,
|
||||
.access-shell--compact {
|
||||
width: calc(100% - 12px);
|
||||
height: calc(100dvh - 12px);
|
||||
grid-template-rows: 88px minmax(0, 1fr);
|
||||
border-radius: 17px;
|
||||
}
|
||||
|
||||
.access-brand-content {
|
||||
column-gap: 11px;
|
||||
padding: 9px 12px;
|
||||
}
|
||||
|
||||
.access-logo,
|
||||
.access-brand-content > img:first-child {
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
}
|
||||
|
||||
.access-brand-title {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.access-brand-description {
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.access-panel-inner,
|
||||
.access-shell--setup .access-panel-inner {
|
||||
padding: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.access-card {
|
||||
width: min(100%, 520px);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.access-card-header {
|
||||
margin-bottom: 28px;
|
||||
}
|
||||
|
||||
.access-card-header .access-eyebrow {
|
||||
color: #4d76b7;
|
||||
letter-spacing: 0.1em;
|
||||
}
|
||||
|
||||
.access-card-title {
|
||||
margin: 0 0 9px;
|
||||
color: #172033;
|
||||
font-size: clamp(26px, 3vw, 34px);
|
||||
letter-spacing: -0.05em;
|
||||
}
|
||||
|
||||
.access-card-description {
|
||||
margin: 0;
|
||||
color: #71809a;
|
||||
font-size: 13px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.access-form {
|
||||
display: grid;
|
||||
gap: 17px;
|
||||
}
|
||||
|
||||
.access-field {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.access-field span,
|
||||
.access-field legend {
|
||||
color: #33415b;
|
||||
font-size: 12px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.access-field input,
|
||||
.access-field textarea {
|
||||
width: 100%;
|
||||
min-height: 44px;
|
||||
padding: 0 13px;
|
||||
border: 1px solid #d8e2ef;
|
||||
border-radius: 11px;
|
||||
outline: none;
|
||||
color: #172033;
|
||||
background: #ffffff;
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
transition:
|
||||
border-color 0.18s ease,
|
||||
box-shadow 0.18s ease;
|
||||
}
|
||||
|
||||
.access-field textarea {
|
||||
min-height: 96px;
|
||||
padding-top: 12px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.access-field input:focus,
|
||||
.access-field textarea:focus {
|
||||
border-color: #4d7bc9;
|
||||
box-shadow: 0 0 0 4px rgba(77, 123, 201, 0.12);
|
||||
}
|
||||
|
||||
.access-options {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 14px;
|
||||
color: #71809a;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.access-check {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.access-check input {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
accent-color: #3568b9;
|
||||
}
|
||||
|
||||
.access-link {
|
||||
color: #3568b9;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.access-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.access-submit {
|
||||
width: 100%;
|
||||
min-height: 46px;
|
||||
margin-top: 4px;
|
||||
border: 0;
|
||||
border-radius: 11px;
|
||||
color: #ffffff;
|
||||
background: linear-gradient(135deg, #3568b9, #28569d);
|
||||
box-shadow: 0 10px 22px rgba(49, 95, 170, 0.23);
|
||||
font: inherit;
|
||||
font-size: 13px;
|
||||
font-weight: 800;
|
||||
transition:
|
||||
transform 0.18s ease,
|
||||
box-shadow 0.18s ease;
|
||||
}
|
||||
|
||||
.access-submit:hover:not(:disabled) {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 13px 26px rgba(49, 95, 170, 0.28);
|
||||
}
|
||||
|
||||
.access-submit:disabled {
|
||||
cursor: wait;
|
||||
opacity: 0.65;
|
||||
}
|
||||
|
||||
.access-message,
|
||||
.access-error {
|
||||
margin: 0;
|
||||
padding: 11px 13px;
|
||||
border-radius: 10px;
|
||||
font-size: 12px;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
.access-message {
|
||||
color: #226443;
|
||||
background: #eaf8f0;
|
||||
}
|
||||
|
||||
.access-error {
|
||||
color: #a13e3e;
|
||||
background: #fff0f0;
|
||||
}
|
||||
|
||||
.access-note {
|
||||
margin: 22px 0 0;
|
||||
padding: 12px 14px;
|
||||
border-left: 3px solid #9ebff4;
|
||||
color: #62728c;
|
||||
background: #f2f6fc;
|
||||
font-size: 11px;
|
||||
line-height: 1.65;
|
||||
}
|
||||
|
||||
.access-return {
|
||||
display: inline-flex;
|
||||
margin-top: 20px;
|
||||
color: #3568b9;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.access-return:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export const accessShellProps = {
|
||||
variant: {
|
||||
type: String,
|
||||
default: "default",
|
||||
validator: (value) => ["default", "setup", "compact"].includes(value),
|
||||
},
|
||||
ariaLabel: {
|
||||
type: String,
|
||||
default: "Scert 访问页面",
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
<script setup>
|
||||
import { accessShellProps } from "./AccessShell.js";
|
||||
|
||||
defineProps(accessShellProps);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main
|
||||
class="access-shell"
|
||||
:class="`access-shell--${variant}`"
|
||||
:aria-label="ariaLabel"
|
||||
>
|
||||
<aside class="access-brand">
|
||||
<div class="access-brand-content">
|
||||
<slot name="brand">
|
||||
<img class="access-logo" src="/Scert.png" alt="Scert 标志" />
|
||||
<p class="access-eyebrow">SCERT</p>
|
||||
<h1 class="access-brand-title">统一证书管理服务</h1>
|
||||
<p class="access-brand-description">
|
||||
安全管理证书申请、续期、部署与状态校验。
|
||||
</p>
|
||||
</slot>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<section class="access-panel">
|
||||
<div class="access-panel-inner">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<style src="./AccessShell.css"></style>
|
||||
Reference in new issue
Block a user