diff --git a/package.json b/package.json index d09146e..b5db968 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "prepare": "husky", "lint:js": "eslint --cache --ext .js,.jsx,.ts,.tsx ./src", "lint:fix": "eslint --fix --cache --ext .js,.jsx,.ts,.tsx ./src", + "analysis": "vite-bundle-visualizer --mode prod", "docs:dev": "vitepress dev docs", "docs:build": "vitepress build docs", "docs:preview": "vitepress preview docs" @@ -32,6 +33,9 @@ "examples/**/*.{js,jsx,ts,tsx}": "eslint --cache --ext .js,.jsx,.ts,.tsx --max-warnings 0" }, "dependencies": { + "@dnd-kit/core": "^6.1.0", + "@dnd-kit/sortable": "^8.0.0", + "@dnd-kit/utilities": "^3.2.2", "@loadable/component": "^5.16.4", "@zhangsai/model": "^0.0.2", "antd": "^5.21.6", @@ -42,6 +46,7 @@ "i18next": "^23.16.4", "immer": "^10.1.1", "react": "^18.3.1", + "react-contexify": "^6.0.0", "react-countup": "^6.5.3", "react-dom": "^18.3.1", "react-helmet-async": "^2.0.5", @@ -49,7 +54,8 @@ "react-router-dom": "^6.27.0", "react-router-toolset": "^0.0.5", "react-use": "^17.5.1", - "store2": "^2.14.3" + "store2": "^2.14.3", + "styled-components": "^6.1.13" }, "devDependencies": { "@types/loadable__component": "^5.13.9", @@ -71,6 +77,7 @@ "msw": "^2.5.2", "typescript": "^5.6.3", "vite": "^5.4.10", + "vite-bundle-visualizer": "^1.2.1", "vite-plugin-svg-icons": "^2.0.1", "vite-plugin-svgr": "^4.2.0", "vitepress": "^1.4.1", diff --git a/src/assets/svg/close.svg b/src/assets/svg/close.svg new file mode 100644 index 0000000..d63c93a --- /dev/null +++ b/src/assets/svg/close.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/svg/close_circle.svg b/src/assets/svg/close_circle.svg new file mode 100644 index 0000000..6abcb56 --- /dev/null +++ b/src/assets/svg/close_circle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/svg/close_left.svg b/src/assets/svg/close_left.svg new file mode 100644 index 0000000..06d5d0d --- /dev/null +++ b/src/assets/svg/close_left.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/svg/close_other.svg b/src/assets/svg/close_other.svg new file mode 100644 index 0000000..8db907a --- /dev/null +++ b/src/assets/svg/close_other.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/svg/close_right.svg b/src/assets/svg/close_right.svg new file mode 100644 index 0000000..6f7eae6 --- /dev/null +++ b/src/assets/svg/close_right.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/assets/svg/language.svg b/src/assets/svg/language.svg index 917dfe5..0ccb9ef 100644 --- a/src/assets/svg/language.svg +++ b/src/assets/svg/language.svg @@ -1 +1,5 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/components/Hover/index.tsx b/src/components/Hover/index.tsx new file mode 100644 index 0000000..fa01711 --- /dev/null +++ b/src/components/Hover/index.tsx @@ -0,0 +1,14 @@ +import { useHover } from 'react-use'; + +type Props = { + children: ((isHovering: boolean) => JSX.Element); +} + +const Hover = (props: Props) => { + const hoverChildren = useHover((isHovering: boolean) => { + return props.children(isHovering); + }); + return hoverChildren; +}; + +export default Hover; diff --git a/src/components/store/index.tsx b/src/components/store/index.tsx new file mode 100644 index 0000000..eb35dcd --- /dev/null +++ b/src/components/store/index.tsx @@ -0,0 +1,42 @@ +/** + * 提供一种稍微简单一些的写法用于创建Context + */ + +import { PropsWithChildren, useContext, Context as ReactContext, createContext } from 'react'; + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +interface CreateStoreParams> { + defaultValue?: T; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function createStore>(params?: CreateStoreParams) { + const { defaultValue } = params ?? {}; + const Context = createContext(defaultValue ?? null!); + + function useStore() { + return useContext(Context); + } + + return { + Context, + useStore, + }; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +interface CreateProviderParams { + Context: ReactContext; + useValue: () => T; +} + +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export function createProvider>({ Context, useValue }: CreateProviderParams) { + const Provider = ({ children }: PropsWithChildren) => { + const value = useValue(); + return ( + {children} + ); + }; + return Provider; +} diff --git a/src/consts/index.ts b/src/consts/index.ts index 51889e8..b51424f 100644 --- a/src/consts/index.ts +++ b/src/consts/index.ts @@ -1,2 +1,3 @@ export const DEFAULT_TITLE = 'react-antd-console'; export const logo = '/images/logo.png'; +export const tab_title = 'tab_title'; diff --git a/src/layouts/ConsoleLayout/consts.ts b/src/layouts/ConsoleLayout/consts.ts new file mode 100644 index 0000000..6eec120 --- /dev/null +++ b/src/layouts/ConsoleLayout/consts.ts @@ -0,0 +1 @@ +export const ClassName__ConsoleLayout_RightSideMain = 'console-layout__right-side-main'; diff --git a/src/layouts/ConsoleLayout/index.less b/src/layouts/ConsoleLayout/index.less index 6be756b..132c05f 100644 --- a/src/layouts/ConsoleLayout/index.less +++ b/src/layouts/ConsoleLayout/index.less @@ -27,5 +27,5 @@ background-color: #fff; overflow: auto; border-radius: 10px; - margin: @layoutGutter 0 @layoutGutter @layoutGutter; + margin: 0 @layoutGutter @layoutGutter; } diff --git a/src/layouts/ConsoleLayout/index.tsx b/src/layouts/ConsoleLayout/index.tsx index 6c0649d..bc55ce4 100644 --- a/src/layouts/ConsoleLayout/index.tsx +++ b/src/layouts/ConsoleLayout/index.tsx @@ -6,6 +6,9 @@ import Header from '../Header'; import Footer from '../Footer'; import { useModel } from '@zhangsai/model'; import { baseModel } from '@/models/base'; +import { ClassName__ConsoleLayout_RightSideMain } from './consts'; +import Provider from './store/Provider'; +import Tabs from '../Tabs'; import './index.less'; /** @@ -20,7 +23,8 @@ const ConsoleLayout: FC = withAuth(() => {
-
+ +
{refreshing ? null : }