mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-11 09:46:37 +08:00
[优化] 优化界面
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import { toast } from 'sonner';
|
import { toast } from 'sonner';
|
||||||
import { cn } from '@/lib/utils/cn';
|
import { cn } from '@/lib/utils/cn';
|
||||||
|
|
||||||
@@ -27,9 +27,15 @@ export function InlineMessage({
|
|||||||
className,
|
className,
|
||||||
onClear,
|
onClear,
|
||||||
}: InlineMessageProps) {
|
}: InlineMessageProps) {
|
||||||
|
const onClearRef = useRef(onClear);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onClearRef.current = onClear;
|
||||||
|
}, [onClear]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Only trigger toast if onClear is provided (dynamic feedback)
|
// Only trigger toast if onClear is provided (dynamic feedback)
|
||||||
if (!onClear || !message) return;
|
if (!onClearRef.current || !message) return;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
position: 'bottom-right' as const,
|
position: 'bottom-right' as const,
|
||||||
@@ -44,10 +50,10 @@ export function InlineMessage({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const timer = setTimeout(() => {
|
const timer = setTimeout(() => {
|
||||||
onClear();
|
onClearRef.current?.();
|
||||||
}, 0);
|
}, 0);
|
||||||
return () => clearTimeout(timer);
|
return () => clearTimeout(timer);
|
||||||
}, [tone, message, onClear]);
|
}, [tone, message]);
|
||||||
|
|
||||||
// If onClear is provided, this is a toast feedback notice, so render nothing inline
|
// If onClear is provided, this is a toast feedback notice, so render nothing inline
|
||||||
if (onClear) {
|
if (onClear) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
import Link from 'next/link';
|
|
||||||
|
|
||||||
import { EmptyState } from '@/components/feedback/empty-state';
|
import { EmptyState } from '@/components/feedback/empty-state';
|
||||||
import { ErrorState } from '@/components/feedback/error-state';
|
import { ErrorState } from '@/components/feedback/error-state';
|
||||||
|
|||||||
Reference in New Issue
Block a user