Migrate to Vite from CRA

This commit is contained in:
1ilit 2023-12-16 05:39:13 +02:00
parent 503d55b528
commit 46685a98fe
52 changed files with 2292 additions and 15125 deletions

21
.eslintrc.cjs Normal file
View File

@ -0,0 +1,21 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
settings: { react: { version: "18.2" } },
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"react/prop-types": 0,
},
};

44
.gitignore vendored
View File

@ -1,27 +1,25 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
test.html
.env.dev
.env
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
.env

View File

@ -1,70 +1,8 @@
# Getting Started with Create React App
# React + Vite
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
## Available Scripts
Currently, two official plugins are available:
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
### Analyzing the Bundle Size
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
### Making a Progressive Web App
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
### Advanced Configuration
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

View File

@ -2,29 +2,15 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="apple-touch-icon" href="/favicon.ico" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css" crossorigin="anonymous">
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body theme-mode="light">
@ -40,6 +26,7 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script type="module" src="/src/main.jsx"></script>
<script src="https://kit.fontawesome.com/e35edcd75e.js" crossorigin="anonymous"></script>
</body>
</html>

16876
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,60 +1,46 @@
{
"name": "frontend",
"version": "0.1.0",
"name": "client-vite",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@douyinfe/semi-ui": "^2.36.0",
"@lexical/react": "^0.12.2",
"@monaco-editor/react": "^4.5.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.5.0",
"@douyinfe/semi-ui": "^2.49.0",
"@lexical/react": "^0.12.5",
"@monaco-editor/react": "^4.6.0",
"axios": "^1.6.2",
"dexie": "^3.2.4",
"dexie-react-hooks": "^1.1.6",
"dexie-react-hooks": "^1.1.7",
"file-saver": "^2.0.5",
"html-to-image": "^1.11.11",
"jsonschema": "^1.4.1",
"jspdf": "^2.5.1",
"lexical": "^0.12.2",
"node-sql-parser": "^4.7.0",
"lexical": "^0.12.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-google-recaptcha": "^3.1.0",
"react-hotkeys-hook": "^4.4.1",
"react-router-dom": "^6.11.2",
"react-scripts": "5.0.1",
"react-router": "^6.21.0",
"react-router-dom": "^6.21.0",
"socket.io-client": "^4.7.2",
"unique-names-generator": "^4.7.1",
"url": "^0.11.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"unique-names-generator": "^4.7.1"
},
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"tailwindcss": "^3.3.2"
"@types/react": "^18.2.43",
"@types/react-dom": "^18.2.17",
"@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.16",
"eslint": "^8.55.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"postcss": "^8.4.32",
"tailwindcss": "^3.3.6",
"vite": "^5.0.8"
}
}

6
postcss.config.js Normal file
View File

@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

View File

