generated from template/vite-react-template
temp
This commit is contained in:
parent
c1247eba32
commit
4d0e945a92
@ -5,9 +5,11 @@ import { Auth } from './modules/layouts/Auth';
|
|||||||
// import { basename } from './modules/basename';
|
// import { basename } from './modules/basename';
|
||||||
import 'github-markdown-css/github-markdown.css';
|
import 'github-markdown-css/github-markdown.css';
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
|
const url = new URL(location.href);
|
||||||
|
const id = url.searchParams.get('id') || undefined;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Flow checkLogin={false} />
|
<Flow checkLogin={false} id={id} />
|
||||||
<ToastContainer />
|
<ToastContainer />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -49,7 +49,7 @@ export class TextEditor {
|
|||||||
StarterKit, // 使用 StarterKit 包含基础功能
|
StarterKit, // 使用 StarterKit 包含基础功能
|
||||||
Highlight,
|
Highlight,
|
||||||
Placeholder.configure({
|
Placeholder.configure({
|
||||||
placeholder: 'Type ! to see commands (e.g., !today, !list !test )...',
|
placeholder: 'Type @ to see commands (e.g., @today, @list @test )...',
|
||||||
}),
|
}),
|
||||||
Typography,
|
Typography,
|
||||||
Markdown,
|
Markdown,
|
||||||
|
@ -16,7 +16,7 @@ export const Commands = Extension.create({
|
|||||||
addOptions() {
|
addOptions() {
|
||||||
return {
|
return {
|
||||||
suggestion: {
|
suggestion: {
|
||||||
char: '!',
|
char: '@',
|
||||||
command: ({ editor, range, props }: any) => {
|
command: ({ editor, range, props }: any) => {
|
||||||
editor
|
editor
|
||||||
.chain()
|
.chain()
|
||||||
|
@ -33,6 +33,8 @@ import { ContextMenu } from './modules/ContextMenu';
|
|||||||
import { useSelect } from './hooks/use-select';
|
import { useSelect } from './hooks/use-select';
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { AppendDemo, DemoLogin } from '../demo-login';
|
import { AppendDemo, DemoLogin } from '../demo-login';
|
||||||
|
import { List } from './pages/List';
|
||||||
|
|
||||||
type NodeData = {
|
type NodeData = {
|
||||||
id: string;
|
id: string;
|
||||||
position: XYPosition;
|
position: XYPosition;
|
||||||
@ -221,6 +223,9 @@ export const Flow = ({ id }: { checkLogin?: boolean; id?: string }) => {
|
|||||||
if (!token) {
|
if (!token) {
|
||||||
return <DemoLogin />;
|
return <DemoLogin />;
|
||||||
}
|
}
|
||||||
|
if (!id) {
|
||||||
|
return <List />;
|
||||||
|
}
|
||||||
const wallStore = useWallStore(
|
const wallStore = useWallStore(
|
||||||
useShallow((state) => {
|
useShallow((state) => {
|
||||||
return {
|
return {
|
||||||
@ -232,7 +237,9 @@ export const Flow = ({ id }: { checkLogin?: boolean; id?: string }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (id) {
|
||||||
wallStore.init(id);
|
wallStore.init(id);
|
||||||
|
}
|
||||||
}, [id]);
|
}, [id]);
|
||||||
|
|
||||||
if (!wallStore.loaded) {
|
if (!wallStore.loaded) {
|
||||||
|
@ -3,9 +3,7 @@ import { useWallStore } from '../store/wall';
|
|||||||
import { useUserWallStore } from '../store/user-wall';
|
import { useUserWallStore } from '../store/user-wall';
|
||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
import { formatDate, formatRelativeDate } from '../../../modules/dayjs';
|
import { formatDate, formatRelativeDate } from '../../../modules/dayjs';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
export const List = () => {
|
export const List = () => {
|
||||||
const navigate = useNavigate();
|
|
||||||
const wallStore = useUserWallStore(
|
const wallStore = useUserWallStore(
|
||||||
useShallow((state) => {
|
useShallow((state) => {
|
||||||
return {
|
return {
|
||||||
@ -20,6 +18,9 @@ export const List = () => {
|
|||||||
const init = () => {
|
const init = () => {
|
||||||
wallStore.queryWallList();
|
wallStore.queryWallList();
|
||||||
};
|
};
|
||||||
|
const navigate = (path: string) => {
|
||||||
|
window.location.href = path;
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div className='p-4 bg-white w-full h-full flex flex-col'>
|
<div className='p-4 bg-white w-full h-full flex flex-col'>
|
||||||
<div
|
<div
|
||||||
@ -37,7 +38,9 @@ export const List = () => {
|
|||||||
key={wall.id}
|
key={wall.id}
|
||||||
className='p-4 border border-gray-200 w-80 rounded-md'
|
className='p-4 border border-gray-200 w-80 rounded-md'
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigate(`/edit/${wall.id}`);
|
const url = new URL(location.href);
|
||||||
|
url.searchParams.set('id', wall.id!);
|
||||||
|
navigate(url.toString());
|
||||||
}}>
|
}}>
|
||||||
<div>
|
<div>
|
||||||
<div>{wall.title}</div>
|
<div>{wall.title}</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user