mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-27 07:32:08 +03:00
refactor: remove unused app pages
This commit is contained in:
parent
483d1d67c6
commit
ca060dbf7a
@ -9,14 +9,11 @@
|
|||||||
"dev:app": "pnpm build:preload && cross-env NODE_ENV=development tauri dev",
|
"dev:app": "pnpm build:preload && cross-env NODE_ENV=development tauri dev",
|
||||||
"dev:prerequisite": "concurrently \"cd ../packages/data-center && pnpm dev\" \"cd ../packages/app && pnpm dev\"",
|
"dev:prerequisite": "concurrently \"cd ../packages/data-center && pnpm dev\" \"cd ../packages/app && pnpm dev\"",
|
||||||
"build:prerequisite": "pnpm build:submodules && pnpm build:rs-types && pnpm build:affine && pnpm build:preload",
|
"build:prerequisite": "pnpm build:submodules && pnpm build:rs-types && pnpm build:affine && pnpm build:preload",
|
||||||
"dev:web": "vite",
|
|
||||||
"build:rs-types": "zx scripts/generateTsTypingsFromJsonSchema.mjs",
|
"build:rs-types": "zx scripts/generateTsTypingsFromJsonSchema.mjs",
|
||||||
"build:web": "tsc && vite build",
|
|
||||||
"build:submodules": "zx scripts/buildSubModules.mjs",
|
"build:submodules": "zx scripts/buildSubModules.mjs",
|
||||||
"build:affine": "zx scripts/buildAffine.mjs",
|
"build:affine": "zx scripts/buildAffine.mjs",
|
||||||
"build:preload": "esbuild src/preload/index.ts --outdir=public/preload",
|
"build:preload": "esbuild src/preload/index.ts --outdir=public/preload",
|
||||||
"build:app": "tauri build",
|
"build:app": "tauri build"
|
||||||
"preview": "vite preview"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@blocksuite/store": "^0.3.1",
|
"@blocksuite/store": "^0.3.1",
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
import styled from '@emotion/styled';
|
|
||||||
import { routes } from '../pages/routes.js';
|
|
||||||
|
|
||||||
const Container = styled.nav`
|
|
||||||
height: var(--title-bar-height);
|
|
||||||
background: #329ea3;
|
|
||||||
user-select: none;
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-start;
|
|
||||||
align-items: center;
|
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
`;
|
|
||||||
const RouteSelect = styled.select`
|
|
||||||
margin-left: 100px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
export function TitleBar() {
|
|
||||||
const navigate = useNavigate();
|
|
||||||
return (
|
|
||||||
<Container data-tauri-drag-region>
|
|
||||||
<RouteSelect
|
|
||||||
onChange={event => {
|
|
||||||
navigate(event?.target?.value);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{routes.map(route => (
|
|
||||||
<option key={route.path} value={route.path}>
|
|
||||||
{route.name}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</RouteSelect>
|
|
||||||
</Container>
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
:root {
|
|
||||||
--title-bar-height: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
margin-top: var(--title-bar-height);
|
|
||||||
height: calc(100vh - var(--title-bar-height));
|
|
||||||
width: 100%;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
#react-root {
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import '@emotion/react';
|
|
||||||
import { StrictMode } from 'react';
|
|
||||||
import ReactDOM from 'react-dom/client';
|
|
||||||
import { RouterProvider } from 'react-router-dom';
|
|
||||||
import { router } from './pages/routes.js';
|
|
||||||
import './main.css';
|
|
||||||
|
|
||||||
const root = document.querySelector('#react-root');
|
|
||||||
if (root !== null) {
|
|
||||||
ReactDOM.createRoot(root).render(
|
|
||||||
<StrictMode>
|
|
||||||
<RouterProvider router={router} />
|
|
||||||
</StrictMode>
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
import { redirect } from 'react-router-dom';
|
|
||||||
import { useEffect } from 'react';
|
|
||||||
|
|
||||||
export function AffineBasicPage() {
|
|
||||||
useEffect(() => {
|
|
||||||
location.href = '/affine-out/index.html';
|
|
||||||
redirect('/affine-out/index.html');
|
|
||||||
}, []);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function AffineDevPage() {
|
|
||||||
useEffect(() => {
|
|
||||||
location.href = 'http://localhost:8080';
|
|
||||||
redirect('http://localhost:8080');
|
|
||||||
}, []);
|
|
||||||
return null;
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
import styled from '@emotion/styled';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
|
|
||||||
const Container = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
|
|
||||||
& > a {
|
|
||||||
color: #333;
|
|
||||||
padding: 10px;
|
|
||||||
&:hover {
|
|
||||||
opacity: 0.7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export function LandingPage() {
|
|
||||||
return (
|
|
||||||
<Container>
|
|
||||||
<Link to="/affine-dev">Affine Dev Build</Link>
|
|
||||||
<Link to="/affine">Affine Dist Bundle</Link>
|
|
||||||
</Container>
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
import { Outlet } from 'react-router-dom';
|
|
||||||
import { TitleBar } from '../components/TitleBar.js';
|
|
||||||
|
|
||||||
export function RootLayout() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<TitleBar />
|
|
||||||
<Outlet />
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
import { createBrowserRouter } from 'react-router-dom';
|
|
||||||
import { AffineBasicPage, AffineDevPage } from './AFFiNE/index.js';
|
|
||||||
import { LandingPage } from './Landing/index.js';
|
|
||||||
import { RootLayout } from './Root.js';
|
|
||||||
|
|
||||||
export const routes = [
|
|
||||||
{
|
|
||||||
path: '/',
|
|
||||||
name: 'Landing Page',
|
|
||||||
element: <LandingPage />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/affine',
|
|
||||||
name: 'AFFiNE Basic',
|
|
||||||
element: <AffineBasicPage />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: '/affine-dev',
|
|
||||||
name: 'AFFiNE Dev',
|
|
||||||
element: <AffineDevPage />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
export const router = createBrowserRouter([
|
|
||||||
{ path: '/', element: <RootLayout />, children: routes },
|
|
||||||
]);
|
|
@ -1,38 +0,0 @@
|
|||||||
const DefaultHeadImgColors = [
|
|
||||||
['#C6F2F3', '#0C6066'],
|
|
||||||
['#FFF5AB', '#896406'],
|
|
||||||
['#FFCCA7', '#8F4500'],
|
|
||||||
['#FFCECE', '#AF1212'],
|
|
||||||
['#E3DEFF', '#511AAB'],
|
|
||||||
];
|
|
||||||
|
|
||||||
// TODO: move this back to AFFiNE repo
|
|
||||||
export async function createDefaultUserAvatar(
|
|
||||||
workspaceName: string
|
|
||||||
): Promise<Blob> {
|
|
||||||
const canvas = document.createElement('canvas');
|
|
||||||
canvas.height = 100;
|
|
||||||
canvas.width = 100;
|
|
||||||
const context = canvas.getContext('2d');
|
|
||||||
if (context === null) {
|
|
||||||
throw new Error('Failed to create avatar canvas');
|
|
||||||
}
|
|
||||||
const randomNumber = Math.floor(Math.random() * 5);
|
|
||||||
const randomColor = DefaultHeadImgColors[randomNumber];
|
|
||||||
context.fillStyle = randomColor[0];
|
|
||||||
context.fillRect(0, 0, 100, 100);
|
|
||||||
context.font = "600 50px 'PingFang SC', 'Microsoft Yahei'";
|
|
||||||
context.fillStyle = randomColor[1];
|
|
||||||
context.textAlign = 'center';
|
|
||||||
context.textBaseline = 'middle';
|
|
||||||
context.fillText(workspaceName[0], 50, 50);
|
|
||||||
return await new Promise<Blob>((resolve, reject) => {
|
|
||||||
canvas.toBlob(blob => {
|
|
||||||
if (blob === null) {
|
|
||||||
reject(new Error('Failed to convert avatar canvas to blob'));
|
|
||||||
} else {
|
|
||||||
resolve(blob);
|
|
||||||
}
|
|
||||||
}, 'image/png');
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user