@bbki.ng/site 1.1.0 → 1.1.2

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
+ ## 1.1.2
4
+
5
+ ## 1.1.1
6
+
3
7
  ## 1.1.0
4
8
 
5
9
  ## 1.0.16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,7 +16,7 @@
16
16
  "url": "git+https://github.com/bbbottle/bbki.ng.git"
17
17
  },
18
18
  "dependencies": {
19
- "@bbki.ng/components": "workspace:2.1.33",
19
+ "@bbki.ng/components": "workspace:2.1.34",
20
20
  "@supabase/supabase-js": "^1.30.6",
21
21
  "classnames": "2.3.1",
22
22
  "react": "^18.0.0",
@@ -24,6 +24,7 @@
24
24
  "react-dom": "^18.0.0",
25
25
  "react-hotkeys-hook": "^3.4.3",
26
26
  "react-router-dom": "6",
27
+ "sonner": "1.4.0",
27
28
  "swr": "^1.2.1"
28
29
  },
29
30
  "devDependencies": {
Binary file
Binary file
package/src/app.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { useContext } from "react";
2
2
  import { Routes, Route, Outlet } from "react-router-dom";
3
- import { Nav, Page, NotFound } from "@bbki.ng/components";
3
+ import { Nav, Page, NotFound, Link } from "@bbki.ng/components";
4
4
  import { HotKeyNav, Stickers } from "./components";
5
5
  import { threeColWrapper } from "@/components/with_wrapper";
6
6
  import { Cover } from "./pages";
@@ -21,6 +21,7 @@ import {
21
21
  GlobalLoadingStateProvider,
22
22
  } from "@/global_loading_state_provider";
23
23
  import { UploadPage } from "@/pages/upload";
24
+ import { Footer } from "@/components/Footer";
24
25
 
25
26
  const Layout = () => {
26
27
  const { isLoading } = useContext(GlobalLoadingContext);
@@ -31,7 +32,7 @@ const Layout = () => {
31
32
  <Nav paths={usePaths()} className="blur-cover" loading={isLoading} />
32
33
  }
33
34
  main={<Outlet />}
34
- footer={null}
35
+ footer={<Footer />}
35
36
  />
36
37
  </>
37
38
  );
@@ -0,0 +1,26 @@
1
+ import React, { useContext } from "react";
2
+ import { Link } from "@bbki.ng/components";
3
+ import { useLocation } from "react-router-dom";
4
+ import { usePaths } from "@/hooks";
5
+ import { GlobalLoadingContext } from "@/global_loading_state_provider";
6
+
7
+ export const Footer = () => {
8
+ const location = useLocation();
9
+ const isRoot = location.pathname === "/";
10
+ const { isLoading } = useContext(GlobalLoadingContext);
11
+
12
+ if (isRoot || isLoading) {
13
+ return;
14
+ }
15
+
16
+ const paths = usePaths();
17
+ const prevPath = paths[paths.length - 2];
18
+
19
+ return (
20
+ <div className="w-full flex justify-center md:hidden">
21
+ <Link to={prevPath.path || ""} className="text-center">
22
+ cd ..
23
+ </Link>
24
+ </div>
25
+ );
26
+ };
@@ -1,4 +1,5 @@
1
- export { Footer } from "./footer";
1
+ import React from "react";
2
+ import { LinkList } from "@bbki.ng/components";
2
3
 
3
4
  export { DisabledText, SmallDisabledText } from "./disabled_text";
4
5
 
@@ -25,3 +26,11 @@ export { Tags } from "./tags";
25
26
  export { Comment } from "./comment";
26
27
 
27
28
  export { MySuspense } from "./my_suspense";
29
+
30
+ export const CenterLinkList = (props: any) => {
31
+ return (
32
+ <div className="flex justify-center pr-32">
33
+ <LinkList {...props} />
34
+ </div>
35
+ );
36
+ };
@@ -1,8 +1,8 @@
1
- import React from "react";
1
+ import React, { useEffect } from "react";
2
+ import { toast } from "sonner";
2
3
 
3
4
  // @ts-ignore
4
5
  import { useRegisterSW } from "virtual:pwa-register/react";
5
- import { CornerPromptBox } from "@/components";
6
6
 
7
7
  export const ReloadPrompt = () => {
8
8
  const {
@@ -21,16 +21,31 @@ export const ReloadPrompt = () => {
21
21
 
22
22
  // @ts-ignore
23
23
  const appVer = GLOBAL_BBKING_VERSION;
24
- console.log("appVer: ", appVer);
25
24
 
26
- return (
27
- <CornerPromptBox
28
- className="z-[1010]"
29
- content={`🚀 发现新版本(当前 v${appVer})。获取更新?`}
30
- showBox={needRefresh}
31
- onCancel={close}
32
- cancelLabel="关闭"
33
- onOk={needRefresh ? () => updateServiceWorker(true) : close}
34
- />
35
- );
25
+ useEffect(() => {
26
+ if (!needRefresh) {
27
+ return;
28
+ }
29
+
30
+ toast("", {
31
+ description: "检测到更新,当前 v" + appVer + "。是否更新?",
32
+ position: "bottom-center",
33
+ actionButtonStyle: {
34
+ backgroundColor: "#fff",
35
+ color: "rgb(37,99,235)",
36
+ },
37
+ action: {
38
+ label: "是",
39
+ onClick: () => {
40
+ if (!needRefresh) {
41
+ setNeedRefresh(false);
42
+ return;
43
+ }
44
+ updateServiceWorker(true);
45
+ },
46
+ },
47
+ });
48
+ }, []);
49
+
50
+ return null;
36
51
  };
@@ -20,11 +20,6 @@ export const GlobalLoadingContext = createContext<LoadingContext>({
20
20
 
21
21
  export const GlobalLoadingStateProvider = (props: { children: ReactNode }) => {
22
22
  const [isLoading, setIsLoading] = useState(false);
23
- const location = useLocation();
24
-
25
- useEffect(() => {
26
- setIsLoading(false);
27
- }, [location.pathname]);
28
23
 
29
24
  return (
30
25
  <GlobalLoadingContext.Provider value={{ isLoading, setIsLoading }}>
package/src/main.tsx CHANGED
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { createRoot } from "react-dom/client";
3
+ import { Toaster } from "sonner";
3
4
  import { BrowserRouter as Router } from "react-router-dom";
4
5
  import { ReloadPrompt } from "@/components";
5
6
  import "@bbki.ng/components/style";
@@ -14,6 +15,7 @@ root.render(
14
15
  <Router>
15
16
  <ReloadPrompt />
16
17
  <App />
18
+ <Toaster />
17
19
  </Router>
18
20
  </React.StrictMode>
19
21
  );
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
2
  import { LinkList } from "@bbki.ng/components";
3
+ import { CenterLinkList } from "@/components";
3
4
 
4
5
  export const Cover = (props: { className: string }) => {
5
6
  return (
6
- <LinkList
7
+ <CenterLinkList
7
8
  links={[
8
9
  {
9
10
  to: "/projects",
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { useProjects } from "@/hooks/use_projects";
3
3
  import { Link, Gallery, ImageRenderer, LinkList } from "@bbki.ng/components";
4
- import { MySuspense } from "@/components";
4
+ import { CenterLinkList, MySuspense } from "@/components";
5
5
 
6
6
  const Projects = () => {
7
7
  const { projects } = useProjects("", true);
@@ -11,7 +11,7 @@ const Projects = () => {
11
11
  name: p.name,
12
12
  }));
13
13
 
14
- return <LinkList links={links} title="照片" />;
14
+ return <CenterLinkList links={links} title=" " />;
15
15
  };
16
16
 
17
17
  export default () => {
@@ -30,11 +30,6 @@ const ProjectDetail = () => {
30
30
  <Gallery images={projects.images.map(imageFormatter)}>
31
31
  {renderUploader()}
32
32
  </Gallery>
33
- <div className="w-full flex justify-center">
34
- <Link to="/projects" className="w-full py-32 md:hidden text-center">
35
- cd ..
36
- </Link>
37
- </div>
38
33
  </>
39
34
  );
40
35
  };
@@ -3,6 +3,7 @@ import { ArticleList } from "./consts";
3
3
  import { LinkList, LinkProps } from "@bbki.ng/components";
4
4
  import { useRouteName } from "@/hooks";
5
5
  import { usePosts } from "@/hooks/use_posts";
6
+ import { CenterLinkList } from "@/components";
6
7
 
7
8
  type TxtProps = {
8
9
  title?: string;
@@ -13,10 +14,17 @@ export default (props: TxtProps) => {
13
14
  const name = useRouteName();
14
15
  const { titleList, isLoading, isError } = usePosts();
15
16
 
16
- const links =
17
- isError || isLoading ? ArticleList : [...ArticleList, ...titleList];
17
+ if (isLoading) {
18
+ return null;
19
+ }
18
20
 
19
- return (
20
- <LinkList links={props.articleList || links} title={props.title || name} />
21
- );
21
+ if (isError) {
22
+ return (
23
+ <CenterLinkList links={props.articleList || ArticleList} title=" " />
24
+ );
25
+ }
26
+
27
+ const links = [...ArticleList, ...titleList];
28
+
29
+ return <CenterLinkList links={props.articleList || links} title=" " />;
22
30
  };
package/vite.config.js CHANGED
@@ -79,9 +79,9 @@ export default defineConfig({
79
79
  ],
80
80
  },
81
81
  manifest: {
82
- name: "BBKi.ng",
83
- short_name: "BBKi.ng",
84
- description: "A Personal Site.",
82
+ name: "bbki.ng",
83
+ short_name: "bbki.ng",
84
+ description: "words, pictures",
85
85
  theme_color: "#ffffff",
86
86
  icons: [
87
87
  {