Skip to content

Commit b34279f

Browse files
committed
feat: package init
0 parents  commit b34279f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+12845
-0
lines changed

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
"@babel/env"
4+
]
5+
}

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.github/workflows/npm-publish.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3+
4+
name: VueVirtualTree Publish
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
jobs:
11+
publish-npm:
12+
runs-on: macos-latest
13+
steps:
14+
- uses: actions/checkout@main
15+
- uses: actions/setup-node@main
16+
with:
17+
node-version: 16
18+
registry-url: https://registry.npmjs.org/
19+
- run: npm install
20+
- run: npm run build
21+
- run: npm publish
22+
env:
23+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.DS_Store
2+
node_modules/
3+
npm-debug.log
4+
yarn-error.log
5+
package-lock.json
6+
7+
# Editor directories and files
8+
*.lock
9+
.idea
10+
*.suo
11+
*.ntvs*
12+
*.njsproj
13+
*.sln
14+
/package-lock.json
15+
.history
16+
dist

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
## CHANGELOG
3+
4+
### v1.0.0
5+
- Release 1.0.0 version
6+

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
# vue-virtual-tree
2+
3+
## 介绍
4+
5+
一款基于 vue2.x,同时支持少量数据或大量数据、多种功能和虚拟滚动(支持固定节点高度和动态节点高度)的树组件。
6+
7+
基于[element-ui](https://element.eleme.cn/#/zh-CN/component/tree)(License:MIT)中抽取的 tree 样式和功能,结合[vue-virtual-scroller](https://github.com/Akryum/vue-virtual-scroller)(License:MIT)所做的树组件。
8+
9+
## v1.0 功能列表 [![npm](https://img.shields.io/npm/v/@fit2cloud/vue-virtual-tree.svg)](https://www.npmjs.com/package/@fit2cloud/vue-virtual-tree)
10+
11+
- 大数据量支持虚拟滚动(支持固定节点高度和动态节点高度)
12+
- 基本树形数据的展示
13+
- 支持 checkbox 选择
14+
- 支持懒加载
15+
- 默认展开和默认选中
16+
- 禁用节点
17+
- 通过多种方式选中节点和获取选中的节点信息
18+
- 支持自定义节点内容
19+
- 支持节点过滤
20+
- 非虚拟滚动下,支持手风琴模式
21+
- 非懒加载时,支持节点拖拽
22+
23+
## 特点
24+
25+
- 支持虚拟滚动
26+
- 不仅支持大数据量的树形数据展示,还支持数据的操作和更改
27+
- 不仅支持固定高度的子 item 的虚拟滚动,还支持子 item 动态高度的虚拟滚动
28+
29+
## 安装
30+
31+
```
32+
npm install @fit2cloud/vue-virtual-tree
33+
```
34+
35+
36+
37+
```
38+
yarn add @fit2cloud/vue-virtual-tree
39+
```
40+
41+
## 引入
42+
43+
### 全局引入
44+
45+
`main.js` 文件中引入:
46+
47+
```JS
48+
import Vue from "vue";
49+
import VueVirtualTree from "@fit2cloud/vue-virtual-tree";
50+
// 样式文件,可以根据需要自定义样式或主题
51+
import "@fit2cloud/vue-virtual-tree/src/assets/index.scss"
52+
53+
Vue.use(VueVirtualTree)
54+
```
55+
56+
### 组件引入
57+
58+
在组件中引入:
59+
60+
```JS
61+
import VueVirtualTree from "@fit2cloud/vue-virtual-tree";
62+
// 样式文件,可以根据需要自定义样式或主题
63+
import "@fit2cloud/vue-virtual-tree/src/assets/index.scss"
64+
65+
export default {
66+
components: {
67+
VueVirtualTree
68+
}
69+
}
70+
```
71+
72+
## 使用:
73+
74+
:warning: 在使用虚拟滚动时,必须设置 `node-key`
75+
76+
```html
77+
<template>
78+
<div class="ve-tree" style="height:calc(100vh - 20px)">
79+
<!-- 不使用虚拟滚动时只需去掉height参数即可 -->
80+
<vue-virtual-tree
81+
ref="veTree"
82+
node-key="id"
83+
height="calc(100vh - 20px)"
84+
:data="treeData"
85+
:props="props"
86+
></vue-virtual-tree>
87+
</div>
88+
</template>
89+
90+
<script>
91+
export default {
92+
data() {
93+
return {
94+
props: {
95+
label: "name",
96+
children: "children"
97+
},
98+
treeData: []
99+
};
100+
},
101+
created() {
102+
const data = [],
103+
root = 8,
104+
children = 3,
105+
base = 1000;
106+
for (let i = 0; i < root; i++) {
107+
data.push({
108+
id: `${i}`,
109+
name: `test-${i}`,
110+
children: []
111+
});
112+
for (let j = 0; j < children; j++) {
113+
data[i].children.push({
114+
id: `${i}-${j}`,
115+
name: `test-${i}-${j}`,
116+
children: []
117+
});
118+
for (let k = 0; k < base; k++) {
119+
data[i].children[j].children.push({
120+
id: `${i}-${j}-${k}`,
121+
name: `test-${i}-${j}-${k}`
122+
});
123+
}
124+
}
125+
}
126+
this.treeData = data;
127+
}
128+
};
129+
</script>
130+
```
131+
132+
## 在项目中改变 SCSS 变量
133+
134+
通过新建一个样式文件,如:`ve-tree-var.scss`,写入以下内容:
135+
136+
```JS
137+
/* 改变主题色变量 */
138+
$--color-primary: #ea5404;
139+
140+
/* 改变 icon 字体路径变量,必需 */
141+
$--font-path: "~@fit2cloud/vue-virtual-tree/src/assets/fonts";
142+
143+
@import "@fit2cloud/vue-virtual-tree/src/assets/index.scss";
144+
```
145+
146+
:warning: 需要注意的是,覆盖字体路径变量是必需的,将其赋值为 @fit2cloud/vue-virtual-tree 中 icon 图标所在的相对路径即可。
147+
148+
然后在 `main.js` 中直接引入以上样式文件即可:
149+
150+
```JS
151+
import Vue from 'vue'
152+
import VueVirtualTree from "@fit2cloud/vue-virtual-tree";
153+
import "./css/ve-tree-var.scss"
154+
155+
Vue.use(VueVirtualTree)
156+
```
157+
158+
## 其它属性和方法
159+
160+
**来自[element-ui 官方文档](https://element.eleme.cn/#/zh-CN/component/tree)**<br />
161+
**需要使用虚拟滚动时,增加 `height` 属性即可,如:**
162+
163+
```html
164+
<vue-virtual-tree
165+
:data="data"
166+
height="calc(100vh - 20px)"
167+
:props="defaultProps"
168+
@node-click="handleNodeClick"
169+
></vue-virtual-tree>
170+
171+
<!-- 默认开启固定高度模式,子item动态高度模式需要手动开启,如下:isDynamic为true开启,配合minItemSize设置第一次渲染时的子item最小高度 -->
172+
<vue-virtual-tree
173+
:data="data"
174+
height="calc(100vh - 20px)"
175+
:props="defaultProps"
176+
@node-click="handleNodeClick"
177+
:minItemSize="50"
178+
isDynamic
179+
></vue-virtual-tree>
180+
```
181+
182+
**[快速查看示例和 api](./element-ui-tree.zh-CN.md)**
183+
184+
### License & Copyright
185+
186+
Copyright (c) 2014-2023 飞致云 FIT2CLOUD, All rights reserved.
187+
188+
Licensed under The GNU General Public License version 3 (GPLv3) (the "License"); you may not use this file except in
189+
compliance with the License. You may obtain a copy of the License at
190+
191+
https://www.gnu.org/licenses/gpl-3.0.html
192+
193+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "
194+
AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
195+
language governing permissions and limitations under the License.

0 commit comments

Comments
 (0)