generated from kevisual/vite-react-template
feat: 添加工作区页面及相关状态管理,优化路由配置
This commit is contained in:
30
src/pages/workspaces/page.tsx
Normal file
30
src/pages/workspaces/page.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { useMarkStore, useWorkspaceStore } from "./store";
|
||||
import { useEffect } from "react";
|
||||
export const App = () => {
|
||||
const markStore = useMarkStore(useShallow(state => {
|
||||
return {
|
||||
init: state.init,
|
||||
list: state.list,
|
||||
}
|
||||
}));
|
||||
const workspaceStore = useWorkspaceStore(useShallow(state => {
|
||||
return {
|
||||
edit: state.edit,
|
||||
setEdit: state.setEdit,
|
||||
}
|
||||
}));
|
||||
useEffect(() => {
|
||||
// @ts-ignore
|
||||
markStore.init('cnb');
|
||||
}, []);
|
||||
console.log('markStore.list', markStore.list);
|
||||
return (
|
||||
<div>
|
||||
<h1>Workspaces</h1>
|
||||
<p>This is the workspaces page.</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default App;
|
||||
14
src/pages/workspaces/store/index.ts
Normal file
14
src/pages/workspaces/store/index.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useMarkStore } from '@kevisual/api/store-mark';
|
||||
export { useMarkStore }
|
||||
|
||||
import { create } from 'zustand';
|
||||
|
||||
type WorkspaceState = {
|
||||
edit: boolean;
|
||||
setEdit: (edit: boolean) => void;
|
||||
}
|
||||
|
||||
export const useWorkspaceStore = create<WorkspaceState>((set) => ({
|
||||
edit: false,
|
||||
setEdit: (edit) => set({ edit }),
|
||||
}));
|
||||
Reference in New Issue
Block a user