feat: 本次提交更新内容如下
好友选择样式完成
This commit is contained in:
@@ -2,25 +2,12 @@ import React from 'react';
|
|||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import BottomNav from './BottomNav';
|
import BottomNav from './BottomNav';
|
||||||
|
|
||||||
// 不需要底部导航的页面路径
|
// 配置需要底部导航的页面路径(白名单)
|
||||||
const NO_BOTTOM_NAV_PATHS = [
|
const BOTTOM_NAV_CONFIG = [
|
||||||
'/login',
|
'/', // 首页
|
||||||
'/register',
|
'/scenarios', // 场景获客
|
||||||
'/forgot-password',
|
'/workspace', // 工作台
|
||||||
'/reset-password',
|
'/profile', // 我的
|
||||||
'/devices',
|
|
||||||
'/devices/',
|
|
||||||
'/wechat-accounts',
|
|
||||||
'/wechat-accounts/',
|
|
||||||
'/scenarios/new',
|
|
||||||
'/scenarios/',
|
|
||||||
'/plans/',
|
|
||||||
'/workspace/auto-group/',
|
|
||||||
'/workspace/moments-sync/',
|
|
||||||
'/workspace/traffic-distribution/',
|
|
||||||
'/workspace/auto-like',
|
|
||||||
'/404',
|
|
||||||
'/500'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
interface LayoutWrapperProps {
|
interface LayoutWrapperProps {
|
||||||
@@ -31,16 +18,20 @@ export default function LayoutWrapper({ children }: LayoutWrapperProps) {
|
|||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
// 检查当前路径是否需要底部导航
|
// 检查当前路径是否需要底部导航
|
||||||
const shouldShowBottomNav = !NO_BOTTOM_NAV_PATHS.some(path =>
|
const shouldShowBottomNav = BOTTOM_NAV_CONFIG.some(path => {
|
||||||
location.pathname.startsWith(path)
|
// 特殊处理首页路由 '/'
|
||||||
);
|
if (path === '/') {
|
||||||
|
return location.pathname === '/';
|
||||||
|
}
|
||||||
|
return location.pathname === path;
|
||||||
|
});
|
||||||
|
|
||||||
// 如果是登录页面,直接渲染内容(不显示底部导航)
|
// 如果是登录页面,直接渲染内容(不显示底部导航)
|
||||||
if (location.pathname === '/login') {
|
if (location.pathname === '/login') {
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 其他页面显示底部导航
|
// 只有在配置列表中的页面才显示底部导航
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-screen">
|
<div className="flex flex-col h-screen">
|
||||||
<div className="flex-1 overflow-y-auto">
|
<div className="flex-1 overflow-y-auto">
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
|
|
||||||
interface CheckboxProps {
|
interface CheckboxProps {
|
||||||
checked?: boolean;
|
checked?: boolean;
|
||||||
|
onCheckedChange?: (checked: boolean) => void;
|
||||||
onChange?: (checked: boolean) => void;
|
onChange?: (checked: boolean) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
@@ -10,17 +11,24 @@ interface CheckboxProps {
|
|||||||
|
|
||||||
export function Checkbox({
|
export function Checkbox({
|
||||||
checked = false,
|
checked = false,
|
||||||
|
onCheckedChange,
|
||||||
onChange,
|
onChange,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
className = '',
|
className = '',
|
||||||
id
|
id
|
||||||
}: CheckboxProps) {
|
}: CheckboxProps) {
|
||||||
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const newChecked = e.target.checked;
|
||||||
|
onCheckedChange?.(newChecked);
|
||||||
|
onChange?.(newChecked);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id={id}
|
id={id}
|
||||||
checked={checked}
|
checked={checked}
|
||||||
onChange={(e) => onChange?.(e.target.checked)}
|
onChange={handleChange}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2 ${className}`}
|
className={`w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500 focus:ring-2 ${className}`}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -4,30 +4,45 @@ interface InputProps {
|
|||||||
value?: string;
|
value?: string;
|
||||||
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||||
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
onKeyDown?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
||||||
|
onClick?: (e: React.MouseEvent<HTMLInputElement>) => void;
|
||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
readOnly?: boolean;
|
readOnly?: boolean;
|
||||||
|
readonly?: boolean;
|
||||||
id?: string;
|
id?: string;
|
||||||
|
type?: string;
|
||||||
|
min?: number;
|
||||||
|
max?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Input({
|
export function Input({
|
||||||
value,
|
value,
|
||||||
onChange,
|
onChange,
|
||||||
onKeyDown,
|
onKeyDown,
|
||||||
|
onClick,
|
||||||
placeholder,
|
placeholder,
|
||||||
className = '',
|
className = '',
|
||||||
readOnly = false,
|
readOnly = false,
|
||||||
id
|
readonly = false,
|
||||||
|
id,
|
||||||
|
type = 'text',
|
||||||
|
min,
|
||||||
|
max
|
||||||
}: InputProps) {
|
}: InputProps) {
|
||||||
|
const isReadOnly = readOnly || readonly;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<input
|
<input
|
||||||
id={id}
|
id={id}
|
||||||
type="text"
|
type={type}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onKeyDown={onKeyDown}
|
onKeyDown={onKeyDown}
|
||||||
|
onClick={onClick}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
readOnly={readOnly}
|
readOnly={isReadOnly}
|
||||||
|
min={min}
|
||||||
|
max={max}
|
||||||
className={`flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${className}`}
|
className={`flex h-10 w-full rounded-md border border-gray-300 bg-white px-3 py-2 text-sm ring-offset-white file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-gray-500 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ${className}`}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
44
nkebao/src/components/ui/radio-group.tsx
Normal file
44
nkebao/src/components/ui/radio-group.tsx
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
|
||||||
|
import { Circle } from "lucide-react"
|
||||||
|
|
||||||
|
import { cn } from "@/utils"
|
||||||
|
|
||||||
|
const RadioGroup = React.forwardRef<
|
||||||
|
React.ElementRef<typeof RadioGroupPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
||||||
|
>(({ className, ...props }, ref) => {
|
||||||
|
return (
|
||||||
|
<RadioGroupPrimitive.Root
|
||||||
|
className={cn("grid gap-2", className)}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
|
||||||
|
|
||||||
|
const RadioGroupItem = React.forwardRef<
|
||||||
|
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
||||||
|
>(({ className, ...props }, ref) => {
|
||||||
|
return (
|
||||||
|
<RadioGroupPrimitive.Item
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
|
||||||
|
<Circle className="h-2.5 w-2.5 fill-current text-current" />
|
||||||
|
</RadioGroupPrimitive.Indicator>
|
||||||
|
</RadioGroupPrimitive.Item>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
|
||||||
|
|
||||||
|
export { RadioGroup, RadioGroupItem }
|
||||||
48
nkebao/src/components/ui/scroll-area.tsx
Normal file
48
nkebao/src/components/ui/scroll-area.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
|
||||||
|
|
||||||
|
import { cn } from "@/utils"
|
||||||
|
|
||||||
|
const ScrollArea = React.forwardRef<
|
||||||
|
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<ScrollAreaPrimitive.Root
|
||||||
|
ref={ref}
|
||||||
|
className={cn("relative overflow-hidden", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
||||||
|
{children}
|
||||||
|
</ScrollAreaPrimitive.Viewport>
|
||||||
|
<ScrollBar />
|
||||||
|
<ScrollAreaPrimitive.Corner />
|
||||||
|
</ScrollAreaPrimitive.Root>
|
||||||
|
))
|
||||||
|
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
|
||||||
|
|
||||||
|
const ScrollBar = React.forwardRef<
|
||||||
|
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
>(({ className, orientation = "vertical", ...props }, ref) => (
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||||
|
ref={ref}
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"flex touch-none select-none transition-colors",
|
||||||
|
orientation === "vertical" &&
|
||||||
|
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
||||||
|
orientation === "horizontal" &&
|
||||||
|
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
||||||
|
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
))
|
||||||
|
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
|
||||||
|
|
||||||
|
export { ScrollArea, ScrollBar }
|
||||||
@@ -5,15 +5,17 @@ interface SwitchProps {
|
|||||||
onCheckedChange: (checked: boolean) => void;
|
onCheckedChange: (checked: boolean) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
|
id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Switch({ checked, onCheckedChange, disabled = false, className = '' }: SwitchProps) {
|
export function Switch({ checked, onCheckedChange, disabled = false, className = '', id }: SwitchProps) {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
role="switch"
|
role="switch"
|
||||||
aria-checked={checked}
|
aria-checked={checked}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
id={id}
|
||||||
onClick={() => !disabled && onCheckedChange(!checked)}
|
onClick={() => !disabled && onCheckedChange(!checked)}
|
||||||
className={`
|
className={`
|
||||||
relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50
|
relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50
|
||||||
|
|||||||
@@ -86,3 +86,47 @@ export function ToastProvider({ children }: ToastProviderProps) {
|
|||||||
</ToastContext.Provider>
|
</ToastContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 直接导出toast函数,用于在组件中直接使用
|
||||||
|
export const toast = (toastData: Omit<Toast, 'id'>) => {
|
||||||
|
// 这里需要确保ToastProvider已经包装了应用
|
||||||
|
// 在实际使用中,应该通过useToast hook来调用
|
||||||
|
console.warn('toast function called without context. Please use useToast hook instead.');
|
||||||
|
|
||||||
|
// 创建一个简单的DOM toast作为fallback
|
||||||
|
const toastElement = document.createElement('div');
|
||||||
|
toastElement.className = `fixed top-4 right-4 z-50 max-w-sm w-full bg-white rounded-lg shadow-lg border p-4 transform transition-all duration-300 ${
|
||||||
|
toastData.variant === 'destructive'
|
||||||
|
? 'border-red-200 bg-red-50'
|
||||||
|
: 'border-gray-200'
|
||||||
|
}`;
|
||||||
|
|
||||||
|
toastElement.innerHTML = `
|
||||||
|
<div class="flex items-start justify-between">
|
||||||
|
<div class="flex-1">
|
||||||
|
<h4 class="font-medium ${toastData.variant === 'destructive' ? 'text-red-800' : 'text-gray-900'}">
|
||||||
|
${toastData.title}
|
||||||
|
</h4>
|
||||||
|
${toastData.description ? `
|
||||||
|
<p class="text-sm mt-1 ${toastData.variant === 'destructive' ? 'text-red-600' : 'text-gray-600'}">
|
||||||
|
${toastData.description}
|
||||||
|
</p>
|
||||||
|
` : ''}
|
||||||
|
</div>
|
||||||
|
<button class="ml-4 text-gray-400 hover:text-gray-600" onclick="this.parentElement.parentElement.remove()">
|
||||||
|
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
document.body.appendChild(toastElement);
|
||||||
|
|
||||||
|
// 自动移除
|
||||||
|
setTimeout(() => {
|
||||||
|
if (toastElement.parentElement) {
|
||||||
|
toastElement.remove();
|
||||||
|
}
|
||||||
|
}, 5000);
|
||||||
|
};
|
||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user