@bbki.ng/site 5.4.24 → 5.4.26

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 (47) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +3 -4
  3. package/src/blog/app.tsx +9 -14
  4. package/src/blog/components/Auth.tsx +5 -9
  5. package/src/blog/components/DelayFadeIn/DelayFadeIn.tsx +5 -5
  6. package/src/blog/components/Pochacco/xwy.tsx +2 -8
  7. package/src/blog/components/Spinner.tsx +2 -2
  8. package/src/blog/components/article/index.tsx +3 -3
  9. package/src/blog/components/effect-layer/EffectContextProvider.tsx +2 -2
  10. package/src/blog/components/effect-layer/EffectLayer.tsx +14 -14
  11. package/src/blog/components/effect-layer/hooks/useRender.ts +12 -15
  12. package/src/blog/components/effect-layer/hooks/useResolution.ts +4 -7
  13. package/src/blog/components/effect-layer/uniforms.ts +7 -9
  14. package/src/blog/components/index.tsx +1 -5
  15. package/src/blog/components/my_suspense.tsx +4 -7
  16. package/src/blog/components/share/share-btn.tsx +3 -3
  17. package/src/blog/components/share/share-icon.tsx +1 -1
  18. package/src/blog/constants/routes.ts +1 -1
  19. package/src/blog/context/global_loading_state_provider.tsx +2 -8
  20. package/src/blog/context/global_routes_provider.tsx +5 -7
  21. package/src/blog/hooks/use_blog_scroll_pos_restoration.ts +9 -9
  22. package/src/blog/hooks/use_font_loading.ts +3 -3
  23. package/src/blog/hooks/use_mouse_position.ts +5 -5
  24. package/src/blog/hooks/use_pathname.ts +2 -2
  25. package/src/blog/hooks/use_paths.ts +8 -8
  26. package/src/blog/hooks/use_posts.ts +1 -0
  27. package/src/blog/main.css +4 -5
  28. package/src/blog/pages/bot/index.tsx +3 -3
  29. package/src/blog/pages/cover/index.tsx +2 -0
  30. package/src/blog/pages/extensions/txt/article.tsx +1 -1
  31. package/src/blog/pages/extensions/txt/index.tsx +2 -2
  32. package/src/blog/pages/index.tsx +2 -2
  33. package/src/blog/pages/streaming/arrow-down.tsx +24 -24
  34. package/src/blog/pages/streaming/index.tsx +29 -29
  35. package/src/blog/pages/streaming/useScrollBtnVisibility.ts +19 -19
  36. package/src/blog/types/articles.ts +1 -1
  37. package/src/blog/types/color.ts +13 -13
  38. package/src/blog/types/cusdis.ts +2 -2
  39. package/src/blog/types/font.ts +2 -2
  40. package/src/blog/types/oss.ts +5 -5
  41. package/src/blog/types/path.ts +1 -1
  42. package/src/blog/types/photo.ts +1 -1
  43. package/src/blog/utils/streaming.ts +16 -14
  44. package/src/index.tsx +2 -2
  45. package/tsconfig.json +1 -0
  46. package/vite.config.js +0 -1
  47. package/src/blog/components/with_wrapper/index.tsx +0 -35
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @bbki.ng/site
2
2
 
3
+ ## 5.4.26
4
+
5
+ ### Patch Changes
6
+
7
+ - 282af74: update ui components
8
+ - 558e40b: update compoennts
9
+ - Updated dependencies [282af74]
10
+ - Updated dependencies [558e40b]
11
+ - @bbki.ng/ui@0.1.1
12
+
13
+ ## 5.4.25
14
+
15
+ ### Patch Changes
16
+
17
+ - 17a06a6: streaming page jsx
18
+
3
19
  ## 5.4.24
4
20
 
5
21
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbki.ng/site",
3
- "version": "5.4.24",
3
+ "version": "5.4.26",
4
4
  "description": "code behind bbki.ng",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "react-dom": "^18.0.0",
15
15
  "react-router-dom": "6",
16
16
  "swr": "^2.2.5",
17
- "@bbki.ng/components": "5.2.14"
17
+ "@bbki.ng/ui": "0.1.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@eslint/compat": "^1.0.0",
@@ -57,8 +57,7 @@
57
57
  "vite-plugin-mdx": "^3.5.8",
58
58
  "vite-plugin-pwa": "0.19",
59
59
  "workbox-window": "^6.3.0",
60
- "@bbki.ng/config": "1.0.6",
61
- "@bbki.ng/stylebase": "3.1.7"
60
+ "@bbki.ng/config": "1.0.6"
62
61
  },
63
62
  "author": "bbbottle",
64
63
  "license": "MIT",
package/src/blog/app.tsx CHANGED
@@ -1,34 +1,23 @@
1
- import React, { useContext, useMemo } from 'react';
1
+ import React, { useContext } from 'react';
2
2
  import { Outlet, Route, Routes } from 'react-router-dom';
3
- import { Nav, NotFound, Page } from '@bbki.ng/components';
4
3
  import { Cover, Streaming } from './pages';
4
+ import { Nav, NotFound, Page, Grid, ErrorBoundary } from '@bbki.ng/ui';
5
5
 
6
6
  import ArticlePage from '@/pages/extensions/txt/article';
7
7
  import Txt from '@/pages/extensions/txt';
8
8
 
9
9
  import { usePaths } from '@/hooks';
10
- import { Login } from '@/pages/login';
11
10
  import { SWR } from '@/swr';
12
11
  import { GlobalLoadingContext } from '@/context/global_loading_state_provider';
13
12
  import { BotRedirect } from '@/pages/bot';
