This commit is contained in:
2025-03-27 12:07:07 +08:00
parent c1247eba32
commit 4d0e945a92
5 changed files with 19 additions and 7 deletions

View File

@@ -33,6 +33,8 @@ import { ContextMenu } from './modules/ContextMenu';
import { useSelect } from './hooks/use-select';
import clsx from 'clsx';
import { AppendDemo, DemoLogin } from '../demo-login';
import { List } from './pages/List';
type NodeData = {
id: string;
position: XYPosition;
@@ -221,6 +223,9 @@ export const Flow = ({ id }: { checkLogin?: boolean; id?: string }) => {
if (!token) {
return <DemoLogin />;
}
if (!id) {
return <List />;
}
const wallStore = useWallStore(
useShallow((state) => {
return {
@@ -232,7 +237,9 @@ export const Flow = ({ id }: { checkLogin?: boolean; id?: string }) => {
);
useEffect(() => {
wallStore.init(id);
if (id) {
wallStore.init(id);
}
}, [id]);
if (!wallStore.loaded) {

View File

@@ -3,9 +3,7 @@ import { useWallStore } from '../store/wall';
import { useUserWallStore } from '../store/user-wall';
import { useShallow } from 'zustand/react/shallow';
import { formatDate, formatRelativeDate } from '../../../modules/dayjs';
import { useNavigate } from 'react-router-dom';
export const List = () => {
const navigate = useNavigate();
const wallStore = useUserWallStore(
useShallow((state) => {
return {
@@ -20,6 +18,9 @@ export const List = () => {
const init = () => {
wallStore.queryWallList();
};
const navigate = (path: string) => {
window.location.href = path;
};
return (
<div className='p-4 bg-white w-full h-full flex flex-col'>
<div
@@ -37,7 +38,9 @@ export const List = () => {
key={wall.id}
className='p-4 border border-gray-200 w-80 rounded-md'
onClick={() => {
navigate(`/edit/${wall.id}`);
const url = new URL(location.href);
url.searchParams.set('id', wall.id!);
navigate(url.toString());
}}>
<div>
<div>{wall.title}</div>