合并服务器配置与部署命令流程
将服务器连接、证书路径、校验命令和重载命令统一到同一表单,并优化 SSH 引导布局。
This commit is contained in:
parent
6e43d5e3a2
commit
7b9329433a
@ -596,7 +596,7 @@ test("serverModal.compilesAndPreservesDeploymentFields", async () => {
|
|||||||
assert.match(html, /value="22"/);
|
assert.match(html, /value="22"/);
|
||||||
assert.match(html, /min="1"/);
|
assert.match(html, /min="1"/);
|
||||||
assert.match(html, /max="65535"/);
|
assert.match(html, /max="65535"/);
|
||||||
assert.equal((html.match(/class="test-help-tip"/g) || []).length, 4);
|
assert.equal((html.match(/class="test-help-tip"/g) || []).length, 5);
|
||||||
for (const path of ["/test/cert.pem", "/test/fullchain.pem", "/test/key.pem"]) {
|
for (const path of ["/test/cert.pem", "/test/fullchain.pem", "/test/key.pem"]) {
|
||||||
assert.ok(html.includes(path));
|
assert.ok(html.includes(path));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,24 +17,62 @@
|
|||||||
.server-modal form {
|
.server-modal form {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
gap: 0 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.server-modal form > .form-grid,
|
|
||||||
.server-modal form > .field {
|
|
||||||
grid-column: span 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.server-modal .form-grid {
|
|
||||||
gap: 14px;
|
gap: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.server-modal .server-form-section {
|
||||||
|
display: grid;
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
gap: 0 18px;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 14px 0 4px;
|
||||||
|
border-top: 1px solid #dce6f1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-modal .server-form-section:first-child {
|
||||||
|
padding-top: 2px;
|
||||||
|
border-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-modal .server-form-section-heading,
|
||||||
|
.server-modal .server-form-grid,
|
||||||
.server-modal .server-paths,
|
.server-modal .server-paths,
|
||||||
.server-modal .form-error,
|
.server-modal .form-error,
|
||||||
.server-modal .modal-actions {
|
.server-modal .modal-actions {
|
||||||
grid-column: 1 / -1;
|
grid-column: 1 / -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.server-modal .server-form-section-heading {
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-start;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-modal .server-form-section-heading h3 {
|
||||||
|
margin: 2px 0 0;
|
||||||
|
color: #214d86;
|
||||||
|
font-size: 17px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-modal .server-form-heading-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-modal .server-form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
gap: 0 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-modal .server-form-field-wide {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
.server-modal .server-paths {
|
.server-modal .server-paths {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
@ -75,29 +113,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.server-modal .server-ssh-key-guide {
|
.server-modal .server-ssh-key-guide {
|
||||||
grid-column: 1 / -1;
|
margin: 0;
|
||||||
min-width: 0;
|
|
||||||
margin: 2px 0 8px;
|
|
||||||
padding: 14px;
|
padding: 14px;
|
||||||
border: 1px solid #c7daf1;
|
border: 1px solid #c7daf1;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
background: #f5f9ff;
|
background: #f5f9ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.server-modal .server-ssh-key-heading {
|
|
||||||
display: flex;
|
|
||||||
align-items: flex-start;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 16px;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.server-modal .server-ssh-key-heading h3 {
|
|
||||||
margin: 2px 0 4px;
|
|
||||||
color: #214d86;
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.server-modal .server-ssh-key-guide .ssh-key-steps {
|
.server-modal .server-ssh-key-guide .ssh-key-steps {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
@ -229,13 +251,17 @@
|
|||||||
border-top: 1px solid #d1e0f1;
|
border-top: 1px solid #d1e0f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.server-modal .server-command-section textarea {
|
||||||
|
min-height: 82px;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 900px) {
|
@media (max-width: 900px) {
|
||||||
.server-modal form {
|
.server-modal form {
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
.server-modal form > .field {
|
.server-modal .server-form-section {
|
||||||
grid-column: span 1;
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
}
|
}
|
||||||
|
|
||||||
.server-modal .server-paths {
|
.server-modal .server-paths {
|
||||||
@ -253,12 +279,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.server-modal form,
|
.server-modal form,
|
||||||
.server-modal .form-grid {
|
.server-modal .server-form-section,
|
||||||
|
.server-modal .server-form-grid {
|
||||||
grid-template-columns: minmax(0, 1fr);
|
grid-template-columns: minmax(0, 1fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
.server-modal form > .form-grid,
|
.server-modal .server-form-section,
|
||||||
.server-modal form > .field {
|
.server-modal .server-form-section-heading,
|
||||||
|
.server-modal .server-form-grid,
|
||||||
|
.server-modal .server-form-field-wide {
|
||||||
grid-column: 1 / -1;
|
grid-column: 1 / -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,103 +61,130 @@ const {
|
|||||||
×
|
×
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form @submit.prevent="saveServer">
|
<form class="server-form" @submit.prevent="saveServer">
|
||||||
<div class="form-grid">
|
<section class="server-form-section">
|
||||||
<label class="field"
|
<div class="server-form-section-heading">
|
||||||
><span>服务器名称</span
|
<div>
|
||||||
><input
|
<p class="eyebrow">服务器配置</p>
|
||||||
v-model="serverForm.name"
|
<h3>基本信息与连接方式</h3>
|
||||||
required
|
</div>
|
||||||
type="text"
|
<HelpTip>
|
||||||
placeholder="例如生产 Nginx" /></label
|
这里的内容、SSH 认证方式、证书路径和服务命令会作为同一台部署服务器的完整配置保存。
|
||||||
><label class="field"
|
</HelpTip>
|
||||||
><span>网站服务</span
|
</div>
|
||||||
><select v-model="serverForm.web_server">
|
<div class="server-form-grid">
|
||||||
<option value="nginx">Nginx</option>
|
<label class="field">
|
||||||
<option value="caddy">Caddy</option>
|
<span>服务器名称</span>
|
||||||
<option value="apache">Apache</option>
|
<input
|
||||||
<option value="custom">自定义</option>
|
v-model="serverForm.name"
|
||||||
</select></label
|
required
|
||||||
>
|
type="text"
|
||||||
</div>
|
placeholder="例如生产 Nginx"
|
||||||
<div class="form-grid">
|
/>
|
||||||
<label class="field"
|
</label>
|
||||||
><span>服务器地址</span
|
<label class="field">
|
||||||
><input
|
<span>网站服务</span>
|
||||||
v-model="serverForm.address"
|
<select v-model="serverForm.web_server">
|
||||||
required
|
<option value="nginx">Nginx</option>
|
||||||
type="text"
|
<option value="caddy">Caddy</option>
|
||||||
placeholder="IP 或主机名" /></label
|
<option value="apache">Apache</option>
|
||||||
><label class="field"
|
<option value="custom">自定义</option>
|
||||||
><span>SSH 端口</span
|
</select>
|
||||||
><input
|
</label>
|
||||||
v-model.number="serverForm.port"
|
<label class="field">
|
||||||
required
|
<span>服务器地址</span>
|
||||||
type="number"
|
<input
|
||||||
min="1"
|
v-model="serverForm.address"
|
||||||
max="65535"
|
required
|
||||||
/></label>
|
type="text"
|
||||||
</div>
|
placeholder="IP 或主机名"
|
||||||
<div class="form-grid">
|
/>
|
||||||
<label class="field"
|
</label>
|
||||||
><span>SSH 用户</span
|
<label class="field">
|
||||||
><input
|
<span>SSH 端口</span>
|
||||||
v-model="serverForm.username"
|
<input
|
||||||
required
|
v-model.number="serverForm.port"
|
||||||
type="text" /></label
|
required
|
||||||
><label class="field"
|
type="number"
|
||||||
><span>认证方式</span
|
min="1"
|
||||||
><select v-model="serverForm.auth_method">
|
max="65535"
|
||||||
<option value="password">SSH 密码</option>
|
/>
|
||||||
<option value="private_key">SSH 私钥</option>
|
</label>
|
||||||
</select></label
|
<label class="field">
|
||||||
>
|
<span>SSH 用户</span>
|
||||||
</div>
|
<input v-model="serverForm.username" required type="text" />
|
||||||
<label v-if="serverForm.auth_method === 'password'" class="field">
|
</label>
|
||||||
<span>SSH 密码</span>
|
<label class="field">
|
||||||
<input
|
<span>认证方式</span>
|
||||||
v-model="serverForm.password"
|
<select v-model="serverForm.auth_method">
|
||||||
type="password"
|
<option value="password">SSH 密码</option>
|
||||||
:required="!serverEditingId || !serverForm.passwordConfigured"
|
<option value="private_key">SSH 私钥</option>
|
||||||
autocomplete="new-password"
|
</select>
|
||||||
placeholder="编辑时留空表示保留原密码"
|
</label>
|
||||||
/>
|
<label v-if="serverForm.auth_method === 'password'" class="field server-form-field-wide">
|
||||||
</label>
|
<span>SSH 密码</span>
|
||||||
<div v-else class="form-grid">
|
<input
|
||||||
<label class="field"
|
v-model="serverForm.password"
|
||||||
><span class="field-label-row"
|
type="password"
|
||||||
><span>SSH 私钥</span
|
:required="!serverEditingId || !serverForm.passwordConfigured"
|
||||||
><button
|
autocomplete="new-password"
|
||||||
class="inline-button"
|
placeholder="编辑时留空表示保留原密码"
|
||||||
type="button"
|
/>
|
||||||
@click="openSSHKeyCreate({ embedded: true })"
|
</label>
|
||||||
>
|
<label v-else class="field server-form-field-wide">
|
||||||
新建或导入
|
<span class="field-label-row">
|
||||||
</button></span
|
<span>SSH 私钥</span>
|
||||||
><select v-model="serverForm.private_key_ref" required>
|
<button
|
||||||
<option value="">请选择已加密保存的私钥</option>
|
class="inline-button"
|
||||||
<option
|
type="button"
|
||||||
v-for="key in sshKeys"
|
@click="openSSHKeyCreate({ embedded: true })"
|
||||||
:key="key.id"
|
>
|
||||||
:value="key.reference"
|
新建或导入
|
||||||
>
|
</button>
|
||||||
{{ key.name }} · {{ key.algorithm }}
|
</span>
|
||||||
</option></select
|
<select v-model="serverForm.private_key_ref" required>
|
||||||
><HelpTip v-if="sshKeys.length === 0"
|
<option value="">请选择已加密保存的私钥</option>
|
||||||
>还没有私钥?点击“新建或导入”,按照引导生成、粘贴或读取私钥文件。</HelpTip
|
<option
|
||||||
></label
|
v-for="key in sshKeys"
|
||||||
>
|
:key="key.id"
|
||||||
</div>
|
:value="key.reference"
|
||||||
<section v-if="showEmbeddedSSHKeyGuide" class="server-ssh-key-guide">
|
>
|
||||||
<div class="server-ssh-key-heading">
|
{{ key.name }} · {{ key.algorithm }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<HelpTip v-if="sshKeys.length === 0">
|
||||||
|
还没有私钥?点击“新建或导入”,按照引导生成、粘贴或读取私钥文件。
|
||||||
|
</HelpTip>
|
||||||
|
</label>
|
||||||
|
<label class="field server-form-field-wide">
|
||||||
|
<span>
|
||||||
|
SSH 主机 SHA256 指纹
|
||||||
|
<HelpTip>请填写通过可信渠道核对过的服务器主机指纹,避免连接到错误的服务器。</HelpTip>
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
v-model="serverForm.host_key_fingerprint"
|
||||||
|
required
|
||||||
|
type="text"
|
||||||
|
placeholder="SHA256:..."
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section v-if="showEmbeddedSSHKeyGuide" class="server-form-section server-ssh-key-guide">
|
||||||
|
<div class="server-form-section-heading">
|
||||||
<div>
|
<div>
|
||||||
<p class="eyebrow">当前服务器</p>
|
<p class="eyebrow">当前服务器</p>
|
||||||
<h3>在这里准备 SSH 私钥</h3>
|
<h3>准备 SSH 私钥</h3>
|
||||||
<span class="muted">准备完成后会自动选中,不需要离开服务器配置。</span>
|
</div>
|
||||||
|
<div class="server-form-heading-actions">
|
||||||
|
<HelpTip>
|
||||||
|
按顺序执行命令后读取本机私钥,保存后会自动选中到当前服务器配置。
|
||||||
|
</HelpTip>
|
||||||
|
<button class="inline-button" type="button" @click="closeSSHKeyForm">
|
||||||
|
收起引导
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="inline-button" type="button" @click="closeSSHKeyForm">
|
|
||||||
收起引导
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="ssh-key-steps">
|
<div class="ssh-key-steps">
|
||||||
<article>
|
<article>
|
||||||
@ -275,72 +302,84 @@ const {
|
|||||||
</div>
|
</div>
|
||||||
<p v-if="sshKeyFormError" class="form-error">{{ sshKeyFormError }}</p>
|
<p v-if="sshKeyFormError" class="form-error">{{ sshKeyFormError }}</p>
|
||||||
<div class="server-ssh-key-actions">
|
<div class="server-ssh-key-actions">
|
||||||
<span class="muted">私钥只会加密保存,服务器配置仅保存安全引用。</span>
|
<HelpTip>私钥会加密保存,服务器配置中只保存安全引用。</HelpTip>
|
||||||
<button class="primary-button" type="button" :disabled="sshKeySaving" @click="saveSSHKey">
|
<button class="primary-button" type="button" :disabled="sshKeySaving" @click="saveSSHKey">
|
||||||
{{ sshKeySaving ? "加密保存中……" : "加密保存并用于当前服务器" }}
|
{{ sshKeySaving ? "加密保存中……" : "加密保存并用于当前服务器" }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<label class="field"
|
|
||||||
><span>SSH 主机 SHA256 指纹</span
|
|
||||||
><input
|
|
||||||
v-model="serverForm.host_key_fingerprint"
|
|
||||||
required
|
|
||||||
type="text"
|
|
||||||
placeholder="SHA256:..."
|
|
||||||
/></label>
|
|
||||||
<div class="server-paths">
|
|
||||||
<label class="field"
|
|
||||||
><span>远程证书路径</span
|
|
||||||
><input
|
|
||||||
v-model="serverForm.certificate_path"
|
|
||||||
required
|
|
||||||
type="text"
|
|
||||||
:placeholder="defaultCertificatePath"
|
|
||||||
/></label>
|
|
||||||
<label class="field"
|
|
||||||
><span>远程完整证书链路径</span
|
|
||||||
><input
|
|
||||||
v-model="serverForm.certificate_chain_path"
|
|
||||||
required
|
|
||||||
type="text"
|
|
||||||
:placeholder="defaultCertificateChainPath"
|
|
||||||
/></label>
|
|
||||||
<label class="field"
|
|
||||||
><span>远程私钥路径 <HelpTip>
|
|
||||||
保存的是路径模板,部署时会将 {域名} 和 {证书类型}
|
|
||||||
替换为实际值。证书类型目录固定为 single、wildcard 或 san。
|
|
||||||
</HelpTip></span
|
|
||||||
><input
|
|
||||||
v-model="serverForm.private_key_path"
|
|
||||||
required
|
|
||||||
type="text"
|
|
||||||
:placeholder="defaultPrivateKeyPath"
|
|
||||||
/></label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<label class="field"
|
<section class="server-form-section">
|
||||||
><span
|
<div class="server-form-section-heading">
|
||||||
>配置校验命令
|
<div>
|
||||||
<HelpTip
|
<p class="eyebrow">证书部署</p>
|
||||||
>每行一个参数;Nginx、Caddy、Apache 留空使用默认命令,自定义服务必须填写</HelpTip
|
<h3>远程文件路径</h3>
|
||||||
></span
|
</div>
|
||||||
><textarea
|
<HelpTip>
|
||||||
v-model="serverForm.validation_command"
|
路径支持 {域名} 和 {证书类型} 占位符,部署时会替换为实际目录。
|
||||||
rows="2"
|
</HelpTip>
|
||||||
placeholder="nginx -t"
|
</div>
|
||||||
></textarea>
|
<div class="server-paths">
|
||||||
</label>
|
<label class="field">
|
||||||
<label class="field"
|
<span>远程证书路径</span>
|
||||||
><span
|
<input
|
||||||
>重载命令
|
v-model="serverForm.certificate_path"
|
||||||
<HelpTip>每行一个参数;留空使用网站服务默认命令</HelpTip></span
|
required
|
||||||
><textarea
|
type="text"
|
||||||
v-model="serverForm.reload_command"
|
:placeholder="defaultCertificatePath"
|
||||||
rows="2"
|
/>
|
||||||
placeholder="nginx -s reload"
|
</label>
|
||||||
></textarea>
|
<label class="field">
|
||||||
</label>
|
<span>远程完整证书链路径</span>
|
||||||
|
<input
|
||||||
|
v-model="serverForm.certificate_chain_path"
|
||||||
|
required
|
||||||
|
type="text"
|
||||||
|
:placeholder="defaultCertificateChainPath"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label class="field">
|
||||||
|
<span>远程私钥路径</span>
|
||||||
|
<input
|
||||||
|
v-model="serverForm.private_key_path"
|
||||||
|
required
|
||||||
|
type="text"
|
||||||
|
:placeholder="defaultPrivateKeyPath"
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="server-form-section server-command-section">
|
||||||
|
<div class="server-form-section-heading">
|
||||||
|
<div>
|
||||||
|
<p class="eyebrow">部署命令</p>
|
||||||
|
<h3>服务校验与重载</h3>
|
||||||
|
</div>
|
||||||
|
<HelpTip>
|
||||||
|
每行填写一个命令参数;标准 Nginx、Caddy、Apache 可以留空使用默认命令,自定义服务需要填写。
|
||||||
|
</HelpTip>
|
||||||
|
</div>
|
||||||
|
<div class="server-form-grid">
|
||||||
|
<label class="field">
|
||||||
|
<span>配置校验命令</span>
|
||||||
|
<textarea
|
||||||
|
v-model="serverForm.validation_command"
|
||||||
|
rows="2"
|
||||||
|
placeholder="nginx -t"
|
||||||
|
></textarea>
|
||||||
|
</label>
|
||||||
|
<label class="field">
|
||||||
|
<span>重载命令</span>
|
||||||
|
<textarea
|
||||||
|
v-model="serverForm.reload_command"
|
||||||
|
rows="2"
|
||||||
|
placeholder="nginx -s reload"
|
||||||
|
></textarea>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<p v-if="serverFormError" class="form-error">{{ serverFormError }}</p>
|
<p v-if="serverFormError" class="form-error">{{ serverFormError }}</p>
|
||||||
<div class="modal-actions">
|
<div class="modal-actions">
|
||||||
<button
|
<button
|
||||||
@ -349,13 +388,10 @@ const {
|
|||||||
:disabled="serverSaving"
|
:disabled="serverSaving"
|
||||||
@click="closeServerForm"
|
@click="closeServerForm"
|
||||||
>
|
>
|
||||||
取消</button
|
取消
|
||||||
><button
|
</button>
|
||||||
class="primary-button"
|
<button class="primary-button" type="submit" :disabled="serverSaving">
|
||||||
type="submit"
|
{{ serverSaving ? "保存中……" : "保存服务器配置" }}
|
||||||
:disabled="serverSaving"
|
|
||||||
>
|
|
||||||
{{ serverSaving ? "保存中……" : "保存服务器" }}
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user