2022-10-17 13:50:40 +03:00
|
|
|
import "./App.css";
|
|
|
|
import { Routes, Route } from "react-router-dom";
|
|
|
|
import Menu from "./components/menu";
|
|
|
|
import CreateNote from "./pages/create";
|
2022-10-20 17:55:09 +03:00
|
|
|
import Save from "./pages/save-local";
|
2022-10-31 18:31:16 +03:00
|
|
|
import Publish from "./pages/publish";
|
2023-04-03 15:23:41 +03:00
|
|
|
import NotePage from "./pages/note";
|
2022-10-20 21:37:09 +03:00
|
|
|
import Notes from "./pages/notes";
|
2022-11-01 20:29:32 +03:00
|
|
|
import PubNote from "./pages/pubNote";
|
|
|
|
import PubError from "./pages/pubError";
|
2023-01-21 16:59:44 +03:00
|
|
|
import PubNoteSafe from "./pages/pubNoteSafe";
|
2023-04-01 20:57:46 +03:00
|
|
|
import RenderMarkdown from "./components/markdown";
|
2023-04-03 15:23:41 +03:00
|
|
|
import socket from "./components/socket";
|
2023-04-03 17:03:01 +03:00
|
|
|
import Settings from "./pages/settings";
|
2023-04-04 15:15:15 +03:00
|
|
|
import { useState } from "react";
|
2023-04-06 17:19:58 +03:00
|
|
|
import { localesProcess } from "./components/utils";
|
2022-10-17 13:50:40 +03:00
|
|
|
|
|
|
|
function App() {
|
2022-10-18 18:32:25 +03:00
|
|
|
Storage.prototype.setObj = function (key, obj) {
|
|
|
|
return this.setItem(key, JSON.stringify(obj));
|
|
|
|
};
|
|
|
|
Storage.prototype.getObj = function (key) {
|
2022-10-20 17:55:09 +03:00
|
|
|
return JSON.parse(this.getItem(key)) || {};
|
2022-10-18 18:32:25 +03:00
|
|
|
};
|
2022-10-31 18:31:16 +03:00
|
|
|
|
2023-04-04 15:15:15 +03:00
|
|
|
const [key, setKey] = useState(Math.random());
|
|
|
|
|
2023-04-03 17:03:01 +03:00
|
|
|
window.settings = localStorage.getObj("settings") || {};
|
2023-04-06 17:19:58 +03:00
|
|
|
|
|
|
|
localesProcess();
|
2023-04-04 15:15:15 +03:00
|
|
|
|
|
|
|
window.addEventListener("reRenderPage", () => {
|
|
|
|
setKey(Math.random());
|
|
|
|
});
|
2023-04-03 17:03:01 +03:00
|
|
|
|
2023-04-04 18:15:46 +03:00
|
|
|
window.socket = socket;
|
|
|
|
|
2023-04-11 11:57:14 +03:00
|
|
|
if (settings.userName == "bruh") {
|
|
|
|
document.body.classList.add(
|
|
|
|
"transition-transform",
|
|
|
|
"transform",
|
|
|
|
"rotate-180"
|
|
|
|
);
|
|
|
|
} else if (document.body.classList.contains("transition-transform")) {
|
|
|
|
document.body.classList.remove("rotate-180");
|
|
|
|
document.body.classList.add("rotate-0");
|
|
|
|
}
|
|
|
|
|
2022-10-17 13:50:40 +03:00
|
|
|
return (
|
2023-04-04 15:15:15 +03:00
|
|
|
<div
|
|
|
|
className="grid grid-cols-4 lg:grid-cols-5 gap-10 text-black dark:text-white"
|
|
|
|
key={key}
|
|
|
|
>
|
2022-10-17 13:50:40 +03:00
|
|
|
<Menu />
|
|
|
|
<div className="col-span-4 p-5 m-4 rounded-2xl">
|
|
|
|
<Routes>
|
|
|
|
<Route path="/" element={<CreateNote />} />
|
2022-10-20 17:55:09 +03:00
|
|
|
<Route path="/notes/save-local" element={<Save />} />
|
2022-10-31 18:31:16 +03:00
|
|
|
<Route path="/notes/publish" element={<Publish />} />
|
2023-04-03 15:23:41 +03:00
|
|
|
<Route path="/notes/:id" element={<NotePage />} />
|
2022-11-01 20:29:32 +03:00
|
|
|
<Route path="/pubNotes/:id" element={<PubNote />} />
|
2023-01-21 16:59:44 +03:00
|
|
|
<Route path="/pubNotesSafe/:id" element={<PubNoteSafe />} />
|
2022-11-01 20:29:32 +03:00
|
|
|
<Route path="/pubError" element={<PubError />} />
|
2023-04-03 17:03:01 +03:00
|
|
|
<Route path="/settings" element={<Settings />} />
|
2022-10-17 13:50:40 +03:00
|
|
|
<Route
|
|
|
|
path="/about"
|
2022-11-01 21:08:39 +03:00
|
|
|
element={
|
2023-02-09 17:15:34 +03:00
|
|
|
<div className="col-span-4 md">
|
2023-04-19 15:47:09 +03:00
|
|
|
<RenderMarkdown>{locals.about_md}</RenderMarkdown>
|
2022-11-01 21:08:39 +03:00
|
|
|
</div>
|
|
|
|
}
|
2022-10-17 13:50:40 +03:00
|
|
|
/>
|
2022-10-20 21:37:09 +03:00
|
|
|
<Route path="/notes" element={<Notes />} />
|
2022-10-17 13:50:40 +03:00
|
|
|
</Routes>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|