feat: 优化代码
This commit is contained in:
parent
4bb265746a
commit
c2084c4a4f
|
|
@ -18,7 +18,7 @@ export const useChatParams = () => {
|
||||||
return { id, characterId };
|
return { id, characterId };
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function ChatPage() {
|
function CharacterChatPage() {
|
||||||
const { id, characterId } = useChatParams();
|
const { id, characterId } = useChatParams();
|
||||||
const [settingOpen, setSettingOpen] = useState(false);
|
const [settingOpen, setSettingOpen] = useState(false);
|
||||||
const switchToChannel = useStreamChatStore((s) => s.switchToChannel);
|
const switchToChannel = useStreamChatStore((s) => s.switchToChannel);
|
||||||
|
|
@ -52,3 +52,4 @@ export default function ChatPage() {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
export default CharacterChatPage;
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,7 @@ export const useStreamChatStore = create<StreamChatStore>((set, get) => ({
|
||||||
async switchToChannel(id: string) {
|
async switchToChannel(id: string) {
|
||||||
const { client, user } = get();
|
const { client, user } = get();
|
||||||
const channel = client!.channel('messaging', id);
|
const channel = client!.channel('messaging', id);
|
||||||
|
set({ currentChannel: channel, messages: [] });
|
||||||
const result = await protect(() =>
|
const result = await protect(() =>
|
||||||
channel.query({
|
channel.query({
|
||||||
messages: { limit: 100 },
|
messages: { limit: 100 },
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ function Topbar() {
|
||||||
if (!response || isLoading) return null;
|
if (!response || isLoading) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center">
|
<div className="flex items-center gap-3">
|
||||||
<LocaleSwitch key="locale-switch" />
|
<LocaleSwitch key="locale-switch" />
|
||||||
{user && <Notice key="notice" />}
|
{user && <Notice key="notice" />}
|
||||||
{user && (
|
{user && (
|
||||||
|
|
|
||||||
|
|
@ -38,19 +38,17 @@ const Notice = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{user && (
|
{user && (
|
||||||
<div className="px-4">
|
<div
|
||||||
<div
|
className="hover:bg-surface-element-hover flex cursor-pointer items-center gap-3 rounded-full p-2 transition-colors"
|
||||||
className="hover:bg-surface-element-hover flex cursor-pointer items-center gap-3 rounded-full p-2 transition-colors"
|
onClick={() => setIsDrawerOpen(true)}
|
||||||
onClick={() => setIsDrawerOpen(true)}
|
>
|
||||||
>
|
<div className="relative flex h-8 w-8 flex-shrink-0 items-center justify-center">
|
||||||
<div className="relative flex h-8 w-8 flex-shrink-0 items-center justify-center">
|
<Image src="/icons/notice.svg" alt="Notice" width={32} height={32} />
|
||||||
<Image src="/icons/notice.svg" alt="Notice" width={32} height={32} />
|
<Badge count={data?.unRead} className="absolute -top-2 -right-2" />
|
||||||
<Badge count={data?.unRead} className="absolute -top-2 -right-2" />
|
</div>
|
||||||
</div>
|
{/* {actualIsExpanded && (
|
||||||
{/* {actualIsExpanded && (
|
|
||||||
<span className="txt-label-m text-txt-primary-normal flex-1">Notice</span>
|
<span className="txt-label-m text-txt-primary-normal flex-1">Notice</span>
|
||||||
)} */}
|
)} */}
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<NoticeDrawer isOpen={isDrawerOpen} onOpenChange={setIsDrawerOpen} />
|
<NoticeDrawer isOpen={isDrawerOpen} onOpenChange={setIsDrawerOpen} />
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue