Skip to content

Commit

Permalink
feat(tree-menu): [tree-menu] Add static data and unused topic variabl…
Browse files Browse the repository at this point in the history
…es for rectification (#2803)

* feat(tree-menu): [tree-menu] Add static data and unused topic variables for rectification

* feat(tree-menu): [tree-menu] Add static data and unused topic variables for rectification
  • Loading branch information
wuyiping0628 authored Jan 17, 2025
1 parent 312dbcf commit d59b0ea
Show file tree
Hide file tree
Showing 10 changed files with 399 additions and 60 deletions.
2 changes: 1 addition & 1 deletion examples/sites/demos/apis/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
type: 'Array',
defaultValue: '',
desc: {
'zh-CN': '数据源',
'zh-CN': '服务端数据',
'en-US': ''
},
mode: ['mobile-first'],
Expand Down
169 changes: 168 additions & 1 deletion examples/sites/demos/pc/app/tree-menu/basic-usage-composition-api.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,174 @@
<template>
<tiny-tree-menu placeholder="输入关键字搜索"></tiny-tree-menu>
<tiny-tree-menu placeholder="输入关键字搜索" :data="treeData"></tiny-tree-menu>
</template>

<script setup>
import { TinyTreeMenu } from '@opentiny/vue'
import { ref } from 'vue'
const treeData = ref([
{
id: 100,
label: '组件总览'
},
{
id: 200,
label: '使用指南',
children: [
{
id: 201,
label: '更新日志'
},
{ id: 202, label: '环境准备' },
{ id: 203, label: '安装' },
{
id: 204,
label: '引入组件',
children: [
{ id: 20401, label: '按需引入' },
{ id: 20402, label: '完整引入' }
]
},
{ id: 205, label: '开发示例' },
{ id: 206, label: '国际化' },
{ id: 207, label: '主题配置' },
{ id: 208, label: '表单校验配置' },
{ id: 209, label: '常见问题' }
]
},
{
id: 300,
label: '框架风格',
children: [
{
id: 301,
label: 'Color 色彩'
},
{ id: 302, label: 'Container 版型' },
{ id: 303, label: 'Font 字体' },
{ id: 304, label: 'Icon 图标' },
{ id: 305, label: 'Layout 布局' }
]
},
{
id: 400,
label: '导航组件',
children: [
{
id: 401,
label: 'Anchor 锚点'
},
{ id: 402, label: 'Guide 引导' },
{ id: 403, label: 'Breadcrumb 面包屑' }
]
},
{
id: 500,
label: '容器组件',
children: [
{
id: 501,
label: 'Carousel 走马灯'
},
{ id: 502, label: 'Collapse 折叠面板' },
{ id: 503, label: 'DialogBox 对话框' }
]
},
{
id: 600,
label: '表单组件',
children: [
{
id: 60101,
label: 'Button 按钮',
url: 'button'
},
{
id: 60102,
label: 'DatePicker 日期选择器',
url: 'date-picker'
},
{
id: 60103,
label: 'Select 选择器',
url: 'select'
},
{
id: 60104,
label: 'DropTimes 下拉时间',
url: 'drop-times'
},
{
id: 60105,
label: 'Input 输入框',
url: 'input'
}
]
},
{
id: 700,
label: '业务组件',
children: [
{
id: 701,
label: 'Amount 金额'
},
{ id: 702, label: 'Area 片区' },
{ id: 703, label: 'Company 公司' }
]
},
{
id: 800,
label: '其他组件',
children: [
{
id: 801,
label: '废弃组件',
children: [
{
id: 80101,
label: 'CreditCardForm 信用卡表单',
url: 'credit-card-form'
},
{
id: 80102,
label: 'DetailPage 表头详情栏',
url: 'detail-page'
}
]
},
{
id: 802,
label: '新增组件',
children: [
{
id: 80201,
label: 'QrCode 二维码',
url: 'qr-code'
},
{
id: 80202,
label: 'Watermark 水印',
url: 'watermark'
},
{
id: 80203,
label: 'MindMap 脑图',
url: 'mind-map'
},
{
id: 80204,
label: 'Skeleton 骨架屏',
url: 'skeleton'
}
]
},
{
id: 803,
label: 'BulletinBoard 公告牌'
},
{ id: 804, label: 'Calendar 日历' }
]
}
])
</script>
19 changes: 17 additions & 2 deletions examples/sites/demos/pc/app/tree-menu/basic-usage.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import { test, expect } from '@playwright/test'

test('基本使用,无数据场景', async ({ page }) => {
test('静态数据', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('tree-menu#basic-usage')

const wrap = page.locator('#basic-usage')
const treeMenu = wrap.locator('.tiny-tree-menu')
const treeNode = treeMenu.locator('.tiny-tree-node__wrapper > .tiny-tree-node')
const treeNodeContent = treeNode.locator('> .tiny-tree-node__content')

await expect(treeMenu.locator('.tiny-input__inner')).toBeVisible()
await expect(treeNode.filter({ hasText: /^$/ })).toBeHidden()
await treeNodeContent.filter({ hasText: /^使$/ }).click()
await expect(treeNode.filter({ hasText: /^$/ })).toBeVisible()
await treeNode.filter({ hasText: /^$/ }).click()
await expect(treeNode.filter({ hasText: /^$/ })).toHaveClass(/is-current/)
await treeNodeContent.filter({ hasText: /^使$/ }).click()
await expect(treeNode.filter({ hasText: /^$/ })).toBeHidden()

// 过滤功能
await treeMenu.locator('.tiny-input__inner').fill('新增组件')
await expect(page.getByTitle('新增组件')).toBeVisible()
await expect(treeNodeContent.filter({ hasText: /^使$/ })).toBeHidden()
await treeMenu.locator('.tiny-input__inner').clear()
await expect(treeNodeContent.filter({ hasText: /^使$/ })).toBeVisible()
})
171 changes: 170 additions & 1 deletion examples/sites/demos/pc/app/tree-menu/basic-usage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<tiny-tree-menu placeholder="输入关键字搜索"></tiny-tree-menu>
<tiny-tree-menu placeholder="输入关键字搜索" :data="treeData"></tiny-tree-menu>
</template>

<script>
Expand All @@ -8,6 +8,175 @@ import { TinyTreeMenu } from '@opentiny/vue'
export default {
components: {
TinyTreeMenu
},
data() {
return {
treeData: [
{
id: 100,
label: '组件总览'
},
{
id: 200,
label: '使用指南',
children: [
{
id: 201,
label: '更新日志'
},
{ id: 202, label: '环境准备' },
{ id: 203, label: '安装' },
{
id: 204,
label: '引入组件',
children: [
{ id: 20401, label: '按需引入' },
{ id: 20402, label: '完整引入' }
]
},
{ id: 205, label: '开发示例' },
{ id: 206, label: '国际化' },
{ id: 207, label: '主题配置' },
{ id: 208, label: '表单校验配置' },
{ id: 209, label: '常见问题' }
]
},
{
id: 300,
label: '框架风格',
children: [
{
id: 301,
label: 'Color 色彩'
},
{ id: 302, label: 'Container 版型' },
{ id: 303, label: 'Font 字体' },
{ id: 304, label: 'Icon 图标' },
{ id: 305, label: 'Layout 布局' }
]
},
{
id: 400,
label: '导航组件',
children: [
{
id: 401,
label: 'Anchor 锚点'
},
{ id: 402, label: 'Guide 引导' },
{ id: 403, label: 'Breadcrumb 面包屑' }
]
},
{
id: 500,
label: '容器组件',
children: [
{
id: 501,
label: 'Carousel 走马灯'
},
{ id: 502, label: 'Collapse 折叠面板' },
{ id: 503, label: 'DialogBox 对话框' }
]
},
{
id: 600,
label: '表单组件',
children: [
{
id: 60101,
label: 'Button 按钮',
url: 'button'
},
{
id: 60102,
label: 'DatePicker 日期选择器',
url: 'date-picker'
},
{
id: 60103,
label: 'Select 选择器',
url: 'select'
},
{
id: 60104,
label: 'DropTimes 下拉时间',
url: 'drop-times'
},
{
id: 60105,
label: 'Input 输入框',
url: 'input'
}
]
},
{
id: 700,
label: '业务组件',
children: [
{
id: 701,
label: 'Amount 金额'
},
{ id: 702, label: 'Area 片区' },
{ id: 703, label: 'Company 公司' }
]
},
{
id: 800,
label: '其他组件',
children: [
{
id: 801,
label: '废弃组件',
children: [
{
id: 80101,
label: 'CreditCardForm 信用卡表单',
url: 'credit-card-form'
},
{
id: 80102,
label: 'DetailPage 表头详情栏',
url: 'detail-page'
}
]
},
{
id: 802,
label: '新增组件',
children: [
{
id: 80201,
label: 'QrCode 二维码',
url: 'qr-code'
},
{
id: 80202,
label: 'Watermark 水印',
url: 'watermark'
},
{
id: 80203,
label: 'MindMap 脑图',
url: 'mind-map'
},
{
id: 80204,
label: 'Skeleton 骨架屏',
url: 'skeleton'
}
]
},
{
id: 803,
label: 'BulletinBoard 公告牌'
},
{ id: 804, label: 'Calendar 日历' }
]
}
]
}
}
}
</script>
Loading

0 comments on commit d59b0ea

Please sign in to comment.