Skip to content

Commit 4ea0950

Browse files
committed
fix: 增加嵌套选择器,首页展示比较正常了
1 parent 7e986f2 commit 4ea0950

File tree

7 files changed

+409
-379
lines changed

7 files changed

+409
-379
lines changed

.stylelintrc.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// .stylelintrc.js
2+
const mergeConfig = require('stylelint-taro/lib/config')
3+
4+
// 合并配置,填写需要适配的端:"h5", "miniprogram", "harmony", "rn"
5+
module.exports = mergeConfig(['h5', 'miniprogram', 'harmony'], {
6+
// 自定义样式规范: 支持sass的语言规范
7+
// customSyntax: "postcss-scss"
8+
// 自定义Stylelint配置
9+
rules: {},
10+
})

package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@
128128
"@rollup/plugin-commonjs": "^25.0.7",
129129
"@rollup/plugin-node-resolve": "15.2.3",
130130
"@rollup/plugin-typescript": "^11.1.6",
131-
"@tarojs/components": "4.0.0-beta.20",
132-
"@tarojs/plugin-platform-alipay": "4.0.0-beta.20",
133-
"@tarojs/plugin-platform-weapp": "4.0.0-beta.20",
134-
"@tarojs/react": "4.0.0-beta.20",
135-
"@tarojs/taro": "4.0.0-beta.20",
131+
"@tarojs/components": "4.0.0-beta.21",
132+
"@tarojs/plugin-platform-alipay": "4.0.0-beta.21",
133+
"@tarojs/plugin-platform-weapp": "4.0.0-beta.21",
134+
"@tarojs/react": "4.0.0-beta.21",
135+
"@tarojs/taro": "4.0.0-beta.21",
136136
"@testing-library/jest-dom": "^6.4.2",
137137
"@testing-library/react": "^14.2.1",
138138
"@types/jest": "^29.5.12",
@@ -200,6 +200,7 @@
200200
"rollup-plugin-delete": "^2.0.0",
201201
"rollup-plugin-dts": "^6.1.0",
202202
"sass": "^1.71.1",
203+
"stylelint-taro": "4.0.0-beta.21",
203204
"shelljs": "^0.8.5",
204205
"ts-jest": "^29.1.2",
205206
"ts-node": "^10.9.2",
@@ -216,6 +217,7 @@
216217
},
217218
"resolutions": {
218219
"@types/react": "^18.2.57",
219-
"@types/react-dom": "^18.2.19"
220+
"@types/react-dom": "^18.2.19",
221+
"@tarojs/parse-css-to-stylesheet": "0.0.38"
220222
}
221223
}

