mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2026-11-23 03:53:34 +08:00
feat(navigation): group example menus and fix tab scroll arrows
This commit is contained in:
parent
11e4ec61c6
commit
82511cf6f5
@ -38,7 +38,7 @@ Page tabs keep multiple tasks open, and breadcrumbs show where you are. Find men
|
||||
|
||||
Declare a page in `apps/admin/src/router/modules` to generate its navigation and breadcrumbs. Route metadata controls menu labels and icons, roles, visibility, and `keepAlive`. Detail pages can extend the breadcrumb while keeping the current menu and tab. Role checks cover both menu filtering and direct navigation. Connect your backend to validate sessions and authorize API requests.
|
||||
|
||||
[Routing guide](apps/admin/src/router/README.md) · [Nested navigation and caching example](apps/admin/src/router/modules/demo/multi-menu.ts)
|
||||
[Routing guide](apps/admin/src/router/README.md) · [Nested navigation and caching example](apps/admin/src/router/modules/demo/navigation.ts)
|
||||
|
||||
### Reusable components, composables, and SVG icons
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ Ray Template 是一套**开箱即用的中后台前端模板**,适合搭建管
|
||||
|
||||
在 `apps/admin/src/router/modules` 声明页面,模板按路由配置生成菜单和面包屑。路由 `meta` 可以配置菜单文案与图标、角色、显示条件和 `keepAlive`。从列表进入详情时,可以保留当前菜单和标签页,只在面包屑中补充详情层级。角色配置同时用于菜单过滤和直接导航时的守卫。接入业务时,由后端校验会话与接口权限。
|
||||
|
||||
[路由与菜单约定](apps/admin/src/router/README.md) · [多级菜单与缓存示例](apps/admin/src/router/modules/demo/multi-menu.ts)
|
||||
[路由与菜单约定](apps/admin/src/router/README.md) · [多级菜单与缓存示例](apps/admin/src/router/modules/demo/navigation.ts)
|
||||
|
||||
### 组件、Hooks 与图标:从可运行的示例里复用
|
||||
|
||||
|
||||
@ -43,11 +43,34 @@ describe('route configuration', () => {
|
||||
const config = exportRouteConfig(bundled)
|
||||
const restored = toRuntimeRoutes(parseRouteConfig(JSON.stringify(config)))
|
||||
|
||||
expect(config.routes.length).toBeGreaterThan(10)
|
||||
expect(expandRoutes(bundled).length).toBeGreaterThan(10)
|
||||
expect(exportRouteConfig(restored)).toEqual(config)
|
||||
expect(expandRoutes(restored)).toEqual(expandRoutes(bundled))
|
||||
})
|
||||
|
||||
it('preserves demo page URLs when grouping the menus', () => {
|
||||
const routes = getStaticAppRoutes()
|
||||
const leaves = expandRoutes(routes).map(({ path }) => path)
|
||||
|
||||
expect(leaves).toEqual(
|
||||
expect.arrayContaining([
|
||||
'/form',
|
||||
'/svg-icons',
|
||||
'/barcode',
|
||||
'/template-hooks',
|
||||
'/router-demo/router-demo-home',
|
||||
'/multi/multi-menu-two/sub-menu/sub-menu-one',
|
||||
'/rely-about',
|
||||
'/tables/basic',
|
||||
'/tables/controlled',
|
||||
'/tables/hooks-output',
|
||||
]),
|
||||
)
|
||||
expect(
|
||||
routes.find(({ path }) => path === '/tables')?.meta.extra?.label,
|
||||
).toBe('TablePro')
|
||||
})
|
||||
|
||||
it('migrates retired icon paths in both menu and external link metadata', () => {
|
||||
const config = parse([
|
||||
{
|
||||
|
||||
@ -13,7 +13,9 @@ import {
|
||||
getStaticAppRoutes,
|
||||
setAppRouteModules,
|
||||
} from '@/router/app-route-modules'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
import { expandRoutes } from '@/router/utils/expand-routes'
|
||||
import { joinRoutePath } from '@/router/utils/join-route-path'
|
||||
import { useSettingActions, useSettingGetters } from '@/store'
|
||||
import { useMemoryCache } from '@/utils/cache-backend'
|
||||
import { exampleFocusKey } from '@/views/demo/hooks/example-focus'
|
||||
@ -45,10 +47,25 @@ const examplePaths = new Set([
|
||||
'/qrcode',
|
||||
])
|
||||
|
||||
function selectExampleRoutes(
|
||||
routes: AppRouteRecordRaw[],
|
||||
parentPath = '',
|
||||
): AppRouteRecordRaw[] {
|
||||
return routes.flatMap((route) => {
|
||||
const path = joinRoutePath(parentPath, route.path)
|
||||
|
||||
if (examplePaths.has(path)) return [route]
|
||||
|
||||
const children = selectExampleRoutes(route.children ?? [], path)
|
||||
|
||||
return children.length ? [{ ...route, children }] : []
|
||||
})
|
||||
}
|
||||
|
||||
const params = new URLSearchParams(location.search)
|
||||
const withLayout = params.get('layout') === '1'
|
||||
const examples = [
|
||||
...getStaticAppRoutes().filter(({ path }) => examplePaths.has(path)),
|
||||
...selectExampleRoutes(getStaticAppRoutes()),
|
||||
{
|
||||
path: '/docs-core-utils',
|
||||
name: 'DocsCoreUtils',
|
||||
|
||||
@ -316,12 +316,7 @@ export default defineComponent({
|
||||
onClick={() => this.scrollX('left')}
|
||||
>
|
||||
{{
|
||||
icon: () => (
|
||||
<RIcon
|
||||
name="directional/expanded"
|
||||
customClassName="menu-tag__left-arrow"
|
||||
/>
|
||||
),
|
||||
icon: () => <RIcon name="directional/left_arrow" />,
|
||||
}}
|
||||
</NButton>
|
||||
<NScrollbar
|
||||
@ -369,14 +364,7 @@ export default defineComponent({
|
||||
onClick={() => this.scrollX('right')}
|
||||
>
|
||||
{{
|
||||
icon: () => (
|
||||
<RIcon
|
||||
name="directional/expanded"
|
||||
style={{
|
||||
transform: 'rotate(180deg)',
|
||||
}}
|
||||
/>
|
||||
),
|
||||
icon: () => <RIcon name="directional/right_arrow" />,
|
||||
}}
|
||||
</NButton>
|
||||
<NButton
|
||||
|
||||
@ -5,6 +5,11 @@
|
||||
"CalculatePrecision": "Precision",
|
||||
"ContextMenu": "Right Click Menu",
|
||||
"Dashboard": "Home",
|
||||
"DemoComponents": "Component examples",
|
||||
"DemoAssets": "Icons and codes",
|
||||
"DemoInteraction": "Hooks and interactions",
|
||||
"DemoNavigation": "Layout and routing",
|
||||
"DemoUtilities": "Developer tools",
|
||||
"Directive": "Directive",
|
||||
"Doc": "Doc",
|
||||
"DocLocal": "Doc (China)",
|
||||
@ -19,18 +24,21 @@
|
||||
"Form": "Form",
|
||||
"Mock": "Mock",
|
||||
"Modal": "Modal",
|
||||
"MultiMenu": "MultiMenu(catch)",
|
||||
"MultiMenu": "Nested menus and cache",
|
||||
"Office": "Office",
|
||||
"Office_Document": "Document",
|
||||
"Office_Presentation": "Presentation",
|
||||
"Office_Spreadsheet": "Spreadsheet",
|
||||
"QRCode": "QRCode",
|
||||
"Rely": "Rely",
|
||||
"RelyAbout": "Rely About",
|
||||
"RelyAbout": "Dependencies and versions",
|
||||
"RouterDemo": "Same Level Router Demo",
|
||||
"Segment": "Segment",
|
||||
"SvgIcon": "SVG Icon",
|
||||
"Table": "Tables",
|
||||
"Table": "Table examples",
|
||||
"TableData": "Data and queries",
|
||||
"TableTools": "Layout and tools",
|
||||
"TableHooks": "Instance hooks",
|
||||
"TableAutoHeight": "Auto height",
|
||||
"TablePro": "Table Pro",
|
||||
"TemplateHooks": "Template Hooks",
|
||||
@ -42,11 +50,11 @@
|
||||
"TableColumns": "Column preferences",
|
||||
"TablePrinting": "Printing and custom regions",
|
||||
"TableCustom": "Slots and instance methods",
|
||||
"TableHooksQuery": "Hooks · Queries and paging",
|
||||
"TableHooksQuery": "Queries and paging",
|
||||
"TableControlled": "Controlled remote paging",
|
||||
"TableSearch": "Advanced search",
|
||||
"TableHooksSelection": "Hooks · Selection and bulk actions",
|
||||
"TableHooksOutput": "Hooks · Export and print",
|
||||
"TableHooksSelection": "Selection and bulk actions",
|
||||
"TableHooksOutput": "Export and print",
|
||||
"RouteManagement": "Route management",
|
||||
"RouteManagementVisual": "Visual editor",
|
||||
"RouteManagementJson": "JSON configuration"
|
||||
|
||||
@ -5,6 +5,11 @@
|
||||
"CalculatePrecision": "数字精度",
|
||||
"ContextMenu": "右键菜单",
|
||||
"Dashboard": "首页",
|
||||
"DemoComponents": "组件示例",
|
||||
"DemoAssets": "图标与编码",
|
||||
"DemoInteraction": "Hooks 与交互",
|
||||
"DemoNavigation": "布局与路由",
|
||||
"DemoUtilities": "开发工具",
|
||||
"Directive": "指令",
|
||||
"Doc": "文档",
|
||||
"DocLocal": "文档 (加速地址)",
|
||||
@ -19,18 +24,21 @@
|
||||
"Form": "表单",
|
||||
"Mock": "Mock 数据",
|
||||
"Modal": "模态框",
|
||||
"MultiMenu": "多级菜单(缓存)",
|
||||
"MultiMenu": "多级菜单与缓存",
|
||||
"Office": "办公",
|
||||
"Office_Document": "文档",
|
||||
"Office_Presentation": "演示",
|
||||
"Office_Spreadsheet": "表格",
|
||||
"QRCode": "二维码",
|
||||
"Rely": "依赖项",
|
||||
"RelyAbout": "关于",
|
||||
"RelyAbout": "依赖与版本",
|
||||
"RouterDemo": "页面详情模式",
|
||||
"Segment": "分段器",
|
||||
"SvgIcon": "SVG 图标",
|
||||
"Table": "表格",
|
||||
"Table": "表格示例",
|
||||
"TableData": "数据与查询",
|
||||
"TableTools": "布局与工具",
|
||||
"TableHooks": "实例 Hooks",
|
||||
"TableAutoHeight": "自适应高度",
|
||||
"TablePro": "高级表格",
|
||||
"TemplateHooks": "模板 Hooks",
|
||||
@ -42,11 +50,11 @@
|
||||
"TableColumns": "列设置与缓存",
|
||||
"TablePrinting": "打印与自定义区域",
|
||||
"TableCustom": "插槽与实例操作",
|
||||
"TableHooksQuery": "Hooks · 查询与分页",
|
||||
"TableHooksQuery": "查询与分页",
|
||||
"TableControlled": "手动远端分页",
|
||||
"TableSearch": "高级搜索",
|
||||
"TableHooksSelection": "Hooks · 选择与批量操作",
|
||||
"TableHooksOutput": "Hooks · 导出与打印",
|
||||
"TableHooksSelection": "选择与批量操作",
|
||||
"TableHooksOutput": "导出与打印",
|
||||
"RouteManagement": "路由管理",
|
||||
"RouteManagementVisual": "可视化配置",
|
||||
"RouteManagementJson": "JSON 配置"
|
||||
|
||||
37
apps/admin/src/router/modules/demo/assets.ts
Normal file
37
apps/admin/src/router/modules/demo/assets.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
export default {
|
||||
path: '/examples/assets',
|
||||
meta: { i18nKey: t('menu.DemoAssets'), icon: 'navigation/icons', order: 30 },
|
||||
children: [
|
||||
{
|
||||
path: '/svg-icons',
|
||||
component: routeView('demo/svg-icons'),
|
||||
meta: {
|
||||
i18nKey: t('menu.SvgIcon'),
|
||||
icon: 'navigation/icons',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/qrcode',
|
||||
component: routeView('demo/qrcode'),
|
||||
meta: {
|
||||
i18nKey: t('menu.QRCode'),
|
||||
icon: 'navigation/qr_code',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/barcode',
|
||||
component: routeView('demo/barcode-demo'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Barcode'),
|
||||
icon: 'navigation/barcode',
|
||||
extra: {
|
||||
label: 'new',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
} satisfies AppRouteRecordRaw
|
||||
@ -1,18 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const axios: AppRouteRecordRaw = {
|
||||
path: '/axios',
|
||||
name: 'RAxios',
|
||||
component: routeView('demo/axios'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Axios'),
|
||||
icon: 'logo/axios',
|
||||
order: 3,
|
||||
keepAlive: true,
|
||||
},
|
||||
}
|
||||
|
||||
export default axios
|
||||
@ -1,19 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const barcode: AppRouteRecordRaw = {
|
||||
path: 'barcode',
|
||||
component: routeView('demo/barcode-demo'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Barcode'),
|
||||
icon: 'navigation/other',
|
||||
order: 2,
|
||||
extra: {
|
||||
label: 'new',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default barcode
|
||||
@ -1,16 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const cacheDemo: AppRouteRecordRaw = {
|
||||
path: '/cache-demo',
|
||||
component: routeView('demo/cache-demo'),
|
||||
meta: {
|
||||
i18nKey: t('menu.CacheDemo'),
|
||||
icon: 'navigation/other',
|
||||
order: 3,
|
||||
},
|
||||
}
|
||||
|
||||
export default cacheDemo
|
||||
82
apps/admin/src/router/modules/demo/components.ts
Normal file
82
apps/admin/src/router/modules/demo/components.ts
Normal file
@ -0,0 +1,82 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
export default {
|
||||
path: '/examples/components',
|
||||
meta: {
|
||||
i18nKey: t('menu.DemoComponents'),
|
||||
icon: 'navigation/components',
|
||||
order: 20,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/form',
|
||||
component: routeView('demo/form'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Form'),
|
||||
icon: 'navigation/form',
|
||||
extra: {
|
||||
label: 'useForm',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/modal-demo',
|
||||
component: routeView('demo/modal-demo'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Modal'),
|
||||
icon: 'navigation/window',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/segment',
|
||||
component: routeView('demo/segment'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Segment'),
|
||||
icon: 'navigation/components',
|
||||
extra: {
|
||||
label: 'segment',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/draggable-card',
|
||||
component: routeView('demo/draggable-card'),
|
||||
meta: {
|
||||
i18nKey: t('menu.DraggableCard'),
|
||||
icon: 'action/draggable',
|
||||
extra: {
|
||||
label: 'drag',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/echart',
|
||||
component: routeView('demo/echart'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Echart'),
|
||||
icon: 'navigation/echart',
|
||||
extra: {
|
||||
label: 'useChart',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/flow',
|
||||
component: routeView('demo/flow-demo'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Flow'),
|
||||
icon: 'navigation/flow',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/iframe',
|
||||
component: routeView('demo/iframe'),
|
||||
meta: {
|
||||
icon: 'navigation/window',
|
||||
noLocalTitle: 'iframe',
|
||||
},
|
||||
},
|
||||
],
|
||||
} satisfies AppRouteRecordRaw
|
||||
@ -1,15 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const contextMenu: AppRouteRecordRaw = {
|
||||
path: '/context-menu',
|
||||
component: routeView('demo/context-menu'),
|
||||
meta: {
|
||||
i18nKey: t('menu.ContextMenu'),
|
||||
icon: 'navigation/other',
|
||||
order: 2,
|
||||
},
|
||||
}
|
||||
|
||||
export default contextMenu
|
||||
@ -1,19 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const directive: AppRouteRecordRaw = {
|
||||
path: '/directive',
|
||||
component: routeView('demo/directive'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Directive'),
|
||||
icon: 'navigation/other',
|
||||
order: 2,
|
||||
extra: {
|
||||
label: 'ellipsis',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default directive
|
||||
@ -8,7 +8,7 @@ export default {
|
||||
component: routeView('demo/doc'),
|
||||
meta: {
|
||||
i18nKey: t('menu.DocLocalInside'),
|
||||
icon: 'navigation/menu',
|
||||
order: 5,
|
||||
icon: 'navigation/document',
|
||||
order: 70,
|
||||
},
|
||||
} satisfies AppRouteRecordRaw
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const r: AppRouteRecordRaw = {
|
||||
path: '/draggable-card',
|
||||
component: routeView('demo/draggable-card'),
|
||||
meta: {
|
||||
i18nKey: t('menu.DraggableCard'),
|
||||
icon: 'navigation/other',
|
||||
order: 2,
|
||||
extra: {
|
||||
label: 'drag',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default r
|
||||
@ -1,19 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const echart: AppRouteRecordRaw = {
|
||||
path: '/echart',
|
||||
component: routeView('demo/echart'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Echart'),
|
||||
icon: 'navigation/echart',
|
||||
order: 1,
|
||||
extra: {
|
||||
label: 'useChart',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default echart
|
||||
@ -1,16 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const r: AppRouteRecordRaw = {
|
||||
path: '/flow',
|
||||
component: routeView('demo/flow-demo'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Flow'),
|
||||
icon: 'navigation/other',
|
||||
order: 2,
|
||||
},
|
||||
}
|
||||
|
||||
export default r
|
||||
@ -1,19 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const form: AppRouteRecordRaw = {
|
||||
path: '/form',
|
||||
component: routeView('demo/form'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Form'),
|
||||
icon: 'navigation/other',
|
||||
order: 2,
|
||||
extra: {
|
||||
label: 'useForm',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default form
|
||||
@ -1,15 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const iframe: AppRouteRecordRaw = {
|
||||
path: '/iframe',
|
||||
component: routeView('demo/iframe'),
|
||||
meta: {
|
||||
icon: 'navigation/other',
|
||||
order: 2,
|
||||
noLocalTitle: 'iframe',
|
||||
},
|
||||
}
|
||||
|
||||
export default iframe
|
||||
53
apps/admin/src/router/modules/demo/interaction.ts
Normal file
53
apps/admin/src/router/modules/demo/interaction.ts
Normal file
@ -0,0 +1,53 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
export default {
|
||||
path: '/examples/interaction',
|
||||
meta: { i18nKey: t('menu.DemoInteraction'), icon: 'action/mouse', order: 40 },
|
||||
children: [
|
||||
{
|
||||
path: '/template-hooks',
|
||||
name: 'TemplateHooks',
|
||||
component: routeView('demo/template-hooks'),
|
||||
meta: {
|
||||
i18nKey: t('menu.TemplateHooks'),
|
||||
icon: 'navigation/components',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/web-hooks',
|
||||
name: 'WebHooks',
|
||||
component: routeView('demo/hooks/web-hooks'),
|
||||
meta: { i18nKey: t('menu.WebHooks'), icon: 'action/mouse' },
|
||||
},
|
||||
{
|
||||
path: '/directive',
|
||||
component: routeView('demo/directive'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Directive'),
|
||||
icon: 'action/adjustment',
|
||||
extra: {
|
||||
label: 'ellipsis',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/context-menu',
|
||||
component: routeView('demo/context-menu'),
|
||||
meta: {
|
||||
i18nKey: t('menu.ContextMenu'),
|
||||
icon: 'action/more',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/scroll-reveal',
|
||||
component: routeView('demo/scroll-reveal'),
|
||||
meta: {
|
||||
i18nKey: t('menu.scrollReveal'),
|
||||
icon: 'directional/expanded',
|
||||
hidden: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
} satisfies AppRouteRecordRaw
|
||||
@ -1,10 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
export default {
|
||||
path: '/layout-demo',
|
||||
name: 'LayoutDemo',
|
||||
component: routeView('demo/layout-demo'),
|
||||
meta: { i18nKey: t('menu.LayoutDemo'), icon: 'navigation/menu', order: 1 },
|
||||
} satisfies AppRouteRecordRaw
|
||||
@ -1,16 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const mockDemo: AppRouteRecordRaw = {
|
||||
path: '/modal-demo',
|
||||
component: routeView('demo/modal-demo'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Modal'),
|
||||
icon: 'navigation/other',
|
||||
order: 3,
|
||||
},
|
||||
}
|
||||
|
||||
export default mockDemo
|
||||
@ -1,73 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const multiMenu: AppRouteRecordRaw = {
|
||||
path: '/multi',
|
||||
component: LAYOUT,
|
||||
meta: {
|
||||
i18nKey: t('menu.MultiMenu'),
|
||||
icon: 'navigation/other',
|
||||
order: 4,
|
||||
extra: {
|
||||
label: 'cache',
|
||||
},
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'multi-menu-one',
|
||||
name: 'MultiMenuOne',
|
||||
component: routeView('demo/multi/views/multi-menu-one'),
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-1',
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'multi-menu-two',
|
||||
name: 'MultiMenuTwo',
|
||||
component: LAYOUT,
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-2',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'sub-menu-other',
|
||||
name: 'SubMenuOther',
|
||||
component: routeView(
|
||||
'demo/multi/views/multi-menu-two/views/sub-menu-other',
|
||||
),
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-2-1',
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'sub-menu',
|
||||
name: 'SubMenu',
|
||||
component: LAYOUT,
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-2-2',
|
||||
keepAlive: true,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'sub-menu-one',
|
||||
name: 'MultiMenuTwoOne',
|
||||
component: routeView(
|
||||
'demo/multi/views/multi-menu-two/views/sub-menu/views/multi-menu-two-one',
|
||||
),
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-2-2-1',
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
export default multiMenu
|
||||
111
apps/admin/src/router/modules/demo/navigation.ts
Normal file
111
apps/admin/src/router/modules/demo/navigation.ts
Normal file
@ -0,0 +1,111 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
export default {
|
||||
path: '/examples/navigation',
|
||||
meta: {
|
||||
i18nKey: t('menu.DemoNavigation'),
|
||||
icon: 'navigation/layout',
|
||||
order: 50,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/layout-demo',
|
||||
name: 'LayoutDemo',
|
||||
component: routeView('demo/layout-demo'),
|
||||
meta: { i18nKey: t('menu.LayoutDemo'), icon: 'navigation/layout' },
|
||||
},
|
||||
{
|
||||
path: '/router-demo',
|
||||
component: LAYOUT,
|
||||
meta: {
|
||||
i18nKey: t('menu.RouterDemo'),
|
||||
icon: 'navigation/routing',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'router-demo-home',
|
||||
component: routeView('demo/router-demo/router-demo-home'),
|
||||
meta: {
|
||||
noLocalTitle: '人员信息(平级模式)',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'router-demo-detail',
|
||||
component: routeView('demo/router-demo/router-demo-detail'),
|
||||
meta: {
|
||||
noLocalTitle: '信息详情',
|
||||
sameLevel: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/multi',
|
||||
component: LAYOUT,
|
||||
meta: {
|
||||
i18nKey: t('menu.MultiMenu'),
|
||||
icon: 'navigation/menu',
|
||||
extra: {
|
||||
label: 'cache',
|
||||
},
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'multi-menu-one',
|
||||
name: 'MultiMenuOne',
|
||||
component: routeView('demo/multi/views/multi-menu-one'),
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-1',
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'multi-menu-two',
|
||||
name: 'MultiMenuTwo',
|
||||
component: LAYOUT,
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-2',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'sub-menu-other',
|
||||
name: 'SubMenuOther',
|
||||
component: routeView(
|
||||
'demo/multi/views/multi-menu-two/views/sub-menu-other',
|
||||
),
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-2-1',
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'sub-menu',
|
||||
name: 'SubMenu',
|
||||
component: LAYOUT,
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-2-2',
|
||||
keepAlive: true,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'sub-menu-one',
|
||||
name: 'MultiMenuTwoOne',
|
||||
component: routeView(
|
||||
'demo/multi/views/multi-menu-two/views/sub-menu/views/multi-menu-two-one',
|
||||
),
|
||||
meta: {
|
||||
noLocalTitle: '多级菜单-2-2-1',
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
} satisfies AppRouteRecordRaw
|
||||
@ -1,16 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const precision: AppRouteRecordRaw = {
|
||||
path: '/precision',
|
||||
component: routeView('demo/precision'),
|
||||
meta: {
|
||||
i18nKey: t('menu.CalculatePrecision'),
|
||||
icon: 'navigation/other',
|
||||
order: 2,
|
||||
},
|
||||
}
|
||||
|
||||
export default precision
|
||||
@ -1,16 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const qrcode: AppRouteRecordRaw = {
|
||||
path: '/qrcode',
|
||||
component: routeView('demo/qrcode'),
|
||||
meta: {
|
||||
i18nKey: t('menu.QRCode'),
|
||||
icon: 'navigation/other',
|
||||
order: 2,
|
||||
},
|
||||
}
|
||||
|
||||
export default qrcode
|
||||
@ -1,16 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const rely: AppRouteRecordRaw = {
|
||||
path: 'rely-about',
|
||||
component: routeView('demo/rely/views/rely-about'),
|
||||
meta: {
|
||||
i18nKey: t('menu.RelyAbout'),
|
||||
icon: 'navigation/rely',
|
||||
order: 999,
|
||||
},
|
||||
}
|
||||
|
||||
export default rely
|
||||
@ -1,33 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const routerDemo: AppRouteRecordRaw = {
|
||||
path: '/router-demo',
|
||||
component: LAYOUT,
|
||||
meta: {
|
||||
i18nKey: t('menu.RouterDemo'),
|
||||
icon: 'navigation/other',
|
||||
order: 3,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'router-demo-home',
|
||||
component: routeView('demo/router-demo/router-demo-home'),
|
||||
meta: {
|
||||
noLocalTitle: '人员信息(平级模式)',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'router-demo-detail',
|
||||
component: routeView('demo/router-demo/router-demo-detail'),
|
||||
meta: {
|
||||
noLocalTitle: '信息详情',
|
||||
sameLevel: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
export default routerDemo
|
||||
@ -1,16 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const scrollReveal: AppRouteRecordRaw = {
|
||||
path: '/scroll-reveal',
|
||||
component: routeView('demo/scroll-reveal'),
|
||||
meta: {
|
||||
i18nKey: t('menu.scrollReveal'),
|
||||
icon: 'navigation/other',
|
||||
hidden: true,
|
||||
},
|
||||
}
|
||||
|
||||
export default scrollReveal
|
||||
@ -1,19 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const segment: AppRouteRecordRaw = {
|
||||
path: '/segment',
|
||||
component: routeView('demo/segment'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Segment'),
|
||||
icon: 'navigation/other',
|
||||
order: 3,
|
||||
extra: {
|
||||
label: 'segment',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
export default segment
|
||||
@ -1,16 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const previewSVGIcons: AppRouteRecordRaw = {
|
||||
path: '/svg-icons',
|
||||
component: routeView('demo/svg-icons'),
|
||||
meta: {
|
||||
i18nKey: t('menu.SvgIcon'),
|
||||
icon: 'navigation/other',
|
||||
order: 3,
|
||||
},
|
||||
}
|
||||
|
||||
export default previewSVGIcons
|
||||
@ -7,74 +7,93 @@ const tables: AppRouteRecordRaw = {
|
||||
meta: {
|
||||
i18nKey: t('menu.Table'),
|
||||
icon: 'navigation/table',
|
||||
order: 2,
|
||||
order: 10,
|
||||
extra: { label: 'TablePro' },
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'basic',
|
||||
name: 'TableDemoBasic',
|
||||
component: routeView('demo/tables/basic'),
|
||||
meta: { i18nKey: t('menu.TableBasic') },
|
||||
path: 'data',
|
||||
meta: { i18nKey: t('menu.TableData') },
|
||||
children: [
|
||||
{
|
||||
path: '/tables/basic',
|
||||
name: 'TableDemoBasic',
|
||||
component: routeView('demo/tables/basic'),
|
||||
meta: { i18nKey: t('menu.TableBasic') },
|
||||
},
|
||||
{
|
||||
path: '/tables/remote',
|
||||
name: 'TableDemoRemote',
|
||||
component: routeView('demo/tables/remote'),
|
||||
meta: { i18nKey: t('menu.TableRemote') },
|
||||
},
|
||||
{
|
||||
path: '/tables/controlled',
|
||||
name: 'TableDemoControlled',
|
||||
component: routeView('demo/tables/controlled'),
|
||||
meta: { i18nKey: t('menu.TableControlled') },
|
||||
},
|
||||
{
|
||||
path: '/tables/search',
|
||||
name: 'TableDemoSearch',
|
||||
component: routeView('demo/tables/search'),
|
||||
meta: { i18nKey: t('menu.TableSearch') },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'remote',
|
||||
name: 'TableDemoRemote',
|
||||
component: routeView('demo/tables/remote'),
|
||||
meta: { i18nKey: t('menu.TableRemote') },
|
||||
path: 'tools',
|
||||
meta: { i18nKey: t('menu.TableTools') },
|
||||
children: [
|
||||
{
|
||||
path: '/tables/auto-height',
|
||||
name: 'TableDemoAutoHeight',
|
||||
component: routeView('demo/tables/auto-height'),
|
||||
meta: { i18nKey: t('menu.TableAutoHeight') },
|
||||
},
|
||||
{
|
||||
path: '/tables/columns',
|
||||
name: 'TableDemoColumns',
|
||||
component: routeView('demo/tables/columns'),
|
||||
meta: { i18nKey: t('menu.TableColumns') },
|
||||
},
|
||||
{
|
||||
path: '/tables/custom',
|
||||
name: 'TableDemoCustom',
|
||||
component: routeView('demo/tables/custom'),
|
||||
meta: { i18nKey: t('menu.TableCustom') },
|
||||
},
|
||||
{
|
||||
path: '/tables/printing',
|
||||
name: 'TableDemoPrinting',
|
||||
component: routeView('demo/tables/printing'),
|
||||
meta: { i18nKey: t('menu.TablePrinting') },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'controlled',
|
||||
name: 'TableDemoControlled',
|
||||
component: routeView('demo/tables/controlled'),
|
||||
meta: { i18nKey: t('menu.TableControlled') },
|
||||
},
|
||||
{
|
||||
path: 'search',
|
||||
name: 'TableDemoSearch',
|
||||
component: routeView('demo/tables/search'),
|
||||
meta: { i18nKey: t('menu.TableSearch') },
|
||||
},
|
||||
{
|
||||
path: 'auto-height',
|
||||
name: 'TableDemoAutoHeight',
|
||||
component: routeView('demo/tables/auto-height'),
|
||||
meta: { i18nKey: t('menu.TableAutoHeight') },
|
||||
},
|
||||
{
|
||||
path: 'columns',
|
||||
name: 'TableDemoColumns',
|
||||
component: routeView('demo/tables/columns'),
|
||||
meta: { i18nKey: t('menu.TableColumns') },
|
||||
},
|
||||
{
|
||||
path: 'printing',
|
||||
name: 'TableDemoPrinting',
|
||||
component: routeView('demo/tables/printing'),
|
||||
meta: { i18nKey: t('menu.TablePrinting') },
|
||||
},
|
||||
{
|
||||
path: 'custom',
|
||||
name: 'TableDemoCustom',
|
||||
component: routeView('demo/tables/custom'),
|
||||
meta: { i18nKey: t('menu.TableCustom') },
|
||||
},
|
||||
{
|
||||
path: 'hooks-query',
|
||||
name: 'TableDemoHooksQuery',
|
||||
component: routeView('demo/tables/hooks-query'),
|
||||
meta: { i18nKey: t('menu.TableHooksQuery') },
|
||||
},
|
||||
{
|
||||
path: 'hooks-selection',
|
||||
name: 'TableDemoHooksSelection',
|
||||
component: routeView('demo/tables/hooks-selection'),
|
||||
meta: { i18nKey: t('menu.TableHooksSelection') },
|
||||
},
|
||||
{
|
||||
path: 'hooks-output',
|
||||
name: 'TableDemoHooksOutput',
|
||||
component: routeView('demo/tables/hooks-output'),
|
||||
meta: { i18nKey: t('menu.TableHooksOutput') },
|
||||
path: 'hooks',
|
||||
meta: { i18nKey: t('menu.TableHooks') },
|
||||
children: [
|
||||
{
|
||||
path: '/tables/hooks-query',
|
||||
name: 'TableDemoHooksQuery',
|
||||
component: routeView('demo/tables/hooks-query'),
|
||||
meta: { i18nKey: t('menu.TableHooksQuery') },
|
||||
},
|
||||
{
|
||||
path: '/tables/hooks-selection',
|
||||
name: 'TableDemoHooksSelection',
|
||||
component: routeView('demo/tables/hooks-selection'),
|
||||
meta: { i18nKey: t('menu.TableHooksSelection') },
|
||||
},
|
||||
{
|
||||
path: '/tables/hooks-output',
|
||||
name: 'TableDemoHooksOutput',
|
||||
component: routeView('demo/tables/hooks-output'),
|
||||
meta: { i18nKey: t('menu.TableHooksOutput') },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import { LAYOUT } from '@/router/constant'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
const axios: AppRouteRecordRaw = {
|
||||
path: '/template-hooks',
|
||||
name: 'TemplateHooks',
|
||||
component: routeView('demo/template-hooks'),
|
||||
meta: {
|
||||
i18nKey: t('menu.TemplateHooks'),
|
||||
icon: 'navigation/other',
|
||||
order: 1,
|
||||
},
|
||||
}
|
||||
|
||||
export default axios
|
||||
48
apps/admin/src/router/modules/demo/utilities.ts
Normal file
48
apps/admin/src/router/modules/demo/utilities.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
export default {
|
||||
path: '/examples/utilities',
|
||||
meta: {
|
||||
i18nKey: t('menu.DemoUtilities'),
|
||||
icon: 'navigation/database',
|
||||
order: 60,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/axios',
|
||||
name: 'RAxios',
|
||||
component: routeView('demo/axios'),
|
||||
meta: {
|
||||
i18nKey: t('menu.Axios'),
|
||||
icon: 'logo/axios',
|
||||
keepAlive: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/cache-demo',
|
||||
component: routeView('demo/cache-demo'),
|
||||
meta: {
|
||||
i18nKey: t('menu.CacheDemo'),
|
||||
icon: 'navigation/database',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/precision',
|
||||
component: routeView('demo/precision'),
|
||||
meta: {
|
||||
i18nKey: t('menu.CalculatePrecision'),
|
||||
icon: 'navigation/other',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/rely-about',
|
||||
component: routeView('demo/rely/views/rely-about'),
|
||||
meta: {
|
||||
i18nKey: t('menu.RelyAbout'),
|
||||
icon: 'navigation/rely',
|
||||
},
|
||||
},
|
||||
],
|
||||
} satisfies AppRouteRecordRaw
|
||||
@ -1,10 +0,0 @@
|
||||
import { t } from '@/hooks/web/useI18n'
|
||||
import { routeView } from '@/router/config/views'
|
||||
import type { AppRouteRecordRaw } from '@/router/types'
|
||||
|
||||
export default {
|
||||
path: '/web-hooks',
|
||||
name: 'WebHooks',
|
||||
component: routeView('demo/hooks/web-hooks'),
|
||||
meta: { i18nKey: t('menu.WebHooks'), icon: 'action/mouse', order: 1 },
|
||||
} satisfies AppRouteRecordRaw
|
||||
@ -30,7 +30,7 @@ import RouteConfigDemo from '../examples/RouteConfigDemo.vue'
|
||||
| `ignoreAutoResetScroll` | 允许页面保留内容区滚动位置,详见滚动工具实现。 |
|
||||
| `extra` | 菜单标记的文本、图标、类型和显隐,见 [useBadge](../reference/hooks/navigation#usebadge)。 |
|
||||
|
||||
嵌套子路由使用相对路径;如果父路由需要承载子内容,参考 [多级菜单示例](https://github.com/XiaoDaiGua-Ray/ray-template/blob/main/apps/admin/src/router/modules/demo/multi-menu.ts) 与 `@/router/constant` 中的 `LAYOUT`。
|
||||
嵌套子路由使用相对路径时会继承父路径。内置示例按用途分组,并以绝对路径保留原有页面地址。查看 [布局与路由示例](https://github.com/XiaoDaiGua-Ray/ray-template/blob/main/apps/admin/src/router/modules/demo/navigation.ts) 里的分组及多级菜单。
|
||||
|
||||
## 登录和角色
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user