Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ src/projects/

### 🆕 如何新增一个新项目(推荐流程)

1) 新建目录:`src/projects/<yourProject>/`
2) 添加入口:`src/projects/<yourProject>/index.tsx`
3) (可选)添加路由覆盖:`src/projects/<yourProject>/routers/index.jsx`
4) 新增 pages/components 业务代码
5) 复制一份脚本(参考 `projectA/projectB`)或直接使用 `cross-env PROJECT=<yourProject> ...` 启动/构建
1. 新建目录:`src/projects/<yourProject>/`
2. 添加入口:`src/projects/<yourProject>/index.tsx`
3. (可选)添加路由覆盖:`src/projects/<yourProject>/routers/index.jsx`
4. 新增 pages/components 业务代码
5. 复制一份脚本(参考 `projectA/projectB`)或直接使用 `cross-env PROJECT=<yourProject> ...` 启动/构建

更多用法详见 [详细文档](./docs/README_PERMISSION.md) 与 [用户角色权限说明](./docs/USER_ROLE_PERMISSION.md)。

Expand Down
8 changes: 4 additions & 4 deletions docs/MULTI_PROJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ Webpack 构建产物目录:

## 新增一个项目(例如 projectC)

1) 创建入口文件:`src/projects/projectC/index.tsx`
1. 创建入口文件:`src/projects/projectC/index.tsx`

2) (可选)创建路由目录:`src/projects/projectC/routers/`
2. (可选)创建路由目录:`src/projects/projectC/routers/`

- 如果你想先复用默认路由:
- `routers/index.jsx` 里写:
Expand All @@ -87,9 +87,9 @@ Webpack 构建产物目录:
- `routers/authRouter.jsx` 里写:
- `export { default } from '@src/routers/authRouter'`

3) (可选)创建静态资源目录:`src/projects/projectC/public/`
3. (可选)创建静态资源目录:`src/projects/projectC/public/`

4) 增加脚本(两种方式选一种)
4. 增加脚本(两种方式选一种)

- 推荐:直接照着 `projectA`/`projectB` 在根 `package.json` 里添加:
- `cross-env PROJECT=projectC vite --host --config vite.config.ts`
Expand Down
3 changes: 2 additions & 1 deletion scripts/dist-tools.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ async function main() {
}

if (cmd === 'http') {
const bins = process.platform === 'win32' ? ['http-server.cmd', 'http-server', 'npx.cmd', 'npx'] : ['http-server', 'npx']
const bins =
process.platform === 'win32' ? ['http-server.cmd', 'http-server', 'npx.cmd', 'npx'] : ['http-server', 'npx']

const r = tryRun(bins, (bin) => {
if (bin.startsWith('npx')) {
Expand Down
9 changes: 7 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export default defineConfig(({ mode }) => {
const outDirAbs = path.resolve(__dirname, outDir)
const zipDir = path.resolve(__dirname, 'dist-vite-zip')
await fs.promises.mkdir(zipDir, { recursive: true })
const archivePath = path.join(zipDir, project === 'default' ? 'pro-react-admin.zip' : `pro-react-admin-${project}.zip`)
const archivePath = path.join(
zipDir,
project === 'default' ? 'pro-react-admin.zip' : `pro-react-admin-${project}.zip`
)

const output = fs.createWriteStream(archivePath)
const archive = archiver('zip', { zlib: { level: 9 } })
Expand Down Expand Up @@ -157,7 +160,9 @@ export default defineConfig(({ mode }) => {
'@container': path.resolve(__dirname, 'src/components/container'),
'@assets': path.resolve(__dirname, 'src/assets'),
'@pages': path.resolve(__dirname, 'src/pages'),
'@routers': fs.existsSync(resolveProjectDir('routers')) ? resolveProjectDir('routers') : path.resolve(__dirname, 'src/routers'),
'@routers': fs.existsSync(resolveProjectDir('routers'))
? resolveProjectDir('routers')
: path.resolve(__dirname, 'src/routers'),
'@utils': path.resolve(__dirname, 'src/utils'),
'@theme': path.resolve(__dirname, 'src/theme'),
},
Expand Down
6 changes: 3 additions & 3 deletions webpack/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ const config = {
'@utils': path.resolve('./src/utils'),
'@theme': path.resolve('./src/theme'),
// 确保关键依赖只有一个实例,避免 zustand middleware 错误
'zustand': path.resolve('./node_modules/zustand'),
'immer': path.resolve('./node_modules/immer'),
'react': path.resolve('./node_modules/react'),
zustand: path.resolve('./node_modules/zustand'),
immer: path.resolve('./node_modules/immer'),
react: path.resolve('./node_modules/react'),
'react-dom': path.resolve('./node_modules/react-dom'),
},
symlinks: false,
Expand Down
Loading