generated from kevisual/vite-react-template
feat: 添加工作区页面及相关状态管理,优化路由配置
This commit is contained in:
@@ -4,4 +4,4 @@
|
||||
### 开发环境
|
||||
VITE_API_URL="https://kevisual.xiongxiao.me"
|
||||
### 生产环境
|
||||
# VITE_API_URL = "https://kevisual.cn"
|
||||
# VITE_API_UR="https://kevisual.cn"
|
||||
|
||||
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 }),
|
||||
}));
|
||||
@@ -11,6 +11,7 @@
|
||||
import { Route as rootRouteImport } from './routes/__root'
|
||||
import { Route as LoginRouteImport } from './routes/login'
|
||||
import { Route as IndexRouteImport } from './routes/index'
|
||||
import { Route as WorkspacesIndexRouteImport } from './routes/workspaces/index'
|
||||
import { Route as RepoIndexRouteImport } from './routes/repo/index'
|
||||
import { Route as ConfigIndexRouteImport } from './routes/config/index'
|
||||
import { Route as ConfigGiteaRouteImport } from './routes/config/gitea'
|
||||
@@ -25,6 +26,11 @@ const IndexRoute = IndexRouteImport.update({
|
||||
path: '/',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const WorkspacesIndexRoute = WorkspacesIndexRouteImport.update({
|
||||
id: '/workspaces/',
|
||||
path: '/workspaces/',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const RepoIndexRoute = RepoIndexRouteImport.update({
|
||||
id: '/repo/',
|
||||
path: '/repo/',
|
||||
@@ -47,6 +53,7 @@ export interface FileRoutesByFullPath {
|
||||
'/config/gitea': typeof ConfigGiteaRoute
|
||||
'/config/': typeof ConfigIndexRoute
|
||||
'/repo/': typeof RepoIndexRoute
|
||||
'/workspaces/': typeof WorkspacesIndexRoute
|
||||
}
|
||||
export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
@@ -54,6 +61,7 @@ export interface FileRoutesByTo {
|
||||
'/config/gitea': typeof ConfigGiteaRoute
|
||||
'/config': typeof ConfigIndexRoute
|
||||
'/repo': typeof RepoIndexRoute
|
||||
'/workspaces': typeof WorkspacesIndexRoute
|
||||
}
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRouteImport
|
||||
@@ -62,13 +70,27 @@ export interface FileRoutesById {
|
||||
'/config/gitea': typeof ConfigGiteaRoute
|
||||
'/config/': typeof ConfigIndexRoute
|
||||
'/repo/': typeof RepoIndexRoute
|
||||
'/workspaces/': typeof WorkspacesIndexRoute
|
||||
}
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
fullPaths: '/' | '/login' | '/config/gitea' | '/config/' | '/repo/'
|
||||
fullPaths:
|
||||
| '/'
|
||||
| '/login'
|
||||
| '/config/gitea'
|
||||
| '/config/'
|
||||
| '/repo/'
|
||||
| '/workspaces/'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to: '/' | '/login' | '/config/gitea' | '/config' | '/repo'
|
||||
id: '__root__' | '/' | '/login' | '/config/gitea' | '/config/' | '/repo/'
|
||||
to: '/' | '/login' | '/config/gitea' | '/config' | '/repo' | '/workspaces'
|
||||
id:
|
||||
| '__root__'
|
||||
| '/'
|
||||
| '/login'
|
||||
| '/config/gitea'
|
||||
| '/config/'
|
||||
| '/repo/'
|
||||
| '/workspaces/'
|
||||
fileRoutesById: FileRoutesById
|
||||
}
|
||||
export interface RootRouteChildren {
|
||||
@@ -77,6 +99,7 @@ export interface RootRouteChildren {
|
||||
ConfigGiteaRoute: typeof ConfigGiteaRoute
|
||||
ConfigIndexRoute: typeof ConfigIndexRoute
|
||||
RepoIndexRoute: typeof RepoIndexRoute
|
||||
WorkspacesIndexRoute: typeof WorkspacesIndexRoute
|
||||
}
|
||||
|
||||
declare module '@tanstack/react-router' {
|
||||
@@ -95,6 +118,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof IndexRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/workspaces/': {
|
||||
id: '/workspaces/'
|
||||
path: '/workspaces'
|
||||
fullPath: '/workspaces/'
|
||||
preLoaderRoute: typeof WorkspacesIndexRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/repo/': {
|
||||
id: '/repo/'
|
||||
path: '/repo'
|
||||
@@ -125,6 +155,7 @@ const rootRouteChildren: RootRouteChildren = {
|
||||
ConfigGiteaRoute: ConfigGiteaRoute,
|
||||
ConfigIndexRoute: ConfigIndexRoute,
|
||||
RepoIndexRoute: RepoIndexRoute,
|
||||
WorkspacesIndexRoute: WorkspacesIndexRoute,
|
||||
}
|
||||
export const routeTree = rootRouteImport
|
||||
._addFileChildren(rootRouteChildren)
|
||||
|
||||
9
src/routes/workspaces/index.tsx
Normal file
9
src/routes/workspaces/index.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import App from '@/pages/workspaces/page'
|
||||
export const Route = createFileRoute('/workspaces/')({
|
||||
component: RouteComponent,
|
||||
})
|
||||
|
||||
function RouteComponent() {
|
||||
return <App />
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import path from 'path';
|
||||
import pkgs from './package.json';
|
||||
import tailwindcss from '@tailwindcss/vite';
|
||||
import { tanstackRouter } from '@tanstack/router-plugin/vite'
|
||||
|
||||
import 'dotenv/config';
|
||||
const isDev = process.env.NODE_ENV === 'development';
|
||||
const basename = isDev ? '/' : pkgs?.basename || '/';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user