amazing-tree 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -0
- package/dist/amazing-tree.cjs.js +1 -0
- package/dist/amazing-tree.css +1 -0
- package/dist/amazing-tree.es.js +437 -0
- package/dist/amazing-tree.umd.js +1 -0
- package/package.json +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# AmazingTree (Vue 3)
|
|
2
|
+
|
|
3
|
+
> :warning:该组件因设计需求,是非受控组件,组件的拖拽功能会修改树形数据 `props.data`
|
|
4
|
+
> 使用需谨慎
|
|
5
|
+
|
|
6
|
+
一个高性能、可拖拽、可选择的虚拟滚动树组件,支持泛型类型自动推导,适合在大型数据集下渲染与交互。
|
|
7
|
+
|
|
8
|
+
**特性**
|
|
9
|
+
|
|
10
|
+
- 虚拟滚动渲染,平滑滚动与自动测量行高
|
|
11
|
+
- 可选中(复选框),支持父子联动或严格模式
|
|
12
|
+
- 拖拽换位与嵌套,提供前置、后置、内部三种放置方式
|
|
13
|
+
- 泛型组件:从 `data` 推导节点业务类型 `T`,事件与插槽类型随之推导
|
|
14
|
+
- 轻量依赖,仅依赖 `vue`
|
|
15
|
+
|
|
16
|
+
**安装**
|
|
17
|
+
|
|
18
|
+
- 待发布到 npm 后:`npm i amazing-tree`
|
|
19
|
+
- 当前仓库本地打包:`npm run build:lib`,产物在 `dist/`
|
|
20
|
+
|
|
21
|
+
**使用**
|
|
22
|
+
|
|
23
|
+
- 基本示例
|
|
24
|
+
|
|
25
|
+
```vue
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { ref } from 'vue'
|
|
28
|
+
import { VirtualTree } from 'amazing-tree'
|
|
29
|
+
|
|
30
|
+
type NodeItem = { uuid: string; name: string; children?: NodeItem[]; [k: string]: unknown }
|
|
31
|
+
const data = ref<NodeItem[]>([])
|
|
32
|
+
|
|
33
|
+
function onDrop(drag: NodeItem, target: NodeItem, type: 'prev' | 'next' | 'inner') {
|
|
34
|
+
console.log(drag, target, type)
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<template>
|
|
39
|
+
<VirtualTree
|
|
40
|
+
:data="data"
|
|
41
|
+
:props="{ value: 'uuid', label: 'name', children: 'children' }"
|
|
42
|
+
:show-checkbox="true"
|
|
43
|
+
:check-strictly="false"
|
|
44
|
+
:default-checked-keys="['id-1', 'id-2']"
|
|
45
|
+
@node-drop="onDrop"
|
|
46
|
+
/>
|
|
47
|
+
</template>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Props**
|
|
51
|
+
|
|
52
|
+
- `data: T[]` 树数据源
|
|
53
|
+
- `props?: { value: string; label: string; children: string }` 字段映射,默认 `{ value:'value', label:'label', children:'children' }`
|
|
54
|
+
- `allowDrag?: (node: T) => boolean` 是否允许拖拽某节点
|
|
55
|
+
- `allowDrop?: (drag: T, drop: T, type: 'prev'|'next'|'inner') => boolean` 是否允许目标位置
|
|
56
|
+
- `height?: number | string` 容器高度,默认 `100%`
|
|
57
|
+
- `highlightColor?: string` 选中行高亮色,默认 `#1e71ff`
|
|
58
|
+
- `backgroundColor?: string` 背景色,默认 `#1d1d24`
|
|
59
|
+
- `textColor?: string` 文本色,默认 `#c8d3de`
|
|
60
|
+
- `hoverColor?: string` 悬浮色,默认 `#5d90e5`
|
|
61
|
+
- `currentNodeKey?: Key` 当前行的 `value`
|
|
62
|
+
- `defaultExpandedKeys?: Key[]` 默认展开的节点 `value` 列表
|
|
63
|
+
- `defaultExpandAll?: boolean` 是否默认全部展开
|
|
64
|
+
- `draggable?: boolean` 是否允许拖拽,默认 `false`
|
|
65
|
+
- `emptyText?: string` 空状态文案,默认 `暂无数据`
|
|
66
|
+
- `showCheckbox?: boolean` 是否显示复选框,默认 `false`
|
|
67
|
+
- `checkStrictly?: boolean` 选择严格模式,父子不联动,默认 `false`
|
|
68
|
+
- `defaultCheckedKeys?: Key[]` 默认勾选的 `value` 列表,默认 `[]`
|
|
69
|
+
- `disabledChecked?: (node: T) => boolean` 是否禁用当前节点复选框,默认 `false`
|
|
70
|
+
|
|
71
|
+
**Events**
|
|
72
|
+
|
|
73
|
+
- `node-click(node: T, ev: MouseEvent)` 点击行
|
|
74
|
+
- `node-contextmenu(node: T, ev: MouseEvent)` 右键菜单
|
|
75
|
+
- `node-drop(drag: T, target: T, type: 'prev'|'next'|'inner')` 拖拽放置
|
|
76
|
+
- `current-change(node: T)` 当前行变化(配合 `currentNodeKey`)
|
|
77
|
+
|
|
78
|
+
**Slots**
|
|
79
|
+
|
|
80
|
+
- `default`:`{ node: T; data: T; level: number; expanded: boolean; isLeaf: boolean }`
|
|
81
|
+
- `empty`:空状态自定义
|
|
82
|
+
|
|
83
|
+
**Expose API**
|
|
84
|
+
|
|
85
|
+
- `getCurrentKey(): Key | null` 获取当前行 `value`
|
|
86
|
+
- `setCurrentKey(id: Key | null): void` 设置当前行并滚动可见
|
|
87
|
+
- `scrollTo(id: Key | null): void` 滚动到指定行(自动展开祖先)
|
|
88
|
+
- `getCheckedKeys(): Key[]` 获取当前勾选集合
|
|
89
|
+
- `setCheckedKeys(keys: Key[]): void` 批量设置勾选(应用联动/严格逻辑)
|
|
90
|
+
- `setChecked(id: Key, checked: boolean): void` 设置单个节点勾选状态
|
|
91
|
+
|
|
92
|
+
**类型与泛型**
|
|
93
|
+
|
|
94
|
+
- 组件声明为泛型:`generic="T extends Record<string, unknown>"`
|
|
95
|
+
- `T` 会从 `data: T[]` 自动推导,事件与插槽参数均按 `T` 类型约束
|
|
96
|
+
- 在模板中若需要强类型事件回调,可在脚本中声明具体 `T`(例如 `NodeItem`)并书写对应函数签名
|
|
97
|
+
|
|
98
|
+
**样式**
|
|
99
|
+
|
|
100
|
+
- 复选框遵循暗色主题风格,支持禁用态 `cursor:not-allowed`,可通过 CSS 变量定制:
|
|
101
|
+
- `--vtree-primary` 主色(默认 `#409eff`)
|
|
102
|
+
- `--vtree-checkbox-*` 系列变量控制背景、边框、禁用与勾选颜色
|
|
103
|
+
|
|
104
|
+
**构建与发布**
|
|
105
|
+
|
|
106
|
+
- 开发:`npm run dev`
|
|
107
|
+
- 类型检查:`npm run type-check`
|
|
108
|
+
- 构建应用:`npm run build`
|
|
109
|
+
- 构建库:`npm run build:lib`(生成 `dist/amazing-tree.es.js`、`amazing-tree.cjs.js`、`amazing-tree.umd.js`)
|
|
110
|
+
- 发布到 npm:在确认 `package.json` 中 `name`、`version`、`files`、`exports` 配置正确后执行 `npm publish`
|
|
111
|
+
|
|
112
|
+
**注意事项**
|
|
113
|
+
|
|
114
|
+
- 库构建将 `vue` 作为外部依赖,使用方需自行安装 `vue@^3.5`
|
|
115
|
+
- 若需要声明文件(`.d.ts`),可引入 `vite-plugin-dts` 或单独生成并随包发布
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),Me=["onMousedown","onClick","onContextmenu"],Ae=["onClick"],Ke=["checked","indeterminate","disabled","onClick"],ze={class:"vtree-label"},Ve={key:1,class:"vtree-empty"},Ie={class:"vtree-empty-inner"},H=28,Le=t.defineComponent({__name:"VirtualTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{}},emits:["node-click","node-contextmenu","node-drop","current-change"],setup(p,{expose:j,emit:Y}){const a=p,I=Y,se=t.computed(()=>a.props.value||"value"),de=t.computed(()=>a.props.label||"label"),_=t.computed(()=>a.props.children||"children"),ve=t.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),y=t.ref(new Set),h=t.ref(new Set),m=t.ref(new Set);function ee(e){return y.value.has(e)}function fe(e){y.value.has(e)?y.value.delete(e):y.value.add(e),i.value=C(a.data||[]),t.nextTick(()=>{M(),k()})}function w(e){return e[se.value]}function E(e){const l=e[_.value];return Array.isArray(l)?l:[]}function he(e){return h.value.has(e)}function pe(e){return m.value.has(e)}function G(e,l){if(l?h.value.add(e):h.value.delete(e),m.value.delete(e),!a.checkStrictly){const n=Z(e,a.data||[]);if(n){const o=[n];for(;o.length;){const r=o.pop(),u=w(r);l?h.value.add(u):h.value.delete(u),m.value.delete(u);const f=E(r);for(const s of f)o.push(s)}const c=q(e,a.data||[])||[];for(const r of c){const u=w(r),f=E(r);let s=!0,d=!1;for(const x of f){const $=w(x),re=h.value.has($),ie=m.value.has($);(re||ie)&&(d=!0),(!re||ie)&&(s=!1)}f.length===0?(h.value.has(u),m.value.delete(u)):s?(h.value.add(u),m.value.delete(u)):d?(h.value.delete(u),m.value.add(u)):(h.value.delete(u),m.value.delete(u))}}}}function te(e){h.value=new Set,m.value=new Set;for(const l of e||[])G(l,!0)}function me(e,l){const n=l.target;a.disabledChecked&&a.disabledChecked(e.node)||G(e.id,!!n.checked)}function C(e){const l=[];function n(o,c,r){for(let u=0;u<o.length;u++){const f=o[u],s=w(f),d=E(f),x=d.length===0;l.push({id:s,node:f,parent:c,level:r,index:u,isLeaf:x}),!x&&y.value.has(s)&&n(d,f,r+1)}}return n(e,null,0),l}const v=t.ref(null),B=t.ref(0),N=t.ref(0),i=t.ref([]),A=t.reactive(new Map),g=t.computed(()=>{let e=0;const l=[];for(const n of i.value){const o=A.get(n.id)||H;e+=o,l.push(e)}return l}),le=t.computed(()=>{const e=g.value;return e.length?e[e.length-1]:0});function ne(e){let l=0,n=g.value.length-1,o=0;for(;l<=n;){const c=l+n>>1;g.value[c]!==void 0&&g.value[c]>=e?(o=c,n=c-1):l=c+1}return o}const K=t.ref(0),b=t.ref(0),z=t.ref(0),J=t.ref(0);function k(){if(N.value=v.value?.clientHeight||0,g.value.length===0||i.value.length===0){K.value=0,b.value=0,z.value=0,J.value=0;return}const e=ne(B.value);K.value=Math.max(0,e-3);const l=i.value[K.value],n=l?A.get(l.id)||H:0,c=(g.value[K.value]??0)-n;z.value=Math.max(0,c);let r=K.value;const u=B.value+N.value+3*H;for(;r<i.value.length&&(g.value[r]??0)<u;)r++;b.value=Math.min(i.value.length,r+1);const s=(g.value[b.value-1]??0)-z.value;if(s<N.value&&b.value<i.value.length){let d=b.value,x=s;for(;x<N.value&&d<i.value.length;)d++,x=(g.value[d-1]??0)-z.value;b.value=d}J.value=Math.max(0,le.value-z.value-((g.value[b.value-1]??0)-z.value))}t.watch([B,()=>a.data,y],()=>{i.value=C(a.data||[]),t.nextTick(M),k()}),t.onMounted(()=>{i.value=C(a.data||[]),t.nextTick(M),k(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&te(a.defaultCheckedKeys),v.value&&(R=new ResizeObserver(()=>{N.value=v.value?.clientHeight||0,k()}),R.observe(v.value))});let R=null;t.onUnmounted(()=>{R&&(R.disconnect(),R=null)});const O=t.reactive(new Map);function ge(e,l){l?O.set(e,l):O.delete(e)}function M(){let e=!1;for(const l of i.value.slice(K.value,b.value)){const n=O.get(l.id);if(n){const o=n.offsetHeight;(!A.has(l.id)||A.get(l.id)!==o)&&(A.set(l.id,o),e=!0)}}e&&k()}function ke(){B.value=v.value?.scrollTop||0,k()}const S=t.ref(!1),Q=t.ref(null),D=t.ref(null),T=t.ref(null),X=t.ref(0),V=t.ref(null),F=t.ref(0);let L=null;function P(){L!=null&&(cancelAnimationFrame(L),L=null)}function ae(){if(!S.value||F.value===0){P();return}const e=v.value;if(!e){P();return}const l=e.scrollHeight-e.clientHeight,n=12;e.scrollTop=Math.max(0,Math.min(l,e.scrollTop+F.value*n)),B.value=e.scrollTop,k(),L=requestAnimationFrame(ae)}function xe(){F.value!==0&&L==null&&(L=requestAnimationFrame(ae)),F.value===0&&P()}function W(e){if(e==null)return null;for(const l of i.value)if(l.id===e)return l;return null}function ye(e){const l=v.value.getBoundingClientRect(),n=e-l.top+B.value;return ne(n)}function we(e,l){!a.draggable||l.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(S.value=!0,Q.value=e.id,X.value=l.clientY,l.preventDefault(),window.addEventListener("mousemove",oe),window.addEventListener("mouseup",ue))}function oe(e){if(!S.value)return;X.value=e.clientY;const l=ye(e.clientY),n=i.value[Math.min(Math.max(l,0),i.value.length-1)];if(D.value=n?.id??null,!n){T.value=null;return}const o=g.value[l]??0,c=A.get(n.id)??H,r=o-c,u=v.value.getBoundingClientRect(),s=(e.clientY-u.top+B.value-r)/c;let d="inner";s<.25?d="prev":s>.75&&(d="next");const x=W(Q.value),$=a.allowDrop?!!(x&&a.allowDrop(x.node,n.node,d)):!0;T.value=$?d:null,F.value=e.clientY>u.bottom?1:e.clientY<u.top?-1:0,xe()}function q(e,l,n=[]){for(const o of l){if(w(o)===e)return n;const c=E(o);if(c.length){const r=q(e,c,[...n,o]);if(r)return r}}return null}function Z(e,l){if(e==null)return null;for(const n of l){if(w(n)===e)return n;const o=E(n),c=Z(e,o);if(c)return c}return null}function U(e){const l=[];for(const n of e){l.push(w(n));const o=E(n);o.length&&l.push(...U(o))}return l}function Ce(e){const l=e.parent;if(l)E(l).splice(e.index,1);else{const n=a.data.findIndex(o=>w(o)===e.id);n>=0&&a.data.splice(n,1)}}function be(e,l,n){if(n==="inner"){Array.isArray(l.node[_.value])||(l.node[_.value]=[]),l.node[_.value].push(e),y.value.add(l.id);return}const o=l.parent;if(o){const c=E(o),r=l.index+(n==="next"?1:0);c.splice(r,0,e)}else{const c=l.index+(n==="next"?1:0);a.data.splice(c,0,e)}}function ue(){if(window.removeEventListener("mousemove",oe),window.removeEventListener("mouseup",ue),P(),!S.value)return;const e=W(Q.value),l=W(D.value),n=T.value;if(S.value=!1,T.value=null,D.value=null,!e||!l||!n||a.allowDrop&&!a.allowDrop(e.node,l.node,n)||e.id===l.id)return;const o=n==="inner"?l.node:l.parent||null;if(o){const f=q(w(o),a.data||[])||[];for(const s of f)if(w(s)===e.id)return}const c=e.node;Ce(e);const r=C(a.data||[]);i.value=r;const u=W(l.id)||l;be(c,u,n),i.value=C(a.data||[]),t.nextTick(()=>{M(),k()}),I("node-drop",c,u.node,n)}function Se(e,l){V.value=e.id,I("node-click",e.node,l)}function Te(e,l){I("node-contextmenu",e.node,l)}t.watchEffect(()=>{t.nextTick(M)}),t.watch(()=>a.currentNodeKey,e=>{V.value=e??null},{immediate:!0}),t.watch(()=>a.defaultExpandedKeys,e=>{y.value=new Set(e||[]),i.value=C(a.data||[]),t.nextTick(()=>{M(),k()})},{immediate:!0}),t.watch(()=>a.defaultExpandAll,e=>{e&&(y.value=new Set(U(a.data||[])),i.value=C(a.data||[]),t.nextTick(()=>{M(),k()}))},{immediate:!0}),t.watch(()=>a.data,()=>{a.defaultExpandAll&&(y.value=new Set(U(a.data||[])),i.value=C(a.data||[]),t.nextTick(()=>{M(),k()}));const e=new Set(U(a.data||[]));h.value=new Set([...h.value].filter(l=>e.has(l))),m.value=new Set([...m.value].filter(l=>e.has(l)))});function Ee(e){const l=q(e,a.data||[])||[];for(const n of l)y.value.add(w(n));i.value=C(a.data||[])}function ce(e){e!=null&&(Ee(e),t.nextTick(()=>{const l=i.value.findIndex(u=>u.id===e);if(l<0||!v.value)return;const n=A.get(e)||H,o=(g.value[l]??0)-n,c=v.value.clientHeight,r=Math.max(0,o-Math.max(0,(c-n)/2));v.value.scrollTop=r,B.value=r,k(),t.nextTick(()=>{const u=O.get(e);if(!u||!v.value)return;const f=u.offsetLeft,s=u.offsetWidth,d=v.value.clientWidth,x=Math.max(0,f+Math.max(0,s/2)-Math.max(0,d/2));v.value.scrollLeft=x})}))}function Be(e){V.value=e??null,ce(V.value)}return j({getCurrentKey:()=>V.value,setCurrentKey:Be,scrollTo:ce,getCheckedKeys:()=>Array.from(h.value),setCheckedKeys:te,setChecked:(e,l)=>G(e,l)}),t.watch(V,e=>{const l=Z(e,a.data||[]);l&&I("current-change",l)}),(e,l)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:v,class:t.normalizeClass(["vtree",{"is-dragging":S.value}]),style:t.normalizeStyle({height:typeof p.height=="number"?p.height+"px":p.height||"100%","--vtree-bg":p.backgroundColor,"--vtree-text":p.textColor,"--vtree-hover":p.hoverColor}),onScroll:ke},[ve.value?(t.openBlock(),t.createElementBlock("div",Ve,[t.renderSlot(e.$slots,"empty",{},()=>[t.createElementVNode("div",Ie,t.toDisplayString(p.emptyText),1)],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",{style:t.normalizeStyle({height:le.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[t.createElementVNode("div",{style:t.normalizeStyle({height:z.value+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(i.value.slice(K.value,b.value),n=>(t.openBlock(),t.createElementBlock("div",{key:n.id,class:"vtree-row-wrapper"},[t.createElementVNode("div",{class:t.normalizeClass(["vtree-row",{"is-target-inner":S.value&&D.value===n.id&&T.value==="inner","is-active":V.value===n.id}]),style:t.normalizeStyle({paddingLeft:n.level*16+"px","--active-color":p.highlightColor}),onMousedown:o=>we(n,o),onClick:o=>Se(n,o),onContextmenu:t.withModifiers(o=>Te(n,o),["prevent"]),ref_for:!0,ref:o=>ge(n.id,o)},[t.createElementVNode("span",{class:t.normalizeClass(["vtree-caret-box",{"is-leaf":n.isLeaf}]),onClick:t.withModifiers(o=>!n.isLeaf&&fe(n.id),["stop"])},[n.isLeaf?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["vtree-caret",{expanded:ee(n.id)}])},null,2))],10,Ae),p.showCheckbox?(t.openBlock(),t.createElementBlock("input",{key:0,class:"vtree-checkbox",type:"checkbox",checked:he(n.id),indeterminate:pe(n.id),disabled:a.disabledChecked?a.disabledChecked(n.node):!1,onClick:t.withModifiers(o=>me(n,o),["stop"])},null,8,Ke)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default",{node:n.node,data:n.node,level:n.level,expanded:ee(n.id),isLeaf:n.isLeaf},()=>[t.createElementVNode("span",ze,t.toDisplayString(n.node[de.value]),1)],!0)],46,Me),S.value&&D.value===n.id&&(T.value==="prev"||T.value==="next")?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["vtree-drop-line",{"is-prev":T.value==="prev","is-next":T.value==="next"}])},null,2)):t.createCommentVNode("",!0)]))),128)),t.createElementVNode("div",{style:t.normalizeStyle({height:J.value+"px"})},null,4)],4),S.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"vtree-ghost",style:t.normalizeStyle({top:X.value+"px"})},null,4)):t.createCommentVNode("",!0)],64))],38))}}),Ne=(p,j)=>{const Y=p.__vccOpts||p;for(const[a,I]of j)Y[a]=I;return Y},Re=Ne(Le,[["__scopeId","data-v-cfceef5a"]]);exports.VirtualTree=Re;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.vtree[data-v-cfceef5a]{width:100%;overflow:auto;position:relative;background:var(--vtree-bg);color:var(--vtree-text);scrollbar-width:thin;scrollbar-color:rgba(144,147,153,.3) transparent;cursor:pointer;--vtree-primary: #409eff;--vtree-checkbox-bg: #1d1d24;--vtree-checkbox-border: #4c4d4f;--vtree-checkbox-hover-border: #8d8e91;--vtree-checkbox-disabled-bg: #2c2f33;--vtree-checkbox-disabled-border: #5c5f63;--vtree-checkbox-check: #ffffff;--vtree-checkbox-check-disabled: #cfd3dc}.vtree.is-dragging[data-v-cfceef5a],.vtree.is-dragging[data-v-cfceef5a] *{-webkit-user-select:none;user-select:none}.vtree[data-v-cfceef5a] *{cursor:pointer}.vtree input[type=checkbox][data-v-cfceef5a]:disabled{cursor:not-allowed}.vtree .vtree-checkbox[data-v-cfceef5a]{-webkit-appearance:none;appearance:none;position:relative;width:14px;height:14px;border:1px solid var(--vtree-checkbox-border);background:var(--vtree-checkbox-bg);border-radius:2px;outline:none;transition:border-color .12s ease,background-color .12s ease,box-shadow .12s ease;vertical-align:middle;margin-right:6px}.vtree .vtree-checkbox[data-v-cfceef5a]:not(:disabled):hover{border-color:var(--vtree-checkbox-hover-border)}.vtree .vtree-checkbox[data-v-cfceef5a]:focus-visible{box-shadow:0 0 0 2px #409eff33}.vtree .vtree-checkbox[data-v-cfceef5a]:checked{background:var(--vtree-primary);border-color:var(--vtree-primary)}.vtree .vtree-checkbox[data-v-cfceef5a]:checked:after{content:"";position:absolute;left:3px;top:0;width:4px;height:8px;border:2px solid var(--vtree-checkbox-check);border-top:0;border-left:0;transform:rotate(45deg)}.vtree .vtree-checkbox[data-v-cfceef5a]:indeterminate{background:var(--vtree-primary);border-color:var(--vtree-primary)}.vtree .vtree-checkbox[data-v-cfceef5a]:indeterminate:after{content:"";position:absolute;left:2px;top:5px;width:10px;height:2px;background:var(--vtree-checkbox-check);border-radius:1px}.vtree .vtree-checkbox[data-v-cfceef5a]:disabled{background:var(--vtree-checkbox-disabled-bg);border-color:var(--vtree-checkbox-disabled-border)}.vtree .vtree-checkbox[data-v-cfceef5a]:disabled:checked:after{border-color:var(--vtree-checkbox-check-disabled)}.vtree .vtree-checkbox[data-v-cfceef5a]:disabled:indeterminate:after{background:var(--vtree-checkbox-check-disabled)}.vtree .vtree-row-wrapper[data-v-cfceef5a]{position:relative}.vtree .vtree-row-wrapper .vtree-drop-line[data-v-cfceef5a]{position:absolute;left:0;right:0;height:0;border-top:2px solid #409eff}.vtree .vtree-row-wrapper .vtree-drop-line.is-prev[data-v-cfceef5a]{top:0}.vtree .vtree-row-wrapper .vtree-drop-line.is-next[data-v-cfceef5a]{bottom:0}.vtree .vtree-row[data-v-cfceef5a]{display:flex;align-items:center;gap:4px;box-sizing:border-box;min-height:24px;padding:2px 8px;white-space:nowrap}.vtree .vtree-row[data-v-cfceef5a]:hover{background:var(--vtree-hover)}.vtree .vtree-row.is-active[data-v-cfceef5a],.vtree .vtree-row.is-active[data-v-cfceef5a]:hover{background:var(--active-color)}.vtree .vtree-row.is-target-inner[data-v-cfceef5a]{outline:2px dashed #409eff}.vtree .vtree-row .vtree-caret-box[data-v-cfceef5a]{display:inline-flex;align-items:center;justify-content:center;height:100%;aspect-ratio:1/1;min-width:16px;margin-right:4px;cursor:pointer}.vtree .vtree-row .vtree-caret-box.is-leaf[data-v-cfceef5a]{pointer-events:none}.vtree .vtree-row .vtree-caret[data-v-cfceef5a]{display:block;width:0;height:0;border-left:5px solid transparent;border-right:5px solid transparent;border-top:6px solid #909399;transform:rotate(-90deg);transition:transform .1s linear}.vtree .vtree-row .vtree-caret.expanded[data-v-cfceef5a]{transform:rotate(0)}.vtree .vtree-row .vtree-label[data-v-cfceef5a]{color:inherit}.vtree .vtree-ghost[data-v-cfceef5a]{position:fixed;left:16px;width:120px;height:24px;background:#409eff33;border:1px solid #409eff;pointer-events:none}.vtree .vtree-empty[data-v-cfceef5a]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.vtree .vtree-empty[data-v-cfceef5a]>*{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.vtree .vtree-empty .vtree-empty-inner[data-v-cfceef5a]{color:var(--vtree-text)}[data-v-cfceef5a] .vtree::-webkit-scrollbar{width:8px;height:8px}[data-v-cfceef5a] .vtree::-webkit-scrollbar-track{background:transparent}[data-v-cfceef5a] .vtree::-webkit-scrollbar-thumb{background-color:#9093994d;border-radius:4px}[data-v-cfceef5a] .vtree::-webkit-scrollbar-thumb:hover{background-color:#90939980}
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import { defineComponent as We, computed as N, ref as i, reactive as we, watch as V, nextTick as C, onMounted as Oe, onUnmounted as Pe, watchEffect as Ue, createElementBlock as T, openBlock as K, normalizeStyle as _, normalizeClass as $, Fragment as ke, createElementVNode as Y, createCommentVNode as le, renderList as $e, withModifiers as ie, renderSlot as Ce, toDisplayString as be } from "vue";
|
|
2
|
+
const qe = ["onMousedown", "onClick", "onContextmenu"], je = ["onClick"], Ge = ["checked", "indeterminate", "disabled", "onClick"], Je = { class: "vtree-label" }, Qe = {
|
|
3
|
+
key: 1,
|
|
4
|
+
class: "vtree-empty"
|
|
5
|
+
}, Xe = { class: "vtree-empty-inner" }, q = 28, Ze = /* @__PURE__ */ We({
|
|
6
|
+
__name: "VirtualTree",
|
|
7
|
+
props: {
|
|
8
|
+
data: {},
|
|
9
|
+
props: { default: () => ({ value: "value", label: "label", children: "children" }) },
|
|
10
|
+
allowDrag: {},
|
|
11
|
+
allowDrop: {},
|
|
12
|
+
height: { default: void 0 },
|
|
13
|
+
highlightColor: { default: "#1e71ff" },
|
|
14
|
+
backgroundColor: { default: "#1d1d24" },
|
|
15
|
+
textColor: { default: "#c8d3de" },
|
|
16
|
+
hoverColor: { default: "#5d90e5" },
|
|
17
|
+
currentNodeKey: {},
|
|
18
|
+
defaultExpandedKeys: {},
|
|
19
|
+
defaultExpandAll: { type: Boolean, default: !1 },
|
|
20
|
+
draggable: { type: Boolean, default: !1 },
|
|
21
|
+
emptyText: { default: "暂无数据" },
|
|
22
|
+
showCheckbox: { type: Boolean, default: !1 },
|
|
23
|
+
checkStrictly: { type: Boolean, default: !1 },
|
|
24
|
+
defaultCheckedKeys: { default: () => [] },
|
|
25
|
+
disabledChecked: {}
|
|
26
|
+
},
|
|
27
|
+
emits: ["node-click", "node-contextmenu", "node-drop", "current-change"],
|
|
28
|
+
setup(p, { expose: ne, emit: j }) {
|
|
29
|
+
const n = p, F = j, Se = N(() => n.props.value || "value"), Me = N(() => n.props.label || "label"), G = N(() => n.props.children || "children"), Ae = N(() => Array.isArray(n.data) ? n.data.length === 0 : !0), w = i(/* @__PURE__ */ new Set()), h = i(/* @__PURE__ */ new Set()), g = i(/* @__PURE__ */ new Set());
|
|
30
|
+
function re(e) {
|
|
31
|
+
return w.value.has(e);
|
|
32
|
+
}
|
|
33
|
+
function Te(e) {
|
|
34
|
+
w.value.has(e) ? w.value.delete(e) : w.value.add(e), s.value = b(n.data || []), C(() => {
|
|
35
|
+
L(), x();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function k(e) {
|
|
39
|
+
return e[Se.value];
|
|
40
|
+
}
|
|
41
|
+
function E(e) {
|
|
42
|
+
const t = e[G.value];
|
|
43
|
+
return Array.isArray(t) ? t : [];
|
|
44
|
+
}
|
|
45
|
+
function Ke(e) {
|
|
46
|
+
return h.value.has(e);
|
|
47
|
+
}
|
|
48
|
+
function Ee(e) {
|
|
49
|
+
return g.value.has(e);
|
|
50
|
+
}
|
|
51
|
+
function ae(e, t) {
|
|
52
|
+
if (t ? h.value.add(e) : h.value.delete(e), g.value.delete(e), !n.checkStrictly) {
|
|
53
|
+
const l = se(e, n.data || []);
|
|
54
|
+
if (l) {
|
|
55
|
+
const a = [l];
|
|
56
|
+
for (; a.length; ) {
|
|
57
|
+
const c = a.pop(), o = k(c);
|
|
58
|
+
t ? h.value.add(o) : h.value.delete(o), g.value.delete(o);
|
|
59
|
+
const f = E(c);
|
|
60
|
+
for (const r of f) a.push(r);
|
|
61
|
+
}
|
|
62
|
+
const u = Z(e, n.data || []) || [];
|
|
63
|
+
for (const c of u) {
|
|
64
|
+
const o = k(c), f = E(c);
|
|
65
|
+
let r = !0, d = !1;
|
|
66
|
+
for (const y of f) {
|
|
67
|
+
const te = k(y), xe = h.value.has(te), ye = g.value.has(te);
|
|
68
|
+
(xe || ye) && (d = !0), (!xe || ye) && (r = !1);
|
|
69
|
+
}
|
|
70
|
+
f.length === 0 ? (h.value.has(o), g.value.delete(o)) : r ? (h.value.add(o), g.value.delete(o)) : d ? (h.value.delete(o), g.value.add(o)) : (h.value.delete(o), g.value.delete(o));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function de(e) {
|
|
76
|
+
h.value = /* @__PURE__ */ new Set(), g.value = /* @__PURE__ */ new Set();
|
|
77
|
+
for (const t of e || []) ae(t, !0);
|
|
78
|
+
}
|
|
79
|
+
function Ie(e, t) {
|
|
80
|
+
const l = t.target;
|
|
81
|
+
n.disabledChecked && n.disabledChecked(e.node) || ae(e.id, !!l.checked);
|
|
82
|
+
}
|
|
83
|
+
function b(e) {
|
|
84
|
+
const t = [];
|
|
85
|
+
function l(a, u, c) {
|
|
86
|
+
for (let o = 0; o < a.length; o++) {
|
|
87
|
+
const f = a[o], r = k(f), d = E(f), y = d.length === 0;
|
|
88
|
+
t.push({ id: r, node: f, parent: u, level: c, index: o, isLeaf: y }), !y && w.value.has(r) && l(d, f, c + 1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return l(e, null, 0), t;
|
|
92
|
+
}
|
|
93
|
+
const v = i(null), I = i(0), W = i(0), s = i([]), R = we(/* @__PURE__ */ new Map()), m = N(() => {
|
|
94
|
+
let e = 0;
|
|
95
|
+
const t = [];
|
|
96
|
+
for (const l of s.value) {
|
|
97
|
+
const a = R.get(l.id) || q;
|
|
98
|
+
e += a, t.push(e);
|
|
99
|
+
}
|
|
100
|
+
return t;
|
|
101
|
+
}), ve = N(() => {
|
|
102
|
+
const e = m.value;
|
|
103
|
+
return e.length ? e[e.length - 1] : 0;
|
|
104
|
+
});
|
|
105
|
+
function fe(e) {
|
|
106
|
+
let t = 0, l = m.value.length - 1, a = 0;
|
|
107
|
+
for (; t <= l; ) {
|
|
108
|
+
const u = t + l >> 1;
|
|
109
|
+
m.value[u] !== void 0 && m.value[u] >= e ? (a = u, l = u - 1) : t = u + 1;
|
|
110
|
+
}
|
|
111
|
+
return a;
|
|
112
|
+
}
|
|
113
|
+
const B = i(0), S = i(0), D = i(0), oe = i(0);
|
|
114
|
+
function x() {
|
|
115
|
+
if (W.value = v.value?.clientHeight || 0, m.value.length === 0 || s.value.length === 0) {
|
|
116
|
+
B.value = 0, S.value = 0, D.value = 0, oe.value = 0;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const e = fe(I.value);
|
|
120
|
+
B.value = Math.max(0, e - 3);
|
|
121
|
+
const t = s.value[B.value], l = t ? R.get(t.id) || q : 0, u = (m.value[B.value] ?? 0) - l;
|
|
122
|
+
D.value = Math.max(0, u);
|
|
123
|
+
let c = B.value;
|
|
124
|
+
const o = I.value + W.value + 3 * q;
|
|
125
|
+
for (; c < s.value.length && (m.value[c] ?? 0) < o; ) c++;
|
|
126
|
+
S.value = Math.min(s.value.length, c + 1);
|
|
127
|
+
const r = (m.value[S.value - 1] ?? 0) - D.value;
|
|
128
|
+
if (r < W.value && S.value < s.value.length) {
|
|
129
|
+
let d = S.value, y = r;
|
|
130
|
+
for (; y < W.value && d < s.value.length; )
|
|
131
|
+
d++, y = (m.value[d - 1] ?? 0) - D.value;
|
|
132
|
+
S.value = d;
|
|
133
|
+
}
|
|
134
|
+
oe.value = Math.max(0, ve.value - D.value - ((m.value[S.value - 1] ?? 0) - D.value));
|
|
135
|
+
}
|
|
136
|
+
V([I, () => n.data, w], () => {
|
|
137
|
+
s.value = b(n.data || []), C(L), x();
|
|
138
|
+
}), Oe(() => {
|
|
139
|
+
s.value = b(n.data || []), C(L), x(), n.defaultCheckedKeys && n.defaultCheckedKeys.length && de(n.defaultCheckedKeys), v.value && (O = new ResizeObserver(() => {
|
|
140
|
+
W.value = v.value?.clientHeight || 0, x();
|
|
141
|
+
}), O.observe(v.value));
|
|
142
|
+
});
|
|
143
|
+
let O = null;
|
|
144
|
+
Pe(() => {
|
|
145
|
+
O && (O.disconnect(), O = null);
|
|
146
|
+
});
|
|
147
|
+
const J = we(/* @__PURE__ */ new Map());
|
|
148
|
+
function Le(e, t) {
|
|
149
|
+
t ? J.set(e, t) : J.delete(e);
|
|
150
|
+
}
|
|
151
|
+
function L() {
|
|
152
|
+
let e = !1;
|
|
153
|
+
for (const t of s.value.slice(B.value, S.value)) {
|
|
154
|
+
const l = J.get(t.id);
|
|
155
|
+
if (l) {
|
|
156
|
+
const a = l.offsetHeight;
|
|
157
|
+
(!R.has(t.id) || R.get(t.id) !== a) && (R.set(t.id, a), e = !0);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
e && x();
|
|
161
|
+
}
|
|
162
|
+
function Re() {
|
|
163
|
+
I.value = v.value?.scrollTop || 0, x();
|
|
164
|
+
}
|
|
165
|
+
const M = i(!1), ue = i(null), P = i(null), A = i(null), ce = i(0), H = i(null), U = i(0);
|
|
166
|
+
let z = null;
|
|
167
|
+
function Q() {
|
|
168
|
+
z != null && (cancelAnimationFrame(z), z = null);
|
|
169
|
+
}
|
|
170
|
+
function he() {
|
|
171
|
+
if (!M.value || U.value === 0) {
|
|
172
|
+
Q();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const e = v.value;
|
|
176
|
+
if (!e) {
|
|
177
|
+
Q();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const t = e.scrollHeight - e.clientHeight, l = 12;
|
|
181
|
+
e.scrollTop = Math.max(0, Math.min(t, e.scrollTop + U.value * l)), I.value = e.scrollTop, x(), z = requestAnimationFrame(he);
|
|
182
|
+
}
|
|
183
|
+
function Be() {
|
|
184
|
+
U.value !== 0 && z == null && (z = requestAnimationFrame(he)), U.value === 0 && Q();
|
|
185
|
+
}
|
|
186
|
+
function X(e) {
|
|
187
|
+
if (e == null) return null;
|
|
188
|
+
for (const t of s.value) if (t.id === e) return t;
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
function De(e) {
|
|
192
|
+
const t = v.value.getBoundingClientRect(), l = e - t.top + I.value;
|
|
193
|
+
return fe(l);
|
|
194
|
+
}
|
|
195
|
+
function He(e, t) {
|
|
196
|
+
!n.draggable || t.button !== 0 || !(!n.allowDrag || n.allowDrag(e.node)) || (M.value = !0, ue.value = e.id, ce.value = t.clientY, t.preventDefault(), window.addEventListener("mousemove", pe), window.addEventListener("mouseup", ge));
|
|
197
|
+
}
|
|
198
|
+
function pe(e) {
|
|
199
|
+
if (!M.value) return;
|
|
200
|
+
ce.value = e.clientY;
|
|
201
|
+
const t = De(e.clientY), l = s.value[Math.min(Math.max(t, 0), s.value.length - 1)];
|
|
202
|
+
if (P.value = l?.id ?? null, !l) {
|
|
203
|
+
A.value = null;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const a = m.value[t] ?? 0, u = R.get(l.id) ?? q, c = a - u, o = v.value.getBoundingClientRect(), r = (e.clientY - o.top + I.value - c) / u;
|
|
207
|
+
let d = "inner";
|
|
208
|
+
r < 0.25 ? d = "prev" : r > 0.75 && (d = "next");
|
|
209
|
+
const y = X(ue.value), te = n.allowDrop ? !!(y && n.allowDrop(y.node, l.node, d)) : !0;
|
|
210
|
+
A.value = te ? d : null, U.value = e.clientY > o.bottom ? 1 : e.clientY < o.top ? -1 : 0, Be();
|
|
211
|
+
}
|
|
212
|
+
function Z(e, t, l = []) {
|
|
213
|
+
for (const a of t) {
|
|
214
|
+
if (k(a) === e) return l;
|
|
215
|
+
const u = E(a);
|
|
216
|
+
if (u.length) {
|
|
217
|
+
const c = Z(e, u, [...l, a]);
|
|
218
|
+
if (c) return c;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
function se(e, t) {
|
|
224
|
+
if (e == null) return null;
|
|
225
|
+
for (const l of t) {
|
|
226
|
+
if (k(l) === e) return l;
|
|
227
|
+
const a = E(l), u = se(e, a);
|
|
228
|
+
if (u) return u;
|
|
229
|
+
}
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
function ee(e) {
|
|
233
|
+
const t = [];
|
|
234
|
+
for (const l of e) {
|
|
235
|
+
t.push(k(l));
|
|
236
|
+
const a = E(l);
|
|
237
|
+
a.length && t.push(...ee(a));
|
|
238
|
+
}
|
|
239
|
+
return t;
|
|
240
|
+
}
|
|
241
|
+
function Ye(e) {
|
|
242
|
+
const t = e.parent;
|
|
243
|
+
if (t)
|
|
244
|
+
E(t).splice(e.index, 1);
|
|
245
|
+
else {
|
|
246
|
+
const l = n.data.findIndex((a) => k(a) === e.id);
|
|
247
|
+
l >= 0 && n.data.splice(l, 1);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function Fe(e, t, l) {
|
|
251
|
+
if (l === "inner") {
|
|
252
|
+
Array.isArray(t.node[G.value]) || (t.node[G.value] = []), t.node[G.value].push(e), w.value.add(t.id);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const a = t.parent;
|
|
256
|
+
if (a) {
|
|
257
|
+
const u = E(a), c = t.index + (l === "next" ? 1 : 0);
|
|
258
|
+
u.splice(c, 0, e);
|
|
259
|
+
} else {
|
|
260
|
+
const u = t.index + (l === "next" ? 1 : 0);
|
|
261
|
+
n.data.splice(u, 0, e);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function ge() {
|
|
265
|
+
if (window.removeEventListener("mousemove", pe), window.removeEventListener("mouseup", ge), Q(), !M.value) return;
|
|
266
|
+
const e = X(ue.value), t = X(P.value), l = A.value;
|
|
267
|
+
if (M.value = !1, A.value = null, P.value = null, !e || !t || !l || n.allowDrop && !n.allowDrop(e.node, t.node, l) || e.id === t.id) return;
|
|
268
|
+
const a = l === "inner" ? t.node : t.parent || null;
|
|
269
|
+
if (a) {
|
|
270
|
+
const f = Z(k(a), n.data || []) || [];
|
|
271
|
+
for (const r of f) if (k(r) === e.id) return;
|
|
272
|
+
}
|
|
273
|
+
const u = e.node;
|
|
274
|
+
Ye(e);
|
|
275
|
+
const c = b(n.data || []);
|
|
276
|
+
s.value = c;
|
|
277
|
+
const o = X(t.id) || t;
|
|
278
|
+
Fe(u, o, l), s.value = b(n.data || []), C(() => {
|
|
279
|
+
L(), x();
|
|
280
|
+
}), F("node-drop", u, o.node, l);
|
|
281
|
+
}
|
|
282
|
+
function ze(e, t) {
|
|
283
|
+
H.value = e.id, F("node-click", e.node, t);
|
|
284
|
+
}
|
|
285
|
+
function Ne(e, t) {
|
|
286
|
+
F("node-contextmenu", e.node, t);
|
|
287
|
+
}
|
|
288
|
+
Ue(() => {
|
|
289
|
+
C(L);
|
|
290
|
+
}), V(
|
|
291
|
+
() => n.currentNodeKey,
|
|
292
|
+
(e) => {
|
|
293
|
+
H.value = e ?? null;
|
|
294
|
+
},
|
|
295
|
+
{ immediate: !0 }
|
|
296
|
+
), V(
|
|
297
|
+
() => n.defaultExpandedKeys,
|
|
298
|
+
(e) => {
|
|
299
|
+
w.value = new Set(e || []), s.value = b(n.data || []), C(() => {
|
|
300
|
+
L(), x();
|
|
301
|
+
});
|
|
302
|
+
},
|
|
303
|
+
{ immediate: !0 }
|
|
304
|
+
), V(
|
|
305
|
+
() => n.defaultExpandAll,
|
|
306
|
+
(e) => {
|
|
307
|
+
e && (w.value = new Set(ee(n.data || [])), s.value = b(n.data || []), C(() => {
|
|
308
|
+
L(), x();
|
|
309
|
+
}));
|
|
310
|
+
},
|
|
311
|
+
{ immediate: !0 }
|
|
312
|
+
), V(
|
|
313
|
+
() => n.data,
|
|
314
|
+
() => {
|
|
315
|
+
n.defaultExpandAll && (w.value = new Set(ee(n.data || [])), s.value = b(n.data || []), C(() => {
|
|
316
|
+
L(), x();
|
|
317
|
+
}));
|
|
318
|
+
const e = new Set(ee(n.data || []));
|
|
319
|
+
h.value = new Set([...h.value].filter((t) => e.has(t))), g.value = new Set([...g.value].filter((t) => e.has(t)));
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
function Ve(e) {
|
|
323
|
+
const t = Z(e, n.data || []) || [];
|
|
324
|
+
for (const l of t) w.value.add(k(l));
|
|
325
|
+
s.value = b(n.data || []);
|
|
326
|
+
}
|
|
327
|
+
function me(e) {
|
|
328
|
+
e != null && (Ve(e), C(() => {
|
|
329
|
+
const t = s.value.findIndex((o) => o.id === e);
|
|
330
|
+
if (t < 0 || !v.value) return;
|
|
331
|
+
const l = R.get(e) || q, a = (m.value[t] ?? 0) - l, u = v.value.clientHeight, c = Math.max(0, a - Math.max(0, (u - l) / 2));
|
|
332
|
+
v.value.scrollTop = c, I.value = c, x(), C(() => {
|
|
333
|
+
const o = J.get(e);
|
|
334
|
+
if (!o || !v.value) return;
|
|
335
|
+
const f = o.offsetLeft, r = o.offsetWidth, d = v.value.clientWidth, y = Math.max(0, f + Math.max(0, r / 2) - Math.max(0, d / 2));
|
|
336
|
+
v.value.scrollLeft = y;
|
|
337
|
+
});
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
function _e(e) {
|
|
341
|
+
H.value = e ?? null, me(H.value);
|
|
342
|
+
}
|
|
343
|
+
return ne({
|
|
344
|
+
getCurrentKey: () => H.value,
|
|
345
|
+
setCurrentKey: _e,
|
|
346
|
+
scrollTo: me,
|
|
347
|
+
getCheckedKeys: () => Array.from(h.value),
|
|
348
|
+
setCheckedKeys: de,
|
|
349
|
+
setChecked: (e, t) => ae(e, t)
|
|
350
|
+
}), V(H, (e) => {
|
|
351
|
+
const t = se(e, n.data || []);
|
|
352
|
+
t && F("current-change", t);
|
|
353
|
+
}), (e, t) => (K(), T("div", {
|
|
354
|
+
ref_key: "containerRef",
|
|
355
|
+
ref: v,
|
|
356
|
+
class: $(["vtree", { "is-dragging": M.value }]),
|
|
357
|
+
style: _({ height: typeof p.height == "number" ? p.height + "px" : p.height || "100%", "--vtree-bg": p.backgroundColor, "--vtree-text": p.textColor, "--vtree-hover": p.hoverColor }),
|
|
358
|
+
onScroll: Re
|
|
359
|
+
}, [
|
|
360
|
+
Ae.value ? (K(), T("div", Qe, [
|
|
361
|
+
Ce(e.$slots, "empty", {}, () => [
|
|
362
|
+
Y("div", Xe, be(p.emptyText), 1)
|
|
363
|
+
], !0)
|
|
364
|
+
])) : (K(), T(ke, { key: 0 }, [
|
|
365
|
+
Y("div", {
|
|
366
|
+
style: _({ height: ve.value + "px", position: "relative", minWidth: "100%", width: "max-content" })
|
|
367
|
+
}, [
|
|
368
|
+
Y("div", {
|
|
369
|
+
style: _({ height: D.value + "px" })
|
|
370
|
+
}, null, 4),
|
|
371
|
+
(K(!0), T(ke, null, $e(s.value.slice(B.value, S.value), (l) => (K(), T("div", {
|
|
372
|
+
key: l.id,
|
|
373
|
+
class: "vtree-row-wrapper"
|
|
374
|
+
}, [
|
|
375
|
+
Y("div", {
|
|
376
|
+
class: $(["vtree-row", { "is-target-inner": M.value && P.value === l.id && A.value === "inner", "is-active": H.value === l.id }]),
|
|
377
|
+
style: _({ paddingLeft: l.level * 16 + "px", "--active-color": p.highlightColor }),
|
|
378
|
+
onMousedown: (a) => He(l, a),
|
|
379
|
+
onClick: (a) => ze(l, a),
|
|
380
|
+
onContextmenu: ie((a) => Ne(l, a), ["prevent"]),
|
|
381
|
+
ref_for: !0,
|
|
382
|
+
ref: (a) => Le(l.id, a)
|
|
383
|
+
}, [
|
|
384
|
+
Y("span", {
|
|
385
|
+
class: $(["vtree-caret-box", { "is-leaf": l.isLeaf }]),
|
|
386
|
+
onClick: ie((a) => !l.isLeaf && Te(l.id), ["stop"])
|
|
387
|
+
}, [
|
|
388
|
+
l.isLeaf ? le("", !0) : (K(), T("span", {
|
|
389
|
+
key: 0,
|
|
390
|
+
class: $(["vtree-caret", { expanded: re(l.id) }])
|
|
391
|
+
}, null, 2))
|
|
392
|
+
], 10, je),
|
|
393
|
+
p.showCheckbox ? (K(), T("input", {
|
|
394
|
+
key: 0,
|
|
395
|
+
class: "vtree-checkbox",
|
|
396
|
+
type: "checkbox",
|
|
397
|
+
checked: Ke(l.id),
|
|
398
|
+
indeterminate: Ee(l.id),
|
|
399
|
+
disabled: n.disabledChecked ? n.disabledChecked(l.node) : !1,
|
|
400
|
+
onClick: ie((a) => Ie(l, a), ["stop"])
|
|
401
|
+
}, null, 8, Ge)) : le("", !0),
|
|
402
|
+
Ce(e.$slots, "default", {
|
|
403
|
+
node: l.node,
|
|
404
|
+
data: l.node,
|
|
405
|
+
level: l.level,
|
|
406
|
+
expanded: re(l.id),
|
|
407
|
+
isLeaf: l.isLeaf
|
|
408
|
+
}, () => [
|
|
409
|
+
Y("span", Je, be(l.node[Me.value]), 1)
|
|
410
|
+
], !0)
|
|
411
|
+
], 46, qe),
|
|
412
|
+
M.value && P.value === l.id && (A.value === "prev" || A.value === "next") ? (K(), T("div", {
|
|
413
|
+
key: 0,
|
|
414
|
+
class: $(["vtree-drop-line", { "is-prev": A.value === "prev", "is-next": A.value === "next" }])
|
|
415
|
+
}, null, 2)) : le("", !0)
|
|
416
|
+
]))), 128)),
|
|
417
|
+
Y("div", {
|
|
418
|
+
style: _({ height: oe.value + "px" })
|
|
419
|
+
}, null, 4)
|
|
420
|
+
], 4),
|
|
421
|
+
M.value ? (K(), T("div", {
|
|
422
|
+
key: 0,
|
|
423
|
+
class: "vtree-ghost",
|
|
424
|
+
style: _({ top: ce.value + "px" })
|
|
425
|
+
}, null, 4)) : le("", !0)
|
|
426
|
+
], 64))
|
|
427
|
+
], 38));
|
|
428
|
+
}
|
|
429
|
+
}), et = (p, ne) => {
|
|
430
|
+
const j = p.__vccOpts || p;
|
|
431
|
+
for (const [n, F] of ne)
|
|
432
|
+
j[n] = F;
|
|
433
|
+
return j;
|
|
434
|
+
}, lt = /* @__PURE__ */ et(Ze, [["__scopeId", "data-v-cfceef5a"]]);
|
|
435
|
+
export {
|
|
436
|
+
lt as VirtualTree
|
|
437
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(A,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(A=typeof globalThis<"u"?globalThis:A||self,t(A.AmazingTree={},A.Vue))})(this,(function(A,t){"use strict";const ue=["onMousedown","onClick","onContextmenu"],fe=["onClick"],he=["checked","indeterminate","disabled","onClick"],ve={class:"vtree-label"},pe={key:1,class:"vtree-empty"},me={class:"vtree-empty-inner"},R=28,ge=((p,G)=>{const _=p.__vccOpts||p;for(const[a,L]of G)_[a]=L;return _})(t.defineComponent({__name:"VirtualTree",props:{data:{},props:{default:()=>({value:"value",label:"label",children:"children"})},allowDrag:{},allowDrop:{},height:{default:void 0},highlightColor:{default:"#1e71ff"},backgroundColor:{default:"#1d1d24"},textColor:{default:"#c8d3de"},hoverColor:{default:"#5d90e5"},currentNodeKey:{},defaultExpandedKeys:{},defaultExpandAll:{type:Boolean,default:!1},draggable:{type:Boolean,default:!1},emptyText:{default:"暂无数据"},showCheckbox:{type:Boolean,default:!1},checkStrictly:{type:Boolean,default:!1},defaultCheckedKeys:{default:()=>[]},disabledChecked:{}},emits:["node-click","node-contextmenu","node-drop","current-change"],setup(p,{expose:G,emit:_}){const a=p,L=_,xe=t.computed(()=>a.props.value||"value"),ke=t.computed(()=>a.props.label||"label"),O=t.computed(()=>a.props.children||"children"),ye=t.computed(()=>Array.isArray(a.data)?a.data.length===0:!0),y=t.ref(new Set),v=t.ref(new Set),m=t.ref(new Set);function te(e){return y.value.has(e)}function we(e){y.value.has(e)?y.value.delete(e):y.value.add(e),s.value=C(a.data||[]),t.nextTick(()=>{M(),x()})}function w(e){return e[xe.value]}function E(e){const l=e[O.value];return Array.isArray(l)?l:[]}function Ce(e){return v.value.has(e)}function be(e){return m.value.has(e)}function J(e,l){if(l?v.value.add(e):v.value.delete(e),m.value.delete(e),!a.checkStrictly){const n=ee(e,a.data||[]);if(n){const o=[n];for(;o.length;){const i=o.pop(),c=w(i);l?v.value.add(c):v.value.delete(c),m.value.delete(c);const h=E(i);for(const d of h)o.push(d)}const r=U(e,a.data||[])||[];for(const i of r){const c=w(i),h=E(i);let d=!0,u=!1;for(const k of h){const j=w(k),se=v.value.has(j),de=m.value.has(j);(se||de)&&(u=!0),(!se||de)&&(d=!1)}h.length===0?(v.value.has(c),m.value.delete(c)):d?(v.value.add(c),m.value.delete(c)):u?(v.value.delete(c),m.value.add(c)):(v.value.delete(c),m.value.delete(c))}}}}function le(e){v.value=new Set,m.value=new Set;for(const l of e||[])J(l,!0)}function Se(e,l){const n=l.target;a.disabledChecked&&a.disabledChecked(e.node)||J(e.id,!!n.checked)}function C(e){const l=[];function n(o,r,i){for(let c=0;c<o.length;c++){const h=o[c],d=w(h),u=E(h),k=u.length===0;l.push({id:d,node:h,parent:r,level:i,index:c,isLeaf:k}),!k&&y.value.has(d)&&n(u,h,i+1)}}return n(e,null,0),l}const f=t.ref(null),B=t.ref(0),D=t.ref(0),s=t.ref([]),K=t.reactive(new Map),g=t.computed(()=>{let e=0;const l=[];for(const n of s.value){const o=K.get(n.id)||R;e+=o,l.push(e)}return l}),ne=t.computed(()=>{const e=g.value;return e.length?e[e.length-1]:0});function ae(e){let l=0,n=g.value.length-1,o=0;for(;l<=n;){const r=l+n>>1;g.value[r]!==void 0&&g.value[r]>=e?(o=r,n=r-1):l=r+1}return o}const z=t.ref(0),b=t.ref(0),V=t.ref(0),Q=t.ref(0);function x(){if(D.value=f.value?.clientHeight||0,g.value.length===0||s.value.length===0){z.value=0,b.value=0,V.value=0,Q.value=0;return}const e=ae(B.value);z.value=Math.max(0,e-3);const l=s.value[z.value],n=l?K.get(l.id)||R:0,r=(g.value[z.value]??0)-n;V.value=Math.max(0,r);let i=z.value;const c=B.value+D.value+3*R;for(;i<s.value.length&&(g.value[i]??0)<c;)i++;b.value=Math.min(s.value.length,i+1);const d=(g.value[b.value-1]??0)-V.value;if(d<D.value&&b.value<s.value.length){let u=b.value,k=d;for(;k<D.value&&u<s.value.length;)u++,k=(g.value[u-1]??0)-V.value;b.value=u}Q.value=Math.max(0,ne.value-V.value-((g.value[b.value-1]??0)-V.value))}t.watch([B,()=>a.data,y],()=>{s.value=C(a.data||[]),t.nextTick(M),x()}),t.onMounted(()=>{s.value=C(a.data||[]),t.nextTick(M),x(),a.defaultCheckedKeys&&a.defaultCheckedKeys.length&&le(a.defaultCheckedKeys),f.value&&(F=new ResizeObserver(()=>{D.value=f.value?.clientHeight||0,x()}),F.observe(f.value))});let F=null;t.onUnmounted(()=>{F&&(F.disconnect(),F=null)});const P=t.reactive(new Map);function Te(e,l){l?P.set(e,l):P.delete(e)}function M(){let e=!1;for(const l of s.value.slice(z.value,b.value)){const n=P.get(l.id);if(n){const o=n.offsetHeight;(!K.has(l.id)||K.get(l.id)!==o)&&(K.set(l.id,o),e=!0)}}e&&x()}function Ee(){B.value=f.value?.scrollTop||0,x()}const S=t.ref(!1),X=t.ref(null),H=t.ref(null),T=t.ref(null),Z=t.ref(0),I=t.ref(null),Y=t.ref(0);let N=null;function W(){N!=null&&(cancelAnimationFrame(N),N=null)}function oe(){if(!S.value||Y.value===0){W();return}const e=f.value;if(!e){W();return}const l=e.scrollHeight-e.clientHeight,n=12;e.scrollTop=Math.max(0,Math.min(l,e.scrollTop+Y.value*n)),B.value=e.scrollTop,x(),N=requestAnimationFrame(oe)}function Be(){Y.value!==0&&N==null&&(N=requestAnimationFrame(oe)),Y.value===0&&W()}function q(e){if(e==null)return null;for(const l of s.value)if(l.id===e)return l;return null}function Me(e){const l=f.value.getBoundingClientRect(),n=e-l.top+B.value;return ae(n)}function Ae(e,l){!a.draggable||l.button!==0||!(!a.allowDrag||a.allowDrag(e.node))||(S.value=!0,X.value=e.id,Z.value=l.clientY,l.preventDefault(),window.addEventListener("mousemove",ce),window.addEventListener("mouseup",re))}function ce(e){if(!S.value)return;Z.value=e.clientY;const l=Me(e.clientY),n=s.value[Math.min(Math.max(l,0),s.value.length-1)];if(H.value=n?.id??null,!n){T.value=null;return}const o=g.value[l]??0,r=K.get(n.id)??R,i=o-r,c=f.value.getBoundingClientRect(),d=(e.clientY-c.top+B.value-i)/r;let u="inner";d<.25?u="prev":d>.75&&(u="next");const k=q(X.value),j=a.allowDrop?!!(k&&a.allowDrop(k.node,n.node,u)):!0;T.value=j?u:null,Y.value=e.clientY>c.bottom?1:e.clientY<c.top?-1:0,Be()}function U(e,l,n=[]){for(const o of l){if(w(o)===e)return n;const r=E(o);if(r.length){const i=U(e,r,[...n,o]);if(i)return i}}return null}function ee(e,l){if(e==null)return null;for(const n of l){if(w(n)===e)return n;const o=E(n),r=ee(e,o);if(r)return r}return null}function $(e){const l=[];for(const n of e){l.push(w(n));const o=E(n);o.length&&l.push(...$(o))}return l}function Ke(e){const l=e.parent;if(l)E(l).splice(e.index,1);else{const n=a.data.findIndex(o=>w(o)===e.id);n>=0&&a.data.splice(n,1)}}function ze(e,l,n){if(n==="inner"){Array.isArray(l.node[O.value])||(l.node[O.value]=[]),l.node[O.value].push(e),y.value.add(l.id);return}const o=l.parent;if(o){const r=E(o),i=l.index+(n==="next"?1:0);r.splice(i,0,e)}else{const r=l.index+(n==="next"?1:0);a.data.splice(r,0,e)}}function re(){if(window.removeEventListener("mousemove",ce),window.removeEventListener("mouseup",re),W(),!S.value)return;const e=q(X.value),l=q(H.value),n=T.value;if(S.value=!1,T.value=null,H.value=null,!e||!l||!n||a.allowDrop&&!a.allowDrop(e.node,l.node,n)||e.id===l.id)return;const o=n==="inner"?l.node:l.parent||null;if(o){const h=U(w(o),a.data||[])||[];for(const d of h)if(w(d)===e.id)return}const r=e.node;Ke(e);const i=C(a.data||[]);s.value=i;const c=q(l.id)||l;ze(r,c,n),s.value=C(a.data||[]),t.nextTick(()=>{M(),x()}),L("node-drop",r,c.node,n)}function Ve(e,l){I.value=e.id,L("node-click",e.node,l)}function Ie(e,l){L("node-contextmenu",e.node,l)}t.watchEffect(()=>{t.nextTick(M)}),t.watch(()=>a.currentNodeKey,e=>{I.value=e??null},{immediate:!0}),t.watch(()=>a.defaultExpandedKeys,e=>{y.value=new Set(e||[]),s.value=C(a.data||[]),t.nextTick(()=>{M(),x()})},{immediate:!0}),t.watch(()=>a.defaultExpandAll,e=>{e&&(y.value=new Set($(a.data||[])),s.value=C(a.data||[]),t.nextTick(()=>{M(),x()}))},{immediate:!0}),t.watch(()=>a.data,()=>{a.defaultExpandAll&&(y.value=new Set($(a.data||[])),s.value=C(a.data||[]),t.nextTick(()=>{M(),x()}));const e=new Set($(a.data||[]));v.value=new Set([...v.value].filter(l=>e.has(l))),m.value=new Set([...m.value].filter(l=>e.has(l)))});function Le(e){const l=U(e,a.data||[])||[];for(const n of l)y.value.add(w(n));s.value=C(a.data||[])}function ie(e){e!=null&&(Le(e),t.nextTick(()=>{const l=s.value.findIndex(c=>c.id===e);if(l<0||!f.value)return;const n=K.get(e)||R,o=(g.value[l]??0)-n,r=f.value.clientHeight,i=Math.max(0,o-Math.max(0,(r-n)/2));f.value.scrollTop=i,B.value=i,x(),t.nextTick(()=>{const c=P.get(e);if(!c||!f.value)return;const h=c.offsetLeft,d=c.offsetWidth,u=f.value.clientWidth,k=Math.max(0,h+Math.max(0,d/2)-Math.max(0,u/2));f.value.scrollLeft=k})}))}function Ne(e){I.value=e??null,ie(I.value)}return G({getCurrentKey:()=>I.value,setCurrentKey:Ne,scrollTo:ie,getCheckedKeys:()=>Array.from(v.value),setCheckedKeys:le,setChecked:(e,l)=>J(e,l)}),t.watch(I,e=>{const l=ee(e,a.data||[]);l&&L("current-change",l)}),(e,l)=>(t.openBlock(),t.createElementBlock("div",{ref_key:"containerRef",ref:f,class:t.normalizeClass(["vtree",{"is-dragging":S.value}]),style:t.normalizeStyle({height:typeof p.height=="number"?p.height+"px":p.height||"100%","--vtree-bg":p.backgroundColor,"--vtree-text":p.textColor,"--vtree-hover":p.hoverColor}),onScroll:Ee},[ye.value?(t.openBlock(),t.createElementBlock("div",pe,[t.renderSlot(e.$slots,"empty",{},()=>[t.createElementVNode("div",me,t.toDisplayString(p.emptyText),1)],!0)])):(t.openBlock(),t.createElementBlock(t.Fragment,{key:0},[t.createElementVNode("div",{style:t.normalizeStyle({height:ne.value+"px",position:"relative",minWidth:"100%",width:"max-content"})},[t.createElementVNode("div",{style:t.normalizeStyle({height:V.value+"px"})},null,4),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(s.value.slice(z.value,b.value),n=>(t.openBlock(),t.createElementBlock("div",{key:n.id,class:"vtree-row-wrapper"},[t.createElementVNode("div",{class:t.normalizeClass(["vtree-row",{"is-target-inner":S.value&&H.value===n.id&&T.value==="inner","is-active":I.value===n.id}]),style:t.normalizeStyle({paddingLeft:n.level*16+"px","--active-color":p.highlightColor}),onMousedown:o=>Ae(n,o),onClick:o=>Ve(n,o),onContextmenu:t.withModifiers(o=>Ie(n,o),["prevent"]),ref_for:!0,ref:o=>Te(n.id,o)},[t.createElementVNode("span",{class:t.normalizeClass(["vtree-caret-box",{"is-leaf":n.isLeaf}]),onClick:t.withModifiers(o=>!n.isLeaf&&we(n.id),["stop"])},[n.isLeaf?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass(["vtree-caret",{expanded:te(n.id)}])},null,2))],10,fe),p.showCheckbox?(t.openBlock(),t.createElementBlock("input",{key:0,class:"vtree-checkbox",type:"checkbox",checked:Ce(n.id),indeterminate:be(n.id),disabled:a.disabledChecked?a.disabledChecked(n.node):!1,onClick:t.withModifiers(o=>Se(n,o),["stop"])},null,8,he)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default",{node:n.node,data:n.node,level:n.level,expanded:te(n.id),isLeaf:n.isLeaf},()=>[t.createElementVNode("span",ve,t.toDisplayString(n.node[ke.value]),1)],!0)],46,ue),S.value&&H.value===n.id&&(T.value==="prev"||T.value==="next")?(t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass(["vtree-drop-line",{"is-prev":T.value==="prev","is-next":T.value==="next"}])},null,2)):t.createCommentVNode("",!0)]))),128)),t.createElementVNode("div",{style:t.normalizeStyle({height:Q.value+"px"})},null,4)],4),S.value?(t.openBlock(),t.createElementBlock("div",{key:0,class:"vtree-ghost",style:t.normalizeStyle({top:Z.value+"px"})},null,4)):t.createCommentVNode("",!0)],64))],38))}}),[["__scopeId","data-v-cfceef5a"]]);A.VirtualTree=ge,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "amazing-tree",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": "^20.19.0 || >=22.12.0"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "vite",
|
|
11
|
+
"build": "run-p type-check \"build-only {@}\" --",
|
|
12
|
+
"preview": "vite preview",
|
|
13
|
+
"build-only": "vite build",
|
|
14
|
+
"build:lib": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && set BUILD_LIB=true&& vite build",
|
|
15
|
+
"type-check": "vue-tsc --build",
|
|
16
|
+
"lint": "eslint . --fix --cache",
|
|
17
|
+
"format": "prettier --write src/",
|
|
18
|
+
"replace-uuids": "node scripts/replace-uuids.mjs",
|
|
19
|
+
"add-has-anim": "node scripts/add-has-anim.mjs"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"vue": "^3.5.22",
|
|
23
|
+
"vue-component-type-helpers": "^3.1.4"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@tsconfig/node22": "^22.0.2",
|
|
27
|
+
"@types/node": "^22.18.11",
|
|
28
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
29
|
+
"@vue/eslint-config-prettier": "^10.2.0",
|
|
30
|
+
"@vue/eslint-config-typescript": "^14.6.0",
|
|
31
|
+
"@vue/tsconfig": "^0.8.1",
|
|
32
|
+
"eslint": "^9.37.0",
|
|
33
|
+
"eslint-plugin-vue": "~10.5.0",
|
|
34
|
+
"jiti": "^2.6.1",
|
|
35
|
+
"npm-run-all2": "^8.0.4",
|
|
36
|
+
"prettier": "3.6.2",
|
|
37
|
+
"sass": "^1.94.1",
|
|
38
|
+
"typescript": "~5.9.0",
|
|
39
|
+
"vite": "^7.1.11",
|
|
40
|
+
"vite-plugin-vue-devtools": "^8.0.3",
|
|
41
|
+
"vue-tsc": "^3.1.1"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
],
|
|
46
|
+
"exports": {
|
|
47
|
+
".": {
|
|
48
|
+
"import": "./dist/amazing-tree.es.js",
|
|
49
|
+
"require": "./dist/amazing-tree.cjs.js"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"author": "maxkang"
|
|
53
|
+
}
|