diff --git a/scripts/.air-windows.toml b/scripts/.air-windows.toml index a8346c9c..7c1e7f69 100644 --- a/scripts/.air-windows.toml +++ b/scripts/.air-windows.toml @@ -2,14 +2,14 @@ root = "." tmp_dir = ".air" [build] - bin = "./.air/memos.exe" - cmd = "go build -o ./.air/memos.exe ./main.go" - delay = 1000 - exclude_dir = [".air", "web", "build"] - exclude_file = [] - exclude_regex = [] - exclude_unchanged = false - follow_symlink = false - full_bin = "" - send_interrupt = true - kill_delay = 2000 +bin = "./.air/memos.exe --mode dev" +cmd = "go build -o ./.air/memos.exe ./main.go" +delay = 1000 +exclude_dir = [".air", "web", "build"] +exclude_file = [] +exclude_regex = [] +exclude_unchanged = false +follow_symlink = false +full_bin = "" +send_interrupt = true +kill_delay = 2000 diff --git a/scripts/.air.toml b/scripts/.air.toml index 29b9f525..350d72de 100644 --- a/scripts/.air.toml +++ b/scripts/.air.toml @@ -2,14 +2,14 @@ root = "." tmp_dir = ".air" [build] - bin = "./.air/memos" - cmd = "go build -o ./.air/memos ./main.go" - delay = 1000 - exclude_dir = [".air", "web", "build"] - exclude_file = [] - exclude_regex = [] - exclude_unchanged = false - follow_symlink = false - full_bin = "" - send_interrupt = true - kill_delay = 2000 +bin = "./.air/memos --mode dev" +cmd = "go build -o ./.air/memos ./main.go" +delay = 1000 +exclude_dir = [".air", "web", "build"] +exclude_file = [] +exclude_regex = [] +exclude_unchanged = false +follow_symlink = false +full_bin = "" +send_interrupt = true +kill_delay = 2000 diff --git a/web/src/components/ChangePasswordDialog.tsx b/web/src/components/ChangePasswordDialog.tsx index b79b9c8f..b5704e76 100644 --- a/web/src/components/ChangePasswordDialog.tsx +++ b/web/src/components/ChangePasswordDialog.tsx @@ -1,7 +1,7 @@ import { useEffect, useState } from "react"; import { toast } from "react-hot-toast"; import { useTranslation } from "react-i18next"; -import { useUserStore } from "@/store/module"; +import { useGlobalStore, useUserStore } from "@/store/module"; import Icon from "./Icon"; import { generateDialog } from "./Dialog"; @@ -10,11 +10,16 @@ type Props = DialogProps; const ChangePasswordDialog: React.FC = ({ destroy }: Props) => { const { t } = useTranslation(); const userStore = useUserStore(); + const globalStore = useGlobalStore(); + const profile = globalStore.state.systemStatus.profile; const [newPassword, setNewPassword] = useState(""); const [newPasswordAgain, setNewPasswordAgain] = useState(""); useEffect(() => { - // do nth + if (profile.mode === "demo" && userStore.state.user?.id === userStore.state.host?.id) { + toast.error("Demo mode does not support this operation."); + destroy(); + } }, []); const handleCloseBtnClick = () => { diff --git a/web/src/components/DemoBanner.tsx b/web/src/components/DemoBanner.tsx new file mode 100644 index 00000000..89800150 --- /dev/null +++ b/web/src/components/DemoBanner.tsx @@ -0,0 +1,38 @@ +import { useEffect, useState } from "react"; +import { useGlobalStore } from "@/store/module"; +import Icon from "./Icon"; + +interface State { + show: boolean; +} + +const DemoBanner: React.FC = () => { + const globalStore = useGlobalStore(); + const profile = globalStore.state.systemStatus.profile; + const [state, setState] = useState({ + show: false, + }); + + useEffect(() => { + const isDemo = profile.mode === "demo"; + setState({ + show: isDemo, + }); + }, []); + + if (!state.show) return null; + + return ( +
+
+ A lightweight, self-hosted memo hub. Open Source and Free forever. + + Install + + +
+
+ ); +}; + +export default DemoBanner; diff --git a/web/src/layouts/Root.tsx b/web/src/layouts/Root.tsx index fd27ddfd..7c779db1 100644 --- a/web/src/layouts/Root.tsx +++ b/web/src/layouts/Root.tsx @@ -1,11 +1,13 @@ import { Outlet } from "react-router-dom"; import Header from "@/components/Header"; import UpgradeVersionBanner from "@/components/UpgradeVersionBanner"; +import DemoBanner from "@/components/DemoBanner"; function Root() { return (
+