@bbki.ng/site 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 2.0.6
4
+
5
+ ## 2.0.5
6
+
3
7
  ## 2.0.4
4
8
 
5
9
  ## 2.0.3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -10,6 +10,7 @@ import React from "react";
10
10
  import { useNavigate } from "react-router-dom";
11
11
  import { supabase } from "@/constants";
12
12
  import { toast } from "sonner";
13
+ import { confirm } from "@/utils";
13
14
 
14
15
  export const LoginMenuItem = () => {
15
16
  const sess = useSupabaseSession();
@@ -20,11 +21,13 @@ export const LoginMenuItem = () => {
20
21
  <ContextMenuItem
21
22
  inset
22
23
  onClick={() => {
23
- supabase.auth.signOut().then(() => {
24
- toast.success("已退出登录", {
25
- position: "bottom-right",
24
+ confirm("确定退出登录吗?", () => {
25
+ supabase.auth.signOut().then(() => {
26
+ toast.success("已退出登录", {
27
+ position: "bottom-right",
28
+ });
26
29
  });
27
- });
30
+ })
28
31
  }}
29
32
  >
30
33
  {sess?.user?.user_metadata && (
@@ -3,6 +3,8 @@ import React from "react";
3
3
  import { GITHUB_REPO_ADDRESS } from "@/constants";
4
4
 
5
5
  export const ViewSourceMenuItem = () => {
6
+ // @ts-ignore
7
+ const appVer = GLOBAL_BBKING_VERSION;
6
8
  return (
7
9
  <ContextMenuItem
8
10
  onClick={() => {
@@ -21,7 +23,7 @@ export const ViewSourceMenuItem = () => {
21
23
  >
22
24
  <path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path>
23
25
  </svg>
24
- view source
26
+ v{appVer}
25
27
  <ContextMenuShortcut>s</ContextMenuShortcut>
26
28
  </ContextMenuItem>
27
29
  );
@@ -34,7 +34,6 @@ export const AppCtxMenu = (props: { children: ReactElement }) => {
34
34
  <ContextMenuTrigger>{props.children}</ContextMenuTrigger>
35
35
  <ContextMenuContent className="w-256">
36
36
  <LoginMenuItem />
37
- <VersionMenuItem />
38
37
  <ViewSourceMenuItem />
39
38
  {showPluginEntry && (
40
39
  <>
@@ -18,16 +18,22 @@ export const GlobalRoutesContext = createContext<GlobalRoutesContextType>({
18
18
  });
19
19
 
20
20
  export const GlobalRoutesProvider = (props: { children: ReactNode }) => {
21
- const [globalRoutes, setGlobalRoutes] = useState<routeInfo[]>([]);
21
+ const [routesMap, setRoutesMap] = useState<{[key: string]: routeInfo}>({});
22
22
 
23
23
  const addGlobalRoute = (r: routeInfo) => {
24
- setGlobalRoutes([...globalRoutes, r]);
24
+ setRoutesMap((prev) => ({ ...prev, [r.name]: r }));
25
25
  };
26
26
 
27
27
  const removeGlobalRoute = (routeName: string) => {
28
- setGlobalRoutes(globalRoutes.filter((r) => r.name !== routeName));
28
+ setRoutesMap((prev) => {
29
+ const copy = { ...prev };
30
+ delete copy[routeName];
31
+ return copy;
32
+ });
29
33
  };
30
34
 
35
+ const globalRoutes = Object.values(routesMap);
36
+
31
37
  return (
32
38
  <GlobalRoutesContext.Provider
33
39
  value={{ globalRoutes, addGlobalRoute, removeGlobalRoute }}