Skip to content

Commit

Permalink
Merge branch 'feat_v3.x' into hxy/cypress/ci-1111
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-huxiyang authored Dec 11, 2024
2 parents d4fc196 + ba35e4c commit e64f61e
Show file tree
Hide file tree
Showing 62 changed files with 451 additions and 13,745 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Other lock files
pnpm-lock.*.yaml

# Editor directories and files
.idea
.vscode
Expand Down
22 changes: 22 additions & 0 deletions .pnpmfile.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function readPackage(pkg, context) {
if(pkg.name == '@nutui/nutui-react-taro') {
// console.log(pkg)
// delete pkg.devDependencies[]
// delete pkg.dependencies[]
}
if (pkg.name === '@nutui/nutui-taro-demo') {
delete pkg.dependencies['@jdreact/jdreact-jsbundle-commonpack']
delete pkg.dependencies['@jdtaro/plugin-platform-jdhybrid']
delete pkg.dependencies['@jdtaro/taro-platform-jdharmony']
delete pkg.dependencies['@jdtaro/plugin-platform-jdharmony-cpp']
delete pkg.dependencies['@dongdesign/inject-jd-platform-styles']
}
return pkg;
}

module.exports = {
hooks: {
readPackage,
},
}

48 changes: 39 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,55 @@ pnpm run dev
# visit in browser: http:http://localhost:3000 (you don't have to open it manually if you've run it in the browser again)
```

### running with mini-program
### running with Taro

```sh
# Clone repository
# Clone the repository
git clone https://github.com/jdf2e/nutui-react.git

# Enter the project dictionary
# Navigate to the project root directory
cd nutui-react

# Install dependencies
pnpm install

# Start development
# dir:packages/nutui-taro-demo/dist/weapp
pnpm run dev:taro:weapp
# Enter mini-program development mode
# Taro H5
pnpm dev:taro h5
# WeChat Mini Program
pnpm dev:taro weapp
# JD Mini Program
pnpm dev:taro jd
# For other platforms, refer to the scripts in the package.json file in the demo directory
```

### running with JDTaro

1. Add a .npmrc file in the root directory of the repository with the following configuration:

```shell
git-branch-lockfile=true
```

```sh
# Clone the repository
git clone https://github.com/jdf2e/nutui-react.git

# Navigate to the project root directory
cd nutui-react

# Install dependencies
pnpm install

# OR run as jd mini-program
# dir:packages/nutui-taro-demo/dist/jd
pnpm run dev:taro:jd
# Enter mini-program development mode
# Taro H5
pnpm dev:jdtaro h5
# WeChat Mini Program
pnpm dev:jdtaro weapp
# JD Mini Program
pnpm dev:jdtaro jd
# harmony cpp
pnpm dev:jdtaro:jdharmonycpp
```

## Build Versions
Expand Down
48 changes: 40 additions & 8 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ pnpm run dev

```

### 本地运行小程序
### 本地运行 Taro 相关的预览

```sh
````sh
# 克隆仓库
git clone https://github.com/jdf2e/nutui-react.git

Expand All @@ -84,14 +84,46 @@ cd nutui-react
pnpm install

# 进入小程序开发模式
# 访问:src/sites/mobile-taro/dist/weapp
pnpm run dev:taro:weapp

# 其他小程序类似,如京东小程序
# 访问:src/sites/mobile-taro/dist/jd
pnpm run dev:taro:jd
```shell
# Taro H5
pnpm dev:taro h5
# 微信小程序
pnpm dev:taro weapp
# 京东小程序
pnpm dev:taro jd
# 其他平台 参考 demo 目录中 package.json 的 script
````
### 本地运行 JDTaro 相关的预览
1. 仓库根目录下增加 .npmrc 文件,增加如下配置:
```shell
git-branch-lockfile=true
```

````sh
# 克隆仓库
git clone https://github.com/jdf2e/nutui-react.git

# 进入项目根目录
cd nutui-react

# 安装依赖
pnpm install --ignore-pnpmfile

