Skip to content

Commit

Permalink
feat(components): Add routing data related to tree components and pag…
Browse files Browse the repository at this point in the history
…e display optimization
  • Loading branch information
small_happy committed Apr 2, 2023
1 parent d203a35 commit a0f55ac
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 10 deletions.
42 changes: 42 additions & 0 deletions src/router/modules/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,48 @@ const component: AuthRoute.Route = {
requiresAuth: true,
icon: 'mdi:table-large'
}
},
{
name: 'component_tree',
path: '/component/tree',
component: 'multi',
children: [
{
name: 'component_tree_tree-basic',
path: '/component/tree/tree-basic',
component: 'self',
meta: {
title: '基础树',
requiresAuth: true,
icon: 'fluent:tree-deciduous-20-regular'
}
},
{
name: 'component_tree_tree-custom',
path: '/component/tree/tree-custom',
component: 'self',
meta: {
title: '自定义树',
requiresAuth: true,
icon: 'fluent:tree-deciduous-20-filled'
}
},
{
name: 'component_tree_tree-functions',
path: '/component/tree/tree-functions',
component: 'self',
meta: {
title: '函数示例',
requiresAuth: true,
icon: 'fluent:tree-evergreen-20-filled'
}
}
],
meta: {
title: '树',
requiresAuth: true,
icon: 'carbon:tree-view-alt'
}
}
],
meta: {
Expand Down
7 changes: 7 additions & 0 deletions src/typings/page-route.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ declare namespace PageRoute {
| 'component_button'
| 'component_card'
| 'component_table'
| 'component_tree'
| 'component_tree_tree-basic'
| 'component_tree_tree-custom'
| 'component_tree_tree-functions'
| 'dashboard'
| 'dashboard_analysis'
| 'dashboard_workbench'
Expand Down Expand Up @@ -89,6 +93,9 @@ declare namespace PageRoute {
| 'component_button'
| 'component_card'
| 'component_table'
| 'component_tree_tree-basic'
| 'component_tree_tree-custom'
| 'component_tree_tree-functions'
| 'dashboard_analysis'
| 'dashboard_workbench'
| 'document_naive'
Expand Down
5 changes: 4 additions & 1 deletion src/views/component/tree/tree-basic/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,11 @@ import { ref, h } from 'vue';
import type { TreeOption, TreeInst } from 'naive-ui';
import { NIcon } from 'naive-ui';
import { repeat } from 'seemly';
import { useIconRender } from '@/composables';
import { useLoading } from '@/hooks';
const { iconRender } = useIconRender();
const cascade = ref<boolean>(true);
const segmented = ref<boolean>(true);
Expand Down Expand Up @@ -310,7 +313,7 @@ const caseEightDefaultExpandedKeys = ref<string[]>(['20']);
const renderSwitcherIconWithExpaned = ({ expanded }: { expanded: boolean }) =>
h(NIcon, null, {
default: () => h(expanded ? <icon-solar-moon-broken /> : <icon-solar-sun-broken />)
default: () => h(expanded ? iconRender({ icon: 'solar:moon-broken' }) : iconRender({ icon: 'solar:sun-broken' }))
});
function createRemoteData() {
Expand Down
2 changes: 1 addition & 1 deletion src/views/component/tree/tree-custom/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function createSuffixData(level = 2, baseKey = ''): TreeOption[] | undefined {
key,
children: createSuffixData(level - 1, key),
suffix: () =>
h(NSpace, { justify: 'space-evenly' }, [
h(NSpace, { justify: 'space-evenly' }, () => [
h(NButton, { text: true, class: 'pt-1.5' }, { default: () => <icon-mdi-plus class="text-18px" /> }),
h(
NButton,
Expand Down
8 changes: 0 additions & 8 deletions src/views/component/tree/tree-functions/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
<n-space :vertical="true">
<n-card title="函数示例">
<n-card>
<template #header>
<n-gradient-text
class="text-20px font-bold"
gradient="linear-gradient(90deg, red 0%, green 50%, blue 100%)"
>
函数合集
</n-gradient-text>
</template>
<template #header-extra>
<n-space justify="space-around">
<n-button dashed type="primary" @click="handleGenerateTreeData">重置数据</n-button>
Expand Down
3 changes: 3 additions & 0 deletions src/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const views: Record<
component_button: () => import('./component/button/index.vue'),
component_card: () => import('./component/card/index.vue'),
component_table: () => import('./component/table/index.vue'),
'component_tree_tree-basic': () => import('./component/tree/tree-basic/index.vue'),
'component_tree_tree-custom': () => import('./component/tree/tree-custom/index.vue'),
'component_tree_tree-functions': () => import('./component/tree/tree-functions/index.vue'),
dashboard_analysis: () => import('./dashboard/analysis/index.vue'),
dashboard_workbench: () => import('./dashboard/workbench/index.vue'),
document_naive: () => import('./document/naive/index.vue'),
Expand Down

0 comments on commit a0f55ac

Please sign in to comment.