@ -1,15 +0,0 @@
{
"short_name": "drawDB",
"name": "drawDB",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

View File

@ -1,8 +0,0 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from "react";
import { useContext, useState } from "react";
import {
Empty,
Row,
@ -27,7 +27,7 @@ import {
} from "../data/data";
import { AreaContext, UndoRedoContext } from "../pages/Editor";
export default function AreaOverview(props) {
export default function AreaOverview() {
const { areas, addArea, deleteArea, updateArea } = useContext(AreaContext);
const { setUndoStack, setRedoStack } = useContext(UndoRedoContext);
const [editField, setEditField] = useState({});

View File

@ -1,4 +1,4 @@
import { React, useContext, useState } from "react";
import { useContext, useState } from "react";
import {
IconCaretdown,
IconChevronRight,
@ -71,7 +71,6 @@ export default function ControlPanel({
state,
setState,
lastSaved,
setLastSaved,
}) {
const MODAL = {
NONE: 0,
@ -209,7 +208,7 @@ export default function ControlPanel({
updateField(a.tid, a.fid, a.undo);
} else if (a.component === "field_delete") {
setTables((prev) =>
prev.map((t, i) => {
prev.map((t) => {
if (t.id === a.tid) {
const temp = t.fields.slice();
temp.splice(a.data.id, 0, a.data);
@ -243,7 +242,7 @@ export default function ControlPanel({
});
} else if (a.component === "index_delete") {
setTables((prev) =>
prev.map((table, i) => {
prev.map((table) => {
if (table.id === a.tid) {
const temp = table.indices.slice();
temp.splice(a.data.id, 0, a.data);
@ -488,7 +487,7 @@ export default function ControlPanel({
.then(() => {
Toast.success("Copied to clipboard.");
})
.catch((e) => {
.catch(() => {
Toast.error("Could not copy to clipboard.");
});
});
@ -617,21 +616,21 @@ export default function ControlPanel({
case ObjectType.TABLE:
navigator.clipboard
.writeText(JSON.stringify({ ...tables[selectedElement.id] }))
.catch((e) => {
.catch(() => {
Toast.error("Could not copy");
});
break;
case ObjectType.NOTE:
navigator.clipboard
.writeText(JSON.stringify({ ...notes[selectedElement.id] }))
.catch((e) => {
.catch(() => {
Toast.error("Could not copy");
});
break;
case ObjectType.AREA:
navigator.clipboard
.writeText(JSON.stringify({ ...areas[selectedElement.id] }))
.catch((e) => {
.catch(() => {
Toast.error("Could not copy");
});
break;
@ -754,7 +753,7 @@ export default function ControlPanel({
setUndoStack([]);
setRedoStack([]);
})
.catch((e) => Toast.error("Oops! Something went wrong."));
.catch(() => Toast.error("Oops! Something went wrong."));
},
},
"Flush storage": {
@ -764,7 +763,7 @@ export default function ControlPanel({
Toast.success("Storage flushed");
window.location.reload(false);
})
.catch((error) => {
.catch(() => {
Toast.error("Oops! Something went wrong.");
});
},
@ -1170,12 +1169,13 @@ export default function ControlPanel({
`${exportData.filename}.${exportData.extension}`
);
return;
case MODAL.CODE:
case MODAL.CODE: {
const blob = new Blob([exportData.data], {
type: "application/json",
});
saveAs(blob, `${exportData.filename}.${exportData.extension}`);
return;
}
case MODAL.IMPORT:
if (error.type !== STATUS.ERROR) {
setSettings((prev) => ({ ...prev, pan: { x: 0, y: 0 } }));
@ -1494,7 +1494,7 @@ export default function ControlPanel({
visible={visible !== MODAL.NONE}
onOk={getModalOnOk}
afterClose={() => {
setExportData((prev) => ({
setExportData(() => ({
data: "",
extension: "",
filename: `diagram_${new Date().toISOString()}`,

View File

@ -1,5 +1,3 @@
import React from "react";
export function IconAddTable({ theme }) {
return (
<svg height="26" width="26">

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from "react";
import { useContext, useState } from "react";
import { Button, Input, Avatar } from "@douyinfe/semi-ui";
import { IconSend } from "@douyinfe/semi-icons";
import { BotMessageContext } from "../pages/Editor";

View File

@ -1,4 +1,4 @@
import React, { useState } from "react";
import { useState } from "react";
import { Link } from "react-router-dom";
import logo from "../assets/logo_light_46.png";
import { SideSheet } from "@douyinfe/semi-ui";

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from "react";
import { useContext, useState } from "react";
import {
Empty,
Row,
@ -24,7 +24,7 @@ import {
import { NoteContext, UndoRedoContext } from "../pages/Editor";
import { noteThemes, Action, ObjectType } from "../data/data";
export default function NotesOverview(props) {
export default function NotesOverview() {
const { notes, updateNote, addNote, deleteNote } = useContext(NoteContext);
const { setUndoStack, setRedoStack } = useContext(UndoRedoContext);
const [value, setValue] = useState("");

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from "react";
import { useContext, useState } from "react";
import {
AutoComplete,
Collapse,
@ -24,7 +24,7 @@ import {
import { Cardinality, Constraint, Action, ObjectType } from "../data/data";
import { TableContext, UndoRedoContext } from "../pages/Editor";
export default function ReferenceOverview(props) {
export default function ReferenceOverview() {
const columns = [
{
title: "Primary",

View File

@ -1,4 +1,4 @@
import { React, useContext } from "react";
import { useContext } from "react";
import { Tabs } from "@douyinfe/semi-ui";
import TableOverview from "./TableOverview";
import ReferenceOverview from "./ReferenceOverview";
@ -21,11 +21,11 @@ const SidePanel = (props) => {
{ tab: "Types", itemKey: Tab.types },
];
const contentList = [
<TableOverview />,
<ReferenceOverview />,
<AreaOverview />,
<NotesOverview />,
<TypesOverview />,
<TableOverview key={1}/>,
<ReferenceOverview key={2}/>,
<AreaOverview key={3}/>,
<NotesOverview key={4}/>,
<TypesOverview key={5}/>,
];
return (

View File

@ -1,4 +1,4 @@
import { React, useContext, useState } from "react";
import { useContext, useState } from "react";
import {
Action,
ObjectType,
@ -43,7 +43,7 @@ import {
} from "../pages/Editor";
import { getSize, hasCheck, hasPrecision, isSized } from "../utils";
export default function TableOverview(props) {
export default function TableOverview() {
const [indexActiveKey, setIndexActiveKey] = useState("");
const [value, setValue] = useState("");
const {
@ -392,10 +392,10 @@ export default function TableOverview(props) {
onChange={(v) =>
updateField(i, j, { values: v })
}
onFocus={(e) =>
onFocus={() =>
setEditField({ values: f.values })
}
onBlur={(e) => {
onBlur={() => {
if (
JSON.stringify(editField.values) ===
JSON.stringify(f.values)

View File

@ -1,4 +1,4 @@
import { React, useContext, useState } from "react";
import { useContext, useState } from "react";
import { Action, ObjectType, sqlDataTypes } from "../data/data";
import {
Collapse,
@ -30,7 +30,7 @@ import {
import { TypeContext, UndoRedoContext } from "../pages/Editor";
import { isSized, hasPrecision, getSize } from "../utils";
export default function TableOverview(props) {
export default function TableOverview() {
const [value, setValue] = useState("");
const { types, addType, deleteType, updateType } = useContext(TypeContext);
const { setUndoStack, setRedoStack } = useContext(UndoRedoContext);
@ -268,10 +268,10 @@ export default function TableOverview(props) {
),
})
}
onFocus={(e) =>
onFocus={() =>
setEditField({ values: f.values })
}
onBlur={(e) => {
onBlur={() => {
if (
JSON.stringify(editField.values) ===
JSON.stringify(f.values)

View File

@ -1,4 +1,4 @@
import { React, useContext, useState } from "react";
import { useContext, useState } from "react";
import { Button, Popover, Input, Toast } from "@douyinfe/semi-ui";
import {
IconEdit,

View File

@ -1,4 +1,4 @@
import React, { useContext, useRef, useState, useEffect } from "react";
import { useContext, useRef, useState, useEffect } from "react";
import Table from "./Table";
import { Action, Cardinality, Constraint, ObjectType } from "../data/data";
import Area from "./Area";
@ -14,7 +14,7 @@ import {
import Note from "./Note";
import { Toast } from "@douyinfe/semi-ui";
export default function Canvas(props) {
export default function Canvas() {
const { tables, updateTable, relationships, addRelationship } =
useContext(TableContext);
const { areas, updateArea } = useContext(AreaContext);
@ -255,7 +255,7 @@ export default function Canvas(props) {
}
};
const handleMouseUp = (e) => {
const handleMouseUp = () => {
if (coordsDidUpdate(dragging.element)) {
const info = getMoveInfo();
setUndoStack((prev) => [
@ -320,7 +320,7 @@ export default function Canvas(props) {
});
};
const handleGripField = (id) => {
const handleGripField = () => {
setPanning(false);
setDragging({ element: ObjectType.NONE, id: -1, prevX: 0, prevY: 0 });
setLinking(true);

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from "react";
import { useContext, useState } from "react";
import { Button, Input, Tag, Avatar } from "@douyinfe/semi-ui";
import { IconSend } from "@douyinfe/semi-icons";
import { socket } from "../data/socket";

View File

@ -1,4 +1,4 @@
import React, { useContext, useState, useEffect } from "react";
import { useContext, useState, useEffect } from "react";
import { Collapse, Badge } from "@douyinfe/semi-ui";
import { SettingsContext, TableContext, TypeContext } from "../pages/Editor";
import { validateDiagram, arrayIsEqual } from "../utils";

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from "react";
import { useContext, useState } from "react";
import {
LayoutContext,
NoteContext,

View File

@ -1,4 +1,4 @@
import { React, useState } from "react";
import { useState } from "react";
import { calcPath } from "../utils";
export default function Relationship(props) {

View File

@ -1,4 +1,4 @@
import React, { useContext, useEffect, useState } from "react";
import { useContext, useEffect, useState } from "react";
import chatIcon from "../assets/chat.png";
import botIcon from "../assets/bot.png";
import teamIcon from "../assets/group.png";
@ -193,8 +193,9 @@ export default function Sidebar() {
if (undoStack.length > 0) {
return (
<List className="sidesheet-theme">
{[...undoStack].reverse().map((e) => (
{[...undoStack].reverse().map((e, i) => (
<List.Item
key={i}
style={{ padding: "4px 18px 4px 18px" }}
className="hover-1"
>

View File

@ -1,4 +1,4 @@
import { React, useState, useContext } from "react";
import { useState, useContext } from "react";
import {
sqlDataTypes,
tableThemes,
@ -535,8 +535,8 @@ export default function Table(props) {
values: v,
})
}
onFocus={(e) => setEditField({ values: f.values })}
onBlur={(e) => {
onFocus={() => setEditField({ values: f.values })}
onBlur={() => {
if (
JSON.stringify(editField.values) ===
JSON.stringify(f.values)
@ -1238,7 +1238,7 @@ export default function Table(props) {
<div className={`${hoveredField === index ? "text-zinc-400" : ""}`}>
<button
className={`w-[10px] h-[10px] bg-[#2f68ad] opacity-80 z-50 rounded-full me-2`}
onMouseDown={(ev) => {
onMouseDown={() => {
props.handleGripField(index);
props.setLine((prev) => ({
...prev,

View File

@ -1,4 +1,4 @@
import React, { useContext, useState } from "react";
import { useContext, useState } from "react";
import {
Checkbox,
Input,

View File

@ -1,21 +0,0 @@
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
import { LocaleProvider } from "@douyinfe/semi-ui";
import en_US from "@douyinfe/semi-ui/lib/es/locale/source/en_US";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
// <React.StrictMode>
<LocaleProvider locale={en_US}>
<App />
</LocaleProvider>
// </React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB

15
src/main.jsx Normal file
View File

@ -0,0 +1,15 @@
// import React from 'react';
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
import { LocaleProvider } from "@douyinfe/semi-ui";
import en_US from "@douyinfe/semi-ui/lib/es/locale/source/en_US";
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
// <React.StrictMode>
<LocaleProvider locale={en_US}>
<App />
</LocaleProvider>
// </React.StrictMode>
);

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState, useCallback, useRef } from "react";
import { useEffect, useState, useCallback, useRef } from "react";
import logo_light from "../assets/logo_light_46.png";
import logo_dark from "../assets/logo_dark_46.png";
import { Banner, Button, Input, Upload, Toast, Spin } from "@douyinfe/semi-ui";
@ -59,32 +59,29 @@ function Form({ theme }) {
}));
};
const onSubmit = useCallback(
(e) => {
setLoading(true);
editor.update(() => {
const sendMail = async () => {
await axios
.post(`${process.env.REACT_APP_BACKEND_URL}/send_email`, {
subject: `[BUG REPORT]: ${data.title}`,
message: $generateHtmlFromNodes(editor),
attachments: data.attachments,
})
.then((res) => {
Toast.success("Bug reported!");
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
resetForm();
})
.catch((err) => {
Toast.error("Oops! Something went wrong.");
setLoading(false);
});
};
sendMail();
});
},
[editor, data]
);
const onSubmit = useCallback(() => {
setLoading(true);
editor.update(() => {
const sendMail = async () => {
await axios
.post(`${import.meta.env.VITE_API_BACKEND_URL}/send_email`, {
subject: `[BUG REPORT]: ${data.title}`,
message: $generateHtmlFromNodes(editor),
attachments: data.attachments,
})
.then(() => {
Toast.success("Bug reported!");
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
resetForm();
})
.catch(() => {
Toast.error("Oops! Something went wrong.");
setLoading(false);
});
};
sendMail();
});
}, [editor, data]);
return (
<div className="p-5 mt-6 card-theme rounded-md">
@ -277,7 +274,7 @@ export default function BugReport() {
closeIcon={null}
description={
<div>
We value your feedback! If you've encountered a bug or issue
We value your feedback! If you&apos;ve encountered a bug or issue
while using our platform, please help us improve by reporting
it. Your input is invaluable in making our service better.
</div>

View File

@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react";
import { useState, useEffect } from "react";
import { Link } from "react-router-dom";
import { IconCrossStroked } from "@douyinfe/semi-icons";
import Navbar from "../components/Navbar";

View File

@ -1,4 +1,4 @@
import React, { useEffect } from "react";
import { useEffect } from "react";
import logo_light from "../assets/logo_light_46.png";
import { Link } from "react-router-dom";
import { Tabs, TabPane } from "@douyinfe/semi-ui";
@ -101,6 +101,7 @@ function Thumbnail({ diagram }) {
})}
{diagram.relationships?.map((e, i) => (
<path
key={i}
d={calcPath(e.startX, e.endX, e.startY, e.endY, zoom)}
fill="none"
strokeWidth={1}
@ -115,7 +116,7 @@ function Thumbnail({ diagram }) {
const fold = 24 * zoom;
const h = n.height * zoom;
return (
<g>
<g key={n.id}>
<path
d={`M${x + fold} ${y} L${x + w - r} ${y} A${r} ${r} 0 0 1 ${
x + w
@ -189,7 +190,7 @@ export default function Templates() {
</div>
<div className="text-sm text-neutral-700">
A compilation of database entity relationship diagrams to give you
a quick start or inspire your application's architecture.
a quick start or inspire your application&apos;s architecture.
</div>
</div>
<Tabs>

View File

@ -1,4 +1,4 @@
import React, { useState, createContext, useEffect } from "react";
import { useState, createContext, useEffect } from "react";
import Sidebar from "../components/Sidebar";
import ControlPanel from "../components/ControlPanel";
import Canvas from "../components/Canvas";
@ -29,7 +29,7 @@ export const MessageContext = createContext();
export const BotMessageContext = createContext();
export const TypeContext = createContext();
export default function Editor(props) {
export default function Editor() {
const [id, setId] = useState(0);
const [title, setTitle] = useState("Untitled Diagram");
const [state, setState] = useState(State.NONE);

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import logo from "../assets/logo_light_46.png";
import { IconEyeClosedSolid, IconEyeOpened } from "@douyinfe/semi-icons";
@ -19,14 +19,14 @@ export default function Login() {
const onSubmit = async () => {
await axios
.post(`${process.env.REACT_APP_BACKEND_URL}/login`, {
.post(`${import.meta.env.VITE_API_BACKEND_URL}/login`, {
email: formValues.email,
password: formValues.password,
})
.then((res) => {
console.log(res);
})
.catch((err) => {});
.catch(() => {});
};
useEffect(() => {
@ -90,7 +90,7 @@ export default function Login() {
Log in
</button>
<div className="text-sm text-center">
Don't have an account?
Don&apos;t have an account?
<Link
to="/signup"
className="ms-2 font-semibold text-indigo-700 hover:underline"

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import logo_light from "../assets/logo_light_46.png";
import logo_dark from "../assets/logo_dark_46.png";
import { AutoComplete, Button } from "@douyinfe/semi-ui";
@ -144,7 +144,7 @@ export default function Shortcuts() {
<div className="p-3 popover-theme">No shortcuts found</div>
}
onChange={(v) => setValue(v)}
onSelect={(v) => {}}
onSelect={() => {}}
></AutoComplete>
</div>
</div>
@ -164,7 +164,7 @@ export default function Shortcuts() {
<div className="p-3 popover-theme">No shortcuts found</div>
}
onChange={(v) => setValue(v)}
onSelect={(v) => {}}
onSelect={() => {}}
></AutoComplete>
</div>
<div className="grid sm:grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 my-6 mx-20 sm:mx-6 gap-5 select-none">

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { Link } from "react-router-dom";
import logo from "../assets/logo_light_46.png";
import ReCAPTCHA from "react-google-recaptcha";
@ -24,7 +24,7 @@ export default function SignUp() {
const onSubmit = async () => {
await axios
.post(`${process.env.REACT_APP_BACKEND_URL}/signup`, {
.post(`${import.meta.env.VITE_API_BACKEND_URL}/signup`, {
username: formValues.username,
email: formValues.email,
password: formValues.password,
@ -32,7 +32,7 @@ export default function SignUp() {
.then((res) => {
console.log(res);
})
.catch((err) => {});
.catch(() => {});
};
useEffect(() => {
@ -109,7 +109,9 @@ export default function SignUp() {
bordered
style={{ marginBottom: "12px" }}
title={
<div className="font-bold text-sm">Password isn't secure</div>
<div className="font-bold text-sm">
Password isn&apos;t secure
</div>
}
description={
<div className="w-[236px]">
@ -124,7 +126,7 @@ export default function SignUp() {
></Banner>
)}
<ReCAPTCHA
sitekey={process.env.REACT_APP_CAPTCHA_SITE_KEY}
sitekey={import.meta.env.VITE_API_CAPTCHA_SITE_KEY}
onChange={() =>
setFormValues((prev) => ({ ...prev, captcha: true }))
}

View File

@ -1,4 +1,4 @@
import React, { useEffect, useState, useCallback, useMemo } from "react";
import { useEffect, useState, useCallback, useMemo } from "react";
import logo_light from "../assets/logo_light_46.png";
import logo_dark from "../assets/logo_dark_46.png";
import {
@ -64,12 +64,12 @@ function SurveyForm({ theme }) {
};
const onSubmit = useCallback(
(e) => {
() => {
setLoading(true);
editor.update(() => {
const sendMail = async () => {
await axios
.post(`${process.env.REACT_APP_BACKEND_URL}/send_email`, {
.post(`${import.meta.env.VITE_API_BACKEND_URL}/send_email`, {
subject: `[SURVEY]: ${new Date().toDateString()}`,
message: `${Object.keys(form).map(
(k) => `<div>${questions[k]}</div><div>${form[k]}</div>`
@ -77,12 +77,12 @@ function SurveyForm({ theme }) {
editor
)}`,
})
.then((res) => {
.then(() => {
Toast.success("Thanks for the feedback!");
editor.dispatchCommand(CLEAR_EDITOR_COMMAND, undefined);
resetForm();
})
.catch((err) => {
.catch(() => {
Toast.error("Oops! Something went wrong.");
setLoading(false);
});

View File

@ -456,7 +456,7 @@ export default function ToolbarPlugin(props) {
}),
editor.registerCommand(
SELECTION_CHANGE_COMMAND,
(_payload, newEditor) => {
() => {
updateToolbar();
return false;
},

View File

@ -1,13 +0,0 @@
const reportWebVitals = onPerfEntry => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@ -1,5 +0,0 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

View File

@ -351,7 +351,7 @@ pre::-webkit-scrollbar-thumb {
}
.link-edit {
background-image: url(/public/images/icons/pencil-fill.svg);
background-image: url(/images/icons/pencil-fill.svg);
background-size: 16px;
background-position: center;
background-repeat: no-repeat;
@ -365,7 +365,7 @@ pre::-webkit-scrollbar-thumb {
}
.link-edit-dark {
background-image: url(/public/images/icons/pencil-fill-dark.svg);
background-image: url(/images/icons/pencil-fill-dark.svg);
background-size: 16px;
background-position: center;
background-repeat: no-repeat;

View File

@ -403,7 +403,7 @@ function checkDefault(field) {
return validateDateStr(field.default);
case "TIME":
return /^(?:[01]?\d|2[0-3]):[0-5]?\d:[0-5]?\d$/.test(field.default);
case "TIMESTAMP":
case "TIMESTAMP": {
if (field.default.toUpperCase() === "CURRENT_TIMESTAMP") {
return true;
}
@ -414,7 +414,8 @@ function checkDefault(field) {
const date = content[0].split("-");
return parseInt(date[0]) >= 1970 && parseInt(date[0]) <= 2038;
case "DATETIME":
}
case "DATETIME": {
if (!/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(field.default)) {
return false;
}
@ -422,6 +423,7 @@ function checkDefault(field) {
const d = c[0].split("-");
return parseInt(d[0]) >= 1000 && parseInt(d[0]) <= 9999;
}
default:
return true;
}

View File

@ -1,5 +1,5 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
export default {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],

7
vite.config.js Normal file
View File

@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})