fix(teacher): 统一详情页返回路径与中英文文案 (P1-3+P2-1)
P1-3: empty-state 默认按钮 variant 改为 outline 并新增 variant prop;button.tsx 导出 ButtonProps;统一 5 个详情页返回路径为 ghost+ArrowLeft+文字标签;course-plan-detail raw a 改为 Link。P2-1: formatLongDate 默认 locale 改为 zh-CN,weekday 改为 short;返回按钮文案中文化;course-plan-detail 全量中文化;grades/analytics 标题中文化。验证:tsc 0 错误,lint 0 错误,架构图 004/005 已同步。
This commit is contained in:
@@ -34,16 +34,18 @@ const buttonVariants = cva(
|
||||
}
|
||||
)
|
||||
|
||||
type ButtonProps = React.ComponentProps<"button"> &
|
||||
VariantProps<typeof buttonVariants> & {
|
||||
asChild?: boolean
|
||||
}
|
||||
|
||||
function Button({
|
||||
className,
|
||||
variant,
|
||||
size,
|
||||
asChild = false,
|
||||
...props
|
||||
}: React.ComponentProps<"button"> &
|
||||
VariantProps<typeof buttonVariants> & {
|
||||
asChild?: boolean
|
||||
}) {
|
||||
}: ButtonProps) {
|
||||
const Comp = asChild ? Slot : "button"
|
||||
|
||||
return (
|
||||
@@ -55,4 +57,4 @@ function Button({
|
||||
)
|
||||
}
|
||||
|
||||
export { Button, buttonVariants }
|
||||
export { Button, buttonVariants, type ButtonProps }
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as React from "react"
|
||||
import Link from "next/link"
|
||||
import { cn } from "@/shared/lib/utils"
|
||||
import { Button } from "@/shared/components/ui/button"
|
||||
import type { ButtonProps } from "@/shared/components/ui/button"
|
||||
|
||||
interface EmptyStateProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
title: string
|
||||
@@ -11,6 +12,8 @@ interface EmptyStateProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
label: string
|
||||
onClick?: () => void
|
||||
href?: string
|
||||
/** 按钮样式,默认 "outline"(次级按钮)。首次引导场景可用 "default"(主按钮) */
|
||||
variant?: ButtonProps["variant"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,11 +47,11 @@ export function EmptyState({
|
||||
)}
|
||||
{action && (
|
||||
action.href ? (
|
||||
<Button asChild variant="default">
|
||||
<Button asChild variant={action.variant ?? "outline"}>
|
||||
<Link href={action.href}>{action.label}</Link>
|
||||
</Button>
|
||||
) : (
|
||||
<Button onClick={action.onClick} variant="default">
|
||||
<Button onClick={action.onClick} variant={action.variant ?? "outline"}>
|
||||
{action.label}
|
||||
</Button>
|
||||
)
|
||||
|
||||
@@ -13,6 +13,34 @@ export function formatDate(date: string | Date, locale: string = "zh-CN") {
|
||||
}).format(new Date(date))
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期+时间(含小时、分钟)。
|
||||
* 用于替代各处重复的 `new Date(x).toLocaleString("zh-CN", {...})` 调用。
|
||||
*/
|
||||
export function formatDateTime(date: string | Date, locale: string = "zh-CN") {
|
||||
return new Intl.DateTimeFormat(locale, {
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
}).format(new Date(date))
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化为长日期(含星期、完整月份名)。
|
||||
* 用于替代 `new Date(x).toLocaleDateString("en-US", { weekday: "long", year: "numeric", month: "long", day: "numeric" })`。
|
||||
* 默认使用中文 locale,输出形如「2026年6月20日 周一」。
|
||||
*/
|
||||
export function formatLongDate(date: string | Date, locale: string = "zh-CN") {
|
||||
return new Intl.DateTimeFormat(locale, {
|
||||
weekday: "short",
|
||||
year: "numeric",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
}).format(new Date(date))
|
||||
}
|
||||
|
||||
/** Next.js App Router 搜索参数类型 */
|
||||
export type SearchParams = { [key: string]: string | string[] | undefined }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user