From 2a621224c32027f2eb274bcd3586f695912d906c Mon Sep 17 00:00:00 2001 From: Jessie Chen Date: Sat, 12 Oct 2024 02:00:33 +0800 Subject: [PATCH] =?UTF-8?q?fix=20:=20=E4=BF=AE=E6=94=B9=E8=B7=AF=E5=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ package.json | 1 + src/App.jsx | 6 +++--- src/components/EditorHeader/ControlPanel.jsx | 14 ++++++++------ src/components/EditorHeader/Modal/Modal.jsx | 6 ++++-- src/pages/Templates.jsx | 9 ++++++--- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 7ceb59f..22a4e1c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,6 @@ dist-ssr *.sln *.sw? .env + +/dist +/docs \ No newline at end of file diff --git a/package.json b/package.json index e61fa25..49c12bf 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "private": true, "version": "0.0.0", "type": "module", + "homepage": "index.html#", "scripts": { "dev": "vite", "build": "vite build", diff --git a/src/App.jsx b/src/App.jsx index f71a929..667b520 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -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 ( - + } /> @@ -52,7 +52,7 @@ export default function App() { } /> } /> - + ); } diff --git a/src/components/EditorHeader/ControlPanel.jsx b/src/components/EditorHeader/ControlPanel.jsx index 593e69d..84e5102 100644 --- a/src/components/EditorHeader/ControlPanel.jsx +++ b/src/components/EditorHeader/ControlPanel.jsx @@ -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"), }, }, }; diff --git a/src/components/EditorHeader/Modal/Modal.jsx b/src/components/EditorHeader/Modal/Modal.jsx index 009b689..27d4dbc 100644 --- a/src/components/EditorHeader/Modal/Modal.jsx +++ b/src/components/EditorHeader/Modal/Modal.jsx @@ -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; }; diff --git a/src/pages/Templates.jsx b/src/pages/Templates.jsx index 58f1558..37c3ea1 100644 --- a/src/pages/Templates.jsx +++ b/src/pages/Templates.jsx @@ -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; };