From 31c3f8a0d32766d76223e4e5efc4b4e2b6e5fd4b Mon Sep 17 00:00:00 2001 From: Tenny Date: Thu, 22 Aug 2024 16:47:46 +0800 Subject: [PATCH 1/5] =?UTF-8?q?chore:=20=E8=87=AA=E5=8A=A8=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=91=BD=E4=BB=A4=E5=8F=98=E6=9B=B4=20publish=20->=20?= =?UTF-8?q?pull=20=E9=81=BF=E5=85=8D=E4=B8=8E=20pnpm=20=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tenny --- package.json | 2 +- scripts/publish.ps1 | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d8d26b53..38a4cc2f 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "docs:preview": "vitepress preview docs", "inspect:eslint": "eslint --inspect-config", "push": "pwsh scripts/publish.ps1 push", - "publish": "./scripts/publish.ps1 publish" + "pull": "pwsh scripts/publish.ps1 publish" }, "devDependencies": { "@types/node": "^22.5.0", diff --git a/scripts/publish.ps1 b/scripts/publish.ps1 index c94a83f6..be14005e 100644 --- a/scripts/publish.ps1 +++ b/scripts/publish.ps1 @@ -21,7 +21,8 @@ if ($Cmd -eq "push") { git merge dev -m "new version" git push origin main - Write-Host $Message + Write-Host " " + Write-Host "提交成功" -ForegroundColor Green } elseif (($Cmd -eq "pull") -or ($Cmd -eq "publish")) { git pull origin main pnpm lib:build From 6f82190fb645bad3e8858ccb57719d07915ad356 Mon Sep 17 00:00:00 2001 From: Tenny Date: Mon, 2 Sep 2024 23:57:51 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat(Virtual):=20=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tenny --- docs/.vitepress/config.ts | 4 ++++ docs/.vitepress/theme/index.ts | 1 + docs/components/virtuallist.md | 40 ++++++++++++++++++++++++++++++++++ src/components/VirtualList.vue | 12 ++++++++++ src/index.ts | 1 + src/style.css | 4 ++++ style/virtual-list/index.css | 9 ++++++++ style/virtual-list/index.js | 1 + 8 files changed, 72 insertions(+) create mode 100644 docs/components/virtuallist.md create mode 100644 src/components/VirtualList.vue create mode 100644 style/virtual-list/index.css create mode 100644 style/virtual-list/index.js diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index 3968643b..e6dd419b 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -164,6 +164,10 @@ export default defineConfig({ text: 'List 滚动列表', link: '/components/list', }, + { + text: 'VirtualList 虚拟列表', + link: '/components/virtuallist', + }, { text: 'Tabs 标签页', link: '/components/tabs', diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 8874aab1..56d9dd86 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -40,6 +40,7 @@ import '../../../style/tag'; import '../../../style/pagination'; import '../../../style/tanstack-table'; import '../../../style/md-input'; +import '../../../style/virtual-list'; export default { extends: DefaultTheme, diff --git a/docs/components/virtuallist.md b/docs/components/virtuallist.md new file mode 100644 index 00000000..46609ed6 --- /dev/null +++ b/docs/components/virtuallist.md @@ -0,0 +1,40 @@ +# VirtualList 虚拟列表 + +当我们遇到数据量很大的情况时,传统的渲染方式会导致浏览器负载过大,页面渲染速度慢,滚动卡顿等一系列问题。 + +对于这种列表数据,我们可以采用虚拟滚动来进行性能优化。 + +## 演示 + + + +### 基础用法 + +对于固定高度, 一次性渲染 `10w` 条数据。 + + + + + + + + +## API + +### VirtualList Props + + +| 参数 | 说明 | 类型 | 默认值 | +| --- | --- | --- | --- | +| x | x | x | x | diff --git a/src/components/VirtualList.vue b/src/components/VirtualList.vue new file mode 100644 index 00000000..719c06a7 --- /dev/null +++ b/src/components/VirtualList.vue @@ -0,0 +1,12 @@ + + diff --git a/src/index.ts b/src/index.ts index b0f8f02c..c1008068 100644 --- a/src/index.ts +++ b/src/index.ts @@ -71,3 +71,4 @@ export { default as Loading } from './directives/loading'; export { default as PageHeader } from './components/PageHeader.vue'; export { default as Tag } from './components/Tag.vue'; export { default as Pagination } from './components/Pagination.vue'; +export { default as VirtualList } from "./components/VirtualList.vue"; diff --git a/src/style.css b/src/style.css index bc5751fe..92c25234 100644 --- a/src/style.css +++ b/src/style.css @@ -237,3 +237,7 @@ select { appearance: auto; } + +.virtual-list-demo-container { + height: 240px; +} diff --git a/style/virtual-list/index.css b/style/virtual-list/index.css new file mode 100644 index 00000000..94f03abc --- /dev/null +++ b/style/virtual-list/index.css @@ -0,0 +1,9 @@ +.nt-virtual-list { + height: 100%; + overflow-y: auto; + -webkit-overflow-scrolling: touch; +} + +.nt-virtual-item { + overflow: hidden; +} diff --git a/style/virtual-list/index.js b/style/virtual-list/index.js new file mode 100644 index 00000000..4582418a --- /dev/null +++ b/style/virtual-list/index.js @@ -0,0 +1 @@ +import "./index.css"; \ No newline at end of file From fa0f3a803896118e6e878608a62877e17e50af15 Mon Sep 17 00:00:00 2001 From: Tenny Date: Mon, 9 Sep 2024 17:56:53 +0800 Subject: [PATCH 3/5] =?UTF-8?q?feat(VirtualList):=20=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/components/virtuallist.md | 2 + src/components/VirtualList.vue | 75 +++++++++++++++++++++++++++++++--- style/virtual-list/index.css | 9 +++- 3 files changed, 79 insertions(+), 7 deletions(-) diff --git a/docs/components/virtuallist.md b/docs/components/virtuallist.md index 46609ed6..6136c86a 100644 --- a/docs/components/virtuallist.md +++ b/docs/components/virtuallist.md @@ -8,6 +8,8 @@ ### 基础用法 diff --git a/src/components/VirtualList.vue b/src/components/VirtualList.vue index 719c06a7..031f10b5 100644 --- a/src/components/VirtualList.vue +++ b/src/components/VirtualList.vue @@ -1,12 +1,77 @@ - + diff --git a/style/virtual-list/index.css b/style/virtual-list/index.css index 94f03abc..b4b2929c 100644 --- a/style/virtual-list/index.css +++ b/style/virtual-list/index.css @@ -1,9 +1,14 @@ .nt-virtual-list { - height: 100%; + max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; + position: relative; +} +.nt-virtual-content { + position: absolute; + top: 0; + width: 100%; } - .nt-virtual-item { overflow: hidden; } From fc0da47069fad48b41a58de02cbaea729aeb724e Mon Sep 17 00:00:00 2001 From: Tenny Date: Mon, 9 Sep 2024 23:02:46 +0800 Subject: [PATCH 4/5] =?UTF-8?q?feat(VirtualList):=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tenny --- docs/components/virtuallist.md | 22 ++++++++++++++++++++-- src/components/VirtualList.vue | 11 ++++++++++- style/virtual-list/index.css | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/docs/components/virtuallist.md b/docs/components/virtuallist.md index 6136c86a..4f76fe4e 100644 --- a/docs/components/virtuallist.md +++ b/docs/components/virtuallist.md @@ -9,7 +9,19 @@ ### 基础用法 @@ -26,8 +38,14 @@ diff --git a/src/components/VirtualList.vue b/src/components/VirtualList.vue index 031f10b5..ee86a071 100644 --- a/src/components/VirtualList.vue +++ b/src/components/VirtualList.vue @@ -1,5 +1,5 @@