mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
chore: add demo banner (#1739)
This commit is contained in:
@ -2,7 +2,7 @@ root = "."
|
|||||||
tmp_dir = ".air"
|
tmp_dir = ".air"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
bin = "./.air/memos.exe"
|
bin = "./.air/memos.exe --mode dev"
|
||||||
cmd = "go build -o ./.air/memos.exe ./main.go"
|
cmd = "go build -o ./.air/memos.exe ./main.go"
|
||||||
delay = 1000
|
delay = 1000
|
||||||
exclude_dir = [".air", "web", "build"]
|
exclude_dir = [".air", "web", "build"]
|
||||||
|
@ -2,7 +2,7 @@ root = "."
|
|||||||
tmp_dir = ".air"
|
tmp_dir = ".air"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
bin = "./.air/memos"
|
bin = "./.air/memos --mode dev"
|
||||||
cmd = "go build -o ./.air/memos ./main.go"
|
cmd = "go build -o ./.air/memos ./main.go"
|
||||||
delay = 1000
|
delay = 1000
|
||||||
exclude_dir = [".air", "web", "build"]
|
exclude_dir = [".air", "web", "build"]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useUserStore } from "@/store/module";
|
import { useGlobalStore, useUserStore } from "@/store/module";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
import { generateDialog } from "./Dialog";
|
import { generateDialog } from "./Dialog";
|
||||||
|
|
||||||
@ -10,11 +10,16 @@ type Props = DialogProps;
|
|||||||
const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
|
const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const globalStore = useGlobalStore();
|
||||||
|
const profile = globalStore.state.systemStatus.profile;
|
||||||
const [newPassword, setNewPassword] = useState("");
|
const [newPassword, setNewPassword] = useState("");
|
||||||
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
const [newPasswordAgain, setNewPasswordAgain] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
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 = () => {
|
const handleCloseBtnClick = () => {
|
||||||
|
38
web/src/components/DemoBanner.tsx
Normal file
38
web/src/components/DemoBanner.tsx
Normal file
@ -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;
|
@ -1,11 +1,13 @@
|
|||||||
import { Outlet } from "react-router-dom";
|
import { Outlet } from "react-router-dom";
|
||||||
import Header from "@/components/Header";
|
import Header from "@/components/Header";
|
||||||
import UpgradeVersionBanner from "@/components/UpgradeVersionBanner";
|
import UpgradeVersionBanner from "@/components/UpgradeVersionBanner";
|
||||||
|
import DemoBanner from "@/components/DemoBanner";
|
||||||
|
|
||||||
function Root() {
|
function Root() {
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-full bg-zinc-100 dark:bg-zinc-800">
|
<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">
|
<div className="w-full h-auto flex flex-col justify-start items-center">
|
||||||
|
<DemoBanner />
|
||||||
<UpgradeVersionBanner />
|
<UpgradeVersionBanner />
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full max-w-6xl mx-auto flex flex-row justify-center items-start">
|
<div className="w-full max-w-6xl mx-auto flex flex-row justify-center items-start">
|
||||||
|
Reference in New Issue
Block a user