chore: update ji branch work
This commit is contained in:
1 parent
6c30e649e3
commit
cbd07c9d1b
9 files changed
+188
-124
No files matched your search
@@ -257,6 +257,7 @@ function stripTimestampSuffix(title: string): string {
|
||||
}
|
||||
|
||||
const BODY_TAB_VALUE = "__body__";
|
||||
const HTML_TAB_VALUE = "__html__";
|
||||
const RUN_LIST_COLLAPSED_WIDTH = 56;
|
||||
const RUN_LIST_DEFAULT_WIDTH = 380;
|
||||
const RUN_LIST_MIN_WIDTH = 280;
|
||||
@@ -427,12 +428,8 @@ export default function PublicScheduledTaskPage() {
|
||||
className="relative flex min-h-0 shrink-0 transition-[width] duration-200 ease-out"
|
||||
style={{ width: visibleRunListWidth }}
|
||||
>
|
||||
<Card
|
||||
className={cn(
|
||||
"flex min-h-0 w-full flex-col overflow-hidden",
|
||||
!runListExpanded && "pointer-events-none [&>*]:invisible",
|
||||
)}
|
||||
>
|
||||
{runListExpanded ? (
|
||||
<Card className="flex min-h-0 w-full flex-col overflow-hidden">
|
||||
<CardHeader className="gap-1">
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<Tooltip>
|
||||
@@ -447,9 +444,21 @@ export default function PublicScheduledTaskPage() {
|
||||
</TooltipContent>
|
||||
)}
|
||||
</Tooltip>
|
||||
<Badge variant={task?.enabled ? "default" : "secondary"} className="shrink-0">
|
||||
{task?.enabled ? "启用" : "暂停"}
|
||||
</Badge>
|
||||
<div className="flex shrink-0 items-center gap-1">
|
||||
<Badge variant={task?.enabled ? "default" : "secondary"}>
|
||||
{task?.enabled ? "启用" : "暂停"}
|
||||
</Badge>
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="text-muted-foreground hover:text-primary size-7"
|
||||
onClick={collapseRunList}
|
||||
title="收起执行记录列表"
|
||||
aria-label="收起执行记录列表"
|
||||
>
|
||||
<ChevronLeft className="size-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{task?.description && task.description.trim() && (
|
||||
<p className="text-muted-foreground line-clamp-3 text-xs leading-relaxed break-all whitespace-pre-wrap">
|
||||
@@ -552,15 +561,20 @@ export default function PublicScheduledTaskPage() {
|
||||
</ScrollArea>
|
||||
</CardContent>
|
||||
</Card>
|
||||
<button
|
||||
type="button"
|
||||
onClick={runListExpanded ? collapseRunList : expandRunList}
|
||||
className="bg-background text-muted-foreground hover:bg-accent hover:text-primary focus-visible:ring-ring absolute top-3 left-1/2 z-30 flex size-9 -translate-x-1/2 items-center justify-center rounded-md border shadow-sm transition-colors focus:outline-none focus-visible:ring-2"
|
||||
title={runListExpanded ? "收起执行记录列表" : "展开执行记录列表"}
|
||||
aria-label={runListExpanded ? "收起执行记录列表" : "展开执行记录列表"}
|
||||
>
|
||||
{runListExpanded ? <ChevronLeft className="size-4" /> : <List className="size-4" />}
|
||||
</button>
|
||||
) : (
|
||||
<Card className="flex min-h-0 w-full flex-col items-center overflow-hidden py-3">
|
||||
<Button
|
||||
size="icon"
|
||||
variant="ghost"
|
||||
className="text-muted-foreground hover:text-primary"
|
||||
onClick={expandRunList}
|
||||
title="展开执行记录列表"
|
||||
aria-label="展开执行记录列表"
|
||||
>
|
||||
<List className="size-4" />
|
||||
</Button>
|
||||
</Card>
|
||||
)}
|
||||
<div
|
||||
role="separator"
|
||||
aria-orientation="vertical"
|
||||
@@ -638,12 +652,14 @@ export default function PublicScheduledTaskPage() {
|
||||
}
|
||||
|
||||
type ContentTab = {
|
||||
/** Stable tab identifier — `__body__` for inline content, `file-<index>` for files. */
|
||||
/** Stable tab identifier — `__html__` for the HTML preview, `__body__` for
|
||||
* inline content, `file-<index>` for files. */
|
||||
value: string;
|
||||
/** Short label rendered in the TabsTrigger. */
|
||||
label: string;
|
||||
/** Distinguishes body vs MD attachment so the editor knows which PUT to call. */
|
||||
kind: "body" | "file";
|
||||
/** Distinguishes the HTML preview vs body vs MD attachment so the renderer /
|
||||
* editor knows what to show and which PUT to call. */
|
||||
kind: "body" | "file" | "html";
|
||||
/** File index (when `kind === "file"`). */
|
||||
fileIndex?: number;
|
||||
/** Filename for downloads (defaults to the run title for body). */
|
||||
@@ -684,17 +700,27 @@ function RunDetailPane({ run, taskId }: { run: PublicRun; taskId: string }) {
|
||||
[run.result?.files],
|
||||
);
|
||||
|
||||
// Tabs: every MD file first (priority per spec), then the inline body.
|
||||
// Tabs: HTML preview first (when present), then every MD file, then the
|
||||
// inline body. For an HTML run that also produced a Markdown file, this keeps
|
||||
// the page preview AND surfaces the .md instead of hiding it. The generated
|
||||
// HTML document itself is never listed as a downloadable "file" tab — it has
|
||||
// its own preview.
|
||||
const tabs: ContentTab[] = useMemo(() => {
|
||||
const list: ContentTab[] = markdownFiles.map((file, idx) => ({
|
||||
value: `file-${file.index}`,
|
||||
// Show the actual filename without the `.md` suffix — the user explicitly
|
||||
// asked for "no '文件' label, just the name without extension".
|
||||
label: stripExtension(file.name) || `文件 ${idx + 1}`,
|
||||
kind: "file",
|
||||
fileIndex: file.index,
|
||||
fileName: file.name,
|
||||
}));
|
||||
const list: ContentTab[] = [];
|
||||
if (isHtmlRun) {
|
||||
list.push({ value: HTML_TAB_VALUE, label: "HTML 预览", kind: "html" });
|
||||
}
|
||||
list.push(
|
||||
...markdownFiles.map((file, idx) => ({
|
||||
value: `file-${file.index}`,
|
||||
// Show the actual filename without the `.md` suffix — the user explicitly
|
||||
// asked for "no '文件' label, just the name without extension".
|
||||
label: stripExtension(file.name) || `文件 ${idx + 1}`,
|
||||
kind: "file" as const,
|
||||
fileIndex: file.index,
|
||||
fileName: file.name,
|
||||
})),
|
||||
);
|
||||
list.push({
|
||||
value: BODY_TAB_VALUE,
|
||||
label: "正文",
|
||||
@@ -702,7 +728,7 @@ function RunDetailPane({ run, taskId }: { run: PublicRun; taskId: string }) {
|
||||
fileName: run.result?.title || "scheduled-task-result",
|
||||
});
|
||||
return list;
|
||||
}, [markdownFiles, run.result?.title]);
|
||||
}, [isHtmlRun, markdownFiles, run.result?.title]);
|
||||
|
||||
const [activeTab, setActiveTab] = useState<string>(tabs[0]?.value ?? BODY_TAB_VALUE);
|
||||
|
||||
@@ -843,13 +869,13 @@ function RunDetailPane({ run, taskId }: { run: PublicRun; taskId: string }) {
|
||||
下载原文件
|
||||
</a>
|
||||
)}
|
||||
{!isHtmlRun && (
|
||||
{activeTabMeta?.kind !== "html" && (
|
||||
<Button size="sm" variant="outline" onClick={handleDownloadWord}>
|
||||
<FileText className="size-4" />
|
||||
下载 Word
|
||||
</Button>
|
||||
)}
|
||||
{!isHtmlRun &&
|
||||
{activeTabMeta?.kind !== "html" &&
|
||||
(isEditing ? (
|
||||
<>
|
||||
<Button
|
||||
@@ -895,22 +921,7 @@ function RunDetailPane({ run, taskId }: { run: PublicRun; taskId: string }) {
|
||||
</CardHeader>
|
||||
|
||||
<CardContent className="min-h-0 flex-1 overflow-hidden p-0">
|
||||
{isHtmlRun ? (
|
||||
<div className="h-full p-4">
|
||||
{htmlContent ? (
|
||||
<iframe
|
||||
title="HTML 预览"
|
||||
sandbox="allow-same-origin"
|
||||
srcDoc={htmlContent}
|
||||
className="h-full min-h-[60vh] w-full rounded-md border bg-white"
|
||||
/>
|
||||
) : (
|
||||
<div className="text-muted-foreground rounded-md border p-3 text-sm">
|
||||
HTML 页面尚未生成或正在生成中。
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
) : tabs.length === 0 ? (
|
||||
{tabs.length === 0 ? (
|
||||
<div className="text-muted-foreground p-6 text-sm">无可用内容。</div>
|
||||
) : (
|
||||
<Tabs
|
||||
@@ -940,7 +951,20 @@ function RunDetailPane({ run, taskId }: { run: PublicRun; taskId: string }) {
|
||||
{run.error}
|
||||
</div>
|
||||
)}
|
||||
{fileIsLoading ? (
|
||||
{activeTabMeta?.kind === "html" ? (
|
||||
htmlContent ? (
|
||||
<iframe
|
||||
title="HTML 预览"
|
||||
sandbox="allow-same-origin"
|
||||
srcDoc={htmlContent}
|
||||
className="min-h-[60vh] w-full flex-1 rounded-md border bg-white"
|
||||
/>
|
||||
) : (
|
||||
<div className="text-muted-foreground rounded-md border p-3 text-sm">
|
||||
HTML 页面尚未生成或正在生成中。
|
||||
</div>
|
||||
)
|
||||
) : fileIsLoading ? (
|
||||
<div className="text-muted-foreground flex items-center gap-2 text-sm">
|
||||
<Loader2 className="size-4 animate-spin" />
|
||||
正在加载文件内容...
|
||||
|
||||
Reference in new issue
Block a user