@bbki.ng/site 5.4.21 → 5.4.24

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.
Files changed (103) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/index.html +12 -19
  3. package/package.json +5 -8
  4. package/src/blog/app.tsx +32 -44
  5. package/src/blog/components/article/index.tsx +8 -17
  6. package/src/blog/components/index.tsx +0 -12
  7. package/src/blog/components/share/share-btn.tsx +5 -8
  8. package/src/blog/constants/index.ts +1 -16
  9. package/src/blog/constants/routes.ts +12 -22
  10. package/src/blog/context/bbcontext.tsx +7 -7
  11. package/src/blog/hooks/index.ts +3 -18
  12. package/src/blog/hooks/use_dynamic_logo.tsx +6 -11
  13. package/src/blog/hooks/use_posts.ts +19 -10
  14. package/src/blog/hooks/use_role.ts +9 -14
  15. package/src/blog/hooks/use_streaming.ts +16 -16
  16. package/src/blog/index.tsx +5 -11
  17. package/src/blog/pages/cover/index.tsx +0 -1
  18. package/src/blog/pages/extensions/txt/article.tsx +7 -21
  19. package/src/blog/pages/extensions/txt/index.tsx +3 -20
  20. package/src/blog/pages/login/index.tsx +18 -42
  21. package/src/blog/swr.tsx +4 -7
  22. package/src/blog/utils/index.ts +9 -172
  23. package/vite.config.js +2 -1
  24. package/src/blog/articles/anti-logic.mdx +0 -61
  25. package/src/blog/articles/bbking-manual.mdx +0 -7
  26. package/src/blog/articles/black-river.mdx +0 -8
  27. package/src/blog/articles/celebration.mdx +0 -21
  28. package/src/blog/articles/cloth.mdx +0 -11
  29. package/src/blog/articles/cooking.mdx +0 -7
  30. package/src/blog/articles/cooldown.mdx +0 -12
  31. package/src/blog/articles/cousin.mdx +0 -15
  32. package/src/blog/articles/fall.mdx +0 -8
  33. package/src/blog/articles/img.mdx +0 -104
  34. package/src/blog/articles/leaves.mdx +0 -7
  35. package/src/blog/articles/liqiu.mdx +0 -7
  36. package/src/blog/articles/loading.mdx +0 -144
  37. package/src/blog/articles/love.mdx +0 -19
  38. package/src/blog/articles/major-cold.mdx +0 -14
  39. package/src/blog/articles/marshroom.mdx +0 -17
  40. package/src/blog/articles/men-without-women.mdx +0 -19
  41. package/src/blog/articles/moment.mdx +0 -9
  42. package/src/blog/articles/movie-day.mdx +0 -15
  43. package/src/blog/articles/photos.mdx +0 -13
  44. package/src/blog/articles/projects.mdx +0 -8
  45. package/src/blog/articles/pseudo-spring.mdx +0 -7
  46. package/src/blog/articles/quote.mdx +0 -26
  47. package/src/blog/articles/red-gun.mdx +0 -19
  48. package/src/blog/articles/rice-noodle.mdx +0 -21
  49. package/src/blog/articles/spring-cooldown.mdx +0 -8
  50. package/src/blog/articles/spring-rain.mdx +0 -10
  51. package/src/blog/articles/travel.mdx +0 -22
  52. package/src/blog/articles/warming-up.mdx +0 -10
  53. package/src/blog/articles/web-burnning.mdx +0 -10
  54. package/src/blog/articles/woke-up.mdx +0 -7
  55. package/src/blog/articles/xwy-and-snowing.mdx +0 -13
  56. package/src/blog/articles/xwy.mdx +0 -9
  57. package/src/blog/components/ImageUploader.tsx +0 -55
  58. package/src/blog/components/Img_ctx_menu/index.tsx +0 -67
  59. package/src/blog/components/Logger.tsx +0 -9
  60. package/src/blog/components/Pochacco/Pochacco.tsx +0 -29
  61. package/src/blog/components/Pochacco/idle.tsx +0 -31
  62. package/src/blog/components/Pochacco/watch.tsx +0 -28
  63. package/src/blog/components/Version.tsx +0 -14
  64. package/src/blog/components/app_ctx_menu/LoginMenuItem.tsx +0 -72
  65. package/src/blog/components/app_ctx_menu/PostMenuItem.tsx +0 -22
  66. package/src/blog/components/app_ctx_menu/VersionMenuItem.tsx +0 -13
  67. package/src/blog/components/app_ctx_menu/ViewSourceMenuItem.tsx +0 -34
  68. package/src/blog/components/app_ctx_menu/index.tsx +0 -35
  69. package/src/blog/components/article_ctx_menu/index.tsx +0 -58
  70. package/src/blog/components/aspect_ratio_box/index.tsx +0 -29
  71. package/src/blog/components/blur_cover/index.tsx +0 -28
  72. package/src/blog/components/hotkey_nav/index.tsx +0 -51
  73. package/src/blog/components/progress_bar/index.tsx +0 -31
  74. package/src/blog/components/reaction/emojis.tsx +0 -143
  75. package/src/blog/components/reaction/oh_reaction.tsx +0 -105
  76. package/src/blog/components/reload_prompt/index.tsx +0 -51
  77. package/src/blog/components/tags/index.tsx +0 -52
  78. package/src/blog/components/video_player/index.tsx +0 -82
  79. package/src/blog/global/mdx.d.ts +0 -9
  80. package/src/blog/hooks/useLoadingIndicator.ts +0 -12
  81. package/src/blog/hooks/useScrollToTop.ts +0 -24
  82. package/src/blog/hooks/useTransitionCls.ts +0 -36
  83. package/src/blog/hooks/use_authed.ts +0 -7
  84. package/src/blog/hooks/use_authed_fetcher.ts +0 -8
  85. package/src/blog/hooks/use_authed_string_post.ts +0 -42
  86. package/src/blog/hooks/use_clipboard_content.ts +0 -21
  87. package/src/blog/hooks/use_clipboard_to_post.ts +0 -48
  88. package/src/blog/hooks/use_del_img.ts +0 -22
  89. package/src/blog/hooks/use_delete_post.ts +0 -22
  90. package/src/blog/hooks/use_file_to_post.ts +0 -38
  91. package/src/blog/hooks/use_img_loading.ts +0 -16
  92. package/src/blog/hooks/use_post.ts +0 -26
  93. package/src/blog/hooks/use_projects.ts +0 -67
  94. package/src/blog/hooks/use_route_name.ts +0 -7
  95. package/src/blog/hooks/use_shared_string_to_post.ts +0 -23
  96. package/src/blog/hooks/use_supa_session.ts +0 -31
  97. package/src/blog/hooks/use_text_plain_file.ts +0 -36
  98. package/src/blog/hooks/use_uploader.ts +0 -34
  99. package/src/blog/hooks/use_video_controls.ts +0 -71
  100. package/src/blog/pages/upload/index.tsx +0 -39
  101. package/src/blog/types/supabase.ts +0 -12
  102. package/src/blog/types/upload.ts +0 -16
  103. package/src/blog/utils/tags.ts +0 -21
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 5.4.24
4
+
5
+ ### Patch Changes
6
+
7
+ - 21296f0: update backend
8
+ - Updated dependencies [21296f0]
9
+ - @bbki.ng/components@5.2.14
10
+
11
+ ## 5.4.23
12
+
13
+ ### Patch Changes
14
+
15
+ - 796a37a: remove unused code
16
+ - Updated dependencies [796a37a]
17
+ - @bbki.ng/components@5.2.13
18
+
19
+ ## 5.4.22
20
+
21
+ ### Patch Changes
22
+
23
+ - f40a245: bug fix
24
+
3
25
  ## 5.4.21
