完善初始化页面、代理配置与远程部署文档

This commit is contained in:
xuans committed 2026-08-29 20:43:41 +08:00
1 parent f85ef10527
commit afdb947bea
9 files changed
+731 -15

No files matched your search

+215
View File
@@ -472,3 +472,218 @@ code {
gap: 0;
}
}
.field-label-row {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.field-label-row > span:first-child {
min-width: 0;
}
.inline-button {
flex: 0 0 auto;
border: 0;
padding: 4px 8px;
border-radius: 6px;
color: #2557a7;
background: #edf4ff;
font-size: 12px;
line-height: 1.4;
cursor: pointer;
}
.inline-button:hover {
color: #17458f;
background: #dceaff;
}
.ssh-key-guide {
margin: 0 0 18px;
padding: 16px;
border: 1px solid #dbe7f7;
border-radius: 12px;
background: linear-gradient(135deg, #f7fbff, #f3f7fc);
}
.ssh-key-guide-heading {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 14px;
color: #183b68;
font-size: 14px;
font-weight: 700;
}
.ssh-key-guide-heading::before {
content: "K";
display: inline-flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
border-radius: 7px;
color: #ffffff;
background: #3677d8;
font-size: 12px;
}
.ssh-key-steps {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
margin: 0;
}
.ssh-key-steps article {
display: flex;
gap: 9px;
min-width: 0;
padding: 11px;
border-radius: 9px;
background: #ffffff;
}
.ssh-key-steps b {
display: inline-flex;
flex: 0 0 22px;
align-items: center;
justify-content: center;
width: 22px;
height: 22px;
border-radius: 50%;
color: #ffffff;
background: #5f93dc;
font-size: 12px;
}
.ssh-key-steps div {
display: grid;
gap: 3px;
min-width: 0;
}
.ssh-key-steps strong {
color: #23466f;
font-size: 12px;
}
.ssh-key-steps span {
color: #687b94;
font-size: 11px;
line-height: 1.55;
}
.ssh-key-platforms {
display: flex;
gap: 6px;
margin: 16px 0 10px;
padding: 4px;
border-radius: 8px;
background: #e8eff9;
}
.platform-tab {
flex: 1;
border: 0;
padding: 8px 10px;
border-radius: 6px;
color: #55708e;
background: transparent;
font-size: 12px;
cursor: pointer;
}
.platform-tab.active {
color: #214f98;
background: #ffffff;
box-shadow: 0 2px 8px rgba(48, 83, 132, 0.12);
font-weight: 700;
}
.ssh-command-card {
margin-top: 10px;
padding: 11px 12px;
border: 1px solid #dfe8f3;
border-radius: 9px;
background: #ffffff;
}
.ssh-command-heading {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
margin-bottom: 7px;
color: #3b5778;
font-size: 12px;
font-weight: 700;
}
.ssh-command-card > code {
display: block;
overflow-wrap: anywhere;
color: #294765;
font-family: Consolas, "SFMono-Regular", monospace;
font-size: 11px;
line-height: 1.65;
white-space: pre-wrap;
}
.ssh-command-card small {
display: block;
margin-top: 8px;
color: #71839a;
font-size: 11px;
line-height: 1.55;
}
.ssh-key-guide-note {
margin: 12px 0 0;
color: #637895;
font-size: 11px;
line-height: 1.6;
}
.field input[type="file"] {
padding: 9px;
color: #5d6f86;
background: #f8fafc;
font-size: 12px;
}
@media (max-width: 700px) {
.ssh-key-steps {
grid-template-columns: 1fr;
}
.field-label-row {
align-items: flex-start;
}
}
.ssh-key-guide-heading > div:first-child {
display: grid;
gap: 3px;
min-width: 0;
}
.ssh-key-guide-heading > div:first-child span {
color: #6d819b;
font-size: 11px;
font-weight: 400;
line-height: 1.55;
}
.guide-badge {
flex: 0 0 auto;
padding: 4px 8px;
border-radius: 999px;
color: #2c68ba;
background: #e2efff;
font-size: 11px;
white-space: nowrap;
}
+48
View File
@@ -22,6 +22,21 @@ export function useDashboard() {
const showSSHKeyForm = ref(false);
const sshKeySaving = ref(false);
const sshKeyFormError = ref("");
const sshKeyPlatform = ref("windows");
const sshKeyPassphraseVisible = ref(false);
const sshKeyCommands = {
windows:
'ssh-keygen -t ed25519 -C "scert-deploy" -f "$HOME\\.ssh\\scert_deploy_ed25519"',
linux:
'ssh-keygen -t ed25519 -C "scert-deploy" -f ~/.ssh/scert_deploy_ed25519',
};
const sshPublicKeyCommands = {
windows:
'Get-Content "$HOME\\.ssh\\scert_deploy_ed25519.pub" | ssh root@服务器地址 "umask 077; mkdir -p ~/.ssh; cat >> ~/.ssh/authorized_keys"',
linux:
'ssh-copy-id -i ~/.ssh/scert_deploy_ed25519.pub 用户名@服务器地址',
};
const certificateTypeLabels = {
single: "单域名",
@@ -178,6 +193,8 @@ export function useDashboard() {
function openSSHKeyCreate() {
sshKeyForm.value = createEmptySSHKeyForm();
sshKeyFormError.value = "";
sshKeyPlatform.value = "windows";
sshKeyPassphraseVisible.value = false;
showSSHKeyForm.value = true;
}
@@ -185,9 +202,34 @@ export function useDashboard() {
if (sshKeySaving.value) return;
sshKeyForm.value = createEmptySSHKeyForm();
sshKeyFormError.value = "";
sshKeyPassphraseVisible.value = false;
showSSHKeyForm.value = false;
}
async function importSSHKeyFile(event) {
const file = event.target.files?.[0];
event.target.value = "";
if (!file) return;
try {
const content = await file.text();
if (!content.trim()) throw new Error("选择的私钥文件为空");
sshKeyForm.value.private_key = content;
sshKeyFormError.value = "";
notice.value = `已读取私钥文件:${file.name}`;
} catch (err) {
sshKeyFormError.value = err.message || "读取私钥文件失败";
}
}
async function copySSHKeyCommand(value, message) {
try {
await navigator.clipboard.writeText(value);
notice.value = message;
} catch {
sshKeyFormError.value = "浏览器未允许访问剪贴板,请手动复制命令";
}
}
async function saveSSHKey() {
sshKeyFormError.value = "";
sshKeySaving.value = true;
@@ -456,6 +498,10 @@ export function useDashboard() {
form,
serverForm,
sshKeyForm,
sshKeyPlatform,
sshKeyPassphraseVisible,
sshKeyCommands,
sshPublicKeyCommands,
defaultCertificatePath,
defaultCertificateChainPath,
defaultPrivateKeyPath,
@@ -467,6 +513,8 @@ export function useDashboard() {
closeServerForm,
openSSHKeyCreate,
closeSSHKeyForm,
importSSHKeyFile,
copySSHKeyCommand,
saveSSHKey,
deleteSSHKey,
saveServer,
+129 -5
View File
@@ -32,6 +32,10 @@ const {
form,
serverForm,
sshKeyForm,
sshKeyPlatform,
sshKeyPassphraseVisible,
sshKeyCommands,
sshPublicKeyCommands,
defaultCertificatePath,
defaultCertificateChainPath,
defaultPrivateKeyPath,
@@ -43,6 +47,8 @@ const {
closeServerForm,
openSSHKeyCreate,
closeSSHKeyForm,
importSSHKeyFile,
copySSHKeyCommand,
saveSSHKey,
deleteSSHKey,
saveServer,
@@ -489,7 +495,15 @@ const {
required
type="text" /></label
><label class="field"
><span>SSH 私钥</span
><span class="field-label-row"
><span>SSH 私钥</span
><button
class="inline-button"
type="button"
@click="openSSHKeyCreate"
>
新建或导入
</button></span
><select v-model="serverForm.private_key_ref" required>
<option value="">请选择已加密保存的私钥</option>
<option
@@ -500,7 +514,7 @@ const {
{{ key.name }} · {{ key.algorithm }}
</option></select
><small v-if="sshKeys.length === 0"
>请先关闭窗口并添加 SSH 私钥。</small
>还没有私钥?点击“新建或导入”,按照引导生成、粘贴或读取私钥文件。</small
></label
>
</div>
@@ -597,6 +611,104 @@ const {
</button>
</div>
<form @submit.prevent="saveSSHKey">
<section class="ssh-key-guide">
<div class="ssh-key-guide-heading">
<div>
<strong>不会准备 SSH 密钥?</strong>
<span>按下面三步操作,完成生成、安装公钥和录入私钥。</span>
</div>
<span class="guide-badge">新手引导</span>
</div>
<div class="ssh-key-steps">
<article>
<b>1</b>
<div>
<strong>在本机生成密钥</strong>
<span>打开 PowerShell、终端或命令提示符,复制下面的命令执行。</span>
</div>
</article>
<article>
<b>2</b>
<div>
<strong>把公钥放到服务器</strong>
<span>公钥放入服务器的授权文件,私钥不要粘贴到服务器。</span>
</div>
</article>
<article>
<b>3</b>
<div>
<strong>录入私钥并保存</strong>
<span>可以直接粘贴,也可以选择本机私钥文件,Scert 会加密保存。</span>
</div>
</article>
</div>
<div class="ssh-key-platforms" role="tablist" aria-label="密钥生成平台">
<button
class="platform-tab"
:class="{ active: sshKeyPlatform === 'windows' }"
type="button"
role="tab"
:aria-selected="sshKeyPlatform === 'windows'"
@click="sshKeyPlatform = 'windows'"
>
Windows
</button>
<button
class="platform-tab"
:class="{ active: sshKeyPlatform === 'linux' }"
type="button"
role="tab"
:aria-selected="sshKeyPlatform === 'linux'"
@click="sshKeyPlatform = 'linux'"
>
Linux / macOS
</button>
</div>
<div class="ssh-command-card">
<div class="ssh-command-heading">
<span>生成命令</span>
<button
class="inline-button"
type="button"
@click="
copySSHKeyCommand(
sshKeyCommands[sshKeyPlatform],
'密钥生成命令已复制'
)
"
>
复制命令
</button>
</div>
<code>{{ sshKeyCommands[sshKeyPlatform] }}</code>
</div>
<div class="ssh-command-card">
<div class="ssh-command-heading">
<span>安装公钥命令</span>
<button
class="inline-button"
type="button"
@click="
copySSHKeyCommand(
sshPublicKeyCommands[sshKeyPlatform],
'公钥安装命令已复制'
)
"
>
复制命令
</button>
</div>
<code>{{ sshPublicKeyCommands[sshKeyPlatform] }}</code>
<small>
Linux 服务器默认位置:<code>~/.ssh/authorized_keys</code>;Windows
OpenSSH 服务器请按照系统说明配置授权文件。
</small>
</div>
<p class="ssh-key-guide-note">
懒人方式:如果你能登录服务器控制台,只需执行生成命令,再把生成的
<code>.pub</code> 公钥内容追加到授权文件,最后在下方选择私钥文件即可。
</p>
</section>
<label class="field"
><span>私钥名称</span
><input
@@ -607,6 +719,10 @@ const {
placeholder="例如生产环境部署私钥"
autocomplete="off"
/></label>
<label class="field"
><span>读取本机私钥文件 <small>可选,读取后仍需点击加密保存</small></span
><input type="file" @change="importSSHKeyFile" /></label
>
<label class="field"
><span
>私钥内容
@@ -620,10 +736,18 @@ const {
></textarea>
</label>
<label class="field"
><span>私钥口令 <small>未加密私钥请留空</small></span
><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="password"
:type="sshKeyPassphraseVisible ? 'text' : 'password'"
maxlength="4096"
autocomplete="new-password"
/></label>
@@ -652,4 +776,4 @@ const {
</div>
</main>
</template>
<style scoped src="./Dashboard.css"></style>
<style scoped src="./Dashboard.css"></style>
+11 -5
View File
@@ -154,7 +154,7 @@ export function useSetupWizard(props, emit) {
}
const atIndex = rawValue.indexOf("@");
if (atIndex <= 0) {
if (atIndex < 0) {
emailLocalPart.value = rawValue;
form.value.admin_email = selectedEmailDomain.value && selectedEmailDomain.value !== "custom"
? `${rawValue}@${selectedEmailDomain.value}`
@@ -164,12 +164,18 @@ export function useSetupWizard(props, emit) {
const localPart = rawValue.slice(0, atIndex).trim();
const domain = rawValue.slice(atIndex + 1).trim().toLowerCase();
if (!localPart || !domain) {
emailLocalPart.value = rawValue;
selectedEmailDomain.value = "";
form.value.admin_email = rawValue;
return;
}
emailLocalPart.value = localPart;
selectedEmailDomain.value = commonEmailDomains.some(
(option) => option.value === domain,
)
? domain
: "custom";
(option) => option.value === domain && option.value !== "custom",
) ? domain : "custom";
form.value.admin_email = `${localPart}@${domain}`;
}
@@ -128,7 +128,7 @@ const {
type="text"
autocomplete="email"
inputmode="email"
placeholder="输入邮箱名称,例如 likb_blue"
placeholder="请输入邮箱名称"
/>
<select
id="admin-email-domain"