mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 01:36:37 +08:00
[新增] 添加 Docker 安装命令构建逻辑并更新节点详情页面
This commit is contained in:
@@ -51,6 +51,7 @@ import {
|
|||||||
} from '@/lib/utils/metrics';
|
} from '@/lib/utils/metrics';
|
||||||
import {
|
import {
|
||||||
buildNodeInstallCommand,
|
buildNodeInstallCommand,
|
||||||
|
buildNodeDockerInstallCommand,
|
||||||
getApplyLabel,
|
getApplyLabel,
|
||||||
getApplyVariant,
|
getApplyVariant,
|
||||||
getNodeStatusLabel,
|
getNodeStatusLabel,
|
||||||
@@ -541,6 +542,10 @@ export function NodeDetailPage({ nodeId }: { nodeId: string }) {
|
|||||||
normalizedServerUrl && node.agent_token
|
normalizedServerUrl && node.agent_token
|
||||||
? buildNodeInstallCommand(normalizedServerUrl, node.agent_token)
|
? buildNodeInstallCommand(normalizedServerUrl, node.agent_token)
|
||||||
: '';
|
: '';
|
||||||
|
const nodeDockerInstallCommand =
|
||||||
|
normalizedServerUrl && node.agent_token
|
||||||
|
? buildNodeDockerInstallCommand(normalizedServerUrl, node.agent_token)
|
||||||
|
: '';
|
||||||
const updateMode = getUpdateMode(node);
|
const updateMode = getUpdateMode(node);
|
||||||
const selectedAgentRelease =
|
const selectedAgentRelease =
|
||||||
selectedReleaseChannel === 'preview'
|
selectedReleaseChannel === 'preview'
|
||||||
@@ -1536,19 +1541,34 @@ export function NodeDetailPage({ nodeId }: { nodeId: string }) {
|
|||||||
<AppCard
|
<AppCard
|
||||||
title="节点标识与部署"
|
title="节点标识与部署"
|
||||||
action={
|
action={
|
||||||
nodeInstallCommand ? (
|
<div className="flex gap-2">
|
||||||
<PrimaryButton
|
{nodeInstallCommand ? (
|
||||||
type="button"
|
<PrimaryButton
|
||||||
onClick={() =>
|
type="button"
|
||||||
void handleCopy(
|
onClick={() =>
|
||||||
nodeInstallCommand,
|
void handleCopy(
|
||||||
'节点专属部署命令已复制。',
|
nodeInstallCommand,
|
||||||
)
|
'脚本部署命令已复制。',
|
||||||
}
|
)
|
||||||
>
|
}
|
||||||
复制部署命令
|
>
|
||||||
</PrimaryButton>
|
复制脚本命令
|
||||||
) : null
|
</PrimaryButton>
|
||||||
|
) : null}
|
||||||
|
{nodeDockerInstallCommand ? (
|
||||||
|
<PrimaryButton
|
||||||
|
type="button"
|
||||||
|
onClick={() =>
|
||||||
|
void handleCopy(
|
||||||
|
nodeDockerInstallCommand,
|
||||||
|
'Docker 部署命令已复制。',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
复制 Docker 命令
|
||||||
|
</PrimaryButton>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
@@ -1582,9 +1602,21 @@ export function NodeDetailPage({ nodeId }: { nodeId: string }) {
|
|||||||
</ResourceField>
|
</ResourceField>
|
||||||
|
|
||||||
{nodeInstallCommand ? (
|
{nodeInstallCommand ? (
|
||||||
<CodeBlock className="whitespace-pre-wrap">
|
<div>
|
||||||
{nodeInstallCommand}
|
<p className="mb-2 text-sm font-medium text-[var(--foreground-primary)]">脚本部署 (Linux / macOS)</p>
|
||||||
</CodeBlock>
|
<CodeBlock className="whitespace-pre-wrap">
|
||||||
|
{nodeInstallCommand}
|
||||||
|
</CodeBlock>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
{nodeDockerInstallCommand ? (
|
||||||
|
<div>
|
||||||
|
<p className="mb-2 text-sm font-medium text-[var(--foreground-primary)]">Docker 部署</p>
|
||||||
|
<CodeBlock className="whitespace-pre-wrap">
|
||||||
|
{nodeDockerInstallCommand}
|
||||||
|
</CodeBlock>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</AppCard>
|
</AppCard>
|
||||||
|
|||||||
@@ -167,3 +167,13 @@ export function buildNodeInstallCommand(serverUrl: string, agentToken: string) {
|
|||||||
` --agent-token ${agentToken}`,
|
` --agent-token ${agentToken}`,
|
||||||
].join('\n');
|
].join('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function buildNodeDockerInstallCommand(serverUrl: string, agentToken: string) {
|
||||||
|
return [
|
||||||
|
`docker run -d --name openflare-agent --restart unless-stopped \\`,
|
||||||
|
` -p 80:80 -p 443:443 -p 127.0.0.1:18081:18081 \\`,
|
||||||
|
` -e OPENFLARE_SERVER_URL=${serverUrl} \\`,
|
||||||
|
` -e OPENFLARE_AGENT_TOKEN=${agentToken} \\`,
|
||||||
|
` ghcr.io/rain-kl/openflare-agent:latest`
|
||||||
|
].join('\n');
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user