packages/nutui-taro-demo/config/index.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ const config = {
2323
outputRoot: `dist/${
2424
process.env.TARO_ENV === 'h5' ? 'demo' : process.env.TARO_ENV
2525
}`,
26-
plugins: [path.resolve(__dirname, '../plugins/inject-scss.js'), '@tarojs/plugin-html', '@tarojs/plugin-platform-harmony-ets'],
26+
plugins: [
27+
path.resolve(__dirname, '../plugins/inject-scss.js'),
28+
'@tarojs/plugin-html',
29+
'@tarojs/plugin-platform-harmony-ets',
30+
],
2731
// harmony 相关配置
2832
harmony: {
2933
// 将编译方式设置为使用 Vite 编译
@@ -34,6 +38,7 @@ const config = {
3438
hapName: 'entry',
3539
// 【可选】modules 的入口名称,默认为 'default'
3640
name: 'default',
41+
useNesting: true,
3742
},
3843
compiler: 'webpack5',
3944
alias: {
@@ -43,7 +48,7 @@ const config = {
4348
'@/utils': path.resolve(__dirname, '../../../src/utils'),
4449
'@nutui/nutui-react-taro': path.resolve(
4550
__dirname,
46-
'../../../src/packages/nutui.react.taro.ts',
51+
'../../../src/packages/nutui.react.taro.ts'
4752
),
4853
},
4954
sass: {
@@ -116,7 +121,7 @@ const config = {
116121
isWatch: true,
117122
}
118123

119-
module.exports = function(merge) {
124+
module.exports = function (merge) {
120125
if (process.env.NODE_ENV === 'development') {
121126
return merge({}, config, require('./dev'))
122127
}

packages/nutui-taro-demo/package.json

+24-25
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,34 @@
4949
"@babel/runtime": "^7.23.9",
5050
"@nutui/touch-emulator": "^1.0.0",
5151
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
52-
"@tarojs/components": "4.0.0-beta.20",
53-
"@tarojs/helper": "4.0.0-beta.20",
54-
"@tarojs/plugin-framework-react": "4.0.0-beta.20",
55-
"@tarojs/plugin-html": "4.0.0-beta.20",
56-
"@tarojs/plugin-platform-alipay": "4.0.0-beta.20",
57-
"@tarojs/plugin-platform-h5": "4.0.0-beta.20",
58-
"@tarojs/plugin-platform-jd": "4.0.0-beta.20",
59-
"@tarojs/plugin-platform-qq": "4.0.0-beta.20",
60-
"@tarojs/plugin-platform-swan": "4.0.0-beta.20",
61-
"@tarojs/plugin-platform-tt": "4.0.0-beta.20",
62-
"@tarojs/plugin-platform-weapp": "4.0.0-beta.20",
63-
"@tarojs/react": "4.0.0-beta.20",
64-
"@tarojs/router": "4.0.0-beta.20",
65-
"@tarojs/runtime": "4.0.0-beta.20",
66-
"@tarojs/shared": "4.0.0-beta.20",
67-
"@tarojs/taro": "4.0.0-beta.20",
68-
"@tarojs/taro-h5": "4.0.0-beta.20",
52+
"@tarojs/components": "4.0.0-beta.21",
53+
"@tarojs/helper": "4.0.0-beta.21",
54+
"@tarojs/plugin-framework-react": "4.0.0-beta.21",
55+
"@tarojs/plugin-html": "4.0.0-beta.21",
56+
"@tarojs/plugin-platform-alipay": "4.0.0-beta.21",
57+
"@tarojs/plugin-platform-h5": "4.0.0-beta.21",
58+
"@tarojs/plugin-platform-jd": "4.0.0-beta.21",
59+
"@tarojs/plugin-platform-qq": "4.0.0-beta.21",
60+
"@tarojs/plugin-platform-swan": "4.0.0-beta.21",
61+
"@tarojs/plugin-platform-tt": "4.0.0-beta.21",
62+
"@tarojs/plugin-platform-weapp": "4.0.0-beta.21",
63+
"@tarojs/react": "4.0.0-beta.21",
64+
"@tarojs/router": "4.0.0-beta.21",
65+
"@tarojs/runtime": "4.0.0-beta.21",
66+
"@tarojs/shared": "4.0.0-beta.21",
67+
"@tarojs/taro": "4.0.0-beta.21",
68+
"@tarojs/taro-h5": "4.0.0-beta.21",
6969
"babel-plugin-import": "^1.13.8",
7070
"react": "^18.2.0",
7171
"react-dom": "^18.2.0",
7272
"react-refresh": "^0.14.0"
73-
7473
},
7574
"devDependencies": {
7675
"@babel/core": "^7.23.9",
77-
"@tarojs/cli": "4.0.0-beta.20",
78-
"@tarojs/plugin-platform-harmony-ets": "4.0.0-beta.20",
79-
"@tarojs/vite-runner": "4.0.0-beta.20",
80-
"@tarojs/webpack5-runner": "4.0.0-beta.20",
76+
"@tarojs/cli": "4.0.0-beta.21",
77+
"@tarojs/plugin-platform-harmony-ets": "4.0.0-beta.21",
78+
"@tarojs/vite-runner": "4.0.0-beta.21",
79+
"@tarojs/webpack5-runner": "4.0.0-beta.21",
8180
"@types/react": "^18.2.57",
8281
"@types/react-dom": "^18.2.19",
8382
"@types/react-router-dom": "^5.3.3",
@@ -87,14 +86,14 @@
8786
"@types/webpack-env": "^1.18.4",
8887
"@typescript-eslint/eslint-plugin": "^7.0.2",
8988
"@typescript-eslint/parser": "^7.0.2",
90-
"babel-preset-taro": "4.0.0-beta.20",
89+
"babel-preset-taro": "4.0.0-beta.21",
9190
"eslint": "^8.56.0",
92-
"eslint-config-taro": "4.0.0-beta.20",
91+
"eslint-config-taro": "4.0.0-beta.21",
9392
"eslint-plugin-import": "^2.29.1",
9493
"eslint-plugin-react": "^7.33.2",
9594
"eslint-plugin-react-hooks": "^4.6.0",
9695
"postcss": "^8.4.35",
9796
"stylelint": "^16.2.1",
9897
"typescript": "^4.9.5"
9998
}
100-
}
99+
}

packages/nutui-taro-demo/src/pages/index/index.scss

+9-9
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ body {
4141
background: transparent;
4242
}
4343

44-
.demo > h2 {
44+
.demo > .h2 {
4545
margin-top: 30px;
4646
margin-bottom: 10px;
4747
font-size: 14px;
@@ -50,7 +50,7 @@ body {
5050
font-weight: normal;
5151
}
5252

53-
.demo > p {
53+
.demo > .p {
5454
font-size: 12px;
5555
}
5656

@@ -72,7 +72,7 @@ body {
7272
height: 117px;
7373
}
7474

75-
.index-header > img {
75+
.index-header > .img {
7676
width: 67px;
7777
height: 67px;
7878
margin-right: 18px;
@@ -84,14 +84,14 @@ body {
8484
flex-direction: column;
8585
}
8686

87-
.index-header .info h1 {
87+
.index-header .info .h1 {
8888
height: 48px;
8989
line-height: 48px;
9090
font-size: 26px;
9191
color: rgb(51, 51, 51);
9292
}
9393

94-
.index-header .info p {
94+
.index-header .info .p {
9595
height: 18px;
9696
line-height: 18px;
9797
font-size: 13px;
@@ -105,18 +105,18 @@ body {
105105
padding: 30px 25px;
106106
}
107107

108-
.index-components > ol {
108+
.index-components > .ol {
109109
margin-bottom: 17px;
110110
}
111111

112-
.index-components > ol > li {
112+
.index-components > .ol > .li {
113113
line-height: 20px;
114114
font-size: 14px;
115115
color: rgb(144, 156, 164);
116116
margin-bottom: 10px;
117117
}
118118

119-
.index-components > ol > ul li {
119+
.index-components > .ol > .ul .li {
120120
display: flex;
121121
align-items: center;
122122
padding: 0 24px;
@@ -128,7 +128,7 @@ body {
128128
margin-bottom: 13px;
129129
}
130130

131-
.index-components > ol > ul li a {
131+
.index-components > .ol > .ul .li .a {
132132
width: 100%;
133133
height: 100%;
134134
font-size: 15px;

packages/nutui-taro-demo/src/pages/index/index.tsx

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react'
22
import Taro from '@tarojs/taro'
3+
import { ScrollView } from '@tarojs/components'
34
import pkg from '@/packages/../config.json'
45
import packageJson from '@/packages/../../package.json'
56
import './index.scss'
@@ -11,7 +12,8 @@ const navs = pkg.nav
1112
try {
1213
console.log('xxx', Schema)
1314
} catch (e) {}
14-
const Index = () => {
15+
// const Index = () => {
16+
function Index() {
1517
const gotoNext = (name: string, enName: string) => {
1618
// 跳转到目的页面,打开新页面
1719
Taro.navigateTo({
@@ -36,28 +38,32 @@ const Index = () => {
3638

3739
return (
3840
<>
39-
<div className="index">
41+
<ScrollView className="index">
4042
<div className="index-header">
4143
<img
44+
className="img"
4245
src={`https://img14.360buyimg.com/imagetools/jfs/t1/117879/25/28831/6279/6329723bE66715a2f/5f099b8feca9e8cc.png`}
4346
alt=""
4447
srcSet=""
4548
/>
4649
<div className="info">
47-
<h1>NutUI React</h1>
48-
<p>京东风格的轻量级小程序组件库 React 版</p>
49-
<p>v{packageJson.version}</p>
50+
<h1 className="h1">NutUI React</h1>
51+
<p className="p">京东风格的轻量级小程序组件库 React 版</p>
52+
<p className="p">v{packageJson.version}</p>
5053
</div>
5154
</div>
5255
<div className="index-components">
5356
{navs.map((nav) => (
54-
<ol key={nav.name}>
55-
{nav.enName === 'dentry1' ? null : <li>{nav.name}</li>}
56-
<ul>
57+
<ol key={nav.name} className="ol">
58+
{nav.enName === 'dentry1' ? null : (
59+
<li className="li">{nav.name}</li>
60+
)}
61+
<ul className="ul">
5762
{nav.packages.map((com) =>
5863
com.show && com.taro ? (
59-
<li key={com.name}>
64+
<li key={com.name} className="li">
6065
<a
66+
className="a"
6167
key={com.name}
6268
onClick={() => gotoNext(com.name, nav.enName)}
6369
>
@@ -70,7 +76,7 @@ const Index = () => {
7076
</ol>
7177
))}
7278
</div>
73-
</div>
79+
</ScrollView>
7480
</>
7581
)
7682
}

0 commit comments

Comments
 (0)