feat: statusline support script

This commit is contained in:
musistudio
2025-08-17 00:25:22 +08:00
parent d2969e4332
commit d6b11e1b60
5 changed files with 123 additions and 19 deletions

View File

@@ -50,6 +50,7 @@ const MODULE_TYPES = [
{ label: "gitBranch", value: "gitBranch" },
{ label: "model", value: "model" },
{ label: "usage", value: "usage" },
{ label: "script", value: "script" },
];
// ANSI颜色代码映射
@@ -675,6 +676,15 @@ export function StatusLineConfigDialog({
color: "bright_magenta",
};
break;
case "script":
newModule = {
type: "script",
icon: "📜",
text: "Script Module",
color: "bright_cyan",
scriptPath: "",
};
break;
default:
newModule = { ...DEFAULT_MODULE, type: moduleType };
}
@@ -920,6 +930,31 @@ export function StatusLineConfigDialog({
</p>
</div>
{/* Script Path 输入框 - 仅在type为script时显示 */}
{selectedModule.type === "script" && (
<div className="space-y-2">
<Label htmlFor="module-script-path">
</Label>
<Input
id="module-script-path"
value={selectedModule.scriptPath || ""}
onChange={(e) =>
handleModuleChange(
selectedModuleIndex,
"scriptPath",
e.target.value
)
}
placeholder="例如: /path/to/your/script.js"
/>
<p className="text-xs text-muted-foreground">
Node.js脚本文件的绝对路径
</p>
</div>
)}
<Button
variant="destructive"
size="sm"

View File

@@ -135,6 +135,7 @@
"gitBranch": "Git Branch",
"model": "Model",
"usage": "Usage",
"script": "Script",
"background_none": "None",
"color_black": "Black",
"color_red": "Red",

View File

@@ -135,6 +135,7 @@
"gitBranch": "Git分支",
"model": "模型",
"usage": "使用情况",
"script": "脚本",
"background_none": "无",
"color_black": "黑色",
"color_red": "红色",

View File

@@ -33,6 +33,7 @@ export interface StatusLineModuleConfig {
text: string;
color?: string;
background?: string;
scriptPath?: string; // 用于script类型的模块指定要执行的Node.js脚本文件路径
}
export interface StatusLineThemeConfig {