完善 Scert 前后端与部署支持
This commit is contained in:
1 parent
afdb947bea
commit
7f0af703ed
85 files changed
+7530
-800
No files matched your search
@@ -2,6 +2,7 @@ import { onMounted, ref } from "vue";
|
||||
|
||||
export function useAppShell() {
|
||||
const setupState = ref(null);
|
||||
const authenticated = ref(null);
|
||||
const bootstrapping = ref(true);
|
||||
const error = ref("");
|
||||
const routePath = window.location.pathname.replace(/\/+$/, "") || "/";
|
||||
@@ -15,15 +16,36 @@ export function useAppShell() {
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "读取初始化状态失败");
|
||||
setupState.value = result;
|
||||
if (result.initialized) {
|
||||
await checkAuth();
|
||||
} else {
|
||||
authenticated.value = false;
|
||||
}
|
||||
} catch (err) {
|
||||
setupState.value = null;
|
||||
authenticated.value = null;
|
||||
error.value = err.message || "无法连接核心服务,请先启动 scert serve";
|
||||
} finally {
|
||||
bootstrapping.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function checkAuth() {
|
||||
const response = await fetch("/api/v1/auth/session", {
|
||||
credentials: "include",
|
||||
});
|
||||
if (response.status === 401) {
|
||||
authenticated.value = false;
|
||||
return;
|
||||
}
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "读取登录状态失败");
|
||||
authenticated.value = result.authenticated === true;
|
||||
}
|
||||
|
||||
function handleInitialized() {
|
||||
setupState.value = { ...setupState.value, initialized: true };
|
||||
authenticated.value = false;
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
@@ -36,6 +58,7 @@ export function useAppShell() {
|
||||
|
||||
return {
|
||||
setupState,
|
||||
authenticated,
|
||||
bootstrapping,
|
||||
error,
|
||||
routePath,
|
||||
|
||||
@@ -8,6 +8,7 @@ import SuperAdminReset from "./views/SuperAdminReset/SuperAdminReset.vue";
|
||||
|
||||
const {
|
||||
setupState,
|
||||
authenticated,
|
||||
bootstrapping,
|
||||
error,
|
||||
routePath,
|
||||
@@ -41,5 +42,7 @@ const {
|
||||
@initialized="handleInitialized"
|
||||
/>
|
||||
|
||||
<Dashboard v-else />
|
||||
<Login v-else-if="setupState && authenticated === false" />
|
||||
|
||||
<Dashboard v-else-if="setupState && authenticated === true" />
|
||||
</template>
|
||||
@@ -155,6 +155,59 @@ h2 {
|
||||
.server-panel {
|
||||
margin-top: 18px;
|
||||
}
|
||||
.operations-panel {
|
||||
margin-top: 18px;
|
||||
}
|
||||
.operation-columns {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
gap: 18px;
|
||||
}
|
||||
.operation-columns h3 {
|
||||
margin: 0 0 10px;
|
||||
color: #32405a;
|
||||
font-size: 15px;
|
||||
}
|
||||
.record-list {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
.record-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
min-height: 54px;
|
||||
padding: 11px 12px;
|
||||
border: 1px solid #edf0f5;
|
||||
border-radius: 11px;
|
||||
background: #fbfcfe;
|
||||
}
|
||||
.record-row > div {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
}
|
||||
.record-row strong,
|
||||
.record-row .muted {
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.compact-empty {
|
||||
min-height: 80px;
|
||||
padding: 18px 8px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.settings-modal {
|
||||
width: min(100%, 760px);
|
||||
}
|
||||
.settings-modal h3 {
|
||||
margin: 22px 0 10px;
|
||||
color: #32405a;
|
||||
font-size: 15px;
|
||||
}
|
||||
.settings-modal h3:first-of-type {
|
||||
margin-top: 0;
|
||||
}
|
||||
.panel-heading {
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
@@ -258,18 +311,59 @@ code {
|
||||
z-index: 10;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 20px;
|
||||
background: rgba(18, 31, 58, 0.45);
|
||||
overflow-y: auto;
|
||||
padding: clamp(16px, 3vw, 32px);
|
||||
background: rgba(18, 31, 58, 0.52);
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
.modal-card {
|
||||
width: min(100%, 560px);
|
||||
max-height: calc(100vh - 40px);
|
||||
width: min(100%, 860px);
|
||||
max-height: calc(100vh - 32px);
|
||||
overflow: auto;
|
||||
padding: 30px;
|
||||
border: 1px solid #e2e8f2;
|
||||
padding: 32px;
|
||||
border: 1px solid #b9cbe0;
|
||||
border-radius: 22px;
|
||||
background: #fff;
|
||||
box-shadow: 0 24px 70px rgba(19, 38, 79, 0.25);
|
||||
box-shadow:
|
||||
0 30px 86px rgba(19, 38, 79, 0.34),
|
||||
0 0 0 5px rgba(227, 237, 248, 0.72),
|
||||
inset 0 1px 0 rgba(255, 255, 255, 0.96);
|
||||
}
|
||||
.ssh-key-modal {
|
||||
width: min(100%, 1080px);
|
||||
overflow: hidden;
|
||||
padding: 30px 34px;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
|
||||
}
|
||||
.ssh-key-modal form {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
|
||||
align-items: start;
|
||||
gap: 24px;
|
||||
}
|
||||
.ssh-key-modal .ssh-key-guide {
|
||||
grid-column: 1;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.ssh-key-form-fields {
|
||||
grid-column: 2;
|
||||
min-width: 0;
|
||||
padding: 18px 18px 16px;
|
||||
border: 1px solid #cfdeed;
|
||||
border-radius: 14px;
|
||||
background: rgba(255, 255, 255, 0.94);
|
||||
box-shadow: 0 8px 22px rgba(45, 79, 123, 0.06);
|
||||
}
|
||||
.ssh-key-form-fields .field:last-of-type {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.ssh-key-form-fields .field textarea {
|
||||
min-height: 230px;
|
||||
}
|
||||
.ssh-key-form-fields .modal-actions {
|
||||
margin-top: 20px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #dbe5f0;
|
||||
}
|
||||
.modal-heading {
|
||||
display: flex;
|
||||
@@ -277,6 +371,8 @@ code {
|
||||
justify-content: space-between;
|
||||
gap: 20px;
|
||||
margin-bottom: 24px;
|
||||
padding-bottom: 18px;
|
||||
border-bottom: 1px solid #dbe5f0;
|
||||
}
|
||||
.modal-heading h2 {
|
||||
margin-bottom: 0;
|
||||
@@ -312,12 +408,12 @@ code {
|
||||
.field select,
|
||||
.field textarea {
|
||||
width: 100%;
|
||||
border: 1px solid #d8e0eb;
|
||||
border: 1px solid #bdcde0;
|
||||
border-radius: 10px;
|
||||
outline: 0;
|
||||
padding: 11px 12px;
|
||||
color: #172033;
|
||||
background: #fbfcfe;
|
||||
background: #ffffff;
|
||||
font: inherit;
|
||||
font-weight: 500;
|
||||
}
|
||||
@@ -443,6 +539,9 @@ code {
|
||||
.metrics-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
.operation-columns {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.panel {
|
||||
padding: 20px;
|
||||
}
|
||||
@@ -473,6 +572,20 @@ code {
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.ssh-key-modal {
|
||||
width: min(100%, 760px);
|
||||
}
|
||||
|
||||
.ssh-key-modal form {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.ssh-key-modal .ssh-key-guide {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
.field-label-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -504,9 +617,10 @@ code {
|
||||
.ssh-key-guide {
|
||||
margin: 0 0 18px;
|
||||
padding: 16px;
|
||||
border: 1px solid #dbe7f7;
|
||||
border: 1px solid #c4d7eb;
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, #f7fbff, #f3f7fc);
|
||||
background: linear-gradient(135deg, #f4f9ff, #edf4fc);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.ssh-key-guide-heading {
|
||||
@@ -544,6 +658,7 @@ code {
|
||||
gap: 9px;
|
||||
min-width: 0;
|
||||
padding: 11px;
|
||||
border: 1px solid #d7e3f0;
|
||||
border-radius: 9px;
|
||||
background: #ffffff;
|
||||
}
|
||||
@@ -605,10 +720,58 @@ code {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.ssh-key-path-line,
|
||||
.ssh-key-path-summary {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin: 8px 0;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid #c7d8e9;
|
||||
border-radius: 9px;
|
||||
color: #3b5778;
|
||||
background: #ffffff;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.ssh-key-path-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.ssh-key-path-line code,
|
||||
.ssh-key-path-summary code {
|
||||
overflow-wrap: anywhere;
|
||||
color: #294765;
|
||||
font-family: Consolas, "SFMono-Regular", monospace;
|
||||
}
|
||||
|
||||
.ssh-key-path-summary {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
margin-top: 0;
|
||||
gap: 6px;
|
||||
background: #f8fbff;
|
||||
}
|
||||
|
||||
.ssh-key-path-summary > div {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ssh-key-path-summary > div:last-child {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.ssh-key-path-summary span {
|
||||
color: #71839a;
|
||||
}
|
||||
|
||||
.ssh-command-card {
|
||||
margin-top: 10px;
|
||||
padding: 11px 12px;
|
||||
border: 1px solid #dfe8f3;
|
||||
border: 1px solid #c7d8e9;
|
||||
border-radius: 9px;
|
||||
background: #ffffff;
|
||||
}
|
||||
@@ -661,6 +824,14 @@ code {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.ssh-key-path-summary {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.ssh-key-path-summary > div:last-child {
|
||||
grid-column: auto;
|
||||
}
|
||||
|
||||
.field-label-row {
|
||||
align-items: flex-start;
|
||||
}
|
||||
@@ -686,4 +857,30 @@ code {
|
||||
background: #e2efff;
|
||||
font-size: 11px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.certificate-import-modal {
|
||||
width: min(100%, 680px);
|
||||
}
|
||||
|
||||
.import-result {
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
margin: 16px 0;
|
||||
padding: 14px 16px;
|
||||
border: 1px solid #bfe7d1;
|
||||
border-radius: 12px;
|
||||
color: #24734b;
|
||||
background: #effbf4;
|
||||
}
|
||||
|
||||
.import-result span {
|
||||
color: #4c7a61;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
@media (min-width: 1100px) {
|
||||
.settings-modal {
|
||||
width: min(100%, 980px);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { computed, onMounted, ref } from "vue";
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
||||
|
||||
export function useDashboard() {
|
||||
const scertLogo = "/Scert.png";
|
||||
@@ -7,6 +7,10 @@ export function useDashboard() {
|
||||
const domains = ref([]);
|
||||
const servers = ref([]);
|
||||
const sshKeys = ref([]);
|
||||
const certificates = ref([]);
|
||||
const tasks = ref([]);
|
||||
const auditLogs = ref([]);
|
||||
const settings = ref(null);
|
||||
const domainServers = ref({});
|
||||
const loading = ref(true);
|
||||
const saving = ref(false);
|
||||
@@ -24,19 +28,63 @@ export function useDashboard() {
|
||||
const sshKeyFormError = ref("");
|
||||
const sshKeyPlatform = ref("windows");
|
||||
const sshKeyPassphraseVisible = ref(false);
|
||||
const sshKeyCommandUsername = ref("用户名");
|
||||
const sshKeyCommandHost = ref("服务器地址");
|
||||
const sshKeyRandomSuffix = ref(createSSHKeyRandomSuffix());
|
||||
const showSettings = ref(false);
|
||||
const settingsSaving = ref(false);
|
||||
const settingsError = ref("");
|
||||
const settingsForm = ref(createEmptySettingsForm());
|
||||
const showCertificateImport = ref(false);
|
||||
const importDomain = ref(null);
|
||||
const importSaving = ref(false);
|
||||
const importError = ref("");
|
||||
const importResult = ref(null);
|
||||
const importFiles = ref({
|
||||
certificate: null,
|
||||
private_key: null,
|
||||
issuer_bundle: null,
|
||||
});
|
||||
const hasOpenModal = computed(
|
||||
() =>
|
||||
showForm.value ||
|
||||
showServerForm.value ||
|
||||
showSSHKeyForm.value ||
|
||||
showSettings.value,
|
||||
);
|
||||
let previousBodyOverflow = "";
|
||||
|
||||
const sshKeyCommands = {
|
||||
watch(hasOpenModal, (isOpen) => {
|
||||
if (isOpen) {
|
||||
previousBodyOverflow = document.body.style.overflow;
|
||||
document.body.style.overflow = "hidden";
|
||||
return;
|
||||
}
|
||||
document.body.style.overflow = previousBodyOverflow;
|
||||
});
|
||||
|
||||
const sshKeyFileName = computed(
|
||||
() =>
|
||||
`${sanitizeSSHKeySegment(sshKeyCommandUsername.value, "用户名")}+scert-${sshKeyRandomSuffix.value}`,
|
||||
);
|
||||
const sshKeyPath = computed(() => `/ssl/ssh/${sshKeyFileName.value}`);
|
||||
const sshKeyPublicPath = computed(() => `${sshKeyPath.value}.pub`);
|
||||
const sshKeyRemoteTarget = computed(
|
||||
() =>
|
||||
`${sanitizeSSHKeySegment(sshKeyCommandUsername.value, "用户名")}@${sanitizeSSHHost(sshKeyCommandHost.value)}`,
|
||||
);
|
||||
const sshKeyCommands = computed(() => ({
|
||||
windows:
|
||||
'ssh-keygen -t ed25519 -C "scert-deploy" -f "$HOME\\.ssh\\scert_deploy_ed25519"',
|
||||
`New-Item -ItemType Directory -Force -Path "/ssl/ssh" | Out-Null; ssh-keygen -t ed25519 -C "scert-deploy" -f "${sshKeyPath.value}"`,
|
||||
linux:
|
||||
'ssh-keygen -t ed25519 -C "scert-deploy" -f ~/.ssh/scert_deploy_ed25519',
|
||||
};
|
||||
const sshPublicKeyCommands = {
|
||||
`sudo install -d -m 700 -o "$(id -un)" -g "$(id -gn)" /ssl/ssh && ssh-keygen -t ed25519 -C "scert-deploy" -f "${sshKeyPath.value}"`,
|
||||
}));
|
||||
const sshPublicKeyCommands = computed(() => ({
|
||||
windows:
|
||||
'Get-Content "$HOME\\.ssh\\scert_deploy_ed25519.pub" | ssh root@服务器地址 "umask 077; mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys"',
|
||||
`Get-Content "${sshKeyPublicPath.value}" | ssh ${sshKeyRemoteTarget.value} "umask 077; mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys"`,
|
||||
linux:
|
||||
'ssh-copy-id -i ~/.ssh/scert_deploy_ed25519.pub 用户名@服务器地址',
|
||||
};
|
||||
`ssh-copy-id -i "${sshKeyPublicPath.value}" ${sshKeyRemoteTarget.value}`,
|
||||
}));
|
||||
|
||||
const certificateTypeLabels = {
|
||||
single: "单域名",
|
||||
@@ -81,6 +129,18 @@ export function useDashboard() {
|
||||
const serverForm = ref(createEmptyServerForm());
|
||||
const sshKeyForm = ref(createEmptySSHKeyForm());
|
||||
|
||||
async function fetchAdmin(path, options = {}) {
|
||||
const response = await fetch(path, {
|
||||
...options,
|
||||
credentials: "include",
|
||||
});
|
||||
if (response.status === 401) {
|
||||
window.location.assign("/login");
|
||||
throw new Error("登录会话已过期,请重新登录");
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
function createEmptyForm() {
|
||||
return {
|
||||
name: "",
|
||||
@@ -114,6 +174,94 @@ export function useDashboard() {
|
||||
return { name: "", private_key: "", passphrase: "" };
|
||||
}
|
||||
|
||||
function createSSHKeyRandomSuffix() {
|
||||
const bytes = new Uint8Array(6);
|
||||
crypto.getRandomValues(bytes);
|
||||
return Array.from(bytes, (value) => value.toString(16).padStart(2, "0")).join(
|
||||
"",
|
||||
);
|
||||
}
|
||||
|
||||
function sanitizeSSHKeySegment(value, fallback) {
|
||||
const normalized = String(value || "")
|
||||
.trim()
|
||||
.replace(/[^\p{L}\p{N}._-]+/gu, "-")
|
||||
.replace(/^-+|-+$/g, "");
|
||||
return normalized || fallback;
|
||||
}
|
||||
|
||||
function sanitizeSSHHost(value) {
|
||||
const normalized = String(value || "")
|
||||
.trim()
|
||||
.replace(/[^a-zA-Z0-9.:[\]-]+/g, "");
|
||||
return normalized || "服务器地址";
|
||||
}
|
||||
|
||||
function createEmptySettingsForm() {
|
||||
return {
|
||||
server: { host: "", port: 5200, https_mode: "direct" },
|
||||
web: { enabled: true, hostname: "", public_ip: "" },
|
||||
paths: { certificate: "" },
|
||||
acme: {
|
||||
ca: "letsencrypt",
|
||||
environment: "staging",
|
||||
account_email: "",
|
||||
renewal_threshold_days: 6,
|
||||
propagation_timeout_secs: 900,
|
||||
propagation_polling_interval_secs: 10,
|
||||
},
|
||||
dns: { provider: "" },
|
||||
notification: {
|
||||
http_enabled: false,
|
||||
smtp_enabled: false,
|
||||
provider: "",
|
||||
endpoint: "",
|
||||
http_path: "/api/email/send",
|
||||
http_login_path: "/api/login",
|
||||
http_auth_mode: "none",
|
||||
event_mode: "detailed",
|
||||
include_deployment_details: true,
|
||||
include_certificate_serial: false,
|
||||
include_management_url: false,
|
||||
sender_name: "Scert",
|
||||
sender_email: "",
|
||||
recipients: [],
|
||||
timeout_secs: 10,
|
||||
retry_count: 3,
|
||||
retry_intervals_secs: [30, 120, 600],
|
||||
smtp_host: "",
|
||||
smtp_port: 587,
|
||||
smtp_username: "",
|
||||
smtp_password: "",
|
||||
smtp_mode: "starttls",
|
||||
smtp_allow_plaintext_auth: false,
|
||||
smtp_credential_configured: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeSettings(value) {
|
||||
const defaults = createEmptySettingsForm();
|
||||
const source = value || {};
|
||||
return {
|
||||
...defaults,
|
||||
...source,
|
||||
server: { ...defaults.server, ...(source.server || {}) },
|
||||
web: { ...defaults.web, ...(source.web || {}) },
|
||||
paths: { ...defaults.paths, ...(source.paths || {}) },
|
||||
acme: { ...defaults.acme, ...(source.acme || {}) },
|
||||
dns: { ...defaults.dns, ...(source.dns || {}) },
|
||||
notification: {
|
||||
...defaults.notification,
|
||||
...(source.notification || {}),
|
||||
smtp_password: "",
|
||||
recipients: Array.isArray(source.notification?.recipients)
|
||||
? source.notification.recipients
|
||||
: [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function displayLabel(labels, value) {
|
||||
return labels[value] || (value ? "未知" : "—");
|
||||
}
|
||||
@@ -195,6 +343,10 @@ export function useDashboard() {
|
||||
sshKeyFormError.value = "";
|
||||
sshKeyPlatform.value = "windows";
|
||||
sshKeyPassphraseVisible.value = false;
|
||||
sshKeyCommandUsername.value = serverForm.value.username.trim() || "用户名";
|
||||
sshKeyCommandHost.value = serverForm.value.address.trim() || "服务器地址";
|
||||
sshKeyRandomSuffix.value = createSSHKeyRandomSuffix();
|
||||
sshKeyForm.value.name = sshKeyFileName.value;
|
||||
showSSHKeyForm.value = true;
|
||||
}
|
||||
|
||||
@@ -234,7 +386,7 @@ export function useDashboard() {
|
||||
sshKeyFormError.value = "";
|
||||
sshKeySaving.value = true;
|
||||
try {
|
||||
const response = await fetch("/api/v1/ssh-keys", {
|
||||
const response = await fetchAdmin("/api/v1/ssh-keys", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(sshKeyForm.value),
|
||||
@@ -260,7 +412,7 @@ export function useDashboard() {
|
||||
)
|
||||
return;
|
||||
try {
|
||||
const response = await fetch(`/api/v1/ssh-keys/${item.id}`, {
|
||||
const response = await fetchAdmin(`/api/v1/ssh-keys/${item.id}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
@@ -299,7 +451,7 @@ export function useDashboard() {
|
||||
const path = serverEditingId.value
|
||||
? `/api/v1/servers/${serverEditingId.value}`
|
||||
: "/api/v1/servers";
|
||||
const response = await fetch(path, {
|
||||
const response = await fetchAdmin(path, {
|
||||
method: serverEditingId.value ? "PUT" : "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
@@ -318,11 +470,147 @@ export function useDashboard() {
|
||||
}
|
||||
}
|
||||
|
||||
async function runDomainAction(item, action, successMessage) {
|
||||
error.value = "";
|
||||
notice.value = "";
|
||||
try {
|
||||
const response = await fetchAdmin(`/api/v1/domains/${item.id}/${action}`, {
|
||||
method: "POST",
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "域名操作失败");
|
||||
notice.value = successMessage;
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
error.value = err.message || "域名操作失败";
|
||||
}
|
||||
}
|
||||
|
||||
function issueDomain(item) {
|
||||
return runDomainAction(item, "issue", `已提交 ${item.name} 的证书申请`);
|
||||
}
|
||||
|
||||
function validateDomain(item) {
|
||||
return runDomainAction(item, "certificate/validate", `已提交 ${item.name} 的证书校验`);
|
||||
}
|
||||
|
||||
function deployDomain(item) {
|
||||
return runDomainAction(item, "deploy", `已提交 ${item.name} 的证书部署`);
|
||||
}
|
||||
|
||||
async function runRenewalNow() {
|
||||
error.value = "";
|
||||
notice.value = "";
|
||||
try {
|
||||
const response = await fetchAdmin("/api/v1/renewal/run", { method: "POST" });
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "执行续期检查失败");
|
||||
const report = result.report || {};
|
||||
notice.value = `续期检查完成:检查 ${report.checked || 0} 项,选中 ${report.selected || 0} 项,成功 ${report.succeeded || 0} 项,失败 ${report.failed || 0} 项`;
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
error.value = err.message || "执行续期检查失败";
|
||||
}
|
||||
}
|
||||
|
||||
function openSettings() {
|
||||
settingsError.value = "";
|
||||
settingsForm.value = normalizeSettings(settings.value);
|
||||
showSettings.value = true;
|
||||
}
|
||||
|
||||
function closeSettings() {
|
||||
if (!settingsSaving.value) showSettings.value = false;
|
||||
}
|
||||
|
||||
async function saveSettings() {
|
||||
settingsError.value = "";
|
||||
settingsSaving.value = true;
|
||||
try {
|
||||
const response = await fetchAdmin("/api/v1/settings", {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(settingsForm.value),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) throw new Error(result.error || "保存系统设置失败");
|
||||
settings.value = result.settings;
|
||||
showSettings.value = false;
|
||||
notice.value = result.message || "系统设置已保存";
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
settingsError.value = err.message || "保存系统设置失败";
|
||||
} finally {
|
||||
settingsSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openCertificateImport(item) {
|
||||
importDomain.value = item;
|
||||
importFiles.value = {
|
||||
certificate: null,
|
||||
private_key: null,
|
||||
issuer_bundle: null,
|
||||
};
|
||||
importResult.value = null;
|
||||
importError.value = "";
|
||||
showCertificateImport.value = true;
|
||||
}
|
||||
|
||||
function closeCertificateImport() {
|
||||
if (!importSaving.value) showCertificateImport.value = false;
|
||||
}
|
||||
|
||||
function selectCertificateImportFile(kind, event) {
|
||||
importFiles.value[kind] = event.target.files?.[0] || null;
|
||||
event.target.value = "";
|
||||
importError.value = "";
|
||||
}
|
||||
|
||||
async function importCertificate() {
|
||||
importError.value = "";
|
||||
importResult.value = null;
|
||||
if (!importFiles.value.certificate || !importFiles.value.private_key) {
|
||||
importError.value = "请选择证书文件和私钥文件";
|
||||
return;
|
||||
}
|
||||
const maxSize = 20 * 1024 * 1024;
|
||||
const files = Object.values(importFiles.value).filter(Boolean);
|
||||
if (files.some((file) => file.size > maxSize)) {
|
||||
importError.value = "单个证书文件不能超过 20 MB";
|
||||
return;
|
||||
}
|
||||
importSaving.value = true;
|
||||
try {
|
||||
const body = new FormData();
|
||||
body.append("certificate", importFiles.value.certificate);
|
||||
body.append("private_key", importFiles.value.private_key);
|
||||
if (importFiles.value.issuer_bundle) {
|
||||
body.append("issuer_bundle", importFiles.value.issuer_bundle);
|
||||
}
|
||||
const response = await fetchAdmin(
|
||||
`/api/v1/domains/${importDomain.value.id}/certificate/import`,
|
||||
{ method: "POST", body },
|
||||
);
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
throw new Error(result.error || "导入证书失败");
|
||||
}
|
||||
importResult.value = result;
|
||||
notice.value = `域名 ${importDomain.value.name} 的证书已导入`;
|
||||
await loadData();
|
||||
} catch (err) {
|
||||
importError.value = err.message || "导入证书失败";
|
||||
} finally {
|
||||
importSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteServer(item) {
|
||||
if (!window.confirm(`确定删除服务器“${item.name}”吗?关联域名也会解除。`))
|
||||
return;
|
||||
try {
|
||||
const response = await fetch(`/api/v1/servers/${item.id}`, {
|
||||
const response = await fetchAdmin(`/api/v1/servers/${item.id}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
@@ -335,7 +623,7 @@ export function useDashboard() {
|
||||
}
|
||||
|
||||
async function saveDomainServers(domainId, serverIds) {
|
||||
const response = await fetch(`/api/v1/domains/${domainId}/servers`, {
|
||||
const response = await fetchAdmin(`/api/v1/domains/${domainId}/servers`, {
|
||||
method: "PUT",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ server_ids: serverIds }),
|
||||
@@ -382,7 +670,7 @@ export function useDashboard() {
|
||||
const path = isEditing.value
|
||||
? `/api/v1/domains/${editingId.value}`
|
||||
: "/api/v1/domains";
|
||||
const response = await fetch(path, {
|
||||
const response = await fetchAdmin(path, {
|
||||
method: isEditing.value ? "PUT" : "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(payload),
|
||||
@@ -412,7 +700,7 @@ export function useDashboard() {
|
||||
error.value = "";
|
||||
notice.value = "";
|
||||
try {
|
||||
const response = await fetch(`/api/v1/domains/${item.id}`, {
|
||||
const response = await fetchAdmin(`/api/v1/domains/${item.id}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
if (!response.ok) {
|
||||
@@ -430,27 +718,42 @@ export function useDashboard() {
|
||||
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("服务接口返回失败");
|
||||
const [
|
||||
statusResponse,
|
||||
domainResponse,
|
||||
serverResponse,
|
||||
sshKeyResponse,
|
||||
certificateResponse,
|
||||
taskResponse,
|
||||
auditResponse,
|
||||
settingsResponse,
|
||||
] = await Promise.all([
|
||||
fetchAdmin("/api/v1/status"),
|
||||
fetchAdmin("/api/v1/domains"),
|
||||
fetchAdmin("/api/v1/servers"),
|
||||
fetchAdmin("/api/v1/ssh-keys"),
|
||||
fetchAdmin("/api/v1/certificates"),
|
||||
fetchAdmin("/api/v1/tasks?limit=20"),
|
||||
fetchAdmin("/api/v1/audit-logs?limit=20"),
|
||||
fetchAdmin("/api/v1/settings"),
|
||||
]);
|
||||
if ([statusResponse, domainResponse, serverResponse, sshKeyResponse, certificateResponse, taskResponse, auditResponse, settingsResponse].some((response) => !response.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 || [];
|
||||
certificates.value = (await certificateResponse.json()).items || [];
|
||||
tasks.value = (await taskResponse.json()).items || [];
|
||||
auditLogs.value = (await auditResponse.json()).items || [];
|
||||
settings.value = await settingsResponse.json();
|
||||
settingsForm.value = normalizeSettings(settings.value);
|
||||
const associations = await Promise.all(
|
||||
domains.value.map(async (item) => {
|
||||
const response = await fetch(`/api/v1/domains/${item.id}/servers`);
|
||||
const response = await fetchAdmin(
|
||||
`/api/v1/domains/${item.id}/servers`,
|
||||
);
|
||||
return [
|
||||
item.id,
|
||||
response.ok ? (await response.json()).items || [] : [],
|
||||
@@ -466,6 +769,9 @@ export function useDashboard() {
|
||||
}
|
||||
|
||||
onMounted(loadData);
|
||||
onBeforeUnmount(() => {
|
||||
document.body.style.overflow = previousBodyOverflow;
|
||||
});
|
||||
|
||||
return {
|
||||
scertLogo,
|
||||
@@ -473,6 +779,11 @@ export function useDashboard() {
|
||||
domains,
|
||||
servers,
|
||||
sshKeys,
|
||||
certificates,
|
||||
tasks,
|
||||
auditLogs,
|
||||
settings,
|
||||
settingsForm,
|
||||
domainServers,
|
||||
loading,
|
||||
saving,
|
||||
@@ -500,6 +811,19 @@ export function useDashboard() {
|
||||
sshKeyForm,
|
||||
sshKeyPlatform,
|
||||
sshKeyPassphraseVisible,
|
||||
sshKeyCommandUsername,
|
||||
sshKeyCommandHost,
|
||||
sshKeyFileName,
|
||||
sshKeyPath,
|
||||
sshKeyPublicPath,
|
||||
showSettings,
|
||||
settingsSaving,
|
||||
settingsError,
|
||||
showCertificateImport,
|
||||
importDomain,
|
||||
importSaving,
|
||||
importError,
|
||||
importResult,
|
||||
sshKeyCommands,
|
||||
sshPublicKeyCommands,
|
||||
defaultCertificatePath,
|
||||
@@ -517,6 +841,10 @@ export function useDashboard() {
|
||||
copySSHKeyCommand,
|
||||
saveSSHKey,
|
||||
deleteSSHKey,
|
||||
openCertificateImport,
|
||||
closeCertificateImport,
|
||||
selectCertificateImportFile,
|
||||
importCertificate,
|
||||
saveServer,
|
||||
deleteServer,
|
||||
saveDomain,
|
||||
|
||||
@@ -7,6 +7,11 @@ const {
|
||||
domains,
|
||||
servers,
|
||||
sshKeys,
|
||||
certificates,
|
||||
tasks,
|
||||
auditLogs,
|
||||
settings,
|
||||
settingsForm,
|
||||
domainServers,
|
||||
loading,
|
||||
saving,
|
||||
@@ -34,6 +39,14 @@ const {
|
||||
sshKeyForm,
|
||||
sshKeyPlatform,
|
||||
sshKeyPassphraseVisible,
|
||||
sshKeyCommandUsername,
|
||||
sshKeyCommandHost,
|
||||
sshKeyFileName,
|
||||
sshKeyPath,
|
||||
sshKeyPublicPath,
|
||||
showSettings,
|
||||
settingsSaving,
|
||||
settingsError,
|
||||
sshKeyCommands,
|
||||
sshPublicKeyCommands,
|
||||
defaultCertificatePath,
|
||||
@@ -56,6 +69,13 @@ const {
|
||||
saveDomain,
|
||||
deleteDomain,
|
||||
loadData,
|
||||
openSettings,
|
||||
closeSettings,
|
||||
saveSettings,
|
||||
issueDomain,
|
||||
validateDomain,
|
||||
deployDomain,
|
||||
runRenewalNow,
|
||||
displayLabel,
|
||||
formatDate,
|
||||
daysRemaining,
|
||||
@@ -74,6 +94,12 @@ const {
|
||||
<button class="secondary-button" type="button" @click="loadData">
|
||||
刷新状态
|
||||
</button>
|
||||
<button class="secondary-button" type="button" @click="runRenewalNow">
|
||||
立即检查续期
|
||||
</button>
|
||||
<button class="secondary-button" type="button" @click="openSettings">
|
||||
系统设置
|
||||
</button>
|
||||
<button
|
||||
class="secondary-button"
|
||||
type="button"
|
||||
@@ -102,8 +128,8 @@ const {
|
||||
}}</span>
|
||||
<h2>让证书续期和部署变得可追踪</h2>
|
||||
<p>
|
||||
统一管理单域名、泛域名和 SAN 证书,后续将接入 lego、DNS
|
||||
验证与远程部署流程。
|
||||
统一管理单域名、泛域名和 SAN 证书,当前已接入 lego、DNS
|
||||
验证、自动续期、远程部署与部署后校验流程。
|
||||
</p>
|
||||
</div>
|
||||
<img class="hero-mark" :src="scertLogo" alt="Scert 标志" />
|
||||
@@ -136,6 +162,59 @@ const {
|
||||
</article>
|
||||
</section>
|
||||
|
||||
<section class="panel operations-panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
<p class="eyebrow">运行概览</p>
|
||||
<h2>最近活动</h2>
|
||||
</div>
|
||||
<span class="muted">最近 20 条记录</span>
|
||||
</div>
|
||||
<div class="operation-columns">
|
||||
<div>
|
||||
<h3>证书状态</h3>
|
||||
<div v-if="certificates.length === 0" class="empty-state compact-empty">暂无证书记录</div>
|
||||
<div v-else class="record-list">
|
||||
<article v-for="item in certificates" :key="item.domain.id" class="record-row">
|
||||
<div>
|
||||
<strong>{{ item.domain.name }}</strong>
|
||||
<span v-if="item.certificate" class="muted">到期:{{ formatDate(item.certificate.saved.not_after) }}</span>
|
||||
<span v-else class="muted">{{ item.certificate_error || "读取失败" }}</span>
|
||||
</div>
|
||||
<span v-if="item.certificate" class="tag success">已保存</span>
|
||||
<span v-else class="tag warning">未保存</span>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h3>任务记录</h3>
|
||||
<div v-if="tasks.length === 0" class="empty-state compact-empty">暂无任务记录</div>
|
||||
<div v-else class="record-list">
|
||||
<article v-for="item in tasks" :key="item.id" class="record-row">
|
||||
<div>
|
||||
<strong>{{ item.task_type }}</strong>
|
||||
<span class="muted">{{ item.message || "无附加信息" }}</span>
|
||||
</div>
|
||||
<span class="tag" :class="statusClass(item.status)">{{ item.status }}</span>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h3>审计日志</h3>
|
||||
<div v-if="auditLogs.length === 0" class="empty-state compact-empty">暂无审计日志</div>
|
||||
<div v-else class="record-list">
|
||||
<article v-for="item in auditLogs" :key="item.id" class="record-row">
|
||||
<div>
|
||||
<strong>{{ item.action }}</strong>
|
||||
<span class="muted">{{ item.message || item.resource_type }}</span>
|
||||
</div>
|
||||
<span class="tag" :class="item.status === 'success' ? 'success' : 'danger'">{{ item.status }}</span>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="panel">
|
||||
<div class="panel-heading">
|
||||
<div>
|
||||
@@ -186,6 +265,18 @@ const {
|
||||
><span>{{ formatDate(item.expires_at) }}</span>
|
||||
</div>
|
||||
<div class="row-actions">
|
||||
<button class="text-button" type="button" @click="issueDomain(item)">
|
||||
申请证书
|
||||
</button>
|
||||
<button class="text-button" type="button" @click="validateDomain(item)">
|
||||
校验证书
|
||||
</button>
|
||||
<button class="text-button" type="button" @click="deployDomain(item)">
|
||||
部署证书
|
||||
</button>
|
||||
<button class="text-button" type="button" @click="openCertificateImport(item)">
|
||||
导入证书
|
||||
</button>
|
||||
<button class="text-button" type="button" @click="openEdit(item)">
|
||||
编辑</button
|
||||
><button
|
||||
@@ -288,7 +379,121 @@ const {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div v-if="showForm" class="modal-backdrop" @click.self="closeForm">
|
||||
<div v-if="showSettings" class="modal-backdrop" @click.self="closeSettings">
|
||||
<section class="modal-card settings-modal" role="dialog" aria-modal="true" aria-label="系统设置">
|
||||
<div class="modal-heading">
|
||||
<div>
|
||||
<p class="eyebrow">系统配置</p>
|
||||
<h2>系统设置</h2>
|
||||
</div>
|
||||
<button class="close-button" type="button" aria-label="关闭" @click="closeSettings">×</button>
|
||||
</div>
|
||||
<form @submit.prevent="saveSettings">
|
||||
<h3>服务监听</h3>
|
||||
<div class="form-grid">
|
||||
<label class="field"><span>监听地址</span><input v-model="settingsForm.server.host" required /></label>
|
||||
<label class="field"><span>服务端口</span><input v-model.number="settingsForm.server.port" type="number" min="1" max="65535" required /></label>
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<label class="field"><span>HTTPS 模式</span><select v-model="settingsForm.server.https_mode"><option value="direct">直接终止 HTTPS</option><option value="proxy">反向代理 HTTPS</option></select></label>
|
||||
<label class="field"><span>证书存储路径</span><input v-model="settingsForm.paths.certificate" required /></label>
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<label class="field"><span>管理页面域名</span><input v-model="settingsForm.web.hostname" placeholder="例如 ssl.example.com" /></label>
|
||||
<label class="field"><span>管理页面公网 IP</span><input v-model="settingsForm.web.public_ip" placeholder="例如 203.0.113.10" /></label>
|
||||
</div>
|
||||
<h3>ACME 设置</h3>
|
||||
<div class="form-grid">
|
||||
<label class="field"><span>ACME 环境</span><select v-model="settingsForm.acme.environment"><option value="staging">测试环境</option><option value="production">生产环境</option></select></label>
|
||||
<label class="field"><span>自动续期阈值(天)</span><input v-model.number="settingsForm.acme.renewal_threshold_days" type="number" min="1" max="365" /></label>
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<label class="field"><span>DNS 传播等待(秒)</span><input v-model.number="settingsForm.acme.propagation_timeout_secs" type="number" min="1" /></label>
|
||||
<label class="field"><span>DNS 检测间隔(秒)</span><input v-model.number="settingsForm.acme.propagation_polling_interval_secs" type="number" min="1" /></label>
|
||||
</div>
|
||||
<h3>HTTP 通知</h3>
|
||||
<div class="form-grid">
|
||||
<label class="switch-field">
|
||||
<input v-model="settingsForm.notification.http_enabled" type="checkbox" />
|
||||
<span><strong>启用 HTTP 通知</strong><small>通过外部邮件或消息服务 API 发送通知</small></span>
|
||||
</label>
|
||||
<label class="field"><span>通知服务商</span><input v-model="settingsForm.notification.provider" placeholder="例如 temporary-mail" /></label>
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<label class="field"><span>通知接口地址</span><input v-model="settingsForm.notification.endpoint" placeholder="https://..." /></label>
|
||||
<label class="field"><span>发件人邮箱</span><input v-model="settingsForm.notification.sender_email" type="email" /></label>
|
||||
</div>
|
||||
<label class="field"><span>收件人</span><input :value="settingsForm.notification.recipients.join(', ')" @input="settingsForm.notification.recipients = $event.target.value.split(/[,,]/).map((item) => item.trim()).filter(Boolean)" placeholder="多个地址用逗号分隔" /></label>
|
||||
<h3>SMTP 通知</h3>
|
||||
<label class="switch-field">
|
||||
<input v-model="settingsForm.notification.smtp_enabled" type="checkbox" />
|
||||
<span><strong>启用 SMTP 通知</strong><small>使用外部 SMTP 服务发送证书任务通知,不会实现邮件服务器端</small></span>
|
||||
</label>
|
||||
<div class="form-grid">
|
||||
<label class="field"><span>SMTP 主机</span><input v-model="settingsForm.notification.smtp_host" placeholder="例如 smtp.example.com" /></label>
|
||||
<label class="field"><span>SMTP 端口</span><input v-model.number="settingsForm.notification.smtp_port" type="number" min="1" max="65535" /></label>
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<label class="field"><span>SMTP 用户名</span><input v-model="settingsForm.notification.smtp_username" autocomplete="username" /></label>
|
||||
<label class="field"><span>SMTP 密码</span><input v-model="settingsForm.notification.smtp_password" type="password" autocomplete="new-password" placeholder="留空表示不更新已保存密码" /></label>
|
||||
</div>
|
||||
<div class="form-grid">
|
||||
<label class="field"><span>连接模式</span><select v-model="settingsForm.notification.smtp_mode"><option value="plain">明文连接</option><option value="starttls">STARTTLS</option><option value="implicit_tls">隐式 TLS</option></select></label>
|
||||
<label class="switch-field">
|
||||
<input v-model="settingsForm.notification.smtp_allow_plaintext_auth" type="checkbox" />
|
||||
<span><strong>允许明文认证</strong><small>仅在明确确认 SMTP 网络受保护时开启</small></span>
|
||||
</label>
|
||||
</div>
|
||||
<p class="security-hint">
|
||||
{{ settingsForm.notification.smtp_credential_configured ? "SMTP 凭据已配置;密码不会回显。填写新密码后保存即可更新。" : "SMTP 凭据尚未配置;启用 SMTP 时请填写用户名和密码。" }}
|
||||
</p>
|
||||
<p v-if="settingsError" class="form-error">{{ settingsError }}</p>
|
||||
<div class="modal-actions">
|
||||
<button class="secondary-button" type="button" :disabled="settingsSaving" @click="closeSettings">取消</button>
|
||||
<button class="primary-button" type="submit" :disabled="settingsSaving">{{ settingsSaving ? "保存中……" : "保存设置" }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
|
||||
<div v-if="showCertificateImport" class="modal-backdrop" @click.self="closeCertificateImport">
|
||||
<section class="modal-card certificate-import-modal" role="dialog" aria-modal="true" aria-label="导入证书">
|
||||
<div class="modal-heading">
|
||||
<div>
|
||||
<p class="eyebrow">证书管理</p>
|
||||
<h2>导入证书</h2>
|
||||
<p class="muted">目标域名:{{ importDomain?.name }}</p>
|
||||
</div>
|
||||
<button class="close-button" type="button" aria-label="关闭" @click="closeCertificateImport">×</button>
|
||||
</div>
|
||||
<form @submit.prevent="importCertificate">
|
||||
<label class="field">
|
||||
<span>证书文件 <small>必选,支持 PEM / CRT</small></span>
|
||||
<input type="file" accept=".pem,.crt,.cer,.txt" required @change="selectCertificateImportFile('certificate', $event)" />
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>私钥文件 <small>必选,内容只上传到服务端并按安全流程处理</small></span>
|
||||
<input type="file" accept=".pem,.key,.txt" required @change="selectCertificateImportFile('private_key', $event)" />
|
||||
</label>
|
||||
<label class="field">
|
||||
<span>证书链文件 <small>可选,支持 PEM / CRT</small></span>
|
||||
<input type="file" accept=".pem,.crt,.cer,.txt" @change="selectCertificateImportFile('issuer_bundle', $event)" />
|
||||
</label>
|
||||
<p class="security-hint">单个文件不能超过 20 MB。导入成功后会自动刷新证书、任务和审计数据。</p>
|
||||
<p v-if="importError" class="form-error">{{ importError }}</p>
|
||||
<div v-if="importResult" class="import-result">
|
||||
<strong>证书导入完成</strong>
|
||||
<span v-if="importResult.deployment">部署结果已返回,请在任务记录中查看详情。</span>
|
||||
<span v-else>证书已保存,可以稍后执行部署。</span>
|
||||
</div>
|
||||
<div class="modal-actions">
|
||||
<button class="secondary-button" type="button" :disabled="importSaving" @click="closeCertificateImport">关闭</button>
|
||||
<button class="primary-button" type="submit" :disabled="importSaving">{{ importSaving ? "导入中……" : "导入证书" }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
</div> <div v-if="showForm" class="modal-backdrop" @click.self="closeForm">
|
||||
<section
|
||||
class="modal-card"
|
||||
role="dialog"
|
||||
@@ -591,7 +796,7 @@ const {
|
||||
@click.self="closeSSHKeyForm"
|
||||
>
|
||||
<section
|
||||
class="modal-card"
|
||||
class="modal-card ssh-key-modal"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="添加 SSH 私钥"
|
||||
@@ -664,6 +869,25 @@ const {
|
||||
Linux / macOS
|
||||
</button>
|
||||
</div>
|
||||
<div class="ssh-key-path-line">
|
||||
<span>本次密钥文件名</span>
|
||||
<code>{{ sshKeyFileName }}</code>
|
||||
<span class="guide-badge">每次随机生成</span>
|
||||
</div>
|
||||
<div class="ssh-key-path-summary">
|
||||
<div>
|
||||
<span>本地私钥位置</span>
|
||||
<code>{{ sshKeyPath }}</code>
|
||||
</div>
|
||||
<div>
|
||||
<span>本地公钥位置</span>
|
||||
<code>{{ sshKeyPublicPath }}</code>
|
||||
</div>
|
||||
<div>
|
||||
<span>远程登录目标</span>
|
||||
<code>{{ sshKeyCommandUsername }}@{{ sshKeyCommandHost }}</code>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ssh-command-card">
|
||||
<div class="ssh-command-heading">
|
||||
<span>生成命令</span>
|
||||
@@ -700,8 +924,8 @@ const {
|
||||
</div>
|
||||
<code>{{ sshPublicKeyCommands[sshKeyPlatform] }}</code>
|
||||
<small>
|
||||
Linux 服务器默认位置:<code>~/.ssh/authorized_keys</code>;Windows
|
||||
OpenSSH 服务器请按照系统说明配置授权文件。
|
||||
本地公钥文件是上面显示的随机路径;安装后会追加到远程用户的
|
||||
<code>~/.ssh/authorized_keys</code>。每台主机、每次新建配置都会生成新的文件名。
|
||||
</small>
|
||||
</div>
|
||||
<p class="ssh-key-guide-note">
|
||||
@@ -709,67 +933,69 @@ const {
|
||||
<code>.pub</code> 公钥内容追加到授权文件,最后在下方选择私钥文件即可。
|
||||
</p>
|
||||
</section>
|
||||
<label class="field"
|
||||
><span>私钥名称</span
|
||||
><input
|
||||
v-model="sshKeyForm.name"
|
||||
required
|
||||
type="text"
|
||||
maxlength="128"
|
||||
placeholder="例如生产环境部署私钥"
|
||||
autocomplete="off"
|
||||
/></label>
|
||||
<label class="field"
|
||||
><span>读取本机私钥文件 <small>可选,读取后仍需点击加密保存</small></span
|
||||
><input type="file" @change="importSSHKeyFile" /></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 class="field-label-row"
|
||||
><span>私钥口令 <small>未加密私钥请留空</small></span
|
||||
><button
|
||||
class="inline-button"
|
||||
<div class="ssh-key-form-fields">
|
||||
<label class="field"
|
||||
><span>私钥名称</span
|
||||
><input
|
||||
v-model="sshKeyForm.name"
|
||||
required
|
||||
type="text"
|
||||
maxlength="128"
|
||||
placeholder="例如生产环境部署私钥"
|
||||
autocomplete="off"
|
||||
/></label>
|
||||
<label class="field"
|
||||
><span>读取本机私钥文件 <small>可选,读取后仍需点击加密保存</small></span
|
||||
><input type="file" @change="importSSHKeyFile" /></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 class="field-label-row"
|
||||
><span>私钥口令 <small>未加密私钥请留空</small></span
|
||||
><button
|
||||
class="inline-button"
|
||||
type="button"
|
||||
@click="sshKeyPassphraseVisible = !sshKeyPassphraseVisible"
|
||||
>
|
||||
{{ sshKeyPassphraseVisible ? "隐藏口令" : "显示口令" }}
|
||||
</button></span
|
||||
><input
|
||||
v-model="sshKeyForm.passphrase"
|
||||
:type="sshKeyPassphraseVisible ? 'text' : '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"
|
||||
@click="sshKeyPassphraseVisible = !sshKeyPassphraseVisible"
|
||||
:disabled="sshKeySaving"
|
||||
@click="closeSSHKeyForm"
|
||||
>
|
||||
{{ sshKeyPassphraseVisible ? "隐藏口令" : "显示口令" }}
|
||||
</button></span
|
||||
><input
|
||||
v-model="sshKeyForm.passphrase"
|
||||
:type="sshKeyPassphraseVisible ? 'text' : '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>
|
||||
取消</button
|
||||
><button
|
||||
class="primary-button"
|
||||
type="submit"
|
||||
:disabled="sshKeySaving"
|
||||
>
|
||||
{{ sshKeySaving ? "加密保存中……" : "加密保存" }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
@@ -24,7 +24,7 @@ export function useLogin() {
|
||||
if (stage.value === "complete") {
|
||||
return `${roleLabels[accountRole.value] || "用户"}登录成功`;
|
||||
}
|
||||
return "管理员登录";
|
||||
return "用户登录";
|
||||
});
|
||||
const stageMessage = computed(() => {
|
||||
if (stage.value === "totp") return "该账户还需完成两步验证。";
|
||||
|
||||
@@ -20,7 +20,7 @@ const {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AccessShell variant="compact" aria-label="Scert 管理员登录">
|
||||
<AccessShell variant="compact" aria-label="Scert 用户登录">
|
||||
<template #brand>
|
||||
<img class="access-logo" src="/Scert.png" alt="Scert 标志" />
|
||||
<p class="access-eyebrow">SCERT 管理后台</p>
|
||||
@@ -33,8 +33,8 @@ const {
|
||||
<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>
|
||||
<h2 class="access-card-title">用户登录</h2>
|
||||
<p class="access-card-description">请输入用户账号,进入 Scert 管理后台。</p>
|
||||
</header>
|
||||
|
||||
<section v-if="stage === 'credentials'">
|
||||
@@ -60,7 +60,7 @@ const {
|
||||
v-model="password"
|
||||
type="password"
|
||||
autocomplete="current-password"
|
||||
placeholder="请输入管理员密码"
|
||||
placeholder="请输入用户密码"
|
||||
required
|
||||
/>
|
||||
</label>
|
||||
|
||||
@@ -1,3 +1,56 @@
|
||||
.password-reset-card {
|
||||
max-width: 470px;
|
||||
}
|
||||
|
||||
.reset-resolution {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
margin: 4px 0 16px;
|
||||
padding: 16px;
|
||||
border: 1px solid #cfe0f4;
|
||||
border-radius: 14px;
|
||||
background: #f4f8fd;
|
||||
color: #31455f;
|
||||
}
|
||||
|
||||
.reset-resolution-label {
|
||||
color: #54708e;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.08em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.reset-resolution strong {
|
||||
color: #172b4d;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.reset-resolution p {
|
||||
margin: 0;
|
||||
line-height: 1.65;
|
||||
}
|
||||
|
||||
.reset-entry-link {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.access-secondary {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid #c3d3e5;
|
||||
border-radius: 10px;
|
||||
background: #ffffff;
|
||||
color: #2e5d91;
|
||||
font: inherit;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.access-submit:disabled {
|
||||
cursor: wait;
|
||||
opacity: 0.65;
|
||||
}
|
||||
@@ -1,32 +1,61 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
export function usePasswordReset() {
|
||||
const username = ref("");
|
||||
const password = ref("");
|
||||
const confirmPassword = ref("");
|
||||
const identifier = ref("");
|
||||
const resolution = ref(null);
|
||||
const message = ref("");
|
||||
const error = ref("");
|
||||
const submitting = ref(false);
|
||||
|
||||
function submit() {
|
||||
async function submit() {
|
||||
if (submitting.value) {
|
||||
return;
|
||||
}
|
||||
message.value = "";
|
||||
error.value = "";
|
||||
if (password.value.length < 8) {
|
||||
error.value = "新密码至少需要 8 个字符。";
|
||||
resolution.value = null;
|
||||
if (!identifier.value.trim()) {
|
||||
error.value = "请输入用户名或绑定邮箱。";
|
||||
return;
|
||||
}
|
||||
if (password.value !== confirmPassword.value) {
|
||||
error.value = "两次输入的新密码不一致。";
|
||||
return;
|
||||
|
||||
submitting.value = true;
|
||||
try {
|
||||
const response = await fetch("/api/v1/password-reset/resolve", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
},
|
||||
credentials: "same-origin",
|
||||
body: JSON.stringify({ identifier: identifier.value.trim() }),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (!response.ok) {
|
||||
throw new Error(result.error || "暂时无法处理密码重置请求,请稍后重试。");
|
||||
}
|
||||
resolution.value = result;
|
||||
message.value = result.description || "已返回密码处理方式。";
|
||||
} catch (submitError) {
|
||||
error.value = submitError.message || "查询密码重置方式失败,请稍后重试。";
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
error.value = "普通管理员密码重置接口尚未接入,请联系超级管理员处理。";
|
||||
}
|
||||
|
||||
function reset() {
|
||||
resolution.value = null;
|
||||
message.value = "";
|
||||
error.value = "";
|
||||
}
|
||||
|
||||
return {
|
||||
username,
|
||||
password,
|
||||
confirmPassword,
|
||||
identifier,
|
||||
resolution,
|
||||
message,
|
||||
error,
|
||||
submitting,
|
||||
submit,
|
||||
reset,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,13 @@ import AccessShell from "../components/AccessShell/AccessShell.vue";
|
||||
import { usePasswordReset } from "./PasswordReset.js";
|
||||
|
||||
const {
|
||||
username,
|
||||
password,
|
||||
confirmPassword,
|
||||
identifier,
|
||||
resolution,
|
||||
message,
|
||||
error,
|
||||
submitting,
|
||||
submit,
|
||||
reset,
|
||||
} = usePasswordReset();
|
||||
</script>
|
||||
|
||||
@@ -19,7 +20,7 @@ const {
|
||||
<p class="access-eyebrow">SCERT 安全中心</p>
|
||||
<h1 class="access-brand-title">保护管理后台安全</h1>
|
||||
<p class="access-brand-description">
|
||||
密码重置入口仅用于已接入认证流程的管理员账号。
|
||||
Scert 会根据账户标识返回安全的密码处理方式,不会在此页面直接接收新密码。
|
||||
</p>
|
||||
</template>
|
||||
|
||||
@@ -27,54 +28,52 @@ const {
|
||||
<header class="access-card-header">
|
||||
<p class="access-eyebrow">账户安全</p>
|
||||
<h2 class="access-card-title">密码重置</h2>
|
||||
<p class="access-card-description">填写账号和新密码,提交密码重置申请。</p>
|
||||
<p class="access-card-description">
|
||||
输入用户名或绑定邮箱,查询该账户可用的重置入口。
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<form class="access-form" @submit.prevent="submit">
|
||||
<label class="access-field">
|
||||
<span>管理员账号</span>
|
||||
<span>管理员账号或邮箱</span>
|
||||
<input
|
||||
id="reset-username"
|
||||
name="username"
|
||||
v-model.trim="username"
|
||||
id="reset-identifier"
|
||||
name="identifier"
|
||||
v-model.trim="identifier"
|
||||
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"
|
||||
placeholder="请输入用户名或绑定邮箱"
|
||||
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>
|
||||
|
||||
<div v-if="resolution" class="reset-resolution" aria-live="polite">
|
||||
<span class="reset-resolution-label">处理方式</span>
|
||||
<strong>{{ resolution.title }}</strong>
|
||||
<p>{{ resolution.description }}</p>
|
||||
<a
|
||||
v-if="resolution.reset_path"
|
||||
class="access-submit reset-entry-link"
|
||||
:href="resolution.reset_path"
|
||||
>
|
||||
前往超级管理员重置入口
|
||||
</a>
|
||||
<button
|
||||
v-else
|
||||
class="access-secondary"
|
||||
type="button"
|
||||
@click="reset"
|
||||
>
|
||||
重新输入账户
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button class="access-submit" type="submit" :disabled="submitting">
|
||||
{{ submitting ? "正在查询…" : "查询重置方式" }}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<a class="access-return" href="/login">返回登录</a>
|
||||
@@ -82,4 +81,4 @@ const {
|
||||
</AccessShell>
|
||||
</template>
|
||||
|
||||
<style src="./PasswordReset.css"></style>
|
||||
<style src="./PasswordReset.css"></style>
|
||||
@@ -124,25 +124,31 @@
|
||||
background: #d5deeb;
|
||||
}
|
||||
|
||||
/* 中间步骤内容独立滚动,避免高级配置展开后被外层卡片裁切。 */
|
||||
.setup-form {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-rows: minmax(0, 1fr) auto;
|
||||
gap: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.setup-step-grid {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: block;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
scrollbar-gutter: stable;
|
||||
}
|
||||
|
||||
.setup-step-card {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
height: auto;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
min-height: 100%;
|
||||
box-sizing: border-box;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
@@ -264,6 +270,20 @@ label > small {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) minmax(88px, 112px);
|
||||
gap: 6px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.email-autofill-probe {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: -1;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.email-input-group input,
|
||||
@@ -275,6 +295,11 @@ label > small {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.email-input-group input.email-autofill-probe {
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
.email-primary-grid,
|
||||
.email-delivery-grid {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
@@ -341,6 +366,12 @@ label > small {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.compact-row > span {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.compact-row strong,
|
||||
.compact-row small,
|
||||
.confirm-row strong,
|
||||
@@ -379,8 +410,28 @@ label > small {
|
||||
background: #f6f8fc;
|
||||
}
|
||||
|
||||
.setup-section-heading {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
margin: 12px 0 2px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
|
||||
.setup-section-heading strong {
|
||||
color: #263c63;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.setup-section-heading span {
|
||||
color: #53647b;
|
||||
font-size: 9px;
|
||||
font-weight: 500;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.provider-description,
|
||||
.dns-verification-success {
|
||||
.dns-verification-success,
|
||||
.dns-verification-report {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
@@ -536,11 +587,92 @@ label > small {
|
||||
background: #effbf4;
|
||||
}
|
||||
|
||||
.dns-verification-report {
|
||||
display: grid;
|
||||
gap: 7px;
|
||||
margin-top: 9px;
|
||||
padding: 9px 11px;
|
||||
border: 1px solid #d7e2f0;
|
||||
border-radius: 10px;
|
||||
color: #435571;
|
||||
background: #f7faff;
|
||||
}
|
||||
|
||||
.dns-report-heading {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.dns-report-heading strong {
|
||||
color: #2d4775;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.dns-report-heading span {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: #53647b;
|
||||
font-size: 9px;
|
||||
font-weight: 500;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.dns-verification-stage {
|
||||
display: grid;
|
||||
grid-template-columns: 72px auto minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
padding: 6px 7px;
|
||||
border-radius: 7px;
|
||||
background: #eef4fb;
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.dns-verification-stage .dns-stage-name {
|
||||
color: #34445f;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.dns-verification-stage strong {
|
||||
color: #28734c;
|
||||
font-size: 9px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.dns-verification-stage small {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
color: #53647b;
|
||||
font-size: 9px;
|
||||
font-weight: 500;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.dns-verification-stage.is-warning {
|
||||
background: #fff8e8;
|
||||
}
|
||||
|
||||
.dns-verification-stage.is-warning strong {
|
||||
color: #996d16;
|
||||
}
|
||||
|
||||
.dns-verification-stage.is-failed {
|
||||
background: #fff1f1;
|
||||
}
|
||||
|
||||
.dns-verification-stage.is-failed strong {
|
||||
color: #a33d3d;
|
||||
}
|
||||
|
||||
.target-switch {
|
||||
width: fit-content;
|
||||
display: inline-flex;
|
||||
gap: 4px;
|
||||
margin-top: 8px;
|
||||
margin-top: 0;
|
||||
padding: 4px;
|
||||
border: 1px solid #e1e8f3;
|
||||
border-radius: 11px;
|
||||
@@ -564,6 +696,18 @@ label > small {
|
||||
box-shadow: 0 3px 10px rgba(36, 64, 107, 0.1);
|
||||
}
|
||||
|
||||
.access-target-field {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
align-content: start;
|
||||
margin-top: 8px;
|
||||
color: #34445f;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
line-height: 1.25;
|
||||
}
|
||||
|
||||
footer {
|
||||
min-width: 0;
|
||||
display: grid;
|
||||
@@ -851,6 +995,14 @@ button:disabled {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.dns-verification-stage {
|
||||
grid-template-columns: 64px auto;
|
||||
}
|
||||
|
||||
.dns-verification-stage small {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.dns-test-actions {
|
||||
margin-top: 5px;
|
||||
}
|
||||
@@ -991,7 +1143,8 @@ button:disabled {
|
||||
.notification-bottom-row .compact-row {
|
||||
min-height: 34px;
|
||||
margin-top: 0;
|
||||
padding: 6px 8px;
|
||||
padding: 6px 5px;
|
||||
column-gap: 3px;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) and (min-width: 641px) {
|
||||
@@ -1024,4 +1177,231 @@ button:disabled {
|
||||
.notification-bottom-row .email-option-grid {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 第二步默认只展示基础配置,高级参数按需展开。 */
|
||||
.notification-guide {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px 12px;
|
||||
min-width: 0;
|
||||
padding: 9px 11px;
|
||||
border: 1px solid #dce8f8;
|
||||
border-radius: 10px;
|
||||
color: #526783;
|
||||
background: linear-gradient(135deg, #f7faff, #f2f7ff);
|
||||
font-size: 10px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.notification-guide strong {
|
||||
flex: 0 0 auto;
|
||||
color: #285398;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.notification-guide span {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.notification-service-row {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.smtp-basic-panel {
|
||||
background: linear-gradient(135deg, #fbfdff, #f6faff);
|
||||
}
|
||||
|
||||
.smtp-config-row {
|
||||
grid-template-columns: minmax(180px, 1.35fr) minmax(100px, 0.55fr) minmax(160px, 1fr) minmax(180px, 1.2fr);
|
||||
}
|
||||
|
||||
.smtp-options-row {
|
||||
grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1.3fr);
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.smtp-plaintext-row {
|
||||
min-height: 34px;
|
||||
margin-top: 7px !important;
|
||||
padding: 7px 9px;
|
||||
border: 1px dashed #e2c98b;
|
||||
border-radius: 9px;
|
||||
background: #fffaf0;
|
||||
}
|
||||
|
||||
.notification-smtp-tip {
|
||||
margin-top: 8px;
|
||||
padding: 7px 9px;
|
||||
border-radius: 8px;
|
||||
color: #6b7180;
|
||||
background: #f5f7fa;
|
||||
font-size: 9px;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
.notification-basic-panel {
|
||||
min-width: 0;
|
||||
padding: 12px;
|
||||
border: 1px solid #e0e8f3;
|
||||
border-radius: 12px;
|
||||
background: #fcfdff;
|
||||
}
|
||||
|
||||
.notification-section-heading {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
min-width: 0;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.notification-section-heading > div {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.notification-section-heading strong {
|
||||
color: #243653;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.notification-section-heading span {
|
||||
color: #687891;
|
||||
font-size: 9px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.notification-recommended-badge {
|
||||
flex: 0 0 auto;
|
||||
padding: 4px 7px;
|
||||
border-radius: 999px;
|
||||
color: #2e6a50;
|
||||
background: #e8f6ed;
|
||||
font-size: 9px;
|
||||
font-weight: 800;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.notification-basic-row {
|
||||
grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.65fr);
|
||||
}
|
||||
|
||||
.notification-basic-panel .notification-sender-row {
|
||||
grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.35fr);
|
||||
}
|
||||
|
||||
.notification-basic-panel label {
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
.notification-advanced-panel {
|
||||
min-width: 0;
|
||||
border: 1px solid #e2e8f2;
|
||||
border-radius: 12px;
|
||||
background: #f9fbfe;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.notification-advanced-toggle {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border: 0;
|
||||
border-radius: 0;
|
||||
color: #34445f;
|
||||
background: transparent;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.notification-advanced-toggle:hover {
|
||||
background: #f1f6fd;
|
||||
}
|
||||
|
||||
.notification-advanced-toggle > span:first-child {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.notification-advanced-toggle strong {
|
||||
color: #34445f;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.notification-advanced-toggle small {
|
||||
color: #718198;
|
||||
font-size: 9px;
|
||||
font-weight: 500;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
.notification-advanced-action {
|
||||
flex: 0 0 auto;
|
||||
color: #3565ae;
|
||||
font-size: 10px;
|
||||
font-weight: 800;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.notification-advanced-content {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
padding: 0 12px 12px;
|
||||
border-top: 1px solid #e7edf5;
|
||||
}
|
||||
|
||||
.notification-advanced-tip {
|
||||
padding: 7px 9px;
|
||||
border-radius: 8px;
|
||||
color: #687891;
|
||||
background: #f1f5fa;
|
||||
font-size: 9px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.notification-advanced-content .notification-row label {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 900px) and (min-width: 641px) {
|
||||
.notification-service-row,
|
||||
.notification-basic-row,
|
||||
.notification-basic-panel .notification-sender-row {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.notification-basic-panel .notification-sender-row label:last-child {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.notification-guide {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.notification-service-row,
|
||||
.notification-basic-row,
|
||||
.notification-basic-panel .notification-sender-row {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.notification-basic-panel .notification-sender-row label:last-child {
|
||||
grid-column: auto;
|
||||
}
|
||||
|
||||
.notification-section-heading {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
}
|
||||
@@ -34,9 +34,14 @@ export function useSetupWizard(props, emit) {
|
||||
const dnsVerification = ref(null);
|
||||
const verificationClock = ref(Date.now());
|
||||
const currentStep = ref(1);
|
||||
const notificationAdvancedVisible = ref(false);
|
||||
const selectedEmailDomain = ref("");
|
||||
const emailLocalPart = ref("");
|
||||
const emailInputElement = ref(null);
|
||||
const emailAutofillElement = ref(null);
|
||||
let emailVisibleEdited = false;
|
||||
let verificationTimer;
|
||||
let emailAutofillTimer;
|
||||
const targetType = ref(props.status.web_public_ip ? "ip" : "hostname");
|
||||
const form = ref({
|
||||
admin_username: "",
|
||||
@@ -45,6 +50,13 @@ export function useSetupWizard(props, emit) {
|
||||
confirm_password: "",
|
||||
server_port: props.status.server_port || 8080,
|
||||
email_http_enabled: false,
|
||||
email_smtp_enabled: false,
|
||||
email_smtp_host: "",
|
||||
email_smtp_port: 587,
|
||||
email_smtp_username: "",
|
||||
email_smtp_password: "",
|
||||
email_smtp_mode: "starttls",
|
||||
email_smtp_allow_plaintext_auth: false,
|
||||
email_provider: "",
|
||||
email_endpoint: "",
|
||||
email_http_path: "/api/email/send",
|
||||
@@ -142,7 +154,47 @@ export function useSetupWizard(props, emit) {
|
||||
}).format(new Date(value));
|
||||
}
|
||||
|
||||
function formatVerificationStageStatus(status) {
|
||||
switch (status) {
|
||||
case "completed":
|
||||
return "已完成";
|
||||
case "warning":
|
||||
return "警告";
|
||||
case "failed":
|
||||
return "失败";
|
||||
default:
|
||||
return "处理中";
|
||||
}
|
||||
}
|
||||
|
||||
function findCommonEmailDomain(domain) {
|
||||
const normalizedDomain = String(domain || "").trim().toLowerCase();
|
||||
return commonEmailDomains.find(
|
||||
(option) =>
|
||||
option.value &&
|
||||
option.value !== "custom" &&
|
||||
option.value === normalizedDomain,
|
||||
);
|
||||
}
|
||||
|
||||
function getEmailLocalPart(value) {
|
||||
const text = String(value || "").trim();
|
||||
const atIndex = text.indexOf("@");
|
||||
return (atIndex >= 0 ? text.slice(0, atIndex) : text).trim();
|
||||
}
|
||||
|
||||
function isCompleteEmail(localPart, domain) {
|
||||
return /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(
|
||||
`${localPart}@${domain}`,
|
||||
);
|
||||
}
|
||||
function updateEmailAutofillValue(value) {
|
||||
if (!emailAutofillElement.value) return;
|
||||
emailAutofillElement.value.value = String(value || "");
|
||||
}
|
||||
|
||||
function handleEmailInput(value) {
|
||||
emailVisibleEdited = true;
|
||||
error.value = "";
|
||||
const rawValue = String(value || "").trim();
|
||||
|
||||
@@ -150,6 +202,7 @@ export function useSetupWizard(props, emit) {
|
||||
emailLocalPart.value = "";
|
||||
selectedEmailDomain.value = "";
|
||||
form.value.admin_email = "";
|
||||
updateEmailAutofillValue("");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -159,6 +212,7 @@ export function useSetupWizard(props, emit) {
|
||||
form.value.admin_email = selectedEmailDomain.value && selectedEmailDomain.value !== "custom"
|
||||
? `${rawValue}@${selectedEmailDomain.value}`
|
||||
: rawValue;
|
||||
updateEmailAutofillValue(form.value.admin_email);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -167,16 +221,87 @@ export function useSetupWizard(props, emit) {
|
||||
|
||||
if (!localPart || !domain) {
|
||||
emailLocalPart.value = rawValue;
|
||||
selectedEmailDomain.value = "";
|
||||
selectedEmailDomain.value = domain ? "custom" : "";
|
||||
form.value.admin_email = rawValue;
|
||||
updateEmailAutofillValue(form.value.admin_email);
|
||||
return;
|
||||
}
|
||||
|
||||
emailLocalPart.value = localPart;
|
||||
selectedEmailDomain.value = commonEmailDomains.some(
|
||||
(option) => option.value === domain && option.value !== "custom",
|
||||
) ? domain : "custom";
|
||||
form.value.admin_email = `${localPart}@${domain}`;
|
||||
const commonDomain = findCommonEmailDomain(domain);
|
||||
if (commonDomain) {
|
||||
emailLocalPart.value = localPart;
|
||||
selectedEmailDomain.value = commonDomain.value;
|
||||
form.value.admin_email = `${localPart}@${commonDomain.value}`;
|
||||
updateEmailAutofillValue(form.value.admin_email);
|
||||
return;
|
||||
}
|
||||
|
||||
emailLocalPart.value = rawValue;
|
||||
selectedEmailDomain.value = "";
|
||||
form.value.admin_email = rawValue;
|
||||
updateEmailAutofillValue(form.value.admin_email);
|
||||
}
|
||||
|
||||
function synchronizeEmailField(value) {
|
||||
const visibleValue = emailInputElement.value?.value?.trim() || "";
|
||||
const autofillValue = emailAutofillElement.value?.value?.trim() || "";
|
||||
const inputValue =
|
||||
value !== undefined
|
||||
? value
|
||||
: visibleValue.includes("@")
|
||||
? visibleValue
|
||||
: emailVisibleEdited
|
||||
? visibleValue
|
||||
: autofillValue.includes("@")
|
||||
? autofillValue
|
||||
: visibleValue;
|
||||
const rawValue = String(inputValue || "").trim();
|
||||
|
||||
if (!rawValue) return;
|
||||
|
||||
if (rawValue.includes("@") || rawValue !== emailLocalPart.value) {
|
||||
handleEmailInput(rawValue);
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
selectedEmailDomain.value &&
|
||||
selectedEmailDomain.value !== "custom"
|
||||
) {
|
||||
form.value.admin_email = `${rawValue}@${selectedEmailDomain.value}`;
|
||||
updateEmailAutofillValue(form.value.admin_email);
|
||||
}
|
||||
}
|
||||
function handleEmailAutofill() {
|
||||
synchronizeEmailField();
|
||||
}
|
||||
|
||||
function handleEmailPaste(event) {
|
||||
const pastedValue = event.clipboardData?.getData("text") || "";
|
||||
if (!pastedValue.includes("@")) return;
|
||||
|
||||
event.preventDefault();
|
||||
handleEmailInput(pastedValue);
|
||||
handleEmailBlur();
|
||||
}
|
||||
|
||||
function handleEmailBlur(value) {
|
||||
synchronizeEmailField(value);
|
||||
const rawValue = String(emailLocalPart.value || "").trim();
|
||||
const atIndex = rawValue.indexOf("@");
|
||||
if (atIndex < 0) {
|
||||
handleEmailInput(rawValue);
|
||||
return;
|
||||
}
|
||||
|
||||
const localPart = rawValue.slice(0, atIndex).trim();
|
||||
const domain = rawValue.slice(atIndex + 1).trim().toLowerCase();
|
||||
if (localPart && isCompleteEmail(localPart, domain)) {
|
||||
emailLocalPart.value = localPart;
|
||||
selectedEmailDomain.value = findCommonEmailDomain(domain)?.value || "custom";
|
||||
form.value.admin_email = `${localPart}@${domain}`;
|
||||
updateEmailAutofillValue(form.value.admin_email);
|
||||
}
|
||||
}
|
||||
|
||||
function applyEmailDomain(domain) {
|
||||
@@ -184,7 +309,8 @@ export function useSetupWizard(props, emit) {
|
||||
if (!domain || domain === "custom") return;
|
||||
|
||||
const currentEmail = form.value.admin_email.trim();
|
||||
const localPart = emailLocalPart.value.trim() || currentEmail.split("@")[0].trim();
|
||||
const localPart =
|
||||
getEmailLocalPart(emailLocalPart.value) || getEmailLocalPart(currentEmail);
|
||||
if (!localPart) {
|
||||
selectedEmailDomain.value = "";
|
||||
error.value = "请先输入邮箱名称,再选择常用邮箱。";
|
||||
@@ -193,7 +319,13 @@ export function useSetupWizard(props, emit) {
|
||||
|
||||
emailLocalPart.value = localPart;
|
||||
form.value.admin_email = `${localPart}@${domain}`;
|
||||
updateEmailAutofillValue(form.value.admin_email);
|
||||
}
|
||||
|
||||
function toggleNotificationAdvanced() {
|
||||
notificationAdvancedVisible.value = !notificationAdvancedVisible.value;
|
||||
}
|
||||
|
||||
async function loadDNSProviders() {
|
||||
dnsCatalogLoading.value = true;
|
||||
dnsCatalogError.value = "";
|
||||
@@ -294,6 +426,9 @@ export function useSetupWizard(props, emit) {
|
||||
}),
|
||||
});
|
||||
const result = await response.json().catch(() => ({}));
|
||||
if (result.test_report) {
|
||||
dnsVerification.value = { test_report: result.test_report };
|
||||
}
|
||||
if (!response.ok) throw new Error(result.error || "DNS API 在线验证失败");
|
||||
dnsVerification.value = result;
|
||||
} catch (err) {
|
||||
@@ -304,6 +439,7 @@ export function useSetupWizard(props, emit) {
|
||||
}
|
||||
|
||||
function validateCurrentStep() {
|
||||
if (currentStep.value === 1) synchronizeEmailField();
|
||||
error.value = "";
|
||||
resultMessage.value = "";
|
||||
|
||||
@@ -320,22 +456,60 @@ export function useSetupWizard(props, emit) {
|
||||
error.value = "请输入合法的超级管理员绑定邮箱。";
|
||||
return false;
|
||||
}
|
||||
if (form.value.admin_password.length < 8) {
|
||||
error.value = "超级管理员密码至少需要 8 个字符。";
|
||||
if (
|
||||
form.value.admin_password.length < 8 ||
|
||||
form.value.admin_password.length > 12
|
||||
) {
|
||||
error.value = "超级管理员密码长度必须为 8 至 12 个字符。";
|
||||
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;
|
||||
}
|
||||
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 (currentStep.value === 2) {
|
||||
if (form.value.email_smtp_enabled) {
|
||||
if (!form.value.email_smtp_host.trim()) {
|
||||
error.value = "启用 SMTP 通知后必须填写 SMTP 主机。";
|
||||
return false;
|
||||
}
|
||||
const smtpPort = Number(form.value.email_smtp_port);
|
||||
if (!Number.isInteger(smtpPort) || smtpPort < 1 || smtpPort > 65535) {
|
||||
error.value = "SMTP 端口必须在 1 至 65535 之间。";
|
||||
return false;
|
||||
}
|
||||
if (!form.value.email_smtp_username.trim()) {
|
||||
error.value = "启用 SMTP 通知后必须填写 SMTP 用户名。";
|
||||
return false;
|
||||
}
|
||||
if (!form.value.email_smtp_password) {
|
||||
error.value = "启用 SMTP 通知后必须填写 SMTP 密码。";
|
||||
return false;
|
||||
}
|
||||
if (!["plain", "starttls", "implicit_tls"].includes(form.value.email_smtp_mode)) {
|
||||
error.value = "SMTP 连接模式无效。";
|
||||
return false;
|
||||
}
|
||||
if (form.value.email_smtp_mode === "plain" && !form.value.email_smtp_allow_plaintext_auth) {
|
||||
error.value = "SMTP 明文模式必须明确允许明文认证,建议改用 STARTTLS 或隐式 TLS。";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (form.value.email_http_enabled && !form.value.email_endpoint.trim()) {
|
||||
error.value = "启用 HTTP 邮件通知后必须填写 API 地址。";
|
||||
return false;
|
||||
@@ -424,14 +598,6 @@ export function useSetupWizard(props, emit) {
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -482,8 +648,11 @@ export function useSetupWizard(props, emit) {
|
||||
async function submit() {
|
||||
error.value = "";
|
||||
resultMessage.value = "";
|
||||
if (form.value.admin_password.length < 8) {
|
||||
error.value = "超级管理员密码至少需要 8 个字符。";
|
||||
if (
|
||||
form.value.admin_password.length < 8 ||
|
||||
form.value.admin_password.length > 12
|
||||
) {
|
||||
error.value = "超级管理员密码长度必须为 8 至 12 个字符。";
|
||||
return;
|
||||
}
|
||||
if (form.value.admin_password !== form.value.confirm_password) {
|
||||
@@ -494,6 +663,29 @@ export function useSetupWizard(props, emit) {
|
||||
error.value = "必须先完成 DNS API 在线验证;验证结果已过期时请重新测试。";
|
||||
return;
|
||||
}
|
||||
if (form.value.email_smtp_enabled) {
|
||||
const smtpPort = Number(form.value.email_smtp_port);
|
||||
if (!form.value.email_smtp_host.trim()) {
|
||||
error.value = "启用 SMTP 通知后必须填写 SMTP 主机。";
|
||||
return;
|
||||
}
|
||||
if (!Number.isInteger(smtpPort) || smtpPort < 1 || smtpPort > 65535) {
|
||||
error.value = "SMTP 端口必须在 1 至 65535 之间。";
|
||||
return;
|
||||
}
|
||||
if (!form.value.email_smtp_username.trim()) {
|
||||
error.value = "启用 SMTP 通知后必须填写 SMTP 用户名。";
|
||||
return;
|
||||
}
|
||||
if (!form.value.email_smtp_password) {
|
||||
error.value = "启用 SMTP 通知后必须填写 SMTP 密码。";
|
||||
return;
|
||||
}
|
||||
if (form.value.email_smtp_mode === "plain" && !form.value.email_smtp_allow_plaintext_auth) {
|
||||
error.value = "SMTP 明文模式必须明确允许明文认证,建议改用 STARTTLS 或隐式 TLS。";
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
emailCredentialPayload();
|
||||
} catch (err) {
|
||||
@@ -520,14 +712,21 @@ export function useSetupWizard(props, emit) {
|
||||
admin_password: form.value.admin_password,
|
||||
server_port: Number(form.value.server_port),
|
||||
email_http_enabled: form.value.email_http_enabled,
|
||||
email_smtp_enabled: form.value.email_smtp_enabled,
|
||||
email_smtp_host: form.value.email_smtp_host,
|
||||
email_smtp_port: Number(form.value.email_smtp_port),
|
||||
email_smtp_username: form.value.email_smtp_username,
|
||||
email_smtp_password: form.value.email_smtp_password,
|
||||
email_smtp_mode: form.value.email_smtp_mode,
|
||||
email_smtp_allow_plaintext_auth: form.value.email_smtp_allow_plaintext_auth,
|
||||
email_provider: form.value.email_provider,
|
||||
email_endpoint: form.value.email_endpoint,
|
||||
email_http_path: form.value.email_http_path,
|
||||
email_http_login_path: form.value.email_http_login_path,
|
||||
email_http_auth_mode: form.value.email_http_auth_mode,
|
||||
email_http_credential_ref: form.value.email_http_credential_ref,
|
||||
email_http_credentials: emailCredentialPayload(),
|
||||
email_http_headers: emailHeaders(),
|
||||
email_http_auth_mode: form.value.email_http_auth_mode,
|
||||
email_http_credential_ref: form.value.email_http_credential_ref,
|
||||
email_http_credentials: emailCredentialPayload(),
|
||||
email_http_headers: emailHeaders(),
|
||||
email_event_mode: form.value.email_event_mode,
|
||||
email_include_deployment_details:
|
||||
form.value.email_include_deployment_details,
|
||||
@@ -581,6 +780,9 @@ export function useSetupWizard(props, emit) {
|
||||
|
||||
onMounted(() => {
|
||||
loadDNSProviders();
|
||||
emailAutofillTimer = window.setInterval(() => {
|
||||
if (currentStep.value === 1) synchronizeEmailField();
|
||||
}, 250);
|
||||
verificationTimer = window.setInterval(() => {
|
||||
verificationClock.value = Date.now();
|
||||
}, 30000);
|
||||
@@ -588,6 +790,7 @@ export function useSetupWizard(props, emit) {
|
||||
|
||||
onUnmounted(() => {
|
||||
if (verificationTimer) window.clearInterval(verificationTimer);
|
||||
if (emailAutofillTimer) window.clearInterval(emailAutofillTimer);
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -608,11 +811,15 @@ export function useSetupWizard(props, emit) {
|
||||
dnsTestDomain,
|
||||
dnsVerification,
|
||||
currentStep,
|
||||
notificationAdvancedVisible,
|
||||
targetType,
|
||||
form,
|
||||
commonEmailDomains,
|
||||
selectedEmailDomain,
|
||||
emailLocalPart,
|
||||
emailInputElement,
|
||||
emailAutofillElement,
|
||||
handleEmailAutofill,
|
||||
targetLabel,
|
||||
emailCredentialLabel,
|
||||
emailCredentialPlaceholder,
|
||||
@@ -620,8 +827,13 @@ export function useSetupWizard(props, emit) {
|
||||
selectedDNSProvider,
|
||||
dnsVerificationValid,
|
||||
formatVerificationExpiry,
|
||||
formatVerificationStageStatus,
|
||||
applyEmailDomain,
|
||||
toggleNotificationAdvanced,
|
||||
handleEmailInput,
|
||||
synchronizeEmailField,
|
||||
handleEmailPaste,
|
||||
handleEmailBlur,
|
||||
testDNS,
|
||||
handleSubmit,
|
||||
previousStep,
|
||||
|
||||
@@ -24,21 +24,32 @@ const {
|
||||
dnsCredentials,
|
||||
dnsCredentialsVisible,
|
||||
maskCredential,
|
||||
emailCredentials,
|
||||
emailCredentialsVisible,
|
||||
dnsTestDomain,
|
||||
dnsVerification,
|
||||
currentStep,
|
||||
notificationAdvancedVisible,
|
||||
targetType,
|
||||
form,
|
||||
commonEmailDomains,
|
||||
selectedEmailDomain,
|
||||
emailLocalPart,
|
||||
emailInputElement,
|
||||
targetLabel,
|
||||
resetURLPreview,
|
||||
emailCredentialLabel,
|
||||
emailCredentialPlaceholder,
|
||||
selectedDNSProvider,
|
||||
dnsVerificationValid,
|
||||
formatVerificationExpiry,
|
||||
formatVerificationStageStatus,
|
||||
applyEmailDomain,
|
||||
toggleNotificationAdvanced,
|
||||
handleEmailInput,
|
||||
synchronizeEmailField,
|
||||
handleEmailPaste,
|
||||
handleEmailBlur,
|
||||
testDNS,
|
||||
handleSubmit,
|
||||
previousStep,
|
||||
@@ -82,7 +93,7 @@ const {
|
||||
<span
|
||||
class="progress-step"
|
||||
:class="{ active: currentStep === 2, complete: currentStep > 2 }"
|
||||
><b>2</b><strong>服务通知</strong><small>端口与邮件</small></span
|
||||
><b>2</b><strong>服务通知</strong><small>邮件通知</small></span
|
||||
>
|
||||
<i aria-hidden="true"></i>
|
||||
<span
|
||||
@@ -120,16 +131,34 @@ const {
|
||||
><span>绑定邮箱</span
|
||||
><div class="email-input-group">
|
||||
<input
|
||||
id="admin-email"
|
||||
name="admin_email"
|
||||
:value="emailLocalPart"
|
||||
@input="handleEmailInput($event.target.value)"
|
||||
required
|
||||
type="text"
|
||||
autocomplete="email"
|
||||
inputmode="email"
|
||||
placeholder="请输入邮箱名称"
|
||||
/>
|
||||
ref="emailAutofillElement"
|
||||
class="email-autofill-probe"
|
||||
id="admin-email-autofill"
|
||||
name="email"
|
||||
autocomplete="section-scert email"
|
||||
tabindex="-1"
|
||||
aria-hidden="true"
|
||||
type="email"
|
||||
@input="handleEmailAutofill"
|
||||
@change="handleEmailAutofill"
|
||||
@blur="handleEmailAutofill"
|
||||
/>
|
||||
<input
|
||||
id="admin-email"
|
||||
name="admin_email"
|
||||
ref="emailInputElement"
|
||||
:value="emailLocalPart"
|
||||
@input="handleEmailInput($event.target.value)"
|
||||
@paste="handleEmailPaste"
|
||||
@change="synchronizeEmailField($event.target.value)"
|
||||
@focus="synchronizeEmailField($event.target.value)"
|
||||
@blur="handleEmailBlur($event.target.value)"
|
||||
@animationstart="handleEmailAutofill"
|
||||
type="text"
|
||||
autocomplete="email"
|
||||
inputmode="email"
|
||||
placeholder="请输入邮箱名称"
|
||||
/>
|
||||
<select
|
||||
id="admin-email-domain"
|
||||
v-model="selectedEmailDomain"
|
||||
@@ -155,9 +184,10 @@ const {
|
||||
v-model="form.admin_password"
|
||||
required
|
||||
minlength="8"
|
||||
maxlength="12"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="至少 8 个字符"
|
||||
placeholder="8-12 个字符"
|
||||
/></label>
|
||||
<label
|
||||
><span>确认密码</span
|
||||
@@ -167,11 +197,77 @@ const {
|
||||
v-model="form.confirm_password"
|
||||
required
|
||||
minlength="8"
|
||||
maxlength="12"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="再次输入密码"
|
||||
/></label>
|
||||
</div>
|
||||
<div class="setup-section-heading">
|
||||
<strong>服务访问配置</strong>
|
||||
<span>先确定 Scert 主服务和管理页面的访问方式,后续步骤会使用这里的配置。</span>
|
||||
</div>
|
||||
<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"
|
||||
/>
|
||||
<small>管理页面和 API 对外提供服务使用的端口。</small>
|
||||
</label>
|
||||
<div class="access-target-field">
|
||||
<span>管理页面访问方式</span>
|
||||
<div class="target-switch" role="group" aria-label="管理页面访问方式">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: targetType === 'hostname' }"
|
||||
:aria-pressed="targetType === 'hostname'"
|
||||
@click="targetType = 'hostname'"
|
||||
>
|
||||
使用域名
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: targetType === 'ip' }"
|
||||
:aria-pressed="targetType === 'ip'"
|
||||
@click="targetType = 'ip'"
|
||||
>
|
||||
使用公网 IP
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
<div class="provider-description reset-preview">
|
||||
<strong>密码重置地址预览</strong>
|
||||
<span>{{ resetURLPreview }}</span>
|
||||
<span>只有手动启动 Scert-admin 后,此地址才会临时可用。</span>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset
|
||||
@@ -181,19 +277,12 @@ const {
|
||||
<legend><span>02</span>服务与通知</legend>
|
||||
|
||||
<div class="notification-layout">
|
||||
<div class="notification-guide">
|
||||
<strong>先完成基础配置</strong>
|
||||
<span>填写邮件服务地址即可继续,其他项目已经提供合理默认值。</span>
|
||||
</div>
|
||||
|
||||
<div class="notification-row notification-service-row">
|
||||
<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 class="confirm-row compact-row">
|
||||
<input
|
||||
id="email-http-enabled"
|
||||
@@ -202,236 +291,352 @@ const {
|
||||
/>
|
||||
<span>
|
||||
<strong>启用 HTTP 邮件通知</strong>
|
||||
<small>兼容 Smail 等 HTTP 邮件服务。</small>
|
||||
<small>通过第三方邮件 API 发送任务通知。</small>
|
||||
</span>
|
||||
</label>
|
||||
<label v-if="form.email_http_enabled">
|
||||
<span>第三方邮箱服务标识</span>
|
||||
<label class="confirm-row compact-row">
|
||||
<input
|
||||
id="email-provider"
|
||||
name="email_provider"
|
||||
v-model.trim="form.email_provider"
|
||||
placeholder="例如 company-mail-api"
|
||||
id="email-smtp-enabled"
|
||||
v-model="form.email_smtp_enabled"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>
|
||||
<strong>启用 SMTP 通知</strong>
|
||||
<small>通过 SMTP 出站客户端发送任务通知。</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="form.email_http_enabled"
|
||||
class="notification-row notification-api-row"
|
||||
>
|
||||
<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>
|
||||
<label>
|
||||
<span>HTTP 请求路径</span>
|
||||
<input
|
||||
id="email-http-path"
|
||||
v-model.trim="form.email_http_path"
|
||||
placeholder="/api/email/send"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>HTTP 认证方式</span>
|
||||
<select
|
||||
id="email-http-auth-mode"
|
||||
v-model="form.email_http_auth_mode"
|
||||
>
|
||||
<option value="none">无认证</option>
|
||||
<option value="bearer">Bearer Token</option>
|
||||
<option value="hmac_sha256">HMAC-SHA256</option>
|
||||
<option value="session">账号登录会话</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="form.email_http_enabled"
|
||||
class="notification-row notification-auth-row"
|
||||
>
|
||||
<label v-if="form.email_http_auth_mode === 'session'">
|
||||
<span>登录请求路径</span>
|
||||
<input
|
||||
id="email-http-login-path"
|
||||
v-model.trim="form.email_http_login_path"
|
||||
placeholder="/api/login"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>已有凭据引用(可选)</span>
|
||||
<input
|
||||
id="email-http-credential-ref"
|
||||
v-model.trim="form.email_http_credential_ref"
|
||||
placeholder="已有 secret://notification/... 引用"
|
||||
/>
|
||||
</label>
|
||||
<div
|
||||
v-if="form.email_http_auth_mode === 'none'"
|
||||
class="notification-auth-note"
|
||||
>
|
||||
当前接口不启用认证,不需要填写凭据。
|
||||
<div v-if="form.email_smtp_enabled" class="notification-basic-panel smtp-basic-panel">
|
||||
<div class="notification-section-heading">
|
||||
<div>
|
||||
<strong>SMTP 通知配置</strong>
|
||||
<span>Scert 只作为 SMTP 出站客户端,不提供 SMTP、IMAP 或 POP3 服务端。</span>
|
||||
</div>
|
||||
<span class="notification-recommended-badge">推荐 STARTTLS</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="
|
||||
form.email_http_enabled &&
|
||||
form.email_http_auth_mode !== 'none'
|
||||
"
|
||||
class="notification-credential-field"
|
||||
>
|
||||
<div class="credential-visibility-row">
|
||||
<span>{{ emailCredentialLabel }}</span>
|
||||
<label class="credential-visibility-control">
|
||||
<div class="notification-row smtp-config-row">
|
||||
<label>
|
||||
<span>SMTP 主机</span>
|
||||
<input
|
||||
v-model="emailCredentialsVisible"
|
||||
type="checkbox"
|
||||
id="email-smtp-host"
|
||||
name="email_smtp_host"
|
||||
v-model.trim="form.email_smtp_host"
|
||||
placeholder="smtp.example.com"
|
||||
autocomplete="off"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>SMTP 端口</span>
|
||||
<input
|
||||
id="email-smtp-port"
|
||||
name="email_smtp_port"
|
||||
v-model.number="form.email_smtp_port"
|
||||
type="number"
|
||||
min="1"
|
||||
max="65535"
|
||||
inputmode="numeric"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>SMTP 用户名</span>
|
||||
<input
|
||||
id="email-smtp-username"
|
||||
name="email_smtp_username"
|
||||
v-model.trim="form.email_smtp_username"
|
||||
placeholder="发件邮箱或账号"
|
||||
autocomplete="username"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>SMTP 密码</span>
|
||||
<input
|
||||
id="email-smtp-password"
|
||||
name="email_smtp_password"
|
||||
v-model="form.email_smtp_password"
|
||||
type="password"
|
||||
placeholder="请输入 SMTP 密码或授权码"
|
||||
autocomplete="new-password"
|
||||
/>
|
||||
<span>显示凭据明文</span>
|
||||
</label>
|
||||
</div>
|
||||
<textarea
|
||||
v-if="emailCredentialsVisible"
|
||||
id="email-http-credentials-visible"
|
||||
v-model="emailCredentials"
|
||||
rows="3"
|
||||
autocomplete="off"
|
||||
:placeholder="emailCredentialPlaceholder"
|
||||
></textarea>
|
||||
<textarea
|
||||
v-else
|
||||
id="email-http-credentials-masked"
|
||||
:value="maskCredential(emailCredentials)"
|
||||
rows="3"
|
||||
readonly
|
||||
autocomplete="off"
|
||||
></textarea>
|
||||
<small>
|
||||
配置时允许明文显示;提交后仅保存加密凭据引用,普通配置文件不会保存密码或令牌。
|
||||
</small>
|
||||
|
||||
<div class="notification-row smtp-options-row">
|
||||
<label>
|
||||
<span>连接模式</span>
|
||||
<select v-model="form.email_smtp_mode">
|
||||
<option value="starttls">STARTTLS(推荐)</option>
|
||||
<option value="implicit_tls">隐式 TLS</option>
|
||||
<option value="plain">明文</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="confirm-row compact-row smtp-plaintext-row">
|
||||
<input
|
||||
id="email-smtp-allow-plaintext-auth"
|
||||
v-model="form.email_smtp_allow_plaintext_auth"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>
|
||||
<strong>允许明文认证</strong>
|
||||
<small>仅在明文模式下使用,存在凭据泄露风险。</small>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="notification-smtp-tip">
|
||||
SMTP 密码只会写入加密敏感信息存储,不会回显到配置文件、接口响应或日志。建议优先使用 STARTTLS 或隐式 TLS。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="form.email_http_enabled"
|
||||
class="provider-description reset-preview"
|
||||
>
|
||||
<div v-if="form.email_http_enabled" class="notification-basic-panel">
|
||||
<div class="notification-section-heading">
|
||||
<div>
|
||||
<strong>邮件通知基础配置</strong>
|
||||
<span>填写服务地址、发件人和收件人即可,技术参数无需修改。</span>
|
||||
</div>
|
||||
<span class="notification-recommended-badge">推荐配置</span>
|
||||
</div>
|
||||
|
||||
<div class="notification-row notification-basic-row">
|
||||
<label>
|
||||
<span>邮件服务地址</span>
|
||||
<input
|
||||
id="email-endpoint"
|
||||
name="email_endpoint"
|
||||
v-model.trim="form.email_endpoint"
|
||||
type="url"
|
||||
placeholder="https://mail.example.com"
|
||||
/>
|
||||
<small>填写邮件服务提供的地址,不需要自行拼接接口路径。</small>
|
||||
</label>
|
||||
<label>
|
||||
<span>邮件服务名称(可选)</span>
|
||||
<input
|
||||
id="email-provider"
|
||||
name="email_provider"
|
||||
v-model.trim="form.email_provider"
|
||||
placeholder="例如:Smail"
|
||||
/>
|
||||
<small>仅用于日志和通知内容中的识别。</small>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="notification-row notification-sender-row">
|
||||
<label>
|
||||
<span>发件人名称</span>
|
||||
<input
|
||||
id="email-sender-name"
|
||||
v-model.trim="form.email_sender_name"
|
||||
placeholder="Scert"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>发件人地址(可选)</span>
|
||||
<input
|
||||
id="email-sender-email"
|
||||
v-model.trim="form.email_sender_email"
|
||||
type="email"
|
||||
placeholder="留空使用管理员邮箱"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>通知收件人</span>
|
||||
<input
|
||||
id="recipients"
|
||||
name="recipients"
|
||||
v-model="form.recipients"
|
||||
placeholder="多个地址使用逗号分隔"
|
||||
/>
|
||||
<small>续期、部署和错误通知将发送到这些地址。</small>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="provider-description reset-preview">
|
||||
<strong>密码重置地址</strong>
|
||||
<span>{{ resetURLPreview }}</span>
|
||||
<span>
|
||||
无需配置独立端口;只有手动启动 Scert-admin
|
||||
后,此地址才会临时可用。
|
||||
</span>
|
||||
<span>只有手动启动 Scert-admin 后,此地址才会临时可用。</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="form.email_http_enabled"
|
||||
class="notification-row notification-sender-row"
|
||||
>
|
||||
<label>
|
||||
<span>发件人名称</span>
|
||||
<input
|
||||
id="email-sender-name"
|
||||
v-model.trim="form.email_sender_name"
|
||||
placeholder="Scert"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>发件人地址</span>
|
||||
<input
|
||||
id="email-sender-email"
|
||||
v-model.trim="form.email_sender_email"
|
||||
type="email"
|
||||
placeholder="留空使用管理员邮箱"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>通知收件人</span>
|
||||
<input
|
||||
id="recipients"
|
||||
name="recipients"
|
||||
v-model="form.recipients"
|
||||
placeholder="多个地址使用逗号分隔"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="form.email_http_enabled" class="notification-advanced-panel">
|
||||
<button
|
||||
class="notification-advanced-toggle"
|
||||
type="button"
|
||||
:aria-expanded="notificationAdvancedVisible"
|
||||
@click="toggleNotificationAdvanced"
|
||||
>
|
||||
<span>
|
||||
<strong>高级配置</strong>
|
||||
<small>认证、请求路径、重试策略和通知内容选项</small>
|
||||
</span>
|
||||
<span class="notification-advanced-action">
|
||||
{{ notificationAdvancedVisible ? "收起配置" : "展开配置" }}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<div
|
||||
v-if="form.email_http_enabled"
|
||||
class="notification-row notification-delivery-row"
|
||||
>
|
||||
<label>
|
||||
<span>通知事件模式</span>
|
||||
<select v-model="form.email_event_mode">
|
||||
<option value="detailed">详细事件</option>
|
||||
<option value="unified">统一事件</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<span>请求超时(秒)</span>
|
||||
<input
|
||||
v-model.number="form.email_timeout_secs"
|
||||
type="number"
|
||||
min="1"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>重试次数</span>
|
||||
<input
|
||||
v-model.number="form.email_retry_count"
|
||||
type="number"
|
||||
min="1"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>重试间隔(秒)</span>
|
||||
<input
|
||||
v-model.trim="form.email_retry_intervals_secs"
|
||||
placeholder="30,120,600"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="notificationAdvancedVisible" class="notification-advanced-content">
|
||||
<div class="notification-advanced-tip">
|
||||
默认值适用于常见 HTTP 邮件服务。只有服务方提供了特殊要求时,才需要修改这里的内容。
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="form.email_http_enabled"
|
||||
class="notification-bottom-row"
|
||||
>
|
||||
<label class="email-headers-field">
|
||||
<span>HTTP 自定义请求头(JSON)</span>
|
||||
<textarea
|
||||
v-model.trim="form.email_http_headers"
|
||||
rows="2"
|
||||
placeholder='例如:{"X-Tenant":"scert"}'
|
||||
></textarea>
|
||||
</label>
|
||||
<div class="setup-grid three-columns compact-options email-option-grid">
|
||||
<label class="confirm-row compact-row">
|
||||
<input
|
||||
v-model="form.email_include_deployment_details"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>部署明细</span>
|
||||
</label>
|
||||
<label class="confirm-row compact-row">
|
||||
<input
|
||||
v-model="form.email_include_certificate_serial"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>证书序列号</span>
|
||||
</label>
|
||||
<label class="confirm-row compact-row">
|
||||
<input
|
||||
v-model="form.email_include_management_url"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>管理后台链接</span>
|
||||
</label>
|
||||
<div class="notification-row notification-api-row">
|
||||
<label>
|
||||
<span>HTTP 请求路径</span>
|
||||
<input
|
||||
id="email-http-path"
|
||||
v-model.trim="form.email_http_path"
|
||||
placeholder="/api/email/send"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>HTTP 认证方式</span>
|
||||
<select
|
||||
id="email-http-auth-mode"
|
||||
v-model="form.email_http_auth_mode"
|
||||
>
|
||||
<option value="none">无认证</option>
|
||||
<option value="bearer">Bearer Token</option>
|
||||
<option value="hmac_sha256">HMAC-SHA256</option>
|
||||
<option value="session">账号登录会话</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-if="form.email_http_auth_mode === 'session'" class="notification-row notification-auth-row">
|
||||
<label>
|
||||
<span>登录请求路径</span>
|
||||
<input
|
||||
id="email-http-login-path"
|
||||
v-model.trim="form.email_http_login_path"
|
||||
placeholder="/api/login"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>已有凭据引用(可选)</span>
|
||||
<input
|
||||
id="email-http-credential-ref"
|
||||
v-model.trim="form.email_http_credential_ref"
|
||||
placeholder="已有安全凭据引用"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div v-else class="notification-row notification-auth-row">
|
||||
<label>
|
||||
<span>已有凭据引用(可选)</span>
|
||||
<input
|
||||
id="email-http-credential-ref"
|
||||
v-model.trim="form.email_http_credential_ref"
|
||||
placeholder="已有安全凭据引用"
|
||||
/>
|
||||
</label>
|
||||
<div class="notification-auth-note">
|
||||
当前接口不启用认证,不需要填写凭据。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="form.email_http_auth_mode !== 'none'"
|
||||
class="notification-credential-field"
|
||||
>
|
||||
<div class="credential-visibility-row">
|
||||
<span>{{ emailCredentialLabel }}</span>
|
||||
<label class="credential-visibility-control">
|
||||
<input
|
||||
v-model="emailCredentialsVisible"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>显示凭据明文</span>
|
||||
</label>
|
||||
</div>
|
||||
<textarea
|
||||
v-if="emailCredentialsVisible"
|
||||
id="email-http-credentials-visible"
|
||||
v-model="emailCredentials"
|
||||
rows="3"
|
||||
autocomplete="off"
|
||||
:placeholder="emailCredentialPlaceholder"
|
||||
></textarea>
|
||||
<textarea
|
||||
v-else
|
||||
id="email-http-credentials-masked"
|
||||
:value="maskCredential(emailCredentials)"
|
||||
rows="3"
|
||||
readonly
|
||||
autocomplete="off"
|
||||
></textarea>
|
||||
<small>
|
||||
配置时允许明文显示;提交后仅保存加密凭据引用,普通配置文件不会保存密码或令牌。
|
||||
</small>
|
||||
</div>
|
||||
|
||||
<div class="notification-row notification-delivery-row">
|
||||
<label>
|
||||
<span>通知事件模式</span>
|
||||
<select v-model="form.email_event_mode">
|
||||
<option value="detailed">详细事件</option>
|
||||
<option value="unified">统一事件</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<span>请求超时(秒)</span>
|
||||
<input
|
||||
v-model.number="form.email_timeout_secs"
|
||||
type="number"
|
||||
min="1"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>重试次数</span>
|
||||
<input
|
||||
v-model.number="form.email_retry_count"
|
||||
type="number"
|
||||
min="1"
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>重试间隔(秒)</span>
|
||||
<input
|
||||
v-model.trim="form.email_retry_intervals_secs"
|
||||
placeholder="30,120,600"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="notification-bottom-row">
|
||||
<label class="email-headers-field">
|
||||
<span>HTTP 自定义请求头(JSON,可选)</span>
|
||||
<textarea
|
||||
v-model.trim="form.email_http_headers"
|
||||
rows="2"
|
||||
placeholder='例如:{"X-Tenant":"scert"}'
|
||||
></textarea>
|
||||
</label>
|
||||
<div class="setup-grid three-columns compact-options email-option-grid">
|
||||
<label class="confirm-row compact-row">
|
||||
<input
|
||||
v-model="form.email_include_deployment_details"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>部署明细</span>
|
||||
</label>
|
||||
<label class="confirm-row compact-row">
|
||||
<input
|
||||
v-model="form.email_include_certificate_serial"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>证书序列号</span>
|
||||
</label>
|
||||
<label class="confirm-row compact-row">
|
||||
<input
|
||||
v-model="form.email_include_management_url"
|
||||
type="checkbox"
|
||||
/>
|
||||
<span>管理后台链接</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -582,7 +787,11 @@ const {
|
||||
"
|
||||
@click="testDNS"
|
||||
>
|
||||
{{ dnsTesting ? "正在创建并清理测试记录……" : "测试 DNS API" }}
|
||||
{{
|
||||
dnsTesting
|
||||
? "正在创建、查询并清理测试记录……"
|
||||
: "测试 DNS API"
|
||||
}}
|
||||
</button>
|
||||
<span
|
||||
>测试会临时创建 DNS-01 TXT
|
||||
@@ -599,55 +808,45 @@ const {
|
||||
}}。修改服务商、测试域名或凭据后需要重新测试。</span
|
||||
>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="dnsVerification && dnsVerification.test_report"
|
||||
class="dns-verification-report"
|
||||
>
|
||||
<div class="dns-report-heading">
|
||||
<strong>在线测试过程</strong>
|
||||
<span v-if="dnsVerification.test_report.record_name">
|
||||
临时记录:{{ dnsVerification.test_report.record_name }}
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="stage in dnsVerification.test_report.stages"
|
||||
:key="stage.name"
|
||||
class="dns-verification-stage"
|
||||
:class="`is-${stage.status}`"
|
||||
>
|
||||
<span class="dns-stage-name">{{ stage.name }}</span>
|
||||
<strong>{{ formatVerificationStageStatus(stage.status) }}</strong>
|
||||
<small>{{ stage.message }}</small>
|
||||
</div>
|
||||
</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>
|
||||
<legend><span>04</span>证书目录与剩余设置</legend>
|
||||
<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
|
||||
<label>
|
||||
<span>证书部署根目录</span>
|
||||
<input
|
||||
id="certificate-root"
|
||||
name="certificate_root"
|
||||
v-model.trim="form.certificate_root"
|
||||
required
|
||||
/></label>
|
||||
<label
|
||||
><span>HTTPS 模式</span
|
||||
><select
|
||||
/>
|
||||
</label>
|
||||
<label>
|
||||
<span>HTTPS 模式</span>
|
||||
<select
|
||||
id="https-mode"
|
||||
name="https_mode"
|
||||
v-model="form.https_mode"
|
||||
@@ -656,22 +855,21 @@ const {
|
||||
<option value="proxy">
|
||||
高级:Nginx/Caddy 终止公网 HTTPS
|
||||
</option>
|
||||
</select></label
|
||||
>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
<label class="confirm-row"
|
||||
><input
|
||||
<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
|
||||
>
|
||||
/>
|
||||
<span>
|
||||
<strong>初始化完成后开启管理页面</strong>
|
||||
<small>桌面端可通过此开关决定是否启用浏览器管理页面。</small>
|
||||
</span>
|
||||
</label>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -52,8 +52,8 @@ export function useSuperAdminReset() {
|
||||
if (!verificationCode.value.trim()) {
|
||||
return "请输入一次性校验码。";
|
||||
}
|
||||
if (password.value.length < 8) {
|
||||
return "新密码至少需要 8 个字符。";
|
||||
if (password.value.length < 8 || password.value.length > 12) {
|
||||
return "新密码长度必须为 8 至 12 个字符。";
|
||||
}
|
||||
if (password.value !== confirmPassword.value) {
|
||||
return "两次输入的新密码不一致。";
|
||||
@@ -138,4 +138,4 @@ export function useSuperAdminReset() {
|
||||
submit,
|
||||
loadSession,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,9 @@ const {
|
||||
v-model="password"
|
||||
type="password"
|
||||
autocomplete="new-password"
|
||||
placeholder="至少 8 个字符"
|
||||
placeholder="8-12 个字符"
|
||||
minlength="8"
|
||||
maxlength="12"
|
||||
:disabled="loading || submitting || success"
|
||||
required
|
||||
/>
|
||||
@@ -77,6 +78,7 @@ const {
|
||||
autocomplete="new-password"
|
||||
placeholder="请再次输入新密码"
|
||||
minlength="8"
|
||||
maxlength="12"
|
||||
:disabled="loading || submitting || success"
|
||||
required
|
||||
/>
|
||||
@@ -111,4 +113,4 @@ const {
|
||||
</AccessShell>
|
||||
</template>
|
||||
|
||||
<style src="./SuperAdminReset.css"></style>
|
||||
<style src="./SuperAdminReset.css"></style>
|
||||
+28
-20
@@ -4,26 +4,34 @@ import vue from '@vitejs/plugin-vue'
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
publicDir: 'logo',
|
||||
server: {
|
||||
host: process.env.SCERT_DEV_HOST || '127.0.0.1',
|
||||
port: Number(process.env.SCERT_DEV_PORT || 5173),
|
||||
proxy: {
|
||||
'/api': process.env.SCERT_API_TARGET || 'http://127.0.0.1:5200',
|
||||
'/healthz': process.env.SCERT_API_TARGET || 'http://127.0.0.1:5200',
|
||||
'/reset': {
|
||||
target: process.env.SCERT_API_TARGET || 'http://127.0.0.1:5200',
|
||||
changeOrigin: false,
|
||||
bypass(request) {
|
||||
if (
|
||||
request.method === 'GET' &&
|
||||
request.headers.accept &&
|
||||
request.headers.accept.includes('text/html')
|
||||
) {
|
||||
return '/index.html';
|
||||
}
|
||||
return undefined;
|
||||
server: (() => {
|
||||
const apiTarget = process.env.SCERT_API_TARGET || 'http://127.0.0.1:5200';
|
||||
const apiProxy = {
|
||||
target: apiTarget,
|
||||
changeOrigin: false,
|
||||
secure: false,
|
||||
};
|
||||
|
||||
return {
|
||||
host: process.env.SCERT_DEV_HOST || '127.0.0.1',
|
||||
port: Number(process.env.SCERT_DEV_PORT || 5173),
|
||||
proxy: {
|
||||
'/api': apiProxy,
|
||||
'/healthz': apiProxy,
|
||||
'/reset': {
|
||||
...apiProxy,
|
||||
bypass(request) {
|
||||
if (
|
||||
request.method === 'GET' &&
|
||||
request.headers.accept &&
|
||||
request.headers.accept.includes('text/html')
|
||||
) {
|
||||
return '/index.html';
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
})(),
|
||||
})
|
||||
Reference in new issue
Block a user