# 进入小程序开发模式
```shell
# Taro H5
pnpm dev:jdtaro h5
# 微信小程序
pnpm dev:jdtaro weapp
# 京东小程序
pnpm dev:jdtaro jd
# harmony cpp
pnpm dev:jdtaro:jdharmonycpp
````
## 构建版本
> AMD 环境、Webpack、Vite 等构建工具环境、服务端建议使用 es 版,非模块化环境(如通过 `<script>` 标签直接引用)建议使用 umd 压缩版。
Expand Down
23 changes: 8 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,30 +54,23 @@
"clone:rn": "pnpm run update:taro:entry && node ./scripts/rn/copy-file.js",
"dev": "vite --open --force",
"dev:rtl": "VITE_RTL=rtl vite --open --force",
"dev:jmapp": "VITE_APP_PROJECT_ID=jmapp vite --open --force",
"dev:jrkf": "VITE_APP_PROJECT_ID=jrkf vite --open --force",
"dev:theme": "npm run generate:themes-dev && npm run checked && vite --force --config vite.config.theme.ts",
"dev:taro:weapp": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:weapp",
"dev:taro:jd": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:jd",
"dev:taro:h5": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:h5",
"dev:taro:h5:jmapp": "pnpm update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:h5:jmapp",
"dev:taro:alipay": "pnpm update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:alipay",
"dev:taro:harmony": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:harmony",
"dev:taro:jdharmony": "pnpm run clone:jdharmony && pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:jdharmony",
"dev:taro:jdharmonycpp": "pnpm run clone:jdharmony cpp && pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:jdharmonycpp",
"dev:taro:jdhybrid": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev:jdhybrid",
"dev:taro:jdrn": "pnpm run clone:rn && pnpm --dir ./packages/nutui-taro-demo dev:jdrn",
"dev:taro:rn:dark": "THEME=dark pnpm dev:taro:rn",
"dev:taro:weapp:jmapp": "pnpm --dir ./packages/nutui-taro-demo && npm run dev:weapp:jmapp",
"dev:taro": "pnpm run update:taro:entry && pnpm --dir ./packages/nutui-taro-demo dev",
"dev:jdtaro": "pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev",
"dev:jdtaro:jdharmonycpp": "pnpm run clone:jdharmony cpp &&pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev:jdharmonycpp",
"dev:jdtaro:jdharmony": "pnpm run clone:jdharmony && pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev:jdharmony",
"dev:taro:jmapp": "pnpm run update:taro:entry && JD=1 pnpm --dir ./packages/nutui-taro-demo dev:jmapp",
"build": "npm run checked && node scripts/build.mjs",
"build:taro": "npm run checked:taro && node scripts/build-taro.mjs",
"build:taro:jd": "pnpm --dir ./packages/nutui-taro-demo build:jd",
"build:taro:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp node scripts/build-taro.mjs",
"build:site": "npm run checked && vite build --config vite.config.site.ts",
"build:site:jmapp": "npm run checked && VITE_APP_PROJECT_ID=jmapp vite build",
"build:taro:site": "pnpm update:taro:entry && npm run checked:taro && npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5",
"build:taro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && VITE_APP_PROJECT_ID=jmapp pnpm --dir ./packages/nutui-taro-demo build:h5",
"build:theme:site": "npm run checked && vite build --config vite.config.theme.ts && npm run generate:themes-dev",
"build:jdtaro:site": "pnpm update:taro:entry && npm run checked:taro && npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5",
"build:taro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5",
"build:jstaro:site:jmapp": "npm run checked:taro && VITE_APP_PROJECT_ID=jmapp npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5",
"generate:file": "node scripts/generate-nutui.js",
"generate:themes": "node scripts/generate-themes.js",
"generate:themes-dev": "node scripts/generate-themes-dev.js",
Expand Down
19 changes: 11 additions & 8 deletions packages/nutui-taro-demo/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const path = require('path')
let fileStr = `src/styles/variables.scss`
let themeStr = `src/styles/theme-default.scss`
const projectID = process.env.VITE_APP_PROJECT_ID
const JD = process.env.JD
console.log('JDJDJDJDJDJD', JD)
if (projectID) {
fileStr = `src/styles/variables-${projectID}.scss`
themeStr = `src/styles/theme-${projectID}.scss`
Expand All @@ -18,20 +20,21 @@ if (process.env.TARO_ENV === 'harmony') {
plugins.push('@tarojs/plugin-platform-harmony-ets')
}

if (process.env.TARO_ENV === 'rn' || process.env.TARO_ENV === 'jdrn') {
if ((process.env.TARO_ENV === 'rn' || process.env.TARO_ENV === 'jdrn') && JD) {
plugins.push('@jdtaro/plugin-platform-jdrn')
}

// 小程序、jd H5 通过此插件覆盖
if (
process.env.TARO_ENV === 'weapp' ||
process.env.TARO_ENV === 'jd' ||
process.env.TARO_ENV === 'jdhybrid'
(process.env.TARO_ENV === 'weapp' ||
process.env.TARO_ENV === 'jd' ||
process.env.TARO_ENV === 'jdhybrid') &&
JD
) {
plugins.push('@dongdesign/inject-jd-platform-styles')
}

if (process.env.TARO_ENV === 'jdhybrid') {
if (process.env.TARO_ENV === 'jdhybrid' && JD) {
plugins.push([
'@jdtaro/plugin-platform-jdhybrid',
{
Expand All @@ -43,10 +46,10 @@ if (process.env.TARO_ENV === 'jdhybrid') {
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
if (process.env.TARO_ENV === 'jdharmony') {
if (process.env.TARO_ENV === 'jdharmony' && JD) {
plugins = ['@jdtaro/taro-platform-jdharmony']
}
if (process.env.TARO_ENV === 'jdharmony_cpp') {
if (process.env.TARO_ENV === 'jdharmony_cpp' && JD) {
plugins = ['@jdtaro/plugin-platform-jdharmony-cpp']
}
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down Expand Up @@ -74,7 +77,7 @@ const config = {
compiler: {
type: 'webpack5',
prebundle: {
exclude: ['@nutui/icons-react-taro']
exclude: ['@nutui/icons-react-taro'],
},
},
alias:
Expand Down
5 changes: 5 additions & 0 deletions packages/nutui-taro-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"css": "sass"
},
"scripts": {
"dev": "taro build --watch --type",
"dev:jmapp": "VITE_APP_PROJECT_ID=jmapp taro build --watch --type",
"build": "taro build --type",
"build:jmapp": "taro build --type",

"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
Expand Down
Loading

0 comments on commit e64f61e

Please sign in to comment.