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
*.sw?
.env
/dist
/docs

View File

@ -3,6 +3,7 @@
"private": true,
"version": "0.0.0",
"type": "module",
"homepage": "index.html#",
"scripts": {
"dev": "vite",
"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 Editor from "./pages/Editor";
import Survey from "./pages/Survey";
@ -13,7 +13,7 @@ import { useSettings } from "./hooks";
export default function App() {
return (
<SettingsContextProvider>
<BrowserRouter>
<HashRouter>
<RestoreScroll />
<Routes>
<Route path="/" element={<LandingPage />} />
@ -52,7 +52,7 @@ export default function App() {
<Route path="/templates" element={<Templates />} />
<Route path="*" element={<LandingPage />} />
</Routes>
</BrowserRouter>
</HashRouter>
</SettingsContextProvider>
);
}

View File

@ -73,7 +73,7 @@ import { jsonToMermaid } from "../../utils/exportAs/mermaid";
import { isRtl } from "../../i18n/utils/rtl";
import { jsonToDocumentation } from "../../utils/exportAs/documentation";
import { IdContext } from "../Workspace";
import packageInfo from '../../../package.json';
export default function ControlPanel({
diagramId,
setDiagramId,
@ -718,7 +718,6 @@ export default function ControlPanel({
const open = () => setModal(MODAL.OPEN);
const saveDiagramAs = () => setModal(MODAL.SAVEAS);
const fullscreen = useFullscreen();
const menu = {
file: {
new: {
@ -726,7 +725,10 @@ export default function ControlPanel({
},
new_window: {
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;
},
},
@ -1333,17 +1335,17 @@ export default function ControlPanel({
},
help: {
shortcuts: {
function: () => window.open("/shortcuts", "_blank"),
function: () => window.open(packageInfo.homepage + "/shortcuts", "_blank"),
shortcut: "Ctrl+H",
},
ask_on_discord: {
function: () => window.open("https://discord.gg/BrjZgNrmR6", "_blank"),
},
report_bug: {
function: () => window.open("/bug-report", "_blank"),
function: () => window.open(packageInfo.homepage + "/bug-report", "_blank"),
},
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 { databases } from "../../../data/databases";
import { isRtl } from "../../../i18n/utils/rtl";
import packageInfo from '../../../../package.json';
const languageExtension = {
sql: [sql()],
json: [json()],
@ -59,6 +59,7 @@ export default function Modal({
setExportData,
importDb,
}) {
const { t, i18n } = useTranslation();
const { setTables, setRelationships, database, setDatabase } = useDiagram();
const { setNotes } = useNotes();
@ -189,7 +190,8 @@ export default function Modal({
};
const createNewDiagram = (id) => {
const newWindow = window.open("/editor");
const hostname = packageInfo.homepage;
const newWindow = window.open(hostname + "/editor");
newWindow.name = "lt " + id;
};

View File

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