mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 15:16:28 +08:00
Merge pull request #375 from toeverything/feature/defaultRoute
feat(routes): clear unused routes
This commit is contained in:
@@ -1,15 +1,9 @@
|
||||
import { Navigate, Route, Routes } from 'react-router-dom';
|
||||
|
||||
import { Login } from './account';
|
||||
import Agenda from './agenda';
|
||||
import { LigoVirgoRootContainer } from './AppContainer';
|
||||
import Recent from './recent';
|
||||
import { RoutePrivate } from './RoutePrivate';
|
||||
import { RoutePublicAutoLogin } from './RoutePublicAutoLogin';
|
||||
import Search from './search';
|
||||
import Settings from './settings';
|
||||
import Shared from './shared';
|
||||
import Starred from './starred';
|
||||
import { PageNotFound } from './status/page-not-found';
|
||||
import { WorkspaceNotFound } from './status/workspace-not-found';
|
||||
import { Tools } from './tools';
|
||||
@@ -25,13 +19,6 @@ export function LigoVirgoRoutes() {
|
||||
path="/error/workspace"
|
||||
element={<WorkspaceNotFound />}
|
||||
/>
|
||||
|
||||
<Route path="/agenda/*" element={<Agenda />} />
|
||||
<Route path="/recent" element={<Recent />} />
|
||||
<Route path="/search" element={<Search />} />
|
||||
<Route path="/settings" element={<Settings />} />
|
||||
<Route path="/shared" element={<Shared />} />
|
||||
<Route path="/started" element={<Starred />} />
|
||||
<Route path="/ui" element={<UIPage />} />
|
||||
<Route
|
||||
path="/:workspace_id/*"
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
export default function Recent() {
|
||||
return <span>Recent</span>;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export default function Search() {
|
||||
return <span>Search</span>;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export default function Settings() {
|
||||
return <span>Settings</span>;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export default function Shared() {
|
||||
return <span>Shared</span>;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export default function Starred() {
|
||||
return <span>Starred</span>;
|
||||
}
|
||||
@@ -31,6 +31,7 @@ export function WorkspaceHome() {
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
navigate(`/${workspace_id}/${user_initial_page_id}`);
|
||||
};
|
||||
navigate_to_user_initial_page();
|
||||
|
||||
@@ -4,7 +4,6 @@ import { WorkspaceRootContainer } from './Container';
|
||||
import { Page } from './docs';
|
||||
import { Edgeless } from './Edgeless';
|
||||
import { WorkspaceHome } from './Home';
|
||||
import Labels from './labels';
|
||||
import Pages from './pages';
|
||||
|
||||
export function WorkspaceContainer() {
|
||||
@@ -21,7 +20,6 @@ export function WorkspaceContainer() {
|
||||
return (
|
||||
<Routes>
|
||||
<Route path="/" element={<WorkspaceRootContainer />}>
|
||||
<Route path="/labels" element={<Labels />} />
|
||||
<Route path="/pages" element={<Pages />} />
|
||||
<Route
|
||||
path="/:page_id/edgeless"
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
import { Virgo } from '@toeverything/framework/virgo';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { useNavigate, useParams } from 'react-router';
|
||||
import { Virgo, BlockEditor } from '@toeverything/framework/virgo';
|
||||
import { debounce } from '@toeverything/utils';
|
||||
|
||||
import { MuiBox as Box, styled, BaseButton } from '@toeverything/components/ui';
|
||||
import { BaseButton, styled } from '@toeverything/components/ui';
|
||||
import {
|
||||
services,
|
||||
type ReturnUnobserve,
|
||||
TemplateFactory,
|
||||
TemplateMeta,
|
||||
type ReturnUnobserve,
|
||||
} from '@toeverything/datasource/db-service';
|
||||
|
||||
const PlaceholderPanelContainer = styled('div')({
|
||||
@@ -48,7 +46,6 @@ export const PlaceholderPanel = (props: PlaceholderPanelProps) => {
|
||||
y: 0,
|
||||
});
|
||||
const [open, setOpen] = useState(false);
|
||||
// const navigate = useNavigate();
|
||||
|
||||
const ifPageChildrenExist = useCallback(async () => {
|
||||
const rootId = await editor.getRootBlockId();
|
||||
|
||||
@@ -1,170 +0,0 @@
|
||||
// import type {
|
||||
// ArrayOperation,
|
||||
// BlockClientInstance,
|
||||
// BlockImplInstance,
|
||||
// MapOperation,
|
||||
// } from '@toeverything/datasource/jwt';
|
||||
// import { getDateIsoStringWithTimezone } from '@toeverything/utils';
|
||||
|
||||
// export async function getRecentPages(
|
||||
// db: BlockClientInstance,
|
||||
// userId: string
|
||||
// ): Promise<string[]> {
|
||||
// try {
|
||||
// const config = await db.getWorkspaceConfig<MapOperation<string>>();
|
||||
// const recent_pages = config.get('recent_pages');
|
||||
// if (recent_pages?.get(userId)) {
|
||||
// return [recent_pages.get(userId) as string];
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
|
||||
// return [''];
|
||||
// }
|
||||
|
||||
// /** Mark the article corresponding to pageId as the most recently accessed article */
|
||||
// export async function setRecentPages(
|
||||
// db: BlockClientInstance,
|
||||
// userId: string,
|
||||
// pageId: string
|
||||
// ): Promise<void> {
|
||||
// try {
|
||||
// const config = await db.getWorkspaceConfig<MapOperation<string>>();
|
||||
// const recent_pages = config.get('recent_pages');
|
||||
// if (recent_pages && recent_pages.get(userId)) {
|
||||
// recent_pages.set(userId, pageId);
|
||||
// } else {
|
||||
// const map = config.createMap<string>();
|
||||
// map.set(userId, pageId);
|
||||
// config.set('recent_pages', map);
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
// export async function setPageTree<TreeItem>(
|
||||
// db: BlockClientInstance,
|
||||
// treeData: TreeItem[]
|
||||
// ): Promise<void> {
|
||||
// try {
|
||||
// const config = await db.getWorkspaceConfig();
|
||||
// const array = config.createArray<TreeItem>();
|
||||
// array.push((treeData as any[]) || []);
|
||||
// config.set('page_tree', array);
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
// async function update_tree_items_title<
|
||||
// TreeItem extends { id: string; title: string; children: TreeItem[] }
|
||||
// >(
|
||||
// db: BlockClientInstance,
|
||||
// items: TreeItem[],
|
||||
// cache: Record<string, string>
|
||||
// ): Promise<TreeItem[]> {
|
||||
// for (const item of items) {
|
||||
// if (cache[item.id]) {
|
||||
// item.title = cache[item.id];
|
||||
// } else {
|
||||
// const page = await db.get(item.id as 'page');
|
||||
// item.title =
|
||||
// page.getDecoration<Array<{ text: string }>>('text')?.[0]
|
||||
// ?.text ||
|
||||
// 'Untitled ' +
|
||||
// getDateIsoStringWithTimezone(page.created)
|
||||
// .slice(11)
|
||||
// .replace('T', ' ');
|
||||
// cache[item.id] = item.title;
|
||||
// }
|
||||
|
||||
// if (item.children.length) {
|
||||
// item.children = await update_tree_items_title(
|
||||
// db,
|
||||
// item.children,
|
||||
// cache
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
// return [...items];
|
||||
// }
|
||||
|
||||
// export async function getPageTree<TreeItem>(
|
||||
// db: BlockClientInstance
|
||||
// ): Promise<TreeItem[]> {
|
||||
// try {
|
||||
// const config = await db.getWorkspaceConfig();
|
||||
// const page_tree = config.get('page_tree') as ArrayOperation<TreeItem>;
|
||||
// const page_tree_items = page_tree?.slice();
|
||||
// if (page_tree && page_tree_items?.length) {
|
||||
// const pages = await update_tree_items_title(
|
||||
// db,
|
||||
// page_tree_items as [],
|
||||
// {}
|
||||
// );
|
||||
// return pages;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// export async function getWorkspaceConfig(
|
||||
// db: BlockClientInstance,
|
||||
// userId: string,
|
||||
// name: string
|
||||
// ): Promise<string> {
|
||||
// try {
|
||||
// // const config = await db.getWorkspaceConfig();
|
||||
// // const map = config.get_map<string>(name);
|
||||
// // if (map && map.get(userId)) {
|
||||
// // return map.get(userId)!;
|
||||
// // }
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
|
||||
// return '';
|
||||
// }
|
||||
|
||||
// export async function setWorkspaceConfig(
|
||||
// db: BlockClientInstance,
|
||||
// userId: string,
|
||||
// name: string,
|
||||
// value: string
|
||||
// ): Promise<void> {
|
||||
// try {
|
||||
// // const config = await db.getWorkspaceConfig();
|
||||
// // const map = config.get_map<string>(name);
|
||||
// // map.set(userId, value === undefined || value === null ? '' : value);
|
||||
// } catch (e) {
|
||||
// console.error(e);
|
||||
// }
|
||||
// }
|
||||
|
||||
// export async function createPage(
|
||||
// db: BlockClientInstance,
|
||||
// title?: string,
|
||||
// content?: string,
|
||||
// metadata?: Record<string, string>
|
||||
// ): Promise<BlockImplInstance | undefined> {
|
||||
// if (db) {
|
||||
// const page: BlockImplInstance = await db.get('page');
|
||||
// if (title) {
|
||||
// page.getContent<string>().set('title', title);
|
||||
// }
|
||||
// if (metadata) {
|
||||
// Object.keys(metadata).forEach(property =>
|
||||
// page.getContent<string>().set(property, metadata[property])
|
||||
// );
|
||||
// }
|
||||
// return page;
|
||||
// }
|
||||
|
||||
// return undefined;
|
||||
// }
|
||||
@@ -1,5 +1,3 @@
|
||||
export { PageTree } from './PageTree';
|
||||
export * from './types';
|
||||
export { usePageTree } from './use-page-tree';
|
||||
|
||||
// export { getRecentPages, setRecentPages } from './block-page';
|
||||
|
||||
Reference in New Issue
Block a user