Skip to content

Commit

Permalink
Merge branch 'd3george:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
yosong-github authored Oct 22, 2024
2 parents ef2b433 + bb966df commit 5e41ca5
Show file tree
Hide file tree
Showing 14 changed files with 1,268 additions and 918 deletions.
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VITE_APP_BASE_API=/api
VITE_APP_HOMEPAGE=/dashboard/workbench
VITE_APP_BASE_PATH=/
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
VITE_APP_BASE_API=/api
VITE_APP_HOMEPAGE=/dashboard/workbench
VITE_APP_BASE_PATH=/
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"react-beautiful-dnd": "^13.1.1",
"react-dom": "18.2.0",
"react-error-boundary": "^4.0.13",
"react-helmet-async": "^1.3.0",
"react-helmet-async": "^2.0.5",
"react-i18next": "^13.2.2",
"react-icons": "^4.11.0",
"react-markdown": "^8.0.7",
Expand All @@ -61,7 +61,6 @@
"screenfull": "^6.0.2",
"simplebar-react": "^3.2.4",
"styled-components": "^6.0.9",
"vite": "^4.4.11",
"zustand": "^4.4.3"
},
"devDependencies": {
Expand Down Expand Up @@ -94,7 +93,7 @@
"eslint-plugin-unused-imports": "^2.0.0",
"husky": "^8.0.3",
"lint-staged": "^13.3.0",
"msw": "2.4.9",
"msw": "^2.4.9",
"postcss": "^8.4.31",
"postcss-import": "^15.1.0",
"postcss-nesting": "^11.3.0",
Expand All @@ -111,8 +110,9 @@
"terser": "^5.26.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"vite": "^5.4.9",
"vite-plugin-svg-icons": "^2.0.1",
"vite-tsconfig-paths": "^4.2.1"
"vite-tsconfig-paths": "^5.0.1"
},
"msw": {
"workerDirectory": "public"
Expand Down
2,039 changes: 1,183 additions & 856 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mockServiceWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* - Please do NOT serve this file on production.
*/

const PACKAGE_VERSION = '2.4.9'
const PACKAGE_VERSION = '2.4.11'
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
Expand Down
9 changes: 5 additions & 4 deletions src/layouts/_common/bread-crumb.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Breadcrumb } from 'antd';
import { ItemType } from 'antd/es/breadcrumb/Breadcrumb';
import { Breadcrumb, type BreadcrumbProps, type GetProp } from 'antd';
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useMatches, Link } from 'react-router-dom';
Expand All @@ -10,13 +9,15 @@ import { menuFilter } from '@/router/utils';

import { AppRouteObject } from '#/router';

type MenuItem = GetProp<BreadcrumbProps, 'items'>[number];

