完成Scert首轮基础骨架开发与复审

This commit is contained in:
xuans committed 2026-08-26 10:34:04 +08:00
commit fd8d8608f5
41 files changed
+6987

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
<script setup>
import { onMounted, ref } from 'vue'
const status = ref(null)
const domains = ref([])
const loading = ref(true)
const error = ref('')
const certificateTypeLabels = { single: '单域名', wildcard: '泛域名', san: 'SAN 多域名' }
const domainStatusLabels = { pending: '等待处理', active: '正常', error: '错误' }
const httpsModeLabels = { direct: '核心服务 HTTPS', proxy: '反向代理 HTTPS' }
function displayLabel(labels, value) {
return labels[value] || (value ? '未知' : '—')
}
async function loadData() {
loading.value = true
error.value = ''
try {
const [statusResponse, domainResponse] = await Promise.all([
fetch('/api/v1/status'),
fetch('/api/v1/domains'),
])
if (!statusResponse.ok || !domainResponse.ok) throw new Error('服务接口返回失败')
status.value = await statusResponse.json()
domains.value = (await domainResponse.json()).items || []
} catch {
error.value = '无法连接核心服务'
} finally {
loading.value = false
}
}
onMounted(loadData)
</script>
<template>
<main class="page-shell">
<header class="topbar">
<div>
<p class="eyebrow">SCERT / SSL 证书管理</p>
<h1>证书管理总览</h1>
</div>
<button class="secondary-button" type="button" @click="loadData">刷新状态</button>
</header>
<section class="hero-card">
<div>
<span class="status-dot" :class="{ online: status }"></span>
<span class="status-label">{{ status ? '核心服务运行中' : '等待连接核心服务' }}</span>
<h2>让证书续期和部署变得可追踪</h2>
<p>首轮界面展示服务状态和托管域名,后续将接入 ACME、DNS 验证与远程部署流程。</p>
</div>
<div class="hero-mark">S</div>
</section>
<p v-if="error" class="error-banner">{{ error }}。请先执行 <code>scert serve</code>。</p>
<section class="metrics-grid">
<article class="metric-card"><span>服务版本</span><strong>{{ status?.version || '—' }}</strong></article>
<article class="metric-card"><span>数据库</span><strong>{{ displayLabel({ sqlite: 'SQLite', mysql: 'MySQL' }, status?.database_driver) || '—' }}</strong></article>
<article class="metric-card"><span>HTTPS 模式</span><strong>{{ displayLabel(httpsModeLabels, status?.https_mode) || '—' }}</strong></article>
<article class="metric-card"><span>托管域名</span><strong>{{ domains.length }}</strong></article>
</section>
<section class="panel">
<div class="panel-heading"><div><p class="eyebrow">域名列表</p><h2>托管域名</h2></div><span class="muted">首轮占位视图</span></div>
<div v-if="loading" class="empty-state">正在读取域名状态……</div>
<div v-else-if="domains.length === 0" class="empty-state">暂未添加托管域名,请通过 CLI 执行 <code>scert domain add</code>。</div>
<div v-else class="domain-list">
<div v-for="item in domains" :key="item.id" class="domain-row">
<div><strong>{{ item.name }}</strong><span>{{ displayLabel(certificateTypeLabels, item.certificate_type) }} · {{ displayLabel(domainStatusLabels, item.status) }}</span></div>
<span class="tag">待处理</span>
</div>
</div>
</section>
</main>
</template>
+5
View File
@@ -0,0 +1,5 @@
import { createApp } from 'vue'
import App from './App.vue'
import './style.css'
createApp(App).mount('#app')
+34
View File
@@ -0,0 +1,34 @@
:root { font-family: Inter, "Microsoft YaHei", sans-serif; color: #172033; background: #f4f7fb; font-synthesis: none; }
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button { font: inherit; cursor: pointer; }
.page-shell { max-width: 1180px; margin: 0 auto; padding: 42px 28px 70px; }
.topbar, .panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.eyebrow { margin: 0 0 9px; color: #687792; font-size: 11px; font-weight: 800; letter-spacing: .15em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(30px, 5vw, 52px); letter-spacing: -.05em; }
h2 { margin-bottom: 10px; font-size: clamp(24px, 4vw, 38px); letter-spacing: -.04em; }
.secondary-button { border: 1px solid #d5ddea; border-radius: 12px; background: #fff; color: #32405a; padding: 11px 16px; font-weight: 700; }
.hero-card { display: flex; align-items: center; justify-content: space-between; min-height: 250px; margin: 36px 0 18px; padding: 36px 42px; border-radius: 28px; color: #fff; background: linear-gradient(120deg, #182b5b, #315aaa); box-shadow: 0 20px 45px rgba(42, 75, 145, .2); }
.hero-card p { max-width: 650px; margin-bottom: 0; color: #d5e1ff; line-height: 1.8; }
.status-label { font-size: 13px; font-weight: 800; }
.status-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: #ffba58; }
.status-dot.online { background: #5ee0a0; box-shadow: 0 0 0 5px rgba(94, 224, 160, .15); }
.hero-mark { display: grid; place-items: center; width: 112px; height: 112px; border: 1px solid rgba(255,255,255,.35); border-radius: 32px; color: #cfe0ff; font-size: 62px; font-weight: 900; }
.error-banner { margin: 18px 0; padding: 14px 18px; border: 1px solid #f0c4c4; border-radius: 12px; color: #9c3b3b; background: #fff2f2; }
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.metric-card, .panel { border: 1px solid #e2e8f2; border-radius: 20px; background: rgba(255,255,255,.86); box-shadow: 0 10px 30px rgba(31, 50, 87, .04); }
.metric-card { padding: 22px; }
.metric-card span, .domain-row span, .muted { color: #7a879d; font-size: 13px; }
.metric-card strong { display: block; margin-top: 13px; font-size: 28px; }
.panel { padding: 28px; }
.panel-heading { margin-bottom: 22px; }
.panel-heading h2 { margin-bottom: 0; font-size: 26px; }
.empty-state { padding: 36px 10px; color: #7a879d; text-align: center; }
code { padding: 2px 6px; border-radius: 6px; background: #eef2f8; font-family: Consolas, monospace; }
.domain-list { display: grid; gap: 10px; }
.domain-row { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border: 1px solid #edf0f5; border-radius: 13px; }
.domain-row strong, .domain-row span { display: block; }
.domain-row strong { margin-bottom: 5px; }
.tag { padding: 5px 10px; border-radius: 99px; background: #fff3d8; color: #9b6a1a !important; font-size: 12px !important; }
@media (max-width: 760px) { .page-shell { padding: 26px 16px 48px; } .hero-card { align-items: flex-start; padding: 28px; } .hero-mark { display: none; } .metrics-grid { grid-template-columns: repeat(2, 1fr); } .panel { padding: 20px; } }