14
13
  import { BBContext } from '@/context/bbcontext';
15
- import { ThreeColLayout, ErrorBoundary } from '@bbki.ng/components';
16
14
  import { useDynamicLogo } from './hooks/use_dynamic_logo';
17
- import { EffectContextProvider } from './components/effect-layer/EffectContextProvider';
18
15
 
19
16
  const Layout = () => {
20
17
  const paths = usePaths();
21
18
  const { isLoading } = useContext(GlobalLoadingContext);
22
19
  const logo = useDynamicLogo();
23
20
 
24
- const middleRenderer = useMemo(() => {
25
- return () => (
26
- <ErrorBoundary>
27
- <Outlet />
28
- </ErrorBoundary>
29
- );
30
- }, []);
31
-
32
21
  return (
33
22
  <Page
34
23
  nav={
@@ -39,7 +28,13 @@ const Layout = () => {
39
28
  customLogo={logo}
40
29
  />
41
30
  }
42
- main={<ThreeColLayout middleRenderer={middleRenderer} />}
31
+ main={
32
+ <Grid leftAside={<div />}>
33
+ <ErrorBoundary>
34
+ <Outlet />
35
+ </ErrorBoundary>
36
+ </Grid>
37
+ }
43
38
  />
44
39
  );
45
40
  };
@@ -1,16 +1,12 @@
1
- import { Role, useRole } from "@/hooks/use_role";
2
- import React from "react";
3
- import { Navigate } from "react-router-dom";
1
+ import { Role, useRole } from '@/hooks/use_role';
2
+ import React from 'react';
3
+ import { Navigate } from 'react-router-dom';
4
4
 
5
- export const Auth = (props: {
6
- children: any;
7
- shouldRedirect?: boolean;
8
- role?: Role[];
9
- }) => {
5
+ export const Auth = (props: { children: any; shouldRedirect?: boolean; role?: Role[] }) => {
10
6
  const myRole = useRole();
11
7
 
12
8
  if (props.role && !props.role.includes(myRole)) {
13
- return props.shouldRedirect ? <Navigate to={"/login"} /> : null;
9
+ return props.shouldRedirect ? <Navigate to={'/login'} /> : null;
14
10
  }
15
11
 
16
12
  return props.children;
@@ -1,5 +1,5 @@
1
- import React, { useEffect } from "react";
2
- import cls from "classnames";
1
+ import React, { useEffect } from 'react';
2
+ import cls from 'classnames';
3
3
 
4
4
  export type DelayFadeInProps = {
5
5
  children: any;
@@ -19,9 +19,9 @@ export const DelayFadeIn = (props: DelayFadeInProps) => {
19
19
  };
20
20
  }, []);
21
21
 
22
- const className = cls("transition-opacity", {
23
- "opacity-100": show,
24
- "opacity-0": !show,
22
+ const className = cls('transition-opacity', {
23
+ 'opacity-100': show,
24
+ 'opacity-0': !show,
25
25
  });
26
26
 
27
27
  return <div className={className}>{props.children}</div>;
@@ -1,14 +1,8 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
 
3
3
  export const Crows = () => {
4
4
  return (
5
- <svg
6
- width="48"
7
- height="48"
8
- viewBox="0 0 48 48"
9
- fill="none"
10
- xmlns="http://www.w3.org/2000/svg"
11
- >
5
+ <svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
12
6
  <path
13
7
  d="M12.821 17.5305C10.709 18.17 9.68345 19.4423 9.22624 20.1359C9.11159 20.3099 9.21615 20.5428 9.42038 20.5839L12.67 21.2381C12.8291 21.2702 12.9328 21.4275 12.9084 21.5879C11.3004 32.1653 21.5275 36.7547 28.6638 33.0597C28.7443 33.018 28.8408 33.0139 28.9245 33.0487C32.8032 34.6598 35.967 34.5662 37.8217 34.3099C38.131 34.2671 38.1505 33.841 37.855 33.7401C29.1343 30.7633 26.0152 24.5245 25.5144 18.8022C25.3835 17.3066 23.8172 13.2016 19.2675 13.0058C15.7934 12.8563 13.6137 15.6103 13.0319 17.325C12.9986 17.4231 12.9201 17.5004 12.821 17.5305Z"
14
8
  fill="#FBD1D2"
@@ -1,5 +1,5 @@
1
- import React, { useContext, useEffect } from "react";
2
- import { GlobalLoadingContext } from "@/context/global_loading_state_provider";
1
+ import React, { useContext, useEffect } from 'react';
2
+ import { GlobalLoadingContext } from '@/context/global_loading_state_provider';
3
3
 
4
4
  export const Spinner = (props: { disableDotIndicator?: boolean }) => {
5
5
  const { disableDotIndicator } = props;
@@ -1,5 +1,5 @@
1
1
  import React, { ReactElement } from 'react';
2
- import { Tags, Article, Button } from '@bbki.ng/components';
2
+ import { Button, Article } from '@bbki.ng/ui';
3
3
  import { ROUTES } from '@/constants';
4
4
  import classNames from 'classnames';
5
5
  import { useNavigate } from 'react-router-dom';
@@ -30,7 +30,7 @@ export const ArticlePage = (props: ArticlePageProps) => {
30
30
  title={title}
31
31
  date={props.date}
32
32
  description={description}
33
- className={`${props.className} mb-128`}
33
+ className={`${props.className} mt-32`}
34
34
  loading={false}
35
35
  >
36
36
  <article className={articleCls}>{props.children}</article>
@@ -41,7 +41,7 @@ export const ArticlePage = (props: ArticlePageProps) => {
41
41
  <div className="">
42
42
  <Button
43
43
  className=""
44
- btnType="button"
44
+ type="button"
45
45
  onClick={() => {
46
46
  navgation(-1);
47
47
  }}
@@ -1,5 +1,5 @@
1
- import React, { createContext, ReactNode } from "react";
2
- import { EffectLayer } from "@/components/effect-layer/EffectLayer";
1
+ import React, { createContext, ReactNode } from 'react';
2
+ import { EffectLayer } from '@/components/effect-layer/EffectLayer';
3
3
 
4
4
  const EffectContext = createContext<any>({});
5
5
 
@@ -1,20 +1,20 @@
1
- import React from "react";
2
- import { Canvas } from "@bbki.ng/components";
3
- import frag from "./main.frag";
4
- import vert from "./shader.vert";
5
- import cls from "classnames";
6
- import uniforms from "./uniforms";
7
- import { useRender } from "@/components/effect-layer/hooks/useRender";
1
+ import React from 'react';
2
+ import { Canvas } from '@bbki.ng/ui';
3
+ import frag from './main.frag';
4
+ import vert from './shader.vert';
5
+ import cls from 'classnames';
6
+ import uniforms from './uniforms';
7
+ import { useRender } from '@/components/effect-layer/hooks/useRender';
8
8
 
9
9
  export const EffectLayer = () => {
10
10
  const canvasDefaultCls = cls(
11
- "fixed",
12
- "top-0",
13
- "left-0",
14
- "h-full",
15
- "pointer-events-none",
16
- "w-full",
17
- "z-999"
11
+ 'fixed',
12
+ 'top-0',
13
+ 'left-0',
14
+ 'h-full',
15
+ 'pointer-events-none',
16
+ 'w-full',
17
+ 'z-999'
18
18
  );
19
19
 
20
20
  const { onRender } = useRender();
@@ -1,25 +1,22 @@
1
- import { useCallback, useState } from "react";
2
- import { useMousePosition } from "@/hooks/use_mouse_position";
3
- import { useResolution } from "@/components/effect-layer/hooks/useResolution";
1
+ import { useCallback, useState } from 'react';
2
+ import { useMousePosition } from '@/hooks/use_mouse_position';
3
+ import { useResolution } from '@/components/effect-layer/hooks/useResolution';
4
4
 
5
5
  export const useRender = () => {
6
6
  const pos = useMousePosition();
7
7
  const resolution = useResolution();
8
8
 
9
- const onRender = useCallback(
10
- (inst: any) => {
11
- if (inst == null) {
12
- return;
13
- }
9
+ const onRender = useCallback((inst: any) => {
10
+ if (inst == null) {
11
+ return;
12
+ }
14
13
 
15
- inst.uniforms.uResolution.value[0] = inst.gl.canvas.width;
16
- inst.uniforms.uResolution.value[1] = inst.gl.canvas.height;
14
+ inst.uniforms.uResolution.value[0] = inst.gl.canvas.width;
15
+ inst.uniforms.uResolution.value[1] = inst.gl.canvas.height;
17
16
 
18
- inst.uniforms.uMouse.value[0] = pos.current.x;
19
- inst.uniforms.uMouse.value[1] = pos.current.y;
20
- },
21
- []
22
- );
17
+ inst.uniforms.uMouse.value[0] = pos.current.x;
18
+ inst.uniforms.uMouse.value[1] = pos.current.y;
19
+ }, []);
23
20
 
24
21
  return { onRender };
25
22
  };
@@ -1,20 +1,17 @@
1
- import { useEffect, useRef } from "react";
1
+ import { useEffect, useRef } from 'react';
2
2
 
3
3
  export const useResolution = () => {
4
- const resolution = useRef<[number, number]>([
5
- window.innerWidth,
6
- window.innerHeight,
7
- ]);
4
+ const resolution = useRef<[number, number]>([window.innerWidth, window.innerHeight]);
8
5
 
9
6
  const updateResolution = () => {
10
7
  resolution.current = [window.innerWidth, window.innerHeight];
11
8
  };
12
9
 
13
10
  useEffect(() => {
14
- window.addEventListener("resize", updateResolution);
11
+ window.addEventListener('resize', updateResolution);
15
12
 
16
13
  return () => {
17
- window.removeEventListener("resize", updateResolution);
14
+ window.removeEventListener('resize', updateResolution);
18
15
  };
19
16
  }, []);
20
17
 
@@ -1,20 +1,18 @@
1
1
  export default {
2
2
  uResolution: {
3
- type: "vec2",
4
- value: [
5
- innerWidth, innerHeight,
6
- ],
3
+ type: 'vec2',
4
+ value: [innerWidth, innerHeight],
7
5
  },
8
6
  uDevicePixelRatio: {
9
- type: "float",
7
+ type: 'float',
10
8
  value: [devicePixelRatio],
11
9
  },
12
10
  pi: {
13
- type: "float",
11
+ type: 'float',
14
12
  value: [Math.PI],
15
13
  },
16
14
  uMouse: {
17
- type: "vec2",
15
+ type: 'vec2',
18
16
  value: [0, 0],
19
- }
20
- }
17
+ },
18
+ };
@@ -1,8 +1,5 @@
1
1
  import React from 'react';
2
- import { LinkList } from '@bbki.ng/components';
3
- import { BlurCover } from '@bbki.ng/components';
4
-
5
- export { withArticleWrapper } from './with_wrapper';
2
+ import { LinkList } from '@bbki.ng/ui';
6
3
 
7
4
  export { MySuspense } from './my_suspense';
8
5
 
@@ -10,7 +7,6 @@ export const CenterLinkList = (props: any) => {
10
7
  return (
11
8
  <div className="flex justify-center relative p-16 h-full">
12
9
  <LinkList {...props} />
13
- <BlurCover status={props.loading ? 'show' : 'silent'} />
14
10
  </div>
15
11
  );
16
12
  };
@@ -1,11 +1,8 @@
1
- import React, { ReactElement, ReactNode, Suspense } from "react";
2
- import { ErrorBoundary } from "@bbki.ng/components";
3
- import { Spinner } from "./Spinner";
1
+ import React, { ReactElement, ReactNode, Suspense } from 'react';
2
+ import { ErrorBoundary } from '@bbki.ng/ui';
3
+ import { Spinner } from './Spinner';
4
4
 
5
- export const MySuspense = (props: {
6
- children: ReactNode;
7
- fallback?: ReactElement;
8
- }) => {
5
+ export const MySuspense = (props: { children: ReactNode; fallback?: ReactElement }) => {
9
6
  return (
10
7
  <ErrorBoundary>
11
8
  <Suspense fallback={<Spinner />}>{props.children}</Suspense>
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Button, ButtonType } from '@bbki.ng/components';
2
+ import { Button } from '@bbki.ng/ui';
3
3
  import { ShareIcon } from './share-icon';
4
4
 
5
5
  export const ShareBtn = ({ shareInfo }: { shareInfo: ShareData }) => {
@@ -17,9 +17,9 @@ export const ShareBtn = ({ shareInfo }: { shareInfo: ShareData }) => {
17
17
 
18
18
  return (
19
19
  <Button
20
- size="small"
20
+ size="sm"
21
21
  className="text-gray-400 hover:text-gray-600 transition-colors ease-in duration-200"
22
- type={ButtonType.GHOST}
22
+ variant="ghost"
23
23
  onClick={handleShare}
24
24
  >
25
25
  <ShareIcon />
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React from 'react';
2
2
 
3
3
  export const ShareIcon = () => (
4
4
  <svg
@@ -13,7 +13,7 @@ export const ROUTE_NAME = {
13
13
  unknown: '未知',
14
14
  };
15
15
 
16
- export const GITHUB_REPO_ADDRESS = 'https://github.com/bbbottle/bottle/tree/main/packages/site';
16
+ export const GITHUB_REPO_ADDRESS = 'https://github.com/bbbottle/bottle/tree/main/apps/site';
17
17
  export const API_ENDPOINT = 'https://cf.bbki.ng';
18
18
  export const API = {
19
19
  POSTS: 'posts',
@@ -1,11 +1,5 @@
1
- import React, {
2
- createContext,
3
- ReactNode,
4
- useState,
5
- Dispatch,
6
- SetStateAction,
7
- } from "react";
8
- import { useFontLoading } from "@/hooks/use_font_loading";
1
+ import React, { createContext, ReactNode, useState, Dispatch, SetStateAction } from 'react';
2
+ import { useFontLoading } from '@/hooks/use_font_loading';
9
3
 
10
4
  type LoadingContext = {
11
5
  isLoading: boolean;
@@ -1,4 +1,4 @@
1
- import React, { createContext, ReactNode, useState } from "react";
1
+ import React, { createContext, ReactNode, useState } from 'react';
2
2
 
3
3
  type routeInfo = {
4
4
  name: string;
@@ -18,14 +18,14 @@ export const GlobalRoutesContext = createContext<GlobalRoutesContextType>({
18
18
  });
19
19
 
20
20
  export const GlobalRoutesProvider = (props: { children: ReactNode }) => {
21
- const [routesMap, setRoutesMap] = useState<{[key: string]: routeInfo}>({});
21
+ const [routesMap, setRoutesMap] = useState<{ [key: string]: routeInfo }>({});
22
22
 
23
23
  const addGlobalRoute = (r: routeInfo) => {
24
- setRoutesMap((prev) => ({ ...prev, [r.name]: r }));
24
+ setRoutesMap(prev => ({ ...prev, [r.name]: r }));
25
25
  };
26
26
 
27
27
  const removeGlobalRoute = (routeName: string) => {
28
- setRoutesMap((prev) => {
28
+ setRoutesMap(prev => {
29
29
  const copy = { ...prev };
30
30
  delete copy[routeName];
31
31
  return copy;
@@ -35,9 +35,7 @@ export const GlobalRoutesProvider = (props: { children: ReactNode }) => {
35
35
  const globalRoutes = Object.values(routesMap);
36
36
 
37
37
  return (
38
- <GlobalRoutesContext.Provider
39
- value={{ globalRoutes, addGlobalRoute, removeGlobalRoute }}
40
- >
38
+ <GlobalRoutesContext.Provider value={{ globalRoutes, addGlobalRoute, removeGlobalRoute }}>
41
39
  {props.children}
42
40
  </GlobalRoutesContext.Provider>
43
41
  );
@@ -1,7 +1,7 @@
1
- import { useCallback, useEffect, useRef } from "react";
2
- import { useLocation } from "react-router-dom";
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+ import { useLocation } from 'react-router-dom';
3
3
 
4
- const SCROLL_STORAGE_KEY = "div-scroll-positions";
4
+ const SCROLL_STORAGE_KEY = 'div-scroll-positions';
5
5
 
6
6
  function getScrollPositions(): Record<string, number> {
7
7
  const stored = sessionStorage.getItem(SCROLL_STORAGE_KEY);
@@ -16,7 +16,7 @@ function saveScrollPosition(key: string, position: number) {
16
16
 
17
17
  export function useBlogScrollReset() {
18
18
  useEffect(() => {
19
- const element = document.getElementById("blog");
19
+ const element = document.getElementById('blog');
20
20
  if (!element) return;
21
21
 
22
22
  element.scrollTop = 0;
@@ -24,13 +24,13 @@ export function useBlogScrollReset() {
24
24
  }
25
25
 
26
26
  export function useBlogScroll() {
27
- const element = document.getElementById("blog");
27
+ const element = document.getElementById('blog');
28
28
 
29
29
  const gotoTop = useCallback(() => {
30
30
  if (!element) return;
31
31
 
32
32
  const id = setTimeout(() => {
33
- element.scrollTo({ top: 0, behavior: "smooth" });
33
+ element.scrollTo({ top: 0, behavior: 'smooth' });
34
34
  }, 150);
35
35
 
36
36
  return () => clearTimeout(id);
@@ -45,7 +45,7 @@ export function useBlogScrollRestoration(debounceMs: number = 100) {
45
45
  const location = useLocation();
46
46
  const isFirstRender = useRef(true);
47
47
  const scrollTimeoutRef = useRef<number>();
48
- const element = document.getElementById("blog");
48
+ const element = document.getElementById('blog');
49
49
  const scrollKey = `blog`;
50
50
 
51
51
  // Restore scroll position on mount
@@ -82,10 +82,10 @@ export function useBlogScrollRestoration(debounceMs: number = 100) {
82
82
  }, debounceMs);
83
83
  };
84
84
 
85
- element.addEventListener("scroll", handleScroll, { passive: true });
85
+ element.addEventListener('scroll', handleScroll, { passive: true });
86
86
 
87
87
  return () => {
88
- element.removeEventListener("scroll", handleScroll);
88
+ element.removeEventListener('scroll', handleScroll);
89
89
  };
90
90
  }, []);
91
91
  }
@@ -1,6 +1,6 @@
1
- import { useEffect, useState } from "react";
2
- import { changeFont } from "@/utils";
3
- import { FontType } from "@/types/font";
1
+ import { useEffect, useState } from 'react';
2
+ import { changeFont } from '@/utils';
3
+ import { FontType } from '@/types/font';
4
4
 
5
5
  export const useFontLoading = () => {
6
6
  const [isFontLoading, setIsFontLoading] = useState(false);
@@ -1,7 +1,7 @@
1
- import {useEffect, useRef} from "react";
1
+ import { useEffect, useRef } from 'react';
2
2
 
3
3
  export const useMousePosition = () => {
4
- const posRef = useRef<{x: number, y:number}>({x: 0, y: 0});
4
+ const posRef = useRef<{ x: number; y: number }>({ x: 0, y: 0 });
5
5
  useEffect(() => {
6
6
  const updateMousePosition = (e: MouseEvent) => {
7
7
  posRef.current = {
@@ -9,9 +9,9 @@ export const useMousePosition = () => {
9
9
  y: e.clientY,
10
10
  };
11
11
  };
12
- window.addEventListener("mousemove", updateMousePosition);
13
- return () => window.removeEventListener("mousemove", updateMousePosition);
12
+ window.addEventListener('mousemove', updateMousePosition);
13
+ return () => window.removeEventListener('mousemove', updateMousePosition);
14
14
  }, []);
15
15
 
16
16
  return posRef;
17
- }
17
+ };
@@ -1,6 +1,6 @@
1
- import { useLocation } from "react-router-dom";
1
+ import { useLocation } from 'react-router-dom';
2
2
 
3
3
  export const usePathName = () => {
4
4
  const { pathname } = useLocation();
5
- return pathname.replace(/\/$/, "");
5
+ return pathname.replace(/\/$/, '');
6
6
  };
@@ -1,25 +1,25 @@
1
- import { pathObj } from "@/types/path";
2
- import { usePathName } from "@/hooks/use_pathname";
1
+ import { pathObj } from '@/types/path';
2
+ import { usePathName } from '@/hooks/use_pathname';
3
3
 
4
4
  export const usePaths = (): pathObj[] => {
5
5
  const pathname = usePathName();
6
6
 
7
- if (pathname === "/") {
8
- return [{ name: "~" }];
7
+ if (pathname === '/') {
8
+ return [{ name: '~' }];
9
9
  }
10
10
 
11
- const pathNameArr = pathname.split("/");
11
+ const pathNameArr = pathname.split('/');
12
12
 
13
13
  const pathsArr: string[] = pathNameArr.map((p: string, index: number) => {
14
14
  return pathNameArr
15
15
  .slice(0, index + 1)
16
- .join("/")
17
- .replace(/^$/, "/");
16
+ .join('/')
17
+ .replace(/^$/, '/');
18
18
  });
19
19
 
20
20
  return pathsArr.map((path, index) => {
21
21
  const isLast = index === pathsArr.length - 1;
22
- const name = decodeURIComponent(pathNameArr[index].replace(/^$/, "~"));
22
+ const name = decodeURIComponent(pathNameArr[index].replace(/^$/, '~'));
23
23
  return isLast
24
24
  ? { name }
25
25
  : {
@@ -28,6 +28,7 @@ export const usePosts = (name: string = '', suspense?: boolean) => {
28
28
  : data.map((p: any) => ({
29
29
  name: p.title,
30
30
  to: p.title,
31
+ children: p.title,
31
32
  }));
32
33
 
33
34
  useEffect(() => {
package/src/blog/main.css CHANGED
@@ -1,6 +1,5 @@
1
- @import "tailwindcss";
2
- @import "@bbki.ng/stylebase";
3
- @source "../../node_modules/@bbki.ng/components/";
1
+ @import 'tailwindcss';
2
+ @import '@bbki.ng/ui/styles';
4
3
 
5
4
  /*
6
5
  The default border color has changed to `currentcolor` in Tailwind CSS v4,
@@ -40,7 +39,7 @@
40
39
 
41
40
  * {
42
41
  -webkit-user-drag: none;
43
- -webkit-font-smoothing: "antialiased";
42
+ -webkit-font-smoothing: 'antialiased';
44
43
  font-weight: 400 !important;
45
44
  }
46
45
 
@@ -69,7 +68,7 @@ body {
69
68
  }
70
69
 
71
70
  .noto-serif {
72
- font-family: "Menlo", "Consolas", "Noto Serif SC", monospace;
71
+ font-family: 'Menlo', 'Consolas', 'Noto Serif SC', monospace;
73
72
  font-weight: 400;
74
73
  font-style: normal;
75
74
  }
@@ -1,10 +1,10 @@
1
- import { useEffect } from "react";
2
- import { useSearchParams } from "react-router-dom";
1
+ import { useEffect } from 'react';
2
+ import { useSearchParams } from 'react-router-dom';
3
3
 
4
4
  export const BotRedirect = () => {
5
5
  const [param] = useSearchParams();
6
6
 
7
- const code = param.get("code");
7
+ const code = param.get('code');
8
8
 
9
9
  useEffect(() => {
10
10
  window.location.href = `https://t.me/BBKingsBot?start=${code}`;
@@ -14,10 +14,12 @@ export const Cover = (props: { className?: string }) => {
14
14
  {
15
15
  to: '/blog',
16
16
  name: 'cd ./blog',
17
+ children: 'cd ./blog',
17
18
  },
18
19
  {
19
20
  to: '/now',
20
21
  name: 'cd ./now',
22
+ children: 'cd ./now',
21
23
  },
22
24
  ...pluginEntry,
23
25
  ]}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { NotFound } from '@bbki.ng/components';
2
+ import { NotFound } from '@bbki.ng/ui';
3
3
  import { useParams } from 'react-router-dom';
4
4
  import { usePosts } from '@/hooks/use_posts';
5
5
  import { ArticlePage } from '@/components/article';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { LinkProps, Button } from '@bbki.ng/components';
2
+ import { LinkProps, Button } from '@bbki.ng/ui';
3
3
  import { usePosts } from '@/hooks/use_posts';
4
4
  import { CenterLinkList } from '@/components';
5
5
  import { useBlogScroll, useBlogScrollRestoration } from '@/hooks/use_blog_scroll_pos_restoration';
@@ -29,7 +29,7 @@ export default (props: TxtProps) => {
29
29
  links={props.articleList || titleList}
30
30
  loading={isLoading}
31
31
  footer={
32
- <Button onClick={gotoTop} className="mt-128">
32
+ <Button onClick={gotoTop} className="mt-32">
33
33
  <svg
34
34
  data-testid="geist-icon"
35
35
  height="16"
@@ -1,2 +1,2 @@
1
- export { Cover } from "./cover";
2
- export { default as Streaming } from "./streaming";
1
+ export { Cover } from './cover';
2
+ export { default as Streaming } from './streaming';
@@ -1,26 +1,26 @@
1
- import classNames from "classnames";
2
- import React from "react";
1
+ import classNames from 'classnames';
2
+ import React from 'react';
3
3
 
4
4
  export const ArrowDownIcon = ({ show }: { show: boolean }) => (
5
- <svg
6
- data-testid="geist-icon"
7
- height="16"
8
- stroke-linejoin="round"
9
- viewBox="0 0 16 16"
10
- width="16"
11
- style={{
12
- rotate: '180deg'
13
- }}
14
- className={classNames("transition-opacity duration-200 inline-block", {
15
- "opacity-0": !show,
16
- "opacity-100": show,
17
- })}
18
- >
19
- <path
20
- fill-rule="evenodd"
21
- clip-rule="evenodd"
22
- d="M8.70711 1.39644C8.31659 1.00592 7.68342 1.00592 7.2929 1.39644L2.21968 6.46966L1.68935 6.99999L2.75001 8.06065L3.28034 7.53032L7.25001 3.56065V14.25V15H8.75001V14.25V3.56065L12.7197 7.53032L13.25 8.06065L14.3107 6.99999L13.7803 6.46966L8.70711 1.39644Z"
23
- fill="currentColor"
24
- ></path>
25
- </svg>
26
- )
5
+ <svg
6
+ data-testid="geist-icon"
7
+ height="16"
8
+ stroke-linejoin="round"
9
+ viewBox="0 0 16 16"
10
+ width="16"
11
+ style={{
12
+ rotate: '180deg',
13
+ }}
14
+ className={classNames('transition-opacity duration-200 inline-block', {
15
+ 'opacity-0': !show,
16
+ 'opacity-100': show,
17
+ })}
18
+ >
19
+ <path
20
+ fill-rule="evenodd"
21
+ clip-rule="evenodd"
22
+ d="M8.70711 1.39644C8.31659 1.00592 7.68342 1.00592 7.2929 1.39644L2.21968 6.46966L1.68935 6.99999L2.75001 8.06065L3.28034 7.53032L7.25001 3.56065V14.25V15H8.75001V14.25V3.56065L12.7197 7.53032L13.25 8.06065L14.3107 6.99999L13.7803 6.46966L8.70711 1.39644Z"
23
+ fill="currentColor"
24
+ ></path>
25
+ </svg>
26
+ );
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
2
  import { useStreaming, StreamingItem } from '@/hooks/use_streaming';
3
3
  import { formatStreamingData } from '@/utils/streaming';
4
- import { Article, Button, ButtonType, Panel } from '@bbki.ng/components';
4
+ import { Button, Panel } from '@bbki.ng/ui';
5
5
  import { useScrollBtnVisibility } from './useScrollBtnVisibility';
6
6
  import classNames from 'classnames';
7
7
  import { ArrowDownIcon } from './arrow-down';
@@ -66,35 +66,35 @@ const Streaming = () => {
66
66
  return <div className="p-8 text-center text-gray-500">加载失败</div>;
67
67
  }
68
68
 
69
+ if (isLoading) {
70
+ return null;
71
+ }
72
+
69
73
  return (
70
- <Article title="" loading={isLoading}>
71
- {isLoading ? null : (
72
- <>
73
- <Panel className="!p-[10px]">
74
- <bb-msg-history
75
- // infinite
76
- hide-scroll-bar
77
- hide-scroll-button
78
- ref={bbMsgHistoryRef}
79
- style={{ height: '100%', '--bb-max-height': '200px' } as React.CSSProperties}
80
- >
81
- {formattedData}
82
- </bb-msg-history>
83
- </Panel>
84
- {scrolled ? (
85
- <Button
86
- className="mt-64"
87
- transparent={!showScrollBtn}
88
- onClick={() => {
89
- bbMsgHistoryRef.current?.scrollToBottom();
90
- }}
91
- >
92
- <ArrowDownIcon show={showScrollBtn} />
93
- </Button>
94
- ) : null}
95
- </>
96
- )}
97
- </Article>
74
+ <>
75
+ <Panel className="p-2.5! mt-32">
76
+ <bb-msg-history
77
+ // infinite
78
+ hide-scroll-bar
79
+ hide-scroll-button
80
+ ref={bbMsgHistoryRef}
81
+ style={{ height: '100%', '--bb-max-height': '300px' } as React.CSSProperties}
82
+ >
83
+ {formattedData}
84
+ </bb-msg-history>
85
+ </Panel>
86
+ {scrolled ? (
87
+ <Button
88
+ className="mt-32"
89
+ transparent={!showScrollBtn}
90
+ onClick={() => {
91
+ bbMsgHistoryRef.current?.scrollToBottom();
92
+ }}
93
+ >
94
+ <ArrowDownIcon show={showScrollBtn} />
95
+ </Button>
96
+ ) : null}
97
+ </>
98
98
  );
99
99
  };
100
100
 
@@ -1,27 +1,27 @@
1
- import { useEffect, useState } from "react";
2
- import { BbMsgHistoryElement } from ".";
1
+ import { useEffect, useState } from 'react';
2
+ import { BbMsgHistoryElement } from '.';
3
3
 
4
4
  export const useScrollBtnVisibility = (ele: BbMsgHistoryElement) => {
5
- const [visible, setVisible] = useState(false);
5
+ const [visible, setVisible] = useState(false);
6
6
 
7
- useEffect(() => {
8
- if (!ele) {
9
- return;
10
- }
7
+ useEffect(() => {
8
+ if (!ele) {
9
+ return;
10
+ }
11
11
 
12
- const handleShow = () => setVisible(true);
13
- const handleHide = () => setVisible(false);
12
+ const handleShow = () => setVisible(true);
13
+ const handleHide = () => setVisible(false);
14
14
 
15
- ele.addEventListener("bb-scrollbuttonshow", handleShow);
16
- ele.addEventListener("bb-scrollbuttonhide", handleHide);
15
+ ele.addEventListener('bb-scrollbuttonshow', handleShow);
16
+ ele.addEventListener('bb-scrollbuttonhide', handleHide);
17
17
 
18
- console.log("add event listeners");
18
+ console.log('add event listeners');
19
19
 
20
- return () => {
21
- ele.removeEventListener("bb-scrollbuttonshow", handleShow);
22
- ele.removeEventListener("bb-scrollbuttonhide", handleHide);
23
- };
24
- }, [ele])
20
+ return () => {
21
+ ele.removeEventListener('bb-scrollbuttonshow', handleShow);
22
+ ele.removeEventListener('bb-scrollbuttonhide', handleHide);
23
+ };
24
+ }, [ele]);
25
25
 
26
- return visible;
27
- }
26
+ return visible;
27
+ };
@@ -1,4 +1,4 @@
1
- import { FunctionComponent } from "react";
1
+ import { FunctionComponent } from 'react';
2
2
 
3
3
  export type MdxArticle = {
4
4
  default: FunctionComponent<any>;
@@ -1,21 +1,21 @@
1
1
  export enum TextColors {
2
- GRAY = "text-gray-400",
3
- RED = "text-red-500",
4
- BLUE = "text-blue-600",
2
+ GRAY = 'text-gray-400',
3
+ RED = 'text-red-500',
4
+ BLUE = 'text-blue-600',
5
5
  }
6
6
 
7
7
  export enum BgColors {
8
- WHITE_GRAY = "bg-gray-50",
9
- LIGHT_GRAY = "bg-gray-100",
10
- GRAY = "bg-gray-400",
11
- RED = "bg-red-500",
12
- BLUE = "bg-blue-600",
13
- LIGHT_BLUE = "bg-blue-300",
14
- WHITE_BLUE = "bg-blue-100",
8
+ WHITE_GRAY = 'bg-gray-50',
9
+ LIGHT_GRAY = 'bg-gray-100',
10
+ GRAY = 'bg-gray-400',
11
+ RED = 'bg-red-500',
12
+ BLUE = 'bg-blue-600',
13
+ LIGHT_BLUE = 'bg-blue-300',
14
+ WHITE_BLUE = 'bg-blue-100',
15
15
  }
16
16
 
17
17
  export enum HoveredTextColors {
18
- GRAY = "hover:bg-gray-100",
19
- RED = "hover:bg-red-100",
20
- BLUR = "hover:bg-blue-100",
18
+ GRAY = 'hover:bg-gray-100',
19
+ RED = 'hover:bg-red-100',
20
+ BLUR = 'hover:bg-blue-100',
21
21
  }
@@ -1,4 +1,4 @@
1
1
  export enum cusdisEvent {
2
- COMMENTS_LOADED = "COMMENTS_LOADED",
3
- COMMENT_SENT = "COMMENT_SENT",
2
+ COMMENTS_LOADED = 'COMMENTS_LOADED',
3
+ COMMENT_SENT = 'COMMENT_SENT',
4
4
  }
@@ -1,4 +1,4 @@
1
1
  export enum FontType {
2
- NotoSerifSC = "noto-serif",
3
- Mono = "font-mono",
2
+ NotoSerifSC = 'noto-serif',
3
+ Mono = 'font-mono',
4
4
  }
@@ -1,9 +1,9 @@
1
1
  export enum ossProcessType {
2
- THUMBNAIL = "thumbnail",
3
- WEBP = "webp",
4
- NULL = "null",
5
- oWEBP = "owebp",
6
- PROG = "prog",
2
+ THUMBNAIL = 'thumbnail',
3
+ WEBP = 'webp',
4
+ NULL = 'null',
5
+ oWEBP = 'owebp',
6
+ PROG = 'prog',
7
7
  }
8
8
 
9
9
  export interface UploadResult {
@@ -1,4 +1,4 @@
1
- import { FunctionComponent } from "react";
1
+ import { FunctionComponent } from 'react';
2
2
 
3
3
  export interface pathObj {
4
4
  path?: string;
@@ -1,4 +1,4 @@
1
- import { ossProcessType } from "@/types/oss";
1
+ import { ossProcessType } from '@/types/oss';
2
2
 
3
3
  export interface Photo {
4
4
  src: string;
@@ -1,27 +1,29 @@
1
- import { StreamingItem } from "@/hooks/use_streaming";
1
+ import { StreamingItem } from '@/hooks/use_streaming';
2
2
 
3
3
  // Format: "author: content" (with optional timestamp)
4
4
  // Timestamp format: YYYY-mm-dd HH:MM:SS
5
5
  export const formatStreamingData = (items: StreamingItem[]): string => {
6
6
  if (!items || items.length === 0) {
7
- return "";
7
+ return '';
8
8
  }
9
9
  // Reverse to show oldest first (bb-msg-history appends to bottom)
10
10
  return [...items]
11
11
  .reverse()
12
- .map((item) => {
12
+ .map(item => {
13
13
  const time = item.createdAt
14
- ? new Date(item.createdAt).toLocaleString("zh-CN", {
15
- year: "numeric",
16
- month: "2-digit",
17
- day: "2-digit",
18
- hour: "2-digit",
19
- minute: "2-digit",
20
- second: "2-digit",
21
- hour12: false,
22
- }).replace(/\//g, "-")
23
- : "";
14
+ ? new Date(item.createdAt)
15
+ .toLocaleString('zh-CN', {
16
+ year: 'numeric',
17
+ month: '2-digit',
18
+ day: '2-digit',
19
+ hour: '2-digit',
20
+ minute: '2-digit',
21
+ second: '2-digit',
22
+ hour12: false,
23
+ })
24
+ .replace(/\//g, '-')
25
+ : '';
24
26
  return time ? `[${time}] ${item.author}: ${item.content}` : `${item.author}: ${item.content}`;
25
27
  })
26
- .join("\n");
28
+ .join('\n');
27
29
  };
package/src/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import { RenderBlogInto } from "./blog";
1
+ import { RenderBlogInto } from './blog';
2
2
 
3
- const blogContainer = document.getElementById("blog") as Element;
3
+ const blogContainer = document.getElementById('blog') as Element;
4
4
 
5
5
  RenderBlogInto(blogContainer);
package/tsconfig.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "lib": ["DOM", "DOM.Iterable", "ESNext"],
5
5
  "jsx": "react",
6
6
  "noEmit": true,
7
+ "moduleResolution": "bundler",
7
8
  "baseUrl": ".",
8
9
  "paths": {
9
10
  "@/*": ["src/blog/*"]
package/vite.config.js CHANGED
@@ -40,7 +40,6 @@ export default defineConfig({
40
40
  resolve: {
41
41
  alias: {
42
42
  '@': path.resolve(__dirname, './src/blog'),
43
- // "@bbki.ng/commponents": path.resolve(__dirname, "../components/lib"),
44
43
  },
45
44
  // preserveSymlinks: true,
46
45
  },
@@ -1,35 +0,0 @@
1
- import React from "react";
2
- import { FunctionComponent } from "react";
3
- import { ArticlePage } from "@/components/article";
4
- import { ThreeColLayout, ErrorBoundary } from "@bbki.ng/components";
5
-
6
- export const withArticleWrapper =
7
- (Component: FunctionComponent<any>): FunctionComponent<any> =>
8
- (props: any) => {
9
- return (
10
- <>
11
- <ArticlePage {...props}>
12
- <Component />
13
- </ArticlePage>
14
- </>
15
- );
16
- };
17
-
18
- export const threeColWrapper =
19
- <T extends object>(Component: any, catchError: boolean = true) =>
20
- (props: T) => {
21
- return (
22
- <ThreeColLayout
23
- middleRenderer={() => {
24
- if (!catchError) {
25
- return <Component {...props} />;
26
- }
27
- return (
28
- <ErrorBoundary>
29
- <Component {...props} />
30
- </ErrorBoundary>
31
- );
32
- }}
33
- />
34
- );
35
- };