feat: Shell 类运行时显示 source 命令(继承环境变量)

- CommandCard 支持 primary/secondary 两种样式
- bash/zsh 使用 source <(curl URL),sh 使用 . <(curl URL),fish 使用 curl URL | source
- 非 Shell 类运行时(python3/node/ruby/php)不显示 source 命令

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-29 13:30:54 +08:00
parent ae4d361ebe
commit e3d380f9ab
4 changed files with 76 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { CreateScriptResponse } from '../types'
import { CreateScriptResponse, isShellRuntime, getSourceCommand } from '../types'
import CommandCard from './CommandCard'
interface Props {
@@ -8,6 +8,8 @@ interface Props {
export default function ResultCard({ result, onReset }: Props) {
const detailUrl = `${window.location.origin}/s/${result.id}`
const showSource = isShellRuntime(result.runtime)
const sourceCommand = showSource ? getSourceCommand(result.url, result.runtime) : null
return (
<div className="space-y-6">
@@ -18,6 +20,19 @@ export default function ResultCard({ result, onReset }: Props) {
<CommandCard command={result.command} />
{showSource && sourceCommand && (
<div>
<p className="text-xs text-gray-500 mb-2">
使 shell
</p>
<CommandCard
command={sourceCommand}
label="继承环境变量"
variant="secondary"
/>
</div>
)}
<div className="bg-gray-800/50 border border-gray-700 rounded-lg p-4 space-y-3">
<div className="flex justify-between text-sm">
<span className="text-gray-400"> ID</span>