4
26
 
5
27
  ### Patch Changes
package/index.html CHANGED
@@ -1,13 +1,10 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="en" class="h-full no-scrollbar">
3
3
  <head>
4
4
  <title>bbki.ng</title>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <meta name="description" content="baby king" />
7
- <meta
8
- name="apple-mobile-web-app-status-bar-style"
9
- content="black-translucent"
10
- />
7
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
11
8
  <link
12
9
  rel="preload"
13
10
  href="https://api.bbki.ng/projects"
@@ -23,17 +20,8 @@
23
20
  type="application/json"
24
21
  />
25
22
  <link rel="icon" type="image/svg" href="/favicon.svg" />
26
- <link
27
- rel="alternate icon"
28
- href="/favicon.ico"
29
- type="image/png"
30
- sizes="16x16"
31
- />
32
- <link
33
- rel="apple-touch-icon"
34
- href="/apple-touch-icon.png?v=1.0"
35
- sizes="180x180"
36
- />
23
+ <link rel="alternate icon" href="/favicon.ico" type="image/png" sizes="16x16" />
24
+ <link rel="apple-touch-icon" href="/apple-touch-icon.png?v=1.0" sizes="180x180" />
37
25
  <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
38
26
  <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
39
27
  <link rel="mask-icon" href="/favicon.svg" color="#FFFFFF" />
