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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user