/**
* 动态面包屑解决方案:https://github.com/MinjieChang/myblog/issues/29
*/
export default function BreadCrumb() {
const { t } = useTranslation();
const matches = useMatches();
const [breadCrumbs, setBreadCrumbs] = useState<ItemType[]>([]);
const [breadCrumbs, setBreadCrumbs] = useState<MenuItem[]>([]);

const flattenedRoutes = useFlattenedRoutes();
const permissionRoutes = usePermissionRoutes();
Expand All @@ -33,7 +34,7 @@ export default function BreadCrumb() {
items = items!
.find((item) => item.meta?.key === key)
?.children?.filter((item) => !item.meta?.hideMenu);
const result: ItemType = {
const result: MenuItem = {
key,
title: t(label),
};
Expand Down
2 changes: 0 additions & 2 deletions src/pages/components/markdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ ReactDOM.render(
<br/>
![cover](https://res.cloudinary.com/trinhmai/image/upload/v1660897321/_minimal_mock/_Cover/cover_19.jpg)
> A block quote with ~~strikethrough~~ and a URL: [https://reactjs.org](https://reactjs.org).
`;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/management/user/profile/projects-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default function ProjectsTab() {
<ProTag color="warning">{item.deadline.diff(dayjs(), 'day')} days left</ProTag>
</div>
<div className="flex w-full ">
<Avatar.Group maxCount={4}>
<Avatar.Group max={{ count: 4 }}>
{item.members.map((memberAvatar, index) => (
<Avatar src={memberAvatar} key={index} />
))}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/management/user/profile/teams-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function TeamsTab() {
</header>
<main className="my-4 opacity-70">{item.desc}</main>
<footer className="flex w-full items-center">
<Avatar.Group maxCount={4}>
<Avatar.Group max={{ count: 4 }}>
{item.members.map((memberAvatar, index) => (
<Avatar src={memberAvatar} key={index} />
))}
Expand Down
10 changes: 6 additions & 4 deletions src/pages/sys/others/kanban/kanban-task.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ function KanbanTask({ index, task }: Props) {

{assignee?.length && (
<Avatar.Group
maxCount={3}
maxStyle={{
color: themeToken.colorPrimary,
backgroundColor: themeToken.colorPrimaryBg,
max={{
count: 3,
style: {
color: themeToken.colorPrimary,
backgroundColor: themeToken.colorPrimaryBg,
},
}}
>
{assignee.map((url) => (
Expand Down
5 changes: 3 additions & 2 deletions src/router/components/auth-guard.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useCallback, useEffect } from 'react';
import { lazy, useCallback, useEffect } from 'react';
import { ErrorBoundary } from 'react-error-boundary';

import PageError from '@/pages/sys/error/PageError';
import { useUserToken } from '@/store/userStore';

import { useRouter } from '../hooks';

const PageError = lazy(() => import('@/pages/sys/error/PageError'));

type Props = {
children: React.ReactNode;
};
Expand Down
6 changes: 4 additions & 2 deletions src/router/hooks/use-route-to-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { useSettings } from '@/store/settingStore';

import { ThemeLayout } from '#/enum';
import { AppRouteObject } from '#/router';
import type { ItemType } from 'antd/es/menu/interface';
import type { GetProp, MenuProps } from 'antd';

type MenuItem = GetProp<MenuProps, 'items'>[number];

/**
* routes -> menus
Expand Down Expand Up @@ -50,7 +52,7 @@ export function useRouteToMenuFn() {
if (children) {
menuItem.children = routeToMenuFn(children);
}
return menuItem as ItemType;
return menuItem as MenuItem;
});
},
[t, themeLayout],
Expand Down
1 change: 1 addition & 0 deletions vite-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface ImportMetaEnv {
readonly VITE_GLOB_APP_TITLE: string;
readonly VITE_APP_BASE_API: string;
readonly VITE_APP_HOMEPAGE: string;
readonly VITE_APP_BASE_PATH: string;
readonly VITE_APP_ENV: 'development' | 'production';
}

Expand Down
98 changes: 57 additions & 41 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,53 +1,69 @@
import path from 'path';

import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig, loadEnv } from 'vite';
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
import tsconfigPaths from 'vite-tsconfig-paths';

// https://vitejs.dev/config/
export default defineConfig({
base: './',
esbuild: {
// drop: ['console', 'debugger'],
},
css: {
// 开css sourcemap方便找css
devSourcemap: true,
},
plugins: [
react(),
// 同步tsconfig.json的path设置alias
tsconfigPaths(),
createSvgIconsPlugin({
// 指定需要缓存的图标文件夹
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
// 指定symbolId格式
symbolId: 'icon-[dir]-[name]',
}),
],
server: {
// 自动打开浏览器
open: true,
host: true,
port: 3001,
proxy: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const base = env.VITE_APP_BASE_PATH || '/';
const isProduction = mode === 'production';

return {
base,
plugins: [
react(),
tsconfigPaths(),
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
symbolId: 'icon-[dir]-[name]',
}),
isProduction &&
visualizer({
open: true,
gzipSize: true,
brotliSize: true,
}),
],
server: {
open: true,
host: true,
port: 3001,
proxy: {
'/api': {
target: 'http://localhost:3000',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
},
},
},
build: {
target: 'esnext',
minify: 'terser',
terserOptions: {
compress: {
// 生产环境移除console
drop_console: true,
drop_debugger: true,
optimizeDeps: {
include: ['react', 'react-dom', 'react-router-dom', 'antd'],
},
esbuild: {
drop: isProduction ? ['console', 'debugger'] : [],
},
build: {
target: 'esnext',
minify: 'esbuild',
sourcemap: false,
cssCodeSplit: true,
chunkSizeWarningLimit: 1000, // 提高警告阈值到 1000 KB

rollupOptions: {
output: {
manualChunks: {
'vendor-react': ['react', 'react-dom', 'react-router-dom'],
'vendor-antd': ['antd', '@ant-design/icons', '@ant-design/cssinjs'],
'vendor-charts': ['apexcharts', 'react-apexcharts'],
'vendor-utils': ['axios', 'dayjs', 'i18next', 'zustand'],
'vendor-ui': ['framer-motion', 'styled-components', '@iconify/react'],
},
},
},
},
},
};
});

0 comments on commit 5e41ca5

Please sign in to comment.