@@ -53,9 +41,14 @@
53
41
  background: #f5f5f5; /* 与组件默认 placeholder 一致 */
54
42
  }
55
43
  </style>
56
- <script src="https://unpkg.com/open-heart-element" type="module"></script>
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@3.0.0/dist/index.js"></script>
44
+ <script
45
+ type="module"
46
+ src="https://cdn.jsdelivr.net/npm/@bbki.ng/bbimg@0.0.3/dist/index.js"
47
+ ></script>
48
+ <script
49
+ type="module"
50
+ src="https://cdn.jsdelivr.net/npm/@bbki.ng/bb-msg-history@3.0.0/dist/index.js"
51
+ ></script>
59
52
  </head>
60
53
 
61
54
  <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.21",
3
+ "version": "5.4.24",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -9,16 +9,12 @@
9
9
  "url": "git+https://github.com/bbbottle/bbki.ng.git"
10
10
  },
11
11
  "dependencies": {
12
- "@supabase/supabase-js": "^1.35.4",
13
- "@tailwindcss/vite": "4.1.17",
14
12
  "classnames": "2.3.1",
15
13
  "react": "^18.0.0",
16
14
  "react-dom": "^18.0.0",
17
- "react-hotkeys-hook": "^3.4.3",
18
15
  "react-router-dom": "6",
19
- "sonner": "1.4.0",
20
16
  "swr": "^2.2.5",
21
- "@bbki.ng/components": "5.2.12"
17
+ "@bbki.ng/components": "5.2.14"
22
18
  },
23
19
  "devDependencies": {
24
20
  "@eslint/compat": "^1.0.0",
@@ -27,6 +23,7 @@
27
23
  "@mdx-js/react": "^3.0.0",
28
24
  "@mdx-js/rollup": "^3.0.0",
29
25
  "@tailwindcss/postcss": "4.1.17",
26
+ "@tailwindcss/vite": "4.1.17",
30
27
  "@tailwindcss/typography": "^0.5.0",
31
28
  "@types/node": "^20.0.0",
32
29
  "@types/react": "^18.0.15",
@@ -60,8 +57,8 @@
60
57
  "vite-plugin-mdx": "^3.5.8",
61
58
  "vite-plugin-pwa": "0.19",
62
59
  "workbox-window": "^6.3.0",
63
- "@bbki.ng/config": "1.0.4",
64
- "@bbki.ng/stylebase": "3.1.5"
60
+ "@bbki.ng/config": "1.0.6",
61
+ "@bbki.ng/stylebase": "3.1.7"
65
62
  },
66
63
  "author": "bbbottle",
67
64
  "license": "MIT",
package/src/blog/app.tsx CHANGED
@@ -1,7 +1,6 @@
1
- import React, { useContext } from 'react';
1
+ import React, { useContext, useMemo } from 'react';
2
2
  import { Outlet, Route, Routes } from 'react-router-dom';
3
3
  import { Nav, NotFound, Page } from '@bbki.ng/components';
4
- import { HotKeyNav } from './components';
5
4
  import { Cover, Streaming } from './pages';
6
5
 
7
6
  import ArticlePage from '@/pages/extensions/txt/article';
@@ -11,70 +10,59 @@ import { usePaths } from '@/hooks';
11
10
  import { Login } from '@/pages/login';
12
11
  import { SWR } from '@/swr';
13
12
  import { GlobalLoadingContext } from '@/context/global_loading_state_provider';
14
- import { AppCtxMenu } from '@/components/app_ctx_menu';
15
13
  import { BotRedirect } from '@/pages/bot';
16
14
  import { BBContext } from '@/context/bbcontext';
17
- import { useClipboardToPost } from '@/hooks/use_clipboard_to_post';
18
- import { useSharedStringToPost } from '@/hooks/use_shared_string_to_post';
19
15
  import { ThreeColLayout, ErrorBoundary } from '@bbki.ng/components';
