Skip to content

Commit 3dedd46

Browse files
committed
feat: 多实例支持
1 parent 1fb3e75 commit 3dedd46

File tree

8 files changed

+36
-12
lines changed

8 files changed

+36
-12
lines changed

docs/react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@z-cloud/virtual-react": "workspace:^",
14+
"@z-cloud/pull-to-refresh": "workspace:^",
1415
"rspress": "^1.40.2"
1516
},
1617
"devDependencies": {

docs/react/src/components/pull-to-refresh/local.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default function LocalPullToRefresh() {
2323
>
2424
<div>当前属于局部刷新,兼容PC、Mobile</div>
2525
<br />
26-
<div>请将当前滚动元素滚动到最顶部,PC端按住鼠标乡下拉查看效果</div>
26+
<div>请将当前滚动元素滚动到最顶部,PC端按住鼠标向下拉查看效果</div>
2727
<PullToRefresh
2828
event={event}
2929
onRefresh={() => new Promise((resolve) => setTimeout(() => resolve(true), 3000))}

docs/react/src/components/pull-to-refresh/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function PagePullToRefresh() {
77
<br />
88
<div>请注意顶部遮挡</div>
99
<br />
10-
<div>请将页面滚动到最顶部,PC端按住鼠标乡下拉查看效果</div>
10+
<div>请将页面滚动到最顶部,PC端按住鼠标向下拉查看效果</div>
1111
<PullToRefresh
1212
style={{ top: 72 }}
1313
onRefresh={() => new Promise((resolve) => setTimeout(() => resolve(true), 3000))}

packages/pull-to-refresh/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
},
4848
"./package.json": "./package.json"
4949
},
50-
"sideEffects": false,
5150
"files": [
5251
"dist"
5352
],
@@ -59,19 +58,20 @@
5958
"@z-cloud/virtual-vanilla": "workspace:^"
6059
},
6160
"devDependencies": {
61+
"@tarojs/components": "catalog:",
62+
"@tarojs/taro": "catalog:",
6263
"@types/react": "catalog:",
6364
"@vitejs/plugin-react": "catalog:",
6465
"@vitejs/plugin-vue": "catalog:",
65-
"@tarojs/components": "catalog:",
66-
"@tarojs/taro": "catalog:",
6766
"react": "catalog:",
68-
"react-dom": "catalog:"
67+
"react-dom": "catalog:",
68+
"vite-plugin-css-injected-by-js": "^3.5.2"
6969
},
7070
"peerDependencies": {
71-
"react": ">=17.0.0",
72-
"vue": ">=3.0.0",
7371
"@tarojs/components": "*",
74-
"@tarojs/taro": "*"
72+
"@tarojs/taro": "*",
73+
"react": ">=17.0.0",
74+
"vue": ">=3.0.0"
7575
},
7676
"peerDependenciesMeta": {
7777
"react": {

packages/pull-to-refresh/src/lib/pull-to-refresh.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class PullToRefresh {
3636
}
3737

3838
public onScroll(scrollTop: number) {
39-
// or scrollTop === 0
39+
// or scrollTop === 0 小程序专用
4040
this.ready = scrollTop < 1
4141

4242
if (!this.ready && this.status !== 'initial') {
@@ -70,7 +70,7 @@ export class PullToRefresh {
7070

7171
this.pullDistance = Math.max(
7272
pullDistance > maxPullDistance ? this.pullDistance + 0.2 : pullDistance,
73-
0
73+
0,
7474
)
7575

7676
this.notify()

packages/pull-to-refresh/src/lib/utils/event.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class EventManager<TEvent = TouchEvent | PointerEvent> {
3737
}
3838

3939
public move(e: TEvent) {
40+
// pointerEvent 不满足效果
4041
if ((hasTouch && !this.isTouchEvent(e as Event)) || !this.pressed) {
4142
return
4243
}

packages/pull-to-refresh/vite.config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import { defineConfig, mergeConfig } from 'vite'
22
import { viteConfig } from '@z-cloud/vite-config'
33
import react from '@vitejs/plugin-react'
4+
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
45

56
const config = defineConfig({
6-
plugins: [react()],
7+
plugins: [react(), cssInjectedByJsPlugin()],
8+
css: {
9+
modules: {
10+
scopeBehaviour: 'local',
11+
},
12+
},
713
})
814

915
export default mergeConfig(
1016
config,
1117
viteConfig({
18+
cssCodeSplit: true,
1219
lib: {
1320
entry: ['./src/index.ts', './src/react/index.ts'],
1421
},

pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)