feat: 增加登录页面的桌面和移动端支持,优化语言切换器和表单组件
Some checks failed
lotteryfront CI / build (push) Has been cancelled
Some checks failed
lotteryfront CI / build (push) Has been cancelled
This commit is contained in:
@@ -12,12 +12,14 @@ import { playerViewportPopoverMaxClass } from "@/lib/player-viewport";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface LanguageSwitcherProps {
|
||||
variant?: "default" | "header" | "minimal";
|
||||
variant?: "default" | "header" | "minimal" | "pill";
|
||||
/** 下拉相对触发器水平对齐:`start`=左对齐(适合左上角触发器),`end`=右对齐(适合顶栏右侧) */
|
||||
menuAlign?: "start" | "end";
|
||||
className?: string;
|
||||
showFlag?: boolean;
|
||||
showLabel?: boolean;
|
||||
/** 显示完整语言名(如「简体中文」),而非缩写 */
|
||||
useFullLabel?: boolean;
|
||||
}
|
||||
|
||||
export function LanguageSwitcher({
|
||||
@@ -26,6 +28,7 @@ export function LanguageSwitcher({
|
||||
className,
|
||||
showFlag = true,
|
||||
showLabel = true,
|
||||
useFullLabel = false,
|
||||
}: LanguageSwitcherProps) {
|
||||
const { i18n, t } = useTranslation("common");
|
||||
const active = normalizeLanguage(i18n.language) as AppLanguage;
|
||||
@@ -46,7 +49,9 @@ export function LanguageSwitcher({
|
||||
setIsOpen(false);
|
||||
}
|
||||
|
||||
const currentLabel = options.find((o) => o.code === active)?.short ?? active.toUpperCase();
|
||||
const currentLabel = useFullLabel
|
||||
? (options.find((o) => o.code === active)?.label ?? active.toUpperCase())
|
||||
: (options.find((o) => o.code === active)?.short ?? active.toUpperCase());
|
||||
const currentFlag = options.find((o) => o.code === active)?.flag ?? "";
|
||||
|
||||
const variantStyles = {
|
||||
@@ -68,12 +73,20 @@ export function LanguageSwitcher({
|
||||
item: "text-gray-800 hover:bg-gray-100",
|
||||
activeItem: "bg-red-50 text-red-600",
|
||||
},
|
||||
pill: {
|
||||
button:
|
||||
"rounded-full border border-gray-200 bg-white px-3 py-1.5 text-gray-600 shadow-sm hover:bg-gray-50",
|
||||
dropdown: "border border-gray-200 bg-white shadow-lg",
|
||||
item: "text-gray-800 hover:bg-gray-100",
|
||||
activeItem: "bg-red-50 text-red-600",
|
||||
},
|
||||
} as const;
|
||||
|
||||
const styles = variantStyles[variant];
|
||||
|
||||
const align =
|
||||
menuAlign ?? (variant === "header" || variant === "default" ? "start" : "end");
|
||||
menuAlign ??
|
||||
(variant === "pill" ? "end" : variant === "header" || variant === "default" ? "start" : "end");
|
||||
|
||||
return (
|
||||
<Popover open={isOpen} onOpenChange={setIsOpen}>
|
||||
|
||||
@@ -4,14 +4,13 @@ import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
|
||||
import { LanguageSwitcher } from "@/components/language-switcher";
|
||||
import { PlayerNotificationBell } from "@/components/layout/player-notification-bell";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
type PlayerDesktopHeaderProps = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
/** 全局顶栏:移动显示 Logo;桌面 Logo 在侧栏顶部,此处仅语言 + 通知 */
|
||||
/** 全局顶栏:移动显示 Logo;桌面 Logo 在侧栏顶部,此处仅语言切换 */
|
||||
export function PlayerDesktopHeader({ className }: PlayerDesktopHeaderProps) {
|
||||
return (
|
||||
<header
|
||||
@@ -38,8 +37,7 @@ export function PlayerDesktopHeader({ className }: PlayerDesktopHeaderProps) {
|
||||
showFlag={false}
|
||||
className="rounded-full border border-[#e4eaf4] bg-[#f8fafc] [&_button]:h-8 [&_button]:gap-1 [&_button]:px-2 [&_button]:text-xs lg:[&_button]:h-9 lg:[&_button]:gap-1.5 lg:[&_button]:px-3 lg:[&_button]:text-sm"
|
||||
/>
|
||||
<PlayerNotificationBell className="inline-flex size-9 items-center justify-center rounded-full border border-[#e4eaf4] bg-[#f8fafc] text-[#0b3f96]" />
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user