20
16
  import { useDynamicLogo } from './hooks/use_dynamic_logo';
17
+ import { EffectContextProvider } from './components/effect-layer/EffectContextProvider';
21
18
 
22
19
  const Layout = () => {
20
+ const paths = usePaths();
23
21
  const { isLoading } = useContext(GlobalLoadingContext);
24
22
  const logo = useDynamicLogo();
23
+
24
+ const middleRenderer = useMemo(() => {
25
+ return () => (
26
+ <ErrorBoundary>
27
+ <Outlet />
28
+ </ErrorBoundary>
29
+ );
30
+ }, []);
31
+
25
32
  return (
26
33
  <Page
27
34
  nav={
28
- <AppCtxMenu>
29
- <Nav
30
- paths={usePaths()}
31
- className="gradient-blur-cover select-none"
32
- loading={isLoading}
33
- customLogo={logo}
34
- />
35
- </AppCtxMenu>
36
- }
37
- main={
38
- <ThreeColLayout
39
- middleRenderer={() => {
40
- return (
41
- <ErrorBoundary>
42
- <Outlet />
43
- </ErrorBoundary>
44
- );
45
- }}
35
+ <Nav
36
+ paths={paths}
37
+ className="gradient-blur-cover select-none"
38
+ loading={isLoading}
39
+ customLogo={logo}
46
40
  />
47
41
  }
42
+ main={<ThreeColLayout middleRenderer={middleRenderer} />}
48
43
  />
49
44
  );
50
45
  };
51
46
 
52
47
  export const App = () => {
53
- useClipboardToPost();
54
-
55
- useSharedStringToPost();
56
-
57
48
  return (
58
49
  <SWR>
59
- <HotKeyNav>
60
- <BBContext>
61
- <Routes>
62
- <Route path="/" element={<Layout />}>
63
- <Route index element={<Cover />} />
64
-
65
- <Route path="blog" element={<Outlet />}>
66
- <Route path="" element={<Txt />} />
67
- <Route path=":title" element={<ArticlePage />} />
68
- </Route>
50
+ <BBContext>
51
+ <Routes>
52
+ <Route path="/" element={<Layout />}>
53
+ <Route index element={<Cover />} />
69
54
 
70
- <Route path="bot" element={<BotRedirect />} />
71
- <Route path="login" element={<Login />} />
72
- <Route path="now" element={<Streaming />} />
55
+ <Route path="blog" element={<Outlet />}>
56
+ <Route path="" element={<Txt />} />
57
+ <Route path=":title" element={<ArticlePage />} />
73
58
  </Route>
74
- <Route path="*" element={<NotFound />} />
75
- </Routes>
76
- </BBContext>
77
- </HotKeyNav>
59
+
60
+ <Route path="bot" element={<BotRedirect />} />
61
+ <Route path="now" element={<Streaming />} />
62
+ </Route>
63
+ <Route path="*" element={<NotFound />} />
64
+ </Routes>
65
+ </BBContext>
78
66
  </SWR>
79
67
  );
80
68
  };
@@ -1,10 +1,8 @@
1
- import React, { ReactElement } from "react";
2
- import { Tags, Article, Button } from "@bbki.ng/components";
3
- import { ROUTES } from "@/constants";
4
- import classNames from "classnames";
5
- import { Reaction } from "../reaction/oh_reaction";
6
- import { useNavigate } from "react-router-dom";
7
- import { ShareBtn } from "../share/share-btn";
1
+ import React, { ReactElement } from 'react';
2
+ import { Tags, Article, Button } from '@bbki.ng/components';
3
+ import { ROUTES } from '@/constants';
4
+ import classNames from 'classnames';
5
+ import { useNavigate } from 'react-router-dom';
8
6
 
