fix : 修改路徑

This commit is contained in:
Jessie Chen
2024-10-12 02:00:33 +08:00
parent 733200db91
commit 2a621224c3
6 changed files with 25 additions and 14 deletions

3
.gitignore vendored
View File

@@ -23,3 +23,6 @@ dist-ssr
*.sln *.sln
*.sw? *.sw?
.env .env
/dist
/docs

View File

@@ -3,6 +3,7 @@
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"homepage": "index.html#",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",

View File

@@ -1,4 +1,4 @@
import { BrowserRouter, Routes, Route, useLocation } from "react-router-dom"; import { HashRouter, Routes, Route, useLocation } from "react-router-dom";
import { useLayoutEffect } from "react"; import { useLayoutEffect } from "react";
import Editor from "./pages/Editor"; import Editor from "./pages/Editor";
import Survey from "./pages/Survey"; import Survey from "./pages/Survey";
@@ -13,7 +13,7 @@ import { useSettings } from "./hooks";
export default function App() { export default function App() {
return ( return (
<SettingsContextProvider> <SettingsContextProvider>
<BrowserRouter> <HashRouter>
<RestoreScroll /> <RestoreScroll />
<Routes> <Routes>
<Route path="/" element={<LandingPage />} /> <Route path="/" element={<LandingPage />} />
@@ -52,7 +52,7 @@ export default function App() {
<Route path="/templates" element={<Templates />} /> <Route path="/templates" element={<Templates />} />
<Route path="*" element={<LandingPage />} /> <Route path="*" element={<LandingPage />} />
</Routes> </Routes>
</BrowserRouter> </HashRouter>
</SettingsContextProvider> </SettingsContextProvider>
); );
} }

View File

@@ -73,7 +73,7 @@ import { jsonToMermaid } from "../../utils/exportAs/mermaid";
import { isRtl } from "../../i18n/utils/rtl"; import { isRtl } from "../../i18n/utils/rtl";
import { jsonToDocumentation } from "../../utils/exportAs/documentation"; import { jsonToDocumentation } from "../../utils/exportAs/documentation";
import { IdContext } from "../Workspace"; import { IdContext } from "../Workspace";
import packageInfo from '../../../package.json';
export default function ControlPanel({ export default function ControlPanel({
diagramId, diagramId,
setDiagramId, setDiagramId,
@@ -718,7 +718,6 @@ export default function ControlPanel({
const open = () => setModal(MODAL.OPEN); const open = () => setModal(MODAL.OPEN);
const saveDiagramAs = () => setModal(MODAL.SAVEAS); const saveDiagramAs = () => setModal(MODAL.SAVEAS);
const fullscreen = useFullscreen(); const fullscreen = useFullscreen();
const menu = { const menu = {
file: { file: {
new: { new: {
@@ -726,7 +725,10 @@ export default function ControlPanel({
}, },
new_window: { new_window: {
function: () => { function: () => {
const newWindow = window.open("/editor", "_blank"); // for chrome extention
const newWindow = window.open(packageInfo.homepage + "/editor", "_blank");
// for normal
// const newWindow = window.open("/editor", "_blank");
newWindow.name = window.name; newWindow.name = window.name;
}, },
}, },
@@ -1333,17 +1335,17 @@ export default function ControlPanel({
}, },
help: { help: {
shortcuts: { shortcuts: {
function: () => window.open("/shortcuts", "_blank"), function: () => window.open(packageInfo.homepage + "/shortcuts", "_blank"),
shortcut: "Ctrl+H", shortcut: "Ctrl+H",
}, },
ask_on_discord: { ask_on_discord: {
function: () => window.open("https://discord.gg/BrjZgNrmR6", "_blank"), function: () => window.open("https://discord.gg/BrjZgNrmR6", "_blank"),
}, },
report_bug: { report_bug: {
function: () => window.open("/bug-report", "_blank"), function: () => window.open(packageInfo.homepage + "/bug-report", "_blank"),
}, },
feedback: { feedback: {
function: () => window.open("/survey", "_blank"), function: () => window.open(packageInfo.homepage + "/survey", "_blank"),
}, },
}, },
}; };

View File

@@ -43,7 +43,7 @@ import { useTranslation } from "react-i18next";
import { importSQL } from "../../../utils/importSQL"; import { importSQL } from "../../../utils/importSQL";
import { databases } from "../../../data/databases"; import { databases } from "../../../data/databases";
import { isRtl } from "../../../i18n/utils/rtl"; import { isRtl } from "../../../i18n/utils/rtl";
import packageInfo from '../../../../package.json';
const languageExtension = { const languageExtension = {
sql: [sql()], sql: [sql()],
json: [json()], json: [json()],
@@ -59,6 +59,7 @@ export default function Modal({
setExportData, setExportData,
importDb, importDb,
}) { }) {
const { t, i18n } = useTranslation(); const { t, i18n } = useTranslation();
const { setTables, setRelationships, database, setDatabase } = useDiagram(); const { setTables, setRelationships, database, setDatabase } = useDiagram();
const { setNotes } = useNotes(); const { setNotes } = useNotes();
@@ -189,7 +190,8 @@ export default function Modal({
}; };
const createNewDiagram = (id) => { const createNewDiagram = (id) => {
const newWindow = window.open("/editor"); const hostname = packageInfo.homepage;
const newWindow = window.open(hostname + "/editor");
newWindow.name = "lt " + id; newWindow.name = "lt " + id;
}; };

View File

@@ -7,8 +7,11 @@ import { useLiveQuery } from "dexie-react-hooks";
import Thumbnail from "../components/Thumbnail"; import Thumbnail from "../components/Thumbnail";
import logo_light from "../assets/logo_light_160.png"; import logo_light from "../assets/logo_light_160.png";
import template_screenshot from "../assets/template_screenshot.png"; import template_screenshot from "../assets/template_screenshot.png";
import packageInfo from '../../package.json';
export default function Templates() { export default function Templates() {
const hostname = packageInfo.homepage;
// for normal
// const newWindow = window.open("/editor", "_blank");
const defaultTemplates = useLiveQuery(() => const defaultTemplates = useLiveQuery(() =>
db.templates.where({ custom: 0 }).toArray() db.templates.where({ custom: 0 }).toArray()
); );
@@ -22,12 +25,12 @@ export default function Templates() {
}; };
const editTemplate = (id) => { const editTemplate = (id) => {
const newWindow = window.open("/editor", "_blank"); const newWindow = window.open(hostname + "/editor", "_blank");
newWindow.name = "t " + id; newWindow.name = "t " + id;
}; };
const forkTemplate = (id) => { const forkTemplate = (id) => {
const newWindow = window.open("/editor", "_blank"); const newWindow = window.open(hostname + "/editor", "_blank");
newWindow.name = "lt " + id; newWindow.name = "lt " + id;
}; };