Skip to content

Commit 43819b0

Browse files
authored
chore: add demo banner (usememos#1739)
1 parent e69f7c7 commit 43819b0

5 files changed

Lines changed: 69 additions & 24 deletions

File tree

scripts/.air-windows.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ root = "."
22
tmp_dir = ".air"
33

44
[build]
5-
bin = "./.air/memos.exe"
6-
cmd = "go build -o ./.air/memos.exe ./main.go"
7-
delay = 1000
8-
exclude_dir = [".air", "web", "build"]
9-
exclude_file = []
10-
exclude_regex = []
11-
exclude_unchanged = false
12-
follow_symlink = false
13-
full_bin = ""
14-
send_interrupt = true
15-
kill_delay = 2000
5+
bin = "./.air/memos.exe --mode dev"
6+
cmd = "go build -o ./.air/memos.exe ./main.go"
7+
delay = 1000
8+
exclude_dir = [".air", "web", "build"]
9+
exclude_file = []
10+
exclude_regex = []
11+
exclude_unchanged = false
12+
follow_symlink = false
13+
full_bin = ""
14+
send_interrupt = true
15+
kill_delay = 2000

scripts/.air.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ root = "."
22
tmp_dir = ".air"
33

44
[build]
5-
bin = "./.air/memos"
6-
cmd = "go build -o ./.air/memos ./main.go"
7-
delay = 1000
8-
exclude_dir = [".air", "web", "build"]
9-
exclude_file = []
10-
exclude_regex = []
11-
exclude_unchanged = false
12-
follow_symlink = false
13-
full_bin = ""
14-
send_interrupt = true
15-
kill_delay = 2000
5+
bin = "./.air/memos --mode dev"
6+
cmd = "go build -o ./.air/memos ./main.go"
7+
delay = 1000
8+
exclude_dir = [".air", "web", "build"]
9+
exclude_file = []
10+
exclude_regex = []
11+
exclude_unchanged = false
12+
follow_symlink = false
13+
full_bin = ""
14+
send_interrupt = true
15+
kill_delay = 2000

web/src/components/ChangePasswordDialog.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useState } from "react";
22
import { toast } from "react-hot-toast";
33
import { useTranslation } from "react-i18next";
4-
import { useUserStore } from "@/store/module";
4+
import { useGlobalStore, useUserStore } from "@/store/module";
55
import Icon from "./Icon";
66
import { generateDialog } from "./Dialog";
77

@@ -10,11 +10,16 @@ type Props = DialogProps;
1010
const ChangePasswordDialog: React.FC<Props> = ({ destroy }: Props) => {
1111
const { t } = useTranslation();
1212
const userStore = useUserStore();
13+
const globalStore = useGlobalStore();
14+
const profile = globalStore.state.systemStatus.profile;
1315
const [newPassword, setNewPassword] = useState("");
1416
const [newPasswordAgain, setNewPasswordAgain] = useState("");
1517

1618
useEffect(() => {
17-
// do nth
19+
if (profile.mode === "demo" && userStore.state.user?.id === userStore.state.host?.id) {
20+
toast.error("Demo mode does not support this operation.");
21+
destroy();
22+
}
1823
}, []);
1924

2025
const handleCloseBtnClick = () => {

web/src/components/DemoBanner.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { useEffect, useState } from "react";
2+
import { useGlobalStore } from "@/store/module";
3+
import Icon from "./Icon";
4+
5+
interface State {
6+
show: boolean;
7+
}
8+
9+
const DemoBanner: React.FC = () => {
10+
const globalStore = useGlobalStore();
11+
const profile = globalStore.state.systemStatus.profile;
12+
const [state, setState] = useState<State>({
13+
show: false,
14+
});
15+
16+
useEffect(() => {
17+
const isDemo = profile.mode === "demo";
18+
setState({
19+
show: isDemo,
20+
});
21+
}, []);
22+
23+
if (!state.show) return null;
24+
25+
return (
26+
<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">
27+
<div className="w-full max-w-6xl px-4 flex flex-row justify-between items-center gap-x-3">
28+
<span>A lightweight, self-hosted memo hub. Open Source and Free forever.</span>
29+
<a className="btn-primary shadow" href="https://usememos.com/docs/install/docker" target="_blank">
30+
Install
31+
<Icon.ExternalLink className="w-4 h-auto ml-1" />
32+
</a>
33+
</div>
34+
</div>
35+
);
36+
};
37+
38+
export default DemoBanner;

web/src/layouts/Root.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { Outlet } from "react-router-dom";
22
import Header from "@/components/Header";
33
import UpgradeVersionBanner from "@/components/UpgradeVersionBanner";
4+
import DemoBanner from "@/components/DemoBanner";
45

56
function Root() {
67
return (
78
<div className="w-full min-h-full bg-zinc-100 dark:bg-zinc-800">
89
<div className="w-full h-auto flex flex-col justify-start items-center">
10+
<DemoBanner />
911
<UpgradeVersionBanner />
1012
</div>
1113
<div className="w-full max-w-6xl mx-auto flex flex-row justify-center items-start">

0 commit comments

Comments
 (0)