Skip to content

Commit

Permalink
refactor: migrate site to nutui-react (#2955)
Browse files Browse the repository at this point in the history
* feat: save my migrate progress

* feat: css transition add list

* feat: save search component progress

* feat: save search component progress

* feat: save taro some logics

* feat: save lang switch

* feat: save some guide and routes logics

* feat: save some guide and routes logics

* feat: save some guide and routes logics

* feat: save some guide & guideTaro routes logics

* fix: 重置Nav Tab刷新逻辑

* chore: delete some logs

* feat: save some backtop logics

* refactor: 打包结构初始配置

* fix: site start vite config

* fix: adjust dir

* fix: extract taro basic structure

* fix: vite taro site 启动入口修复

* fix: change from spa to routes 分离

* fix: header import failed

* fix: taro doc build failed

* fix: test build h5  demo routes

* feat: taro site构建流程

* fix: add redirect link to resolve empty page bug

* fix: resolve tabs activeName incorrect

* fix: resolve conflicts

* fix: build error

* fix: build error

* refactor: 简化site启动方式并更新相关的E2E测试配置

* chore: 简化本地开发方式,移除vite冗余配置

* fix: e2e url

* fix: remove pics

* fix: remove useless files

* fix: remove useless files

* fix: code highlight

* chore: resolve conflict s

* chore: remove harmony.css files

* chore: remove harmony.css files and add git ignore file

* chore: update selected version

* chore: update docs
  • Loading branch information
Alex-huxiyang authored Mar 5, 2025
1 parent 4d38121 commit 6a23255
Show file tree
Hide file tree
Showing 102 changed files with 9,649 additions and 1,321 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
.npmrc
/dist
/dist-demo
/dist-site
/release
/libs
/jd/upload.js
Expand Down Expand Up @@ -53,4 +54,7 @@ pnpm-lock.*.yaml
*.sw?

# vitest
/html
/html

# Harmony CSS files
src/packages/**/*.harmony.css
2 changes: 1 addition & 1 deletion cypress/e2e/h5/index.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ import { checkH5Blank } from '../common/pageWhiteTest.cy'
// import './exhibition.cy'
// import './feedback.cy'

describe('All Taro Demos White Page Test', () => {
describe('All H5 Demos White Page Test', () => {
checkH5Blank()
})
3 changes: 2 additions & 1 deletion cypress/e2e/utils/visit-demo.cy.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const visitH5Demo = (componentName, delay = 500) => {
const getPath = () => `${Cypress.env('baseUrl')}${componentName}`
const getPath = () =>
`http://localhost:5173/react/demo.html#/zh-CN/component/${componentName.toLowerCase()}`
cy.visit(getPath(componentName), {
onBeforeLoad: (win) => {
Object.defineProperty(win.navigator, 'userAgent', {
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
continue.</strong>
</noscript>
<div id="doc"></div>
<script type="module" src="/src/sites/doc/main.tsx"></script>
<script type="module" src="/src/sites/sites-react/doc/main.tsx"></script>
<script>
//分享配置
var shareOption = {
Expand Down
85 changes: 85 additions & 0 deletions index.taro.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>NutUI - 移动端React组件库</title>
<meta content="telephone=no" name="format-detection" />
<link rel="dns-prefetch" href="//wl.jd.com">
<link rel="dns-prefetch" href="//h5.m.jd.com">
<link rel="dns-prefetch" href="//img14.360buyimg.com">
<link rel="dns-prefetch" href="//img10.360buyimg.com">
<link rel="dns-prefetch" href="//mercury.jd.com">
<link rel="dns-prefetch" href="//stream-outside.jd.com">
<link rel="dns-prefetch" href="//static.hotjar.com">
<link rel="shortcut icon"
href="//img14.360buyimg.com/imagetools/jfs/t1/167902/2/8762/791358/603742d7E9b4275e3/e09d8f9a8bf4c0ef.png" />
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
<script src="//h5.m.jd.com/babelDiy/Zeus/2846ykuM7PwipD9E2RzMj2BGEQpA/plugin/share.min.js"></script>
<style>
html {
background: #f7f7f7;
}

a[title="站长统计"] {
display: none;
}
</style>
<!-- Hotjar Tracking Code for nutui.jd.com -->
<script async>
(function (h, o, t, j, a, r) {
h.hj =
h.hj ||
function () {
(h.hj.q = h.hj.q || []).push(arguments);
};
h._hjSettings = { hjid: 1900179, hjsv: 6 };
a = o.getElementsByTagName("head")[0];
r = o.createElement("script");
r.async = 1;
r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
a.appendChild(r);
})(window, document, "//static.hotjar.com/c/hotjar-", ".js?sv=");
</script>
</head>

<body>
<noscript>
<strong>We're sorry but it doesn't work
properly without JavaScript enabled. Please enable it to
continue.</strong>
</noscript>
<div id="doc"></div>
<script type="module" src="/src/sites/sites-react/doc-taro/main.tsx"></script>
<script>
//分享配置
var shareOption = {
iconUrl: "https://nutui.jd.com/img/logo_share.png",
url: "https://nutui.jd.com/demo.html#/index",
title: "轻量级移动端Vue组件库 - NutUI 3.0",
desc: "京东风格的Vue组件库",
};

try {
/*初始化分享*/
share.shareInit(shareOption);
} catch (e) {
console.log(e);
}
</script>
<script type="text/javascript">
var jaq = jaq || [];
jaq.push(["account", "JA2018_1831300"]);
jaq.push(["domain", "jd.com"]);
(function () {
var ja = document.createElement("script");
ja.type = "text/javascript";
ja.async = true;
ja.src = "//wl.jd.com/joya.js";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(ja, s);
})();
</script>
<script type="text/javascript" src="//s23.cnzz.com/z_stat.php?id=1276268086&web_id=1276268086"></script>
</body>

</html>
32 changes: 18 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@
"build": "node ./scripts/replace-css-var.js && npm run checked && node scripts/build.mjs",
"build:taro": "node ./scripts/replace-css-var.js && npm run checked:taro && node scripts/build-taro.mjs",
"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.mts",
"build:site:jmapp": "npm run checked && VITE_APP_PROJECT_ID=jmapp vite build",
"prebuild:taro:site": "pnpm run update:taro:entry",
"build:taro:site": "npm run checked:taro && npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5",
"build:jdtaro:site": "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:jdtaro: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",
"build:demo": "npm run checked && vite build --config vite.config.demo.ts",
"build:demo:jmapp": "npm run checked && VITE_APP_PROJECT_ID=jmapp vite build",
"prebuild:taro:demo": "SKIPDD=1 pnpm run update:taro:entry",
"build:taro:demo": "npm run checked:taro && npm run generate:file:taro:pages && pnpm --dir ./packages/nutui-taro-demo build:h5",
"build:site": "vite build --config vite.config.site.mts",
"build:taro:site": "vite build --config vite.config.site.taro.mts && node ./scripts/rename.js",
"build:jdtaro:demo": "npm run checked:taro && npm run generate:file:taro:pages && JD=1 pnpm --dir ./packages/nutui-taro-demo build:h5",
"build:taro:demo: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:jdtaro:demo: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 All @@ -86,12 +88,12 @@
"publish:beta": "npm publish --tag beta",
"test": "vitest --coverage",
"test:ui": "vitest --ui --coverage",
"cypress:run": "cypress run --env baseUrl=http://localhost:5173/react/demo.html#/zh-CN/component/ --spec 'cypress/e2e/h5/index.cy.js'",
"cypress:open": "cypress open --env baseUrl=http://localhost:5173/react/demo.html#/zh-CN/component/ 'cypress/e2e/h5/index.cy.js'",
"cypress:run": "cypress run --spec 'cypress/e2e/h5/index.cy.js'",
"cypress:open": "cypress open 'cypress/e2e/h5/index.cy.js'",
"cypress:run:taro": "cypress run --env baseUrl=http://localhost:10086/#/ --spec 'cypress/e2e/taro/index.cy.js'",
"cypress:open:taro": "cypress open --env baseUrl=http://localhost:10086/#/ 'cypress/e2e/taro/index.cy.js'",
"e2e:run:h5": "start-server-and-test dev http://localhost:5173/ cypress:run",
"e2e:open:h5": "start-server-and-test dev http://localhost:5173/ cypress:open",
"e2e:run:h5": "start-server-and-test dev http://localhost:5173/react/ cypress:run",
"e2e:open:h5": "start-server-and-test dev http://localhost:5173/react/ cypress:open",
"e2e:run:taro": "start-server-and-test dev:taro:h5 http://localhost:10086 cypress:run:taro",
"e2e:open:taro": "start-server-and-test dev:taro:h5 http://localhost:10086 cypress:open:taro",
"update:taro:entry": "node ./scripts/harmony/update-taro-entry",
Expand All @@ -112,16 +114,18 @@
"@use-gesture/react": "10.2.20",
"async-validator": "^4.2.5",
"classnames": "^2.5.1",
"react-fast-compare": "^3.2.2",
"lodash.kebabcase": "^4.1.1",
"lottie-miniprogram": "^1.0.12",
"lottie-react": "^2.4.0",
"react-transition-group": "^4.4.5"
"react-fast-compare": "^3.2.2",
"react-transition-group": "^4.4.5",
"rehype-highlight": "^7.0.2"
},
"devDependencies": {
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@commitlint/cli": "^19.0.3",
"@commitlint/config-conventional": "^19.0.3",
"@inquirer/prompts": "^7.2.3",
"@loadable/component": "^5.16.3",
"@mdx-js/mdx": "^3.0.1",
"@mdx-js/react": "^3.0.1",
Expand All @@ -131,6 +135,7 @@
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "16.0.0",
"@rollup/plugin-typescript": "^11.1.6",
"@shikijs/markdown-it": "^3.0.0",
"@swc/core": "^1.4.8",
"@tarojs/components": "4.0.8-beta.1",
"@tarojs/plugin-platform-alipay": "4.0.8-beta.1",
Expand All @@ -156,7 +161,6 @@
"@vitejs/plugin-react": "^4.2.1",
"@vitest/coverage-v8": "^2.0.4",
"@vitest/ui": "^2.0.4",
"@inquirer/prompts":"^7.2.3",
"autoprefixer": "^10.4.17",
"axios": "^1.6.7",
"cypress": "^13.15.0",
Expand Down
Loading

0 comments on commit 6a23255

Please sign in to comment.