-
Notifications
You must be signed in to change notification settings - Fork 333
feat(select-wrapper,base-select,tree-select,grid-select):tree-select support lazy loading #3915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <template> | ||
| <tiny-tree-select v-model="value" :tree-op="treeOp" lazy :load="load" :after-load="afterLoad"></tiny-tree-select> | ||
| </template> | ||
|
|
||
| <script> | ||
| import { TinyTreeSelect } from '@opentiny/vue' | ||
|
|
||
| export default { | ||
| components: { | ||
| TinyTreeSelect | ||
| }, | ||
| data() { | ||
| return { | ||
| value: '', | ||
| treeOp: {} | ||
| } | ||
| }, | ||
| methods: { | ||
| // node 为点击的节点,resolve 为回调函数,用于异步返回下层节点的数据 | ||
| load(node, resolve) { | ||
| console.log('即将加载节点下级数据:', node) | ||
|
|
||
| // 通过 level =0 来识别第一次加载 | ||
| if (node.level === 0) { | ||
| resolve([ | ||
| { value: '1', label: '一级 1' }, | ||
| { value: '2', label: '一级 2' }, | ||
| { value: '3', label: '一级 3' } | ||
| ]) | ||
| } | ||
| // 通过 data 有值,识别是用户点击后的加载 | ||
| else if (node.data) { | ||
| const parentId = node.data.value | ||
| const parentLabel = node.data.label | ||
|
|
||
| const children = Array.from({ length: 5 }, (v, k) => k + 1).map((num) => ({ | ||
| value: `${parentId}-${num}`, | ||
| label: `${parentLabel}-${num}`, | ||
| disabled: Math.random() - 0.5 > 0, // 随机禁用节点 | ||
| isLeaf: Math.random() - 0.5 > 0 // 随机设置叶子节点 | ||
| })) | ||
|
|
||
| // 模拟异步返回 | ||
| setTimeout(() => resolve(children), Math.random() * 2 * 1000) | ||
| } | ||
| }, | ||
| afterLoad(data) { | ||
| console.log('afterLoad 属性触发:', data) | ||
| } | ||
| } | ||
| } | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| [data-tag='tiny-base-select'], | ||
| [data-tag='tiny-tree-select'] { | ||
| width: 280px; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
| </template> | ||
|
|
||
| <script> | ||
| import { TinySelect, TinyOption } from '@opentiny/vue' | ||
| import { TinySelectWrapper as TinySelect, TinyOption } from '@opentiny/vue' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for TinySelectWrapper and TinySelect in the repository
# First, find the main export files for these components
echo "=== Searching for TinySelectWrapper definition ==="
fd -t f "select-wrapper" -i | head -20
echo -e "\n=== Searching for TinySelect definition ==="
fd -t f "select" -i | grep -v node_modules | grep -v dist | head -20
echo -e "\n=== Looking for export statements with TinySelectWrapper ==="
rg -n "export.*TinySelectWrapper" --type=ts --type=vue
echo -e "\n=== Looking for export statements with TinySelect ==="
rg -n "export.*TinySelect" --type=ts --type=vue | grep -v TinySelectWrapper | head -10Repository: opentiny/tiny-vue Length of output: 1958 🏁 Script executed: #!/bin/bash
# Let's find the actual component source code
echo "=== Finding package structure ==="
ls -la packages/ | head -20
echo -e "\n=== Searching for select-wrapper component source ==="
find . -path ./node_modules -prune -o -path ./dist -prune -o -type f -name "*select-wrapper*" -print | head -20
echo -e "\n=== Searching for select component source ==="
find . -path ./node_modules -prune -o -path ./dist -prune -o -type f -name "*select.vue" -o -name "*select.ts" -print | grep -E "packages|src" | head -20
echo -e "\n=== Looking in vue package ==="
ls -la packages/vue/src/components/ | grep -i selectRepository: opentiny/tiny-vue Length of output: 2090 🏁 Script executed: #!/bin/bash
# Let's explore the vue package structure
echo "=== Structure of packages/vue ==="
ls -la packages/vue/src/
echo -e "\n=== Looking for select components ==="
ls -la packages/vue/src/
echo -e "\n=== Find all select-related files ==="
find packages/vue -name "*select*" -type f 2>/dev/null | grep -v node_modules | head -20
echo -e "\n=== Find select.ts or select.vue in packages ==="
find packages -name "select.ts" -o -name "select.vue" 2>/dev/null | grep -v node_modules | head -20Repository: opentiny/tiny-vue Length of output: 25878 🏁 Script executed: #!/bin/bash
# Let's look at what files are in select and select-wrapper directories
echo "=== Files in select directory ==="
ls -la packages/vue/src/select/
echo -e "\n=== Files in select-wrapper directory ==="
ls -la packages/vue/src/select-wrapper/
echo -e "\n=== Content of select-wrapper index ==="
cat packages/vue/src/select-wrapper/index.ts 2>/dev/null || echo "Not found"
echo -e "\n=== Content of select index ==="
cat packages/vue/src/select/index.ts 2>/dev/null || echo "Not found"Repository: opentiny/tiny-vue Length of output: 2814 🏁 Script executed: #!/bin/bash
# Let's check the src directories
echo "=== Files in select/src ==="
ls -la packages/vue/src/select/src/
echo -e "\n=== Files in select-wrapper/src ==="
ls -la packages/vue/src/select-wrapper/src/
echo -e "\n=== Content of select-wrapper/src/index.vue ==="
head -100 packages/vue/src/select-wrapper/src/index.vue 2>/dev/null || echo "Not found"
echo -e "\n=== Content of select/src/index.vue ==="
head -100 packages/vue/src/select/src/index.vue 2>/dev/null || echo "Not found"Repository: opentiny/tiny-vue Length of output: 941 🏁 Script executed: #!/bin/bash
# Let's check the index.ts files which contain the actual component logic
echo "=== Content of select-wrapper/src/index.ts ==="
cat packages/vue/src/select-wrapper/src/index.ts
echo -e "\n=== Content of select/src/index.ts (first 150 lines) ==="
head -150 packages/vue/src/select/src/index.tsRepository: opentiny/tiny-vue Length of output: 10964 🏁 Script executed: #!/bin/bash
# Let's get the complete select/src/index.ts to compare props
echo "=== Full content of select/src/index.ts ==="
cat packages/vue/src/select/src/index.tsRepository: opentiny/tiny-vue Length of output: 7658 🏁 Script executed: #!/bin/bash
# Let's compare the props more carefully - let me extract and compare them
echo "=== Analyzing prop differences ==="
python3 << 'EOF'
import re
# Read both files
with open('packages/vue/src/select-wrapper/src/index.ts', 'r') as f:
wrapper_content = f.read()
with open('packages/vue/src/select/src/index.ts', 'r') as f:
select_content = f.read()
# Extract props section
wrapper_props = re.search(r'props:\s*\{(.*?)\n \},', wrapper_content, re.DOTALL)
select_props = re.search(r'props:\s*\{(.*?)\n \},', select_content, re.DOTALL)
if wrapper_props and select_props:
wrapper_text = wrapper_props.group(1)
select_text = select_props.group(1)
# Find differences by comparing line by line
wrapper_lines = set(wrapper_text.strip().split('\n'))
select_lines = set(select_text.strip().split('\n'))
only_in_wrapper = wrapper_lines - select_lines
only_in_select = select_lines - wrapper_lines
if only_in_wrapper or only_in_select:
print("Props ONLY in SelectWrapper:")
for line in sorted(only_in_wrapper):
if line.strip():
print(f" {line.strip()}")
print("\nProps ONLY in Select:")
for line in sorted(only_in_select):
if line.strip():
print(f" {line.strip()}")
else:
print("All props are identical between SelectWrapper and Select")
else:
print("Could not parse props")
EOFRepository: opentiny/tiny-vue Length of output: 147 🏁 Script executed: #!/bin/bash
# Let's do a simple diff instead
echo "=== Diff between select-wrapper and select props ==="
diff -u <(sed -n '/props: {/,/},/p' packages/vue/src/select/src/index.ts | grep -E "^\s+(.*?):" | head -50) <(sed -n '/props: {/,/},/p' packages/vue/src/select-wrapper/src/index.ts | grep -E "^\s+(.*?):" | head -50)
echo -e "\n=== Check for InputBoxType vs inputBoxType ==="
grep -n "inputBoxType\|InputBoxType" packages/vue/src/select/src/index.ts
grep -n "inputBoxType\|InputBoxType" packages/vue/src/select-wrapper/src/index.tsRepository: opentiny/tiny-vue Length of output: 314 🏁 Script executed: #!/bin/bash
# Let's check the exact lines around the InputBoxType/inputBoxType difference
echo "=== Select InputBoxType (lines 325-335) ==="
sed -n '325,335p' packages/vue/src/select/src/index.ts
echo -e "\n=== SelectWrapper inputBoxType (lines 325-335) ==="
sed -n '325,335p' packages/vue/src/select-wrapper/src/index.ts
echo -e "\n=== Component names ==="
echo "Select name:"
grep "name: \$prefix" packages/vue/src/select/src/index.ts
echo "SelectWrapper name:"
grep "name: \$prefix" packages/vue/src/select-wrapper/src/index.tsRepository: opentiny/tiny-vue Length of output: 782 API Incompatibility: TinySelectWrapper does not fully implement TinySelect interface. The import alias does not guarantee API compatibility. Verified differences:
These breaking changes risk silent bugs where templates work but props are ignored. Either ensure TinySelectWrapper props match TinySelect exactly, or document that this is not a drop-in replacement. |
||
| import { iconFile } from '@opentiny/vue-icon' | ||
| export default { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing en-US description.
The new lazy demo entry is missing the
en-USdescription (Line 80), while the zh-CN description is complete. The PC version of this file (examples/sites/demos/pc/app/tree-select/webdoc/tree-select.js) includes both translations. Add the en-US description for i18n completeness.🔎 Apply this diff to add the missing en-US description:
desc: { 'zh-CN': - '通过 <code>lazy</code> 属性,启用懒加载模式。<br>通过 <code>load</code> 函数属性,触发加载,初始会执行一次。<br>通过 <code>after-load</code> 函数属性,监听下级节点加载完毕的事件。' + '通过 <code>lazy</code> 属性,启用懒加载模式。<br>通过 <code>load</code> 函数属性,触发加载,初始会执行一次。<br>通过 <code>after-load</code> 函数属性,监听下级节点加载完毕的事件。', + 'en-US': + 'Enable lazy loading mode with the <code>lazy</code> property. <br>load is triggered by the <code>load</code> function property, which is initially executed once. <br>afterLoad </code> function properties are used to listen for events when a subordinate node has finished loading.' },🤖 Prompt for AI Agents