Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: add demo banner (#1739)
boojack43819b021eb1
diff --git a/scripts/.air-windows.toml b/scripts/.air-windows.tomlindex a8346c9c4..7c1e7f69e 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 = 2000diff --git a/scripts/.air.toml b/scripts/.air.tomlindex 29b9f525b..350d72def 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 = 2000diff --git a/web/src/components/ChangePasswordDialog.tsx b/web/src/components/ChangePasswordDialog.tsxindex b79b9c8fa..b5704e769 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<Props> = ({ 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.tsxnew file mode 100644index 000000000..89800150e--- /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<State>({+ show: false,+ });++ useEffect(() => {+ const isDemo = profile.mode === "demo";+ setState({+ show: isDemo,+ });+ }, []);++ if (!state.show) return null;++ return (+ <div className="flex flex-row items-center justify-center w-full py-2 text-lg font-medium dark:text-gray-300 bg-white dark:bg-zinc-700 shadow">+ <div className="w-full max-w-6xl px-4 flex flex-row justify-between items-center gap-x-3">+ <span>A lightweight, self-hosted memo hub. Open Source and Free forever.</span>+ <a className="btn-primary shadow" href="https://usememos.com/docs/install/docker" target="_blank">+ Install+ <Icon.ExternalLink className="w-4 h-auto ml-1" />+ </a>+ </div>+ </div>+ );+};++export default DemoBanner;diff --git a/web/src/layouts/Root.tsx b/web/src/layouts/Root.tsxindex fd27ddfd4..7c779db16 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 (<div className="w-full min-h-full bg-zinc-100 dark:bg-zinc-800"><div className="w-full h-auto flex flex-col justify-start items-center">+ <DemoBanner /><UpgradeVersionBanner /></div><div className="w-full max-w-6xl mx-auto flex flex-row justify-center items-start">