9
7
  export type ArticlePageProps = {
10
8
  tags?: string[];
@@ -19,18 +17,12 @@ export type ArticlePageProps = {
19
17
  export const ArticlePage = (props: ArticlePageProps) => {
20
18
  const { tags: tagNames, title, description, headless } = props;
21
19
  const navgation = useNavigate();
22
- // const defaultTag = { children: "目录", to: "/blog" };
23
- const allTags = tagNames
24
- ? tagNames.map((t) => ({ children: t, to: `${ROUTES.TAGS}/${t}` }))
25
- : [];
26
-
27
- // const allTags = [defaultTag, ...tags];
28
20
 
29
21
  if (headless) {
30
22
  return props.children;
31
23
  }
32
24
 
33
- const articleCls = classNames("prose", "mb-32");
25
+ const articleCls = classNames('prose', 'mb-32');
34
26
 
35
27
  return (
36
28
  <>
@@ -42,10 +34,9 @@ export const ArticlePage = (props: ArticlePageProps) => {
42
34
  loading={false}
43
35
  >
44
36
  <article className={articleCls}>{props.children}</article>
45
- <div className="relative -left-8">
46
- {allTags.length ? <Tags tags={allTags} className="mb-32" /> : null}
37
+ {/*<div className="relative -left-8">
47
38
  <Reaction title={title} url={window.location.href} />
48
- </div>
39
+ </div>*/}
49
40
  </Article>
50
41
  <div className="">
51
42
  <Button
@@ -4,18 +4,6 @@ import { BlurCover } from '@bbki.ng/components';
4
4
 
5
5
  export { withArticleWrapper } from './with_wrapper';
6
6
 
7
- export { HotKeyNav } from './hotkey_nav';
8
-
9
- export { VideoPlayer } from './video_player';
10
-
11
- export { ProgressBar } from './progress_bar';
12
-
13
- export { BlurCover } from './blur_cover';
14
-
15
- export { ReloadPrompt } from './reload_prompt';
16
-
17
- export { Tags } from './tags';
18
-
19
7
  export { MySuspense } from './my_suspense';
20
8
 
21
9
  export const CenterLinkList = (props: any) => {
@@ -1,20 +1,17 @@
1
- import React from "react";
2
- import { Button, ButtonType } from "@bbki.ng/components";
3
- import { ShareIcon } from "./share-icon";
4
- import { toast } from "sonner";
1
+ import React from 'react';
2
+ import { Button, ButtonType } from '@bbki.ng/components';
3
+ import { ShareIcon } from './share-icon';
5
4
 
6
5
  export const ShareBtn = ({ shareInfo }: { shareInfo: ShareData }) => {
7
6
  const handleShare = async () => {
8
7
  try {
9
8
  await navigator.share(shareInfo);
10
- toast.success("已分享");
11
9
  } catch (error) {
12
- const isAbortError = (error as Error).name === "AbortError";
10
+ const isAbortError = (error as Error).name === 'AbortError';
13
11
  if (isAbortError) {
14
12
  return;
15
13
  }
16
-
17
- toast.error((error as Error).message);
14
+ console.error('Share failed:', (error as Error).message);
18
15
  }
19
16
  };
20
17
 
@@ -1,16 +1 @@
1
- import { createClient } from "@supabase/supabase-js";
2
-
3
- export { ROUTES, ROUTE_NAME, GITHUB_REPO_ADDRESS } from "./routes";
4
- export const DEFAULT_DELAY = 200;
5
- export const SUPABASE: {
6
- ANNO: string;
7
- URL: string;
8
- BB_KING_ID: string;
9
- BB_QUEEN_ID: string;
10
- } = {
11
- ANNO: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImN2eHFtdXNmYXh3dXl2eXV1ZWNvIiwicm9sZSI6ImFub24iLCJpYXQiOjE2NDQ4MjkwNTEsImV4cCI6MTk2MDQwNTA1MX0.lg90OVR7s6tjbDamVaI9FR2M2fc6OVfsfGd4j9MXu3M",
12
- URL: "https://cvxqmusfaxwuyvyuueco.supabase.co",
13
- BB_KING_ID: "e6795b1d-7ee0-4afe-be63-796670848175",
14
- BB_QUEEN_ID: "ca7d5130-2826-4bcb-86ad-6fab1fae8e3d",
15
- };
16
- export const supabase = createClient(SUPABASE.URL, SUPABASE.ANNO);
1
+ export { ROUTES, ROUTE_NAME, GITHUB_REPO_ADDRESS } from './routes';
@@ -1,30 +1,20 @@
1
1
  export const ROUTES = {
2
- INDEX: "/",
3
- CONTENT: "/blog",
4
- HELP: "/blog/说明书",
5
- TAGS: "/tags",
6
- LOGIN: "/login",
7
- BLOG: "/blog",
2
+ INDEX: '/',
3
+ CONTENT: '/blog',
4
+ HELP: '/blog/说明书',
5
+ TAGS: '/tags',
6
+ LOGIN: '/login',
7
+ BLOG: '/blog',
8
8
  };
9
9
 
10
10
  export const ROUTE_NAME = {
11
- [ROUTES.CONTENT]: "目录",
12
- [ROUTES.BLOG]: "文章",
13
- unknown: "未知",
11
+ [ROUTES.CONTENT]: '目录',
12
+ [ROUTES.BLOG]: '文章',
13
+ unknown: '未知',
14
14
  };
15
15
 
16
- export const GITHUB_REPO_ADDRESS =
17
- "https://github.com/bbbottle/bottle/tree/main/packages/site";
18
- export const OSS_ADDRESS = "https://zjh-im-res.oss-cn-shenzhen.aliyuncs.com";
19
- export const API_ENDPOINT = "https://api.bbki.ng";
20
- export const API_CF_ENDPOINT = "https://cf.bbki.ng";
16
+ export const GITHUB_REPO_ADDRESS = 'https://github.com/bbbottle/bottle/tree/main/packages/site';
17
+ export const API_ENDPOINT = 'https://cf.bbki.ng';
21
18
  export const API = {
22
- PROJECTS: "projects",
23
- UPLOAD_IMG: "upload",
24
- POST: "post",
25
- REMOVE_POST: "remove_post",
26
- REMOVE_IMG: "remove_image",
27
- MOVIES: "movies",
28
- BOOKS: "books",
29
- POSTS: "posts",
19
+ POSTS: 'posts',
30
20
  };
@@ -1,14 +1,14 @@
1
- import React, { ReactNode } from "react";
2
- import { GlobalLoadingStateProvider } from "@/context/global_loading_state_provider";
3
- import {
4
- GlobalRoutesContext,
5
- GlobalRoutesProvider,
6
- } from "@/context/global_routes_provider";
1
+ import React, { ReactNode } from 'react';
2
+ import { GlobalLoadingStateProvider } from '@/context/global_loading_state_provider';
3
+ import { GlobalRoutesContext, GlobalRoutesProvider } from '@/context/global_routes_provider';
4
+ import { EffectContextProvider } from '@/components/effect-layer/EffectContextProvider';
7
5
 
8
6
  export const BBContext = (props: { children: ReactNode }) => {
9
7
  return (
10
8
  <GlobalLoadingStateProvider>
11
- <GlobalRoutesProvider>{props.children}</GlobalRoutesProvider>
9
+ <GlobalRoutesProvider>
10
+ <EffectContextProvider>{props.children}</EffectContextProvider>
11
+ </GlobalRoutesProvider>
12
12
  </GlobalLoadingStateProvider>
13
13
  );
14
14
  };
@@ -1,18 +1,3 @@
1
- import { buildSimpleApiHooks } from "@/utils";
2
- import { API } from "@/constants/routes";
3
-
4
- export { usePaths } from "./use_paths";
5
- export { useRouteName } from "./use_route_name";
6
- export { useImgLoading } from "./use_img_loading";
7
-
8
- export {
9
- useVideoControls,
10
- useVideoProgress,
11
- useVideoEleHeight,
12
- } from "./use_video_controls";
13
-
14
- export const useMovies = buildSimpleApiHooks(API.MOVIES, "movies");
15
- export const useBooks = buildSimpleApiHooks(API.BOOKS, "books");
16
-
17
- export { useStreaming } from "./use_streaming";
18
- export type { StreamingItem } from "./use_streaming";
1
+ export { usePaths } from './use_paths';
2
+ export { useStreaming } from './use_streaming';
3
+ export type { StreamingItem } from './use_streaming';
@@ -1,19 +1,14 @@
1
- import React from "react";
2
- import { Role, useRole } from "./use_role";
3
- import { Pochacco, PochaccoPose } from "@/components/Pochacco/Pochacco";
4
- import { useLocation } from "react-router-dom";
1
+ import React from 'react';
2
+ import { Role, useRole } from './use_role';
3
+ import { useLocation } from 'react-router-dom';
4
+ import { Crows } from '@/components/Pochacco/xwy';
5
5
 
6
6
  export const useDynamicLogo = () => {
7
7
  const role = useRole();
8
- const isQueen = role === Role.QUEEN;
9
8
  const location = useLocation();
10
9
 
11
- if (decodeURIComponent(location.pathname).includes("小乌鸦")) {
12
- return <Pochacco pose={PochaccoPose.Crows} />;
13
- }
14
-
15
- if (isQueen) {
16
- return <Pochacco pose={PochaccoPose.Watching} />;
10
+ if (decodeURIComponent(location.pathname).includes('小乌鸦')) {
11
+ return <Crows />;
17
12
  }
18
13
 
19
14
  return null;
@@ -1,18 +1,29 @@
1
- import { API } from "@/constants/routes";
2
- import useSWR from "swr";
3
- import { useContext, useEffect } from "react";
4
- import { GlobalLoadingContext } from "@/context/global_loading_state_provider";
1
+ import useSWR from 'swr';
2
+ import { useContext, useEffect } from 'react';
3
+ import { GlobalLoadingContext } from '@/context/global_loading_state_provider';
4
+ import { baseFetcher } from '@/utils';
5
+ import { API_ENDPOINT } from '@/constants/routes';
5
6
 
6
- export const usePosts = (name: string = "", suspense?: boolean) => {
7
- const { data, error } = useSWR(API.POSTS, {
7
+ // In dev, use /api prefix to leverage Vite proxy to localhost:8787
8
+ const isProd = typeof window !== 'undefined' && /^https:\/\/bbki\.ng/.test(window.location.href);
9
+ const POSTS_API = !isProd ? '/api/posts' : `${API_ENDPOINT}/posts`;
10
+
11
+ // Use baseFetcher for full URLs, cfApiFetcher is for relative paths
12
+ const postsFetcher = (resource: string) => baseFetcher(resource);
13
+
14
+ export const usePosts = (name: string = '', suspense?: boolean) => {
15
+ const { data: response, error } = useSWR(POSTS_API, postsFetcher, {
8
16
  revalidateOnFocus: false,
9
17
  suspense,
10
18
  });
11
19
 
20
+ // Extract posts array from API response { status: "success", data: [...] }
21
+ const data = response?.data;
22
+
12
23
  let isLoading = !data && !error;
13
24
  const { setIsLoading } = useContext(GlobalLoadingContext);
14
25
  const titleList =
15
- isLoading || error
26
+ isLoading || error || !data
16
27
  ? []
17
28
  : data.map((p: any) => ({
18
29
  name: p.title,
@@ -24,9 +35,7 @@ export const usePosts = (name: string = "", suspense?: boolean) => {
24
35
  }, [isLoading]);
25
36
 
26
37
  const posts =
27
- isLoading || name == "" || error
28
- ? data
29
- : data.find((p: any) => p.title == name);
38
+ isLoading || name == '' || error || !data ? data : data.find((p: any) => p.title == name);
30
39
 
31
40
  return {
32
41
  posts: posts,
@@ -1,19 +1,14 @@
1
- import { useSupabaseSession } from "@/hooks/use_supa_session";
2
-
3
1
  export enum Role {
4
- KING = "king",
5
- QUEEN = "queen",
6
- ANNO = "anno",
2
+ KING = 'king',
3
+ QUEEN = 'queen',
4
+ ANNO = 'anno',
7
5
  }
8
- export const useRole = (): Role => {
9
- const sess = useSupabaseSession();
10
- if (sess?.isKing) {
11
- return Role.KING;
12
- }
13
-
14
- if (sess?.isQueen) {
15
- return Role.QUEEN;
16
- }
17
6
 
7
+ /**
8
+ * Returns user role
9
+ * Currently always returns ANNO as role-based authentication is now handled via API keys in CLI
10
+ * Frontend role management may be re-implemented in the future
11
+ */
12
+ export const useRole = (): Role => {
18
13
  return Role.ANNO;
19
14
  };
@@ -1,13 +1,13 @@
1
- import useSWR from "swr";
2
- import useSWRInfinite from "swr/infinite";
3
- import { baseFetcher, withBBApi } from "@/utils";
4
- import { API_CF_ENDPOINT } from "@/constants/routes";
5
- import { useContext, useEffect, useState, useCallback } from "react";
6
- import { GlobalLoadingContext } from "@/context/global_loading_state_provider";
1
+ import useSWR from 'swr';
2
+ import useSWRInfinite from 'swr/infinite';
3
+ import { baseFetcher, withBBApi } from '@/utils';
4
+ import { API_ENDPOINT } from '@/constants/routes';
5
+ import { useContext, useEffect, useState, useCallback } from 'react';
6
+ import { GlobalLoadingContext } from '@/context/global_loading_state_provider';
7
7
 
8
8
  // In dev, use /api prefix to leverage Vite proxy to localhost:8787
9
- const isProd = typeof window !== "undefined" && /^https:\/\/bbki.ng/.test(window.location.href);
10
- const API_BASE = !isProd ? "/api" : API_CF_ENDPOINT;
9
+ const isProd = typeof window !== 'undefined' && /^https:\/\/bbki.ng/.test(window.location.href);
10
+ const API_BASE = !isProd ? '/api' : API_ENDPOINT;
11
11
 
12
12
  export type StreamingItem = {
13
13
  id: string;
@@ -38,13 +38,13 @@ function buildStreamingUrl(params: StreamingQueryParams = {}): string {
38
38
  const url = new URL(`${API_BASE}/streaming`, !isProd ? window.location.origin : undefined);
39
39
 
40
40
  if (params.before) {
41
- url.searchParams.set("before", params.before);
41
+ url.searchParams.set('before', params.before);
42
42
  }
43
43
  if (params.after) {
44
- url.searchParams.set("after", params.after);
44
+ url.searchParams.set('after', params.after);
45
45
  }
46
46
  if (params.offset) {
47
- url.searchParams.set("offset", params.offset.toString());
47
+ url.searchParams.set('offset', params.offset.toString());
48
48
  }
49
49
 
50
50
  return !isProd ? url.pathname + url.search : url.toString();
@@ -61,11 +61,11 @@ async function fetchStreaming(params: StreamingQueryParams = {}): Promise<Stream
61
61
 
62
62
  // SWR key generator for streaming queries
63
63
  const getStreamingKey = (params: StreamingQueryParams) => {
64
- const parts = ["streaming"];
64
+ const parts = ['streaming'];
65
65
  if (params.before) parts.push(`before=${params.before}`);
66
66
  if (params.after) parts.push(`after=${params.after}`);
67
67
  if (params.offset) parts.push(`offset=${params.offset}`);
68
- return parts.join("?");
68
+ return parts.join('?');
69
69
  };
70
70
 
71
71
  interface UseStreamingOptions {
@@ -91,12 +91,12 @@ export function useStreaming(options: UseStreamingOptions = {}) {
91
91
 
92
92
  const isLoading = !data && !error;
93
93
 
94
- const [_, forceUpdate] = useState(0);
94
+ const [, forceUpdate] = useState(0);
95
95
 
96
96
  // make rerender when customElement defined
97
97
  useEffect(() => {
98
- customElements.whenDefined("bb-msg-history").then(() => {
99
- forceUpdate((prev) => prev + 1);
98
+ customElements.whenDefined('bb-msg-history').then(() => {
99
+ forceUpdate(prev => prev + 1);
100
100
  });
101
101
  }, []);
102
102
 
@@ -1,11 +1,8 @@
1
- import React from "react";
2
- import { createRoot } from "react-dom/client";
3
- import { Toaster } from "sonner";
4
- import { BrowserRouter as Router } from "react-router-dom";
5
- import { ReloadPrompt } from "@/components";
6
- import App from "./app";
7
- import "./main.css";
8
- import Logger from "@/components/Logger";
1
+ import React from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import { BrowserRouter as Router } from 'react-router-dom';
4
+ import App from './app';
5
+ import './main.css';
9
6
 
10
7
  export const RenderBlogInto = (ele: Element) => {
11
8
  const root = createRoot(ele);
@@ -13,9 +10,6 @@ export const RenderBlogInto = (ele: Element) => {
13
10
  <React.StrictMode>
14
11
  <Router>
15
12
  <App />
16
- <Toaster />
17
- <Logger />
18
- <ReloadPrompt />
19
13
  </Router>
20
14
  </React.StrictMode>
21
15
  );
@@ -1,7 +1,6 @@
1
1
  import React, { useContext } from 'react';
2
2
  import { CenterLinkList } from '@/components';
3
3
  import { GlobalRoutesContext } from '@/context/global_routes_provider';
4
- import { Version } from '@/components/Version';
5
4
 
6
5
  export const Cover = (props: { className?: string }) => {
7
6
  const globalRouteCtx = useContext(GlobalRoutesContext);