@bbki.ng/site 5.4.2 → 5.4.3

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,7 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 5.4.3
4
+
3
5
  ## 5.4.2
4
6
 
5
7
  ## 5.4.1
package/index.html CHANGED
@@ -55,7 +55,7 @@
55
55
  </style>
56
56
  <script src="https://unpkg.com/open-heart-element" type="module"></script>
57
57
  <script type="module" src="https://cdn.jsdelivr.net/npm/@bbki.ng/bbimg@0.0.3/dist/index.js"></script>
58
- <script type="module" src="https://cdn.jsdelivr.net/npm/@bbki.ng/bb-msg-history@0.6.1/dist/index.js"></script>
58
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@bbki.ng/bb-msg-history@0.7.1/dist/index.js"></script>
59
59
  </head>
60
60
 
61
61
  <body class="h-full m-0 flex flex-col font-mono">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "5.4.2",
3
+ "version": "5.4.3",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,8 +20,8 @@
20
20
  "sonner": "1.4.0",
21
21
  "swr": "^2.2.5",
22
22
  "vaul": "1.1.2",
23
- "@bbki.ng/stylebase": "3.1.1",
24
- "@bbki.ng/components": "5.2.2"
23
+ "@bbki.ng/components": "5.2.2",
24
+ "@bbki.ng/stylebase": "3.1.1"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@mdx-js/mdx": "2.0.0-next.9",
@@ -1,6 +1,8 @@
1
1
  import useSWR from "swr";
2
2
  import { baseFetcher, withBBApi } from "@/utils";
3
3
  import { API_CF_ENDPOINT } from "@/constants/routes";
4
+ import { useContext, useEffect } from "react";
5
+ import { GlobalLoadingContext } from "@/context/global_loading_state_provider";
4
6
 
5
7
  // In dev, use /api prefix to leverage Vite proxy to localhost:8787
6
8
  const isProd = typeof window !== "undefined" && /^https:\/\/bbki.ng/.test(window.location.href);
@@ -22,9 +24,17 @@ export const useStreaming = () => {
22
24
  refreshInterval: 1000,
23
25
  });
24
26
 
27
+ const isLoading = !data && !error;
28
+
29
+ const { setIsLoading } = useContext(GlobalLoadingContext);
30
+
31
+ useEffect(() => {
32
+ setIsLoading(isLoading);
33
+ }, [isLoading, setIsLoading]);
34
+
25
35
  return {
26
36
  streaming: data?.data as StreamingItem[] | undefined,
27
37
  isError: error,
28
- isLoading: !data && !error,
38
+ isLoading,
29
39
  };
30
40
  };
@@ -10,7 +10,9 @@ declare global {
10
10
  "bb-msg-history": React.DetailedHTMLProps<
11
11
  React.HTMLAttributes<HTMLElement>,
12
12
  HTMLElement
13
- >;
13
+ > & {
14
+ loading?: boolean;
15
+ };
14
16
  }
15
17
  }
16
18
  }
@@ -19,12 +21,17 @@ const Streaming = () => {
19
21
  const { streaming, isLoading, isError } = useStreaming();
20
22
  const bbMsgHistoryRef = useRef<HTMLElement>(null);
21
23
 
24
+
22
25
  if (isError) {
23
26
  return <div className="p-8 text-center text-gray-500">加载失败</div>;
24
27
  }
25
28
 
26
29
  const formattedData = formatStreamingData(streaming || []);
27
30
 
31
+ if (isLoading) {
32
+ return null;
33
+ }
34
+
28
35
  return (
29
36
 
30
37
  <div className="h-full w-full p-4">