@bbki.ng/site 5.4.22 → 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.
- package/CHANGELOG.md +16 -0
- package/index.html +12 -19
- package/package.json +5 -8
- package/src/blog/app.tsx +21 -33
- package/src/blog/components/article/index.tsx +8 -17
- package/src/blog/components/index.tsx +0 -6
- package/src/blog/components/share/share-btn.tsx +5 -8
- package/src/blog/constants/index.ts +1 -16
- package/src/blog/constants/routes.ts +12 -22
- package/src/blog/context/bbcontext.tsx +7 -7
- package/src/blog/hooks/index.ts +3 -18
- package/src/blog/hooks/use_dynamic_logo.tsx +6 -11
- package/src/blog/hooks/use_posts.ts +19 -10
- package/src/blog/hooks/use_role.ts +9 -14
- package/src/blog/hooks/use_streaming.ts +2 -2
- package/src/blog/index.tsx +5 -11
- package/src/blog/pages/cover/index.tsx +0 -1
- package/src/blog/pages/extensions/txt/article.tsx +7 -21
- package/src/blog/pages/extensions/txt/index.tsx +2 -17
- package/src/blog/pages/login/index.tsx +18 -42
- package/src/blog/swr.tsx +4 -7
- package/src/blog/utils/index.ts +9 -172
- package/vite.config.js +2 -1
- package/src/blog/articles/anti-logic.mdx +0 -61
- package/src/blog/articles/bbking-manual.mdx +0 -7
- package/src/blog/articles/black-river.mdx +0 -8
- package/src/blog/articles/celebration.mdx +0 -21
- package/src/blog/articles/cloth.mdx +0 -11
- package/src/blog/articles/cooking.mdx +0 -7
- package/src/blog/articles/cooldown.mdx +0 -12
- package/src/blog/articles/cousin.mdx +0 -15
- package/src/blog/articles/fall.mdx +0 -8
- package/src/blog/articles/img.mdx +0 -104
- package/src/blog/articles/leaves.mdx +0 -7
- package/src/blog/articles/liqiu.mdx +0 -7
- package/src/blog/articles/loading.mdx +0 -144
- package/src/blog/articles/love.mdx +0 -19
- package/src/blog/articles/major-cold.mdx +0 -14
- package/src/blog/articles/marshroom.mdx +0 -17
- package/src/blog/articles/men-without-women.mdx +0 -19
- package/src/blog/articles/moment.mdx +0 -9
- package/src/blog/articles/movie-day.mdx +0 -15
- package/src/blog/articles/photos.mdx +0 -13
- package/src/blog/articles/projects.mdx +0 -8
- package/src/blog/articles/pseudo-spring.mdx +0 -7
- package/src/blog/articles/quote.mdx +0 -26
- package/src/blog/articles/red-gun.mdx +0 -19
- package/src/blog/articles/rice-noodle.mdx +0 -21
- package/src/blog/articles/spring-cooldown.mdx +0 -8
- package/src/blog/articles/spring-rain.mdx +0 -10
- package/src/blog/articles/travel.mdx +0 -22
- package/src/blog/articles/warming-up.mdx +0 -10
- package/src/blog/articles/web-burnning.mdx +0 -10
- package/src/blog/articles/woke-up.mdx +0 -7
- package/src/blog/articles/xwy-and-snowing.mdx +0 -13
- package/src/blog/articles/xwy.mdx +0 -9
- package/src/blog/components/ImageUploader.tsx +0 -55
- package/src/blog/components/Img_ctx_menu/index.tsx +0 -67
- package/src/blog/components/Logger.tsx +0 -9
- package/src/blog/components/Pochacco/Pochacco.tsx +0 -29
- package/src/blog/components/Pochacco/idle.tsx +0 -31
- package/src/blog/components/Pochacco/watch.tsx +0 -28
- package/src/blog/components/Version.tsx +0 -14
- package/src/blog/components/app_ctx_menu/LoginMenuItem.tsx +0 -72
- package/src/blog/components/app_ctx_menu/PostMenuItem.tsx +0 -22
- package/src/blog/components/app_ctx_menu/VersionMenuItem.tsx +0 -13
- package/src/blog/components/app_ctx_menu/ViewSourceMenuItem.tsx +0 -34
- package/src/blog/components/app_ctx_menu/index.tsx +0 -35
- package/src/blog/components/article_ctx_menu/index.tsx +0 -58
- package/src/blog/components/blur_cover/index.tsx +0 -28
- package/src/blog/components/hotkey_nav/index.tsx +0 -51
- package/src/blog/components/progress_bar/index.tsx +0 -31
- package/src/blog/components/reaction/emojis.tsx +0 -143
- package/src/blog/components/reaction/oh_reaction.tsx +0 -105
- package/src/blog/components/reload_prompt/index.tsx +0 -51
- package/src/blog/components/tags/index.tsx +0 -52
- package/src/blog/hooks/useLoadingIndicator.ts +0 -12
- package/src/blog/hooks/useScrollToTop.ts +0 -24
- package/src/blog/hooks/useTransitionCls.ts +0 -36
- package/src/blog/hooks/use_authed.ts +0 -7
- package/src/blog/hooks/use_authed_fetcher.ts +0 -9
- package/src/blog/hooks/use_authed_string_post.ts +0 -42
- package/src/blog/hooks/use_clipboard_content.ts +0 -21
- package/src/blog/hooks/use_clipboard_to_post.ts +0 -48
- package/src/blog/hooks/use_del_img.ts +0 -22
- package/src/blog/hooks/use_delete_post.ts +0 -22
- package/src/blog/hooks/use_file_to_post.ts +0 -38
- package/src/blog/hooks/use_img_loading.ts +0 -16
- package/src/blog/hooks/use_post.ts +0 -26
- package/src/blog/hooks/use_projects.ts +0 -67
- package/src/blog/hooks/use_route_name.ts +0 -7
- package/src/blog/hooks/use_shared_string_to_post.ts +0 -23
- package/src/blog/hooks/use_supa_session.ts +0 -32
- package/src/blog/hooks/use_text_plain_file.ts +0 -36
- package/src/blog/hooks/use_uploader.ts +0 -34
- package/src/blog/hooks/use_video_controls.ts +0 -71
- package/src/blog/types/supabase.ts +0 -12
- package/src/blog/types/upload.ts +0 -16
- package/src/blog/utils/tags.ts +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
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
|
+
|
|
3
19
|
## 5.4.22
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/index.html
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
<!
|
|
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
|
-
|
|
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
|
|
57
|
-
|
|
58
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
64
|
-
"@bbki.ng/stylebase": "3.1.
|
|
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
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,13 +10,11 @@ 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 = () => {
|
|
23
20
|
const paths = usePaths();
|
|
@@ -35,14 +32,12 @@ const Layout = () => {
|
|
|
35
32
|
return (
|
|
36
33
|
<Page
|
|
37
34
|
nav={
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/>
|
|
45
|
-
</AppCtxMenu>
|
|
35
|
+
<Nav
|
|
36
|
+
paths={paths}
|
|
37
|
+
className="gradient-blur-cover select-none"
|
|
38
|
+
loading={isLoading}
|
|
39
|
+
customLogo={logo}
|
|
40
|
+
/>
|
|
46
41
|
}
|
|
47
42
|
main={<ThreeColLayout middleRenderer={middleRenderer} />}
|
|
48
43
|
/>
|
|
@@ -50,31 +45,24 @@ const Layout = () => {
|
|
|
50
45
|
};
|
|
51
46
|
|
|
52
47
|
export const App = () => {
|
|
53
|
-
useClipboardToPost();
|
|
54
|
-
|
|
55
|
-
useSharedStringToPost();
|
|
56
|
-
|
|
57
48
|
return (
|
|
58
49
|
<SWR>
|
|
59
|
-
<
|
|
60
|
-
<
|
|
61
|
-
<
|
|
62
|
-
<Route
|
|
63
|
-
<Route index element={<Cover />} />
|
|
50
|
+
<BBContext>
|
|
51
|
+
<Routes>
|
|
52
|
+
<Route path="/" element={<Layout />}>
|
|
53
|
+
<Route index element={<Cover />} />
|
|
64
54
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
</Route>
|
|
69
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
|
2
|
-
import { Tags, Article, Button } from
|
|
3
|
-
import { ROUTES } from
|
|
4
|
-
import classNames from
|
|
5
|
-
import {
|
|
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(
|
|
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
|
-
|
|
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,12 +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 { BlurCover } from './blur_cover';
|
|
10
|
-
|
|
11
|
-
export { ReloadPrompt } from './reload_prompt';
|
|
12
|
-
|
|
13
7
|
export { MySuspense } from './my_suspense';
|
|
14
8
|
|
|
15
9
|
export const CenterLinkList = (props: any) => {
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { Button, ButtonType } from
|
|
3
|
-
import { ShareIcon } from
|
|
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 ===
|
|
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
|
-
|
|
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:
|
|
4
|
-
HELP:
|
|
5
|
-
TAGS:
|
|
6
|
-
LOGIN:
|
|
7
|
-
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
|
-
|
|
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
|
-
|
|
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
|
|
2
|
-
import { GlobalLoadingStateProvider } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
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>
|
|
9
|
+
<GlobalRoutesProvider>
|
|
10
|
+
<EffectContextProvider>{props.children}</EffectContextProvider>
|
|
11
|
+
</GlobalRoutesProvider>
|
|
12
12
|
</GlobalLoadingStateProvider>
|
|
13
13
|
);
|
|
14
14
|
};
|
package/src/blog/hooks/index.ts
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
|
2
|
-
import { Role, useRole } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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 <
|
|
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
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
-
|
|
7
|
-
|
|
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 ==
|
|
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 =
|
|
5
|
-
QUEEN =
|
|
6
|
-
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
1
|
import useSWR from 'swr';
|
|
2
2
|
import useSWRInfinite from 'swr/infinite';
|
|
3
3
|
import { baseFetcher, withBBApi } from '@/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { API_ENDPOINT } from '@/constants/routes';
|
|
5
5
|
import { useContext, useEffect, useState, useCallback } from 'react';
|
|
6
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
9
|
const isProd = typeof window !== 'undefined' && /^https:\/\/bbki.ng/.test(window.location.href);
|
|
10
|
-
const API_BASE = !isProd ? '/api' :
|
|
10
|
+
const API_BASE = !isProd ? '/api' : API_ENDPOINT;
|
|
11
11
|
|
|
12
12
|
export type StreamingItem = {
|
|
13
13
|
id: string;
|
package/src/blog/index.tsx
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { createRoot } from
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
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);
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { NotFound, DropZone } from '@bbki.ng/components';
|
|
5
|
-
import { useLocation, useParams } from 'react-router-dom';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NotFound } from '@bbki.ng/components';
|
|
3
|
+
import { useParams } from 'react-router-dom';
|
|
6
4
|
import { usePosts } from '@/hooks/use_posts';
|
|
7
5
|
import { ArticlePage } from '@/components/article';
|
|
8
|
-
import { GlobalLoadingContext } from '@/context/global_loading_state_provider';
|
|
9
|
-
import { useFile2Post } from '@/hooks/use_file_to_post';
|
|
10
|
-
import { useAuthed } from '@/hooks/use_authed';
|
|
11
|
-
import { ArticleCtxMenu } from '@/components/article_ctx_menu';
|
|
12
6
|
import { useBlogScrollReset } from '@/hooks/use_blog_scroll_pos_restoration';
|
|
13
7
|
|
|
14
8
|
export default () => {
|
|
15
9
|
const { title } = useParams();
|
|
16
10
|
const { posts, isError, isLoading } = usePosts(title);
|
|
17
|
-
const { setIsLoading } = useContext(GlobalLoadingContext);
|
|
18
|
-
|
|
19
|
-
const reader = useFile2Post();
|
|
20
|
-
const isKing = useAuthed();
|
|
21
11
|
|
|
22
12
|
useBlogScrollReset();
|
|
23
13
|
|
|
@@ -33,15 +23,11 @@ export default () => {
|
|
|
33
23
|
return null;
|
|
34
24
|
}
|
|
35
25
|
|
|
36
|
-
const date = posts.
|
|
26
|
+
const date = posts.createdAt ? posts.createdAt.split('T')[0] : '';
|
|
37
27
|
|
|
38
28
|
return (
|
|
39
|
-
<
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
<div dangerouslySetInnerHTML={{ __html: posts.content }} />
|
|
43
|
-
</ArticleCtxMenu>
|
|
44
|
-
</ArticlePage>
|
|
45
|
-
</DropZone>
|
|
29
|
+
<ArticlePage title={title} date={date}>
|
|
30
|
+
<div dangerouslySetInnerHTML={{ __html: posts.content }} />
|
|
31
|
+
</ArticlePage>
|
|
46
32
|
);
|
|
47
33
|
};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { LinkProps,
|
|
2
|
+
import { LinkProps, Button } from '@bbki.ng/components';
|
|
3
3
|
import { usePosts } from '@/hooks/use_posts';
|
|
4
4
|
import { CenterLinkList } from '@/components';
|
|
5
|
-
import { useAuthed } from '@/hooks/use_authed';
|
|
6
|
-
import { useFile2Post } from '@/hooks/use_file_to_post';
|
|
7
|
-
import { useClipboardToPost } from '@/hooks/use_clipboard_to_post';
|
|
8
|
-
import { useLocation } from 'react-router-dom';
|
|
9
5
|
import { useBlogScroll, useBlogScrollRestoration } from '@/hooks/use_blog_scroll_pos_restoration';
|
|
10
6
|
|
|
11
7
|
type TxtProps = {
|
|
@@ -13,7 +9,7 @@ type TxtProps = {
|
|
|
13
9
|
articleList?: LinkProps[];
|
|
14
10
|
};
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
export default (props: TxtProps) => {
|
|
17
13
|
const { titleList, isLoading, isError } = usePosts();
|
|
18
14
|
|
|
19
15
|
useBlogScrollRestoration();
|
|
@@ -53,14 +49,3 @@ const Posts = (props: TxtProps) => {
|
|
|
53
49
|
/>
|
|
54
50
|
);
|
|
55
51
|
};
|
|
56
|
-
|
|
57
|
-
export default (props: TxtProps) => {
|
|
58
|
-
const reader = useFile2Post();
|
|
59
|
-
const isKing = useAuthed();
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<DropZone onDrop={reader} disabled={!isKing}>
|
|
63
|
-
<Posts {...props} />
|
|
64
|
-
</DropZone>
|
|
65
|
-
);
|
|
66
|
-
};
|