perf: 更完善的全局类型提示

This commit is contained in:
RealityBoy 2022-11-25 12:49:38 +08:00 committed by GitHub
parent ecba3c2e7f
commit 301356ebd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
44 changed files with 725 additions and 364 deletions

View File

@ -20,7 +20,7 @@
- [点我查看国内文档站](https://yiming_chang.gitee.io/pure-admin-doc) - [点我查看国内文档站](https://yiming_chang.gitee.io/pure-admin-doc)
- [点我查看国外文档站](https://xiaoxian521.github.io/pure-admin-doc) - [点我查看国外文档站](https://xiaoxian521.github.io/pure-admin-doc)
## 精简版(提供 `非国际化``国际化` 两个版本选择) ## 精简版(实际项目开发请用精简版,提供 `非国际化``国际化` 两个版本选择)
- [点我查看非国际化精简版](https://github.com/xiaoxian521/pure-admin-thin) - [点我查看非国际化精简版](https://github.com/xiaoxian521/pure-admin-thin)
- [点我查看国际化精简版](https://github.com/xiaoxian521/pure-admin-thin/tree/i18n) - [点我查看国际化精简版](https://github.com/xiaoxian521/pure-admin-thin/tree/i18n)

View File

@ -72,6 +72,11 @@ menus:
hsPureDocument: Pure Doc(Embedded) hsPureDocument: Pure Doc(Embedded)
externalLink: Pure Doc(External) externalLink: Pure Doc(External)
hsEpDocument: Element Plus Doc(Embedded) hsEpDocument: Element Plus Doc(Embedded)
hsVueDocument: Vue3 Doc(Embedded)
hsViteDocument: Vite Doc(Embedded)
hsPiniaDocument: Pinia Doc(Embedded)
hsRouterDocument: Vue Router Doc(Embedded)
hsTailwindcssDocument: Tailwindcss Doc(Embedded)
hsAbout: About hsAbout: About
hsResult: Result Page hsResult: Result Page
hsSuccess: Success Page hsSuccess: Success Page
@ -97,6 +102,7 @@ menus:
hsdanmaku: Danmaku Components hsdanmaku: Danmaku Components
hsPureTableBase: Base Usage hsPureTableBase: Base Usage
hsPureTableHigh: High Usage hsPureTableHigh: High Usage
hsTree: Big Data Tree
status: status:
hsLoad: Loading... hsLoad: Loading...
login: login:

View File

@ -69,9 +69,14 @@ menus:
hsPrint: 打印 hsPrint: 打印
hsDownload: 下载 hsDownload: 下载
hsExternalPage: 外部页面 hsExternalPage: 外部页面
hsPureDocument: 平台文档(内嵌) hsPureDocument: 平台文档(内嵌)
externalLink: 平台文档(外链) externalLink: 平台文档(外链)
hsEpDocument: Element Plus文档(内嵌) hsEpDocument: Element Plus 文档(内嵌)
hsVueDocument: Vue3 文档(内嵌)
hsViteDocument: Vite 文档(内嵌)
hsPiniaDocument: Pinia 文档(内嵌)
hsRouterDocument: Vue Router 文档(内嵌)
hsTailwindcssDocument: Tailwindcss 文档(内嵌)
hsAbout: 关于 hsAbout: 关于
hsResult: 结果页面 hsResult: 结果页面
hsSuccess: 成功页面 hsSuccess: 成功页面
@ -97,6 +102,7 @@ menus:
hsdanmaku: 弹幕组件 hsdanmaku: 弹幕组件
hsPureTableBase: 基础用法 hsPureTableBase: 基础用法
hsPureTableHigh: 高级用法 hsPureTableHigh: 高级用法
hsTree: 大数据树业务组件
status: status:
hsLoad: 加载中... hsLoad: 加载中...
login: login:

View File

@ -1,5 +1,6 @@
// 模拟后端动态生成路由 // 模拟后端动态生成路由
import { MockMethod } from "vite-plugin-mock"; import { MockMethod } from "vite-plugin-mock";
import { system, permission, frame, tabs } from "@/router/enums";
/** /**
* roles "admin""common" * roles "admin""common"
@ -12,7 +13,7 @@ const systemRouter = {
meta: { meta: {
icon: "setting", icon: "setting",
title: "menus.hssysManagement", title: "menus.hssysManagement",
rank: 11 rank: system
}, },
children: [ children: [
{ {
@ -61,7 +62,7 @@ const permissionRouter = {
meta: { meta: {
title: "menus.permission", title: "menus.permission",
icon: "lollipop", icon: "lollipop",
rank: 10 rank: permission
}, },
children: [ children: [
{ {
@ -89,9 +90,17 @@ const frameRouter = {
meta: { meta: {
icon: "monitor", icon: "monitor",
title: "menus.hsExternalPage", title: "menus.hsExternalPage",
rank: 8 rank: frame
}, },
children: [ children: [
{
path: "/external",
name: "https://yiming_chang.gitee.io/pure-admin-doc",
meta: {
title: "menus.externalLink",
roles: ["admin", "common"]
}
},
{ {
path: "/iframe/pure", path: "/iframe/pure",
name: "FramePure", name: "FramePure",
@ -101,14 +110,6 @@ const frameRouter = {
roles: ["admin", "common"] roles: ["admin", "common"]
} }
}, },
{
path: "/external",
name: "https://yiming_chang.gitee.io/pure-admin-doc",
meta: {
title: "menus.externalLink",
roles: ["admin", "common"]
}
},
{ {
path: "/iframe/ep", path: "/iframe/ep",
name: "FrameEp", name: "FrameEp",
@ -117,6 +118,51 @@ const frameRouter = {
frameSrc: "https://element-plus.org/zh-CN/", frameSrc: "https://element-plus.org/zh-CN/",
roles: ["admin", "common"] roles: ["admin", "common"]
} }
},
{
path: "/iframe/vue3",
name: "FrameVue",
meta: {
title: "menus.hsVueDocument",
frameSrc: "https://cn.vuejs.org/",
roles: ["admin", "common"]
}
},
{
path: "/iframe/vite",
name: "FrameVite",
meta: {
title: "menus.hsViteDocument",
frameSrc: "https://cn.vitejs.dev/",
roles: ["admin", "common"]
}
},
{
path: "/iframe/pinia",
name: "FramePinia",
meta: {
title: "menus.hsPiniaDocument",
frameSrc: "https://pinia.vuejs.org/zh/index.html",
roles: ["admin", "common"]
}
},
{
path: "/iframe/vue-router",
name: "FrameRouter",
meta: {
title: "menus.hsRouterDocument",
frameSrc: "https://router.vuejs.org/zh/",
roles: ["admin", "common"]
}
},
{
path: "/iframe/tailwindcss",
name: "FrameTailwindcss",
meta: {
title: "menus.hsTailwindcssDocument",
frameSrc: "https://tailwindcss.com/docs/installation",
roles: ["admin", "common"]
}
} }
] ]
}; };
@ -126,7 +172,7 @@ const tabsRouter = {
meta: { meta: {
icon: "IF-team-icontabs", icon: "IF-team-icontabs",
title: "menus.hstabs", title: "menus.hstabs",
rank: 13 rank: tabs
}, },
children: [ children: [
{ {

View File

@ -3,9 +3,9 @@ import { useRouter } from "vue-router";
import { cloneDeep } from "lodash-unified"; import { cloneDeep } from "lodash-unified";
import SearchResult from "./SearchResult.vue"; import SearchResult from "./SearchResult.vue";
import SearchFooter from "./SearchFooter.vue"; import SearchFooter from "./SearchFooter.vue";
import { deleteChildren } from "@/utils/tree";
import { useNav } from "@/layout/hooks/useNav"; import { useNav } from "@/layout/hooks/useNav";
import { transformI18n } from "@/plugins/i18n"; import { transformI18n } from "@/plugins/i18n";
import { deleteChildren } from "@pureadmin/utils";
import { useDebounceFn, onKeyStroke } from "@vueuse/core"; import { useDebounceFn, onKeyStroke } from "@vueuse/core";
import { ref, watch, computed, nextTick, shallowRef } from "vue"; import { ref, watch, computed, nextTick, shallowRef } from "vue";
import { usePermissionStoreHook } from "@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";

View File

@ -4,7 +4,6 @@ import { useRoute } from "vue-router";
import { emitter } from "@/utils/mitt"; import { emitter } from "@/utils/mitt";
import SidebarItem from "./sidebarItem.vue"; import SidebarItem from "./sidebarItem.vue";
import leftCollapse from "./leftCollapse.vue"; import leftCollapse from "./leftCollapse.vue";
import type { StorageConfigs } from "/#/index";
import { useNav } from "@/layout/hooks/useNav"; import { useNav } from "@/layout/hooks/useNav";
import { storageLocal } from "@pureadmin/utils"; import { storageLocal } from "@pureadmin/utils";
import { ref, computed, watch, onBeforeMount } from "vue"; import { ref, computed, watch, onBeforeMount } from "vue";

View File

@ -9,7 +9,6 @@ import {
getCurrentInstance getCurrentInstance
} from "vue"; } from "vue";
import { tagsViewsType } from "../types"; import { tagsViewsType } from "../types";
import type { StorageConfigs } from "/#/index";
import { useEventListener } from "@vueuse/core"; import { useEventListener } from "@vueuse/core";
import { useRoute, useRouter } from "vue-router"; import { useRoute, useRouter } from "vue-router";
import { transformI18n, $t } from "@/plugins/i18n"; import { transformI18n, $t } from "@/plugins/i18n";

View File

@ -1,6 +1,5 @@
// 多组件库的国际化和本地项目国际化兼容 // 多组件库的国际化和本地项目国际化兼容
import { App, WritableComputedRef } from "vue"; import { App, WritableComputedRef } from "vue";
import type { StorageConfigs } from "/#/index";
import { storageLocal } from "@pureadmin/utils"; import { storageLocal } from "@pureadmin/utils";
import { type I18n, createI18n } from "vue-i18n"; import { type I18n, createI18n } from "vue-i18n";

47
src/router/enums.ts Normal file
View File

@ -0,0 +1,47 @@
// 完整版菜单比较多,将 rank 抽离出来,在此方便维护
const home = 0, // 平台规定只有 home 路由的 rank 才能为 0 ,所以后端在返回 rank 的时候需要从 1 开始哦
doc = 1,
utils = 2,
table = 3,
tree = 4,
able = 5,
components = 6,
frame = 7,
nested = 8,
result = 9,
error = 10,
list = 11,
permission = 12,
system = 13,
tabs = 14,
formdesign = 15,
flowchart = 16,
ppt = 17,
editor = 18,
guide = 19,
about = 20;
export {
home,
doc,
utils,
table,
tree,
able,
components,
frame,
nested,
result,
error,
list,
permission,
system,
tabs,
formdesign,
flowchart,
ppt,
editor,
guide,
about
};

View File

@ -1,6 +1,5 @@
import "@/utils/sso"; import "@/utils/sso";
import { getConfig } from "@/config"; import { getConfig } from "@/config";
import { toRouteType } from "./types";
import NProgress from "@/utils/progress"; import NProgress from "@/utils/progress";
import { findIndex } from "lodash-unified"; import { findIndex } from "lodash-unified";
import { transformI18n } from "@/plugins/i18n"; import { transformI18n } from "@/plugins/i18n";
@ -23,12 +22,9 @@ import {
formatTwoStageRoutes, formatTwoStageRoutes,
formatFlatteningRoutes formatFlatteningRoutes
} from "./utils"; } from "./utils";
import { import { buildHierarchyTree } from "@/utils/tree";
isUrl, import { isUrl, openLink, storageSession } from "@pureadmin/utils";
openLink,
storageSession,
buildHierarchyTree
} from "@pureadmin/utils";
import remainingRouter from "./modules/remaining"; import remainingRouter from "./modules/remaining";
/** src/router/modules .ts remaining.ts /** src/router/modules .ts remaining.ts

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { able } from "@/router/enums";
const ableRouter: RouteConfigsTable = { export default {
path: "/able", path: "/able",
redirect: "/able/watermark", redirect: "/able/watermark",
meta: { meta: {
icon: "ubuntu-fill", icon: "ubuntu-fill",
title: $t("menus.hsAble"), title: $t("menus.hsAble"),
rank: 5 rank: able
}, },
children: [ children: [
{ {
@ -163,6 +163,4 @@ const ableRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default ableRouter;

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { about } from "@/router/enums";
const aboutRouter: RouteConfigsTable = { export default {
path: "/about", path: "/about",
redirect: "/about/index", redirect: "/about/index",
meta: { meta: {
// icon: "question-line", // icon: "question-line",
title: $t("menus.hsAbout"), title: $t("menus.hsAbout"),
rank: 15 rank: about
}, },
children: [ children: [
{ {
@ -19,6 +19,4 @@ const aboutRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default aboutRouter;

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { components } from "@/router/enums";
const componentsRouter: RouteConfigsTable = { export default {
path: "/components", path: "/components",
redirect: "/components/video", redirect: "/components/video",
meta: { meta: {
icon: "menu", icon: "menu",
title: $t("menus.hscomponents"), title: $t("menus.hscomponents"),
rank: 6 rank: components
}, },
children: [ children: [
{ {
@ -127,6 +127,4 @@ const componentsRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default componentsRouter;

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { editor } from "@/router/enums";
const editorRouter: RouteConfigsTable = { export default {
path: "/editor", path: "/editor",
redirect: "/editor/index", redirect: "/editor/index",
meta: { meta: {
icon: "edit", icon: "edit",
title: $t("menus.hseditor"), title: $t("menus.hseditor"),
rank: 2 rank: editor
}, },
children: [ children: [
{ {
@ -20,6 +20,4 @@ const editorRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default editorRouter;

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { error } from "@/router/enums";
const errorRouter: RouteConfigsTable = { export default {
path: "/error", path: "/error",
redirect: "/error/403", redirect: "/error/403",
meta: { meta: {
icon: "information-line", icon: "information-line",
title: $t("menus.hsabnormal"), title: $t("menus.hsabnormal"),
rank: 9 rank: error
}, },
children: [ children: [
{ {
@ -35,6 +35,4 @@ const errorRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default errorRouter;

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { flowchart } from "@/router/enums";
const flowChartRouter: RouteConfigsTable = { export default {
path: "/flowChart", path: "/flowChart",
redirect: "/flowChart/index", redirect: "/flowChart/index",
meta: { meta: {
icon: "set-up", icon: "set-up",
title: $t("menus.hsflowChart"), title: $t("menus.hsflowChart"),
rank: 1 rank: flowchart
}, },
children: [ children: [
{ {
@ -19,6 +19,4 @@ const flowChartRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default flowChartRouter;

View File

@ -1,14 +1,14 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { formdesign } from "@/router/enums";
const IFrame = () => import("@/layout/frameView.vue"); const IFrame = () => import("@/layout/frameView.vue");
const formDesignRouter: RouteConfigsTable = { export default {
path: "/formDesign", path: "/formDesign",
redirect: "/formDesign/index", redirect: "/formDesign/index",
meta: { meta: {
icon: "terminal-window-line", icon: "terminal-window-line",
title: $t("menus.hsFormDesign"), title: $t("menus.hsFormDesign"),
rank: 2 rank: formdesign
}, },
children: [ children: [
{ {
@ -22,6 +22,4 @@ const formDesignRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default formDesignRouter;

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { guide } from "@/router/enums";
const guideRouter: RouteConfigsTable = { export default {
path: "/guide", path: "/guide",
redirect: "/guide/index", redirect: "/guide/index",
meta: { meta: {
icon: "guide", icon: "guide",
title: $t("menus.hsguide"), title: $t("menus.hsguide"),
rank: 14 rank: guide
}, },
children: [ children: [
{ {
@ -19,6 +19,4 @@ const guideRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default guideRouter;

View File

@ -1,8 +1,8 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { home } from "@/router/enums";
const Layout = () => import("@/layout/index.vue"); const Layout = () => import("@/layout/index.vue");
const homeRouter: RouteConfigsTable = { export default {
path: "/", path: "/",
name: "Home", name: "Home",
component: Layout, component: Layout,
@ -10,7 +10,7 @@ const homeRouter: RouteConfigsTable = {
meta: { meta: {
icon: "home-filled", icon: "home-filled",
title: $t("menus.hshome"), title: $t("menus.hshome"),
rank: 0 rank: home
}, },
children: [ children: [
{ {
@ -22,6 +22,4 @@ const homeRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default homeRouter;

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { list } from "@/router/enums";
const ableRouter: RouteConfigsTable = { export default {
path: "/list", path: "/list",
redirect: "/list/card", redirect: "/list/card",
meta: { meta: {
icon: "list-check", icon: "list-check",
title: $t("menus.hsList"), title: $t("menus.hsList"),
rank: 12 rank: list
}, },
children: [ children: [
{ {
@ -21,6 +21,4 @@ const ableRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default ableRouter;

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { nested } from "@/router/enums";
const nestedRouter: RouteConfigsTable = { export default {
path: "/nested", path: "/nested",
redirect: "/nested/menu1/menu1-1", redirect: "/nested/menu1/menu1-1",
meta: { meta: {
title: $t("menus.hsmenus"), title: $t("menus.hsmenus"),
icon: "histogram", icon: "histogram",
rank: 7 rank: nested
}, },
children: [ children: [
{ {
@ -82,6 +82,4 @@ const nestedRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default nestedRouter;

View File

@ -1,13 +1,13 @@
import type { RouteConfigsTable } from "/#/index"; import { ppt } from "@/router/enums";
const IFrame = () => import("@/layout/frameView.vue"); const IFrame = () => import("@/layout/frameView.vue");
const pptRouter: RouteConfigsTable = { export default {
path: "/ppt", path: "/ppt",
redirect: "/ppt/index", redirect: "/ppt/index",
meta: { meta: {
icon: "ppt", icon: "ppt",
title: "PPT", title: "PPT",
rank: 3 rank: ppt
}, },
children: [ children: [
{ {
@ -21,6 +21,4 @@ const pptRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default pptRouter;

View File

@ -0,0 +1,24 @@
import { doc } from "@/router/enums";
import hot from "@/assets/svg/hot.svg?component";
const IFrame = () => import("@/layout/frameView.vue");
export default {
path: "/pure-admin-doc",
redirect: "/pure-admin-doc/index",
meta: {
icon: hot,
title: "pure-admin-doc",
rank: doc
},
children: [
{
path: "/pure-admin-doc/index",
name: "FrameDoc",
component: IFrame,
meta: {
title: "pure-admin-doc",
frameSrc: "https://yiming_chang.gitee.io/pure-admin-doc/"
}
}
]
} as RouteConfigsTable;

View File

@ -0,0 +1,24 @@
import { utils } from "@/router/enums";
import hot from "@/assets/svg/hot.svg?component";
const IFrame = () => import("@/layout/frameView.vue");
export default {
path: "/pure-admin-utils",
redirect: "/pure-admin-utils/index",
meta: {
icon: hot,
title: "pure-admin-utils",
rank: utils
},
children: [
{
path: "/pure-admin-utils/index",
name: "FrameUtils",
component: IFrame,
meta: {
title: "pure-admin-utils",
frameSrc: "https://pure-admin-utils.netlify.app/"
}
}
]
} as RouteConfigsTable;

View File

@ -1,8 +1,7 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index";
const Layout = () => import("@/layout/index.vue"); const Layout = () => import("@/layout/index.vue");
const remainingRouter: Array<RouteConfigsTable> = [ export default [
{ {
path: "/login", path: "/login",
name: "Login", name: "Login",
@ -20,7 +19,7 @@ const remainingRouter: Array<RouteConfigsTable> = [
icon: "home-filled", icon: "home-filled",
title: $t("menus.hshome"), title: $t("menus.hshome"),
showLink: false, showLink: false,
rank: 104 rank: 102
}, },
children: [ children: [
{ {
@ -38,9 +37,7 @@ const remainingRouter: Array<RouteConfigsTable> = [
meta: { meta: {
title: $t("menus.hsempty"), title: $t("menus.hsempty"),
showLink: false, showLink: false,
rank: 105 rank: 103
} }
} }
]; ] as Array<RouteConfigsTable>;
export default remainingRouter;

View File

@ -1,13 +1,13 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import type { RouteConfigsTable } from "/#/index"; import { result } from "@/router/enums";
const resultRouter: RouteConfigsTable = { export default {
path: "/result", path: "/result",
redirect: "/result/success", redirect: "/result/success",
meta: { meta: {
icon: "checkbox-circle-line", icon: "checkbox-circle-line",
title: $t("menus.hsResult"), title: $t("menus.hsResult"),
rank: 8 rank: result
}, },
children: [ children: [
{ {
@ -27,6 +27,4 @@ const resultRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default resultRouter;

View File

@ -1,14 +1,14 @@
import { $t } from "@/plugins/i18n"; import { $t } from "@/plugins/i18n";
import { table } from "@/router/enums";
import hot from "@/assets/svg/hot.svg?component"; import hot from "@/assets/svg/hot.svg?component";
import type { RouteConfigsTable } from "/#/index";
const flowChartRouter: RouteConfigsTable = { export default {
path: "/pure-table", path: "/pure-table",
redirect: "/pure-table/index", redirect: "/pure-table/index",
meta: { meta: {
icon: hot, icon: hot,
title: "pure-admin-table", title: "pure-admin-table",
rank: 4 rank: table
}, },
children: [ children: [
{ {
@ -28,6 +28,4 @@ const flowChartRouter: RouteConfigsTable = {
} }
} }
] ]
}; } as RouteConfigsTable;
export default flowChartRouter;

View File

@ -0,0 +1,23 @@
import { $t } from "@/plugins/i18n";
import { tree } from "@/router/enums";
import hot from "@/assets/svg/hot.svg?component";
export default {
path: "/tree",
redirect: "/tree/index",
meta: {
icon: hot,
title: $t("menus.hsTree"),
rank: tree
},
children: [
{
path: "/tree/index",
name: "Tree",
component: () => import("@/views/tree/index.vue"),
meta: {
title: $t("menus.hsTree")
}
}
]
} as RouteConfigsTable;

View File

@ -1,9 +0,0 @@
import { RouteLocationNormalized } from "vue-router";
export interface toRouteType extends RouteLocationNormalized {
meta: {
roles: Array<string>;
keepAlive?: boolean;
dynamicLevel?: string;
};
}

View File

@ -14,9 +14,9 @@ import { RouteConfigs } from "@/layout/types";
import { import {
isString, isString,
storageSession, storageSession,
buildHierarchyTree,
isIncludeAllChildren isIncludeAllChildren
} from "@pureadmin/utils"; } from "@pureadmin/utils";
import { buildHierarchyTree } from "@/utils/tree";
import { cloneDeep, intersection } from "lodash-unified"; import { cloneDeep, intersection } from "lodash-unified";
import { sessionKey, type DataInfo } from "@/utils/auth"; import { sessionKey, type DataInfo } from "@/utils/auth";
import { usePermissionStoreHook } from "@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";

View File

@ -2,7 +2,6 @@ import { store } from "@/store";
import { appType } from "./types"; import { appType } from "./types";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { getConfig } from "@/config"; import { getConfig } from "@/config";
import type { StorageConfigs } from "/#/index";
import { deviceDetection, storageLocal } from "@pureadmin/utils"; import { deviceDetection, storageLocal } from "@pureadmin/utils";
export const useAppStore = defineStore({ export const useAppStore = defineStore({

View File

@ -1,7 +1,6 @@
import { store } from "@/store"; import { store } from "@/store";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { getConfig } from "@/config"; import { getConfig } from "@/config";
import type { StorageConfigs } from "/#/index";
import { storageLocal } from "@pureadmin/utils"; import { storageLocal } from "@pureadmin/utils";
export const useEpThemeStore = defineStore({ export const useEpThemeStore = defineStore({

View File

@ -1,7 +1,6 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { store } from "@/store"; import { store } from "@/store";
import { isEqual } from "@pureadmin/utils"; import { isEqual } from "@pureadmin/utils";
import type { StorageConfigs } from "/#/index";
import { routerArrays } from "@/layout/types"; import { routerArrays } from "@/layout/types";
import { multiType, positionType } from "./types"; import { multiType, positionType } from "./types";
import { isUrl, storageLocal } from "@pureadmin/utils"; import { isUrl, storageLocal } from "@pureadmin/utils";

188
src/utils/tree.ts Normal file
View File

@ -0,0 +1,188 @@
/**
* @description uniqueId
* @param tree
* @returns uniqueId组成的数组
*/
export const extractPathList = (tree: any[]): any => {
if (!Array.isArray(tree)) {
console.warn("tree must be an array");
return [];
}
if (!tree || tree.length === 0) return [];
const expandedPaths: Array<number | string> = [];
for (const node of tree) {
const hasChildren = node.children && node.children.length > 0;
if (hasChildren) {
extractPathList(node.children);
}
expandedPaths.push(node.uniqueId);
}
return expandedPaths;
};
/**
* @description children的length为1children并自动组建唯一uniqueId
* @param tree
* @param pathList id组成的数组
* @returns uniqueId后的树
*/
export const deleteChildren = (tree: any[], pathList = []): any => {
if (!Array.isArray(tree)) {
console.warn("menuTree must be an array");
return [];
}
if (!tree || tree.length === 0) return [];
for (const [key, node] of tree.entries()) {
if (node.children && node.children.length === 1) delete node.children;
node.id = key;
node.parentId = pathList.length ? pathList[pathList.length - 1] : null;
node.pathList = [...pathList, node.id];
node.uniqueId =
node.pathList.length > 1 ? node.pathList.join("-") : node.pathList[0];
const hasChildren = node.children && node.children.length > 0;
if (hasChildren) {
deleteChildren(node.children, node.pathList);
}
}
return tree;
};
/**
* @description
* @param tree
* @param pathList id组成的数组
* @returns
*/
export const buildHierarchyTree = (tree: any[], pathList = []): any => {
if (!Array.isArray(tree)) {
console.warn("tree must be an array");
return [];
}
if (!tree || tree.length === 0) return [];
for (const [key, node] of tree.entries()) {
node.id = key;
node.parentId = pathList.length ? pathList[pathList.length - 1] : null;
node.pathList = [...pathList, node.id];
const hasChildren = node.children && node.children.length > 0;
if (hasChildren) {
buildHierarchyTree(node.children, node.pathList);
}
}
return tree;
};
/**
* @description 广uniqueId找当前节点信息
* @param tree
* @param uniqueId uniqueId
* @returns
*/
export const getNodeByUniqueId = (
tree: any[],
uniqueId: number | string
): any => {
if (!Array.isArray(tree)) {
console.warn("menuTree must be an array");
return [];
}
if (!tree || tree.length === 0) return [];
const item = tree.find(node => node.uniqueId === uniqueId);
if (item) return item;
const childrenList = tree
.filter(node => node.children)
.map(i => i.children)
.flat(1) as unknown;
return getNodeByUniqueId(childrenList as any[], uniqueId);
};
/**
* @description uniqueId节点中追加字段
* @param tree
* @param uniqueId uniqueId
* @param fields
* @returns
*/
export const appendFieldByUniqueId = (
tree: any[],
uniqueId: number | string,
fields: object
): any => {
if (!Array.isArray(tree)) {
console.warn("menuTree must be an array");
return [];
}
if (!tree || tree.length === 0) return [];
for (const node of tree) {
const hasChildren = node.children && node.children.length > 0;
if (
node.uniqueId === uniqueId &&
Object.prototype.toString.call(fields) === "[object Object]"
)
Object.assign(node, fields);
if (hasChildren) {
appendFieldByUniqueId(node.children, uniqueId, fields);
}
}
return tree;
};
/**
* @description
* @param data
* @param id id字段 id
* @param parentId parentId
* @param children children
* @returns
*/
export const handleTree = (
data: any[],
id?: string,
parentId?: string,
children?: string
): any => {
if (!Array.isArray(data)) {
console.warn("data must be an array");
return [];
}
const config = {
id: id || "id",
parentId: parentId || "parentId",
childrenList: children || "children"
};
const childrenListMap: any = {};
const nodeIds: any = {};
const tree = [];
for (const d of data) {
const parentId = d[config.parentId];
if (childrenListMap[parentId] == null) {
childrenListMap[parentId] = [];
}
nodeIds[d[config.id]] = d;
childrenListMap[parentId].push(d);
}
for (const d of data) {
const parentId = d[config.parentId];
if (nodeIds[parentId] == null) {
tree.push(d);
}
}
for (const t of tree) {
adaptToChildrenList(t);
}
function adaptToChildrenList(o: Record<string, any>) {
if (childrenListMap[o[config.id]] !== null) {
o[config.childrenList] = childrenListMap[o[config.id]];
}
if (o[config.childrenList]) {
for (const c of o[config.childrenList]) {
adaptToChildrenList(c);
}
}
}
return tree;
};

View File

@ -3,7 +3,7 @@ import { computed } from "vue";
import { clone } from "@pureadmin/utils"; import { clone } from "@pureadmin/utils";
import { transformI18n } from "@/plugins/i18n"; import { transformI18n } from "@/plugins/i18n";
import ElTreeLine from "@/components/ReTreeLine"; import ElTreeLine from "@/components/ReTreeLine";
import { extractPathList, deleteChildren } from "@pureadmin/utils"; import { extractPathList, deleteChildren } from "@/utils/tree";
import { usePermissionStoreHook } from "@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";
defineOptions({ defineOptions({

View File

@ -4,7 +4,7 @@ import { clone } from "@pureadmin/utils";
import type { ElTreeV2 } from "element-plus"; import type { ElTreeV2 } from "element-plus";
import { transformI18n } from "@/plugins/i18n"; import { transformI18n } from "@/plugins/i18n";
import { useRenderIcon } from "@/components/ReIcon/src/hooks"; import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { extractPathList, deleteChildren } from "@pureadmin/utils"; import { extractPathList, deleteChildren } from "@/utils/tree";
import { usePermissionStoreHook } from "@/store/modules/permission"; import { usePermissionStoreHook } from "@/store/modules/permission";
import type { TreeNode } from "element-plus/es/components/tree-v2/src/types"; import type { TreeNode } from "element-plus/es/components/tree-v2/src/types";

View File

@ -1,8 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { useColumns } from "./columns"; import { useColumns } from "./columns";
import { handleTree } from "@/utils/tree";
import { getDeptList } from "@/api/system"; import { getDeptList } from "@/api/system";
import { FormInstance } from "element-plus"; import { FormInstance } from "element-plus";
import { handleTree } from "@pureadmin/utils";
import { reactive, ref, onMounted } from "vue"; import { reactive, ref, onMounted } from "vue";
import { TableProBar } from "@/components/ReTable"; import { TableProBar } from "@/components/ReTable";
import { useRenderIcon } from "@/components/ReIcon/src/hooks"; import { useRenderIcon } from "@/components/ReIcon/src/hooks";

View File

@ -1,7 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { handleTree } from "@/utils/tree";
import type { ElTree } from "element-plus"; import type { ElTree } from "element-plus";
import { getDeptList } from "@/api/system"; import { getDeptList } from "@/api/system";
import { handleTree } from "@pureadmin/utils";
import { useRenderIcon } from "@/components/ReIcon/src/hooks"; import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { ref, watch, onMounted, getCurrentInstance } from "vue"; import { ref, watch, onMounted, getCurrentInstance } from "vue";

View File

@ -9,7 +9,7 @@ import {
deleteChildren, deleteChildren,
getNodeByUniqueId, getNodeByUniqueId,
appendFieldByUniqueId appendFieldByUniqueId
} from "@pureadmin/utils"; } from "@/utils/tree";
import { useDetail } from "./hooks"; import { useDetail } from "./hooks";
defineOptions({ defineOptions({

7
src/views/tree/index.vue Normal file
View File

@ -0,0 +1,7 @@
<script setup lang="ts"></script>
<template>
<div>即将发布</div>
</template>
<style scoped></style>

269
types/global.d.ts vendored
View File

@ -1,25 +1,21 @@
import type { import type {
ComponentRenderProxy,
VNode, VNode,
ComponentPublicInstance,
FunctionalComponent, FunctionalComponent,
PropType as VuePropType PropType as VuePropType,
ComponentPublicInstance
} from "vue"; } from "vue";
import type { ECharts } from "echarts"; import type { ECharts } from "echarts";
import { type ResponsiveStorage } from "./index"; import type { ResponsiveStorage } from "./index";
import type { TableColumns } from "@pureadmin/table"; import type { TableColumns } from "@pureadmin/table";
import { type RouteComponent, type RouteLocationNormalized } from "vue-router";
// GlobalComponents for Volar /**
declare module "vue" { * `.vue` `.ts` `.tsx` 使
export interface GlobalComponents { */
IconifyIconOffline: typeof import("../src/components/ReIcon")["IconifyIconOffline"];
IconifyIconOnline: typeof import("../src/components/ReIcon")["IconifyIconOnline"];
FontIcon: typeof import("../src/components/ReIcon")["FontIcon"];
Auth: typeof import("../src/components/ReAuth")["Auth"];
}
}
declare global { declare global {
/**
*
*/
const __APP_INFO__: { const __APP_INFO__: {
pkg: { pkg: {
name: string; name: string;
@ -29,6 +25,10 @@ declare global {
}; };
lastBuildTime: string; lastBuildTime: string;
}; };
/**
* Window
*/
interface Window { interface Window {
// Global vue app instance // Global vue app instance
__APP__: App<Element>; __APP__: App<Element>;
@ -42,39 +42,9 @@ declare global {
msRequestAnimationFrame: (callback: FrameRequestCallback) => number; msRequestAnimationFrame: (callback: FrameRequestCallback) => number;
} }
// vue /**
type PropType<T> = VuePropType<T>; *
*/
type Writable<T> = {
-readonly [P in keyof T]: T[P];
};
type Nullable<T> = T | null;
type NonNullable<T> = T extends null | undefined ? never : T;
type Recordable<T = any> = Record<string, T>;
type ReadonlyRecordable<T = any> = {
readonly [key: string]: T;
};
type Indexable<T = any> = {
[key: string]: T;
};
type DeepPartial<T> = {
[P in keyof T]?: DeepPartial<T[P]>;
};
type TimeoutHandle = ReturnType<typeof setTimeout>;
type IntervalHandle = ReturnType<typeof setInterval>;
interface ChangeEvent extends Event {
target: HTMLInputElement;
}
interface WheelEvent {
path?: EventTarget[];
}
interface ImportMetaEnv extends ViteEnv {
__: unknown;
}
type ViteCompression = type ViteCompression =
| "none" | "none"
| "gzip" | "gzip"
@ -84,7 +54,11 @@ declare global {
| "brotli-clear" | "brotli-clear"
| "both-clear"; | "both-clear";
declare interface ViteEnv { /**
*
* @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#%E5%85%B7%E4%BD%93%E9%85%8D%E7%BD%AE}
*/
interface ViteEnv {
VITE_PORT: number; VITE_PORT: number;
VITE_PUBLIC_PATH: string; VITE_PUBLIC_PATH: string;
VITE_ROUTER_HISTORY: string; VITE_ROUTER_HISTORY: string;
@ -92,7 +66,16 @@ declare global {
VITE_COMPRESSION: ViteCompression; VITE_COMPRESSION: ViteCompression;
} }
declare interface ServerConfigs { /**
* `@pureadmin/table` `TableColumns` 便
*/
interface TableColumnList extends Array<TableColumns> {}
/**
* `public/serverConfig.json`
* @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-json}
*/
interface ServerConfigs {
Version?: string; Version?: string;
Title?: string; Title?: string;
FixedHeader?: boolean; FixedHeader?: boolean;
@ -121,32 +104,176 @@ declare global {
}; };
} }
declare interface GlobalPropertiesApi { /**
* `ServerConfigs`
* @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/config/#serverconfig-json}
*/
interface StorageConfigs {
version?: string;
title?: string;
fixedHeader?: boolean;
hiddenSideBar?: boolean;
multiTagsCache?: boolean;
keepAlive?: boolean;
locale?: string;
layout?: string;
theme?: string;
darkMode?: boolean;
grey?: boolean;
weak?: boolean;
hideTabs?: boolean;
sidebarStatus?: boolean;
epThemeColor?: string;
showLogo?: boolean;
showModel?: string;
mapConfigure?: {
amapKey?: string;
options: {
resizeEnable?: boolean;
center?: number[];
zoom?: number;
};
};
username?: string;
}
/**
* `responsive-storage` `storage`
*/
interface ResponsiveStorage {
locale: {
locale?: string;
};
layout: {
layout?: string;
theme?: string;
darkMode?: boolean;
sidebarStatus?: boolean;
epThemeColor?: string;
};
configure: {
grey?: boolean;
weak?: boolean;
hideTabs?: boolean;
showLogo?: boolean;
showModel?: string;
multiTagsCache?: boolean;
};
tags?: Array<any>;
}
/**
* `src/router`
*/
interface toRouteType extends RouteLocationNormalized {
meta: {
roles: Array<string>;
keepAlive?: boolean;
dynamicLevel?: string;
};
}
/**
* @description
*/
interface RouteChildrenConfigsTable {
/** 子路由地址 `必填` */
path: string;
/** 路由名字(对应不要重复,和当前组件的`name`保持一致)`必填` */
name?: string;
/** 路由重定向 `可选` */
redirect?: string;
/** 按需加载组件 `可选` */
component?: RouteComponent;
meta?: {
/** 菜单名称(兼容国际化、非国际化,如何用国际化的写法就必须在根目录的`locales`文件夹下对应添加) `必填` */
title: string;
/** 菜单图标 `可选` */
icon?: string | FunctionalComponent;
/** 菜单名称右侧的额外图标,支持`fontawesome`、`iconfont`、`element-plus-icon` `可选` */
extraIcon?: {
svg?: boolean;
name?: string;
};
/** 是否在菜单中显示(默认`true``可选` */
showLink?: boolean;
/** 是否显示父级菜单 `可选` */
showParent?: boolean;
/** 页面级别权限设置 `可选` */
roles?: Array<string>;
/** 按钮级别权限设置 `可选` */
auths?: Array<string>;
/** 路由组件缓存(开启 `true`、关闭 `false``可选` */
keepAlive?: boolean;
/** 内嵌的`iframe`链接 `可选` */
frameSrc?: string;
/** `iframe`页是否开启首次加载动画(默认`true``可选` */
frameLoading?: boolean;
/** 页面加载动画有两种形式一种直接采用vue内置的`transitions`动画,另一种是使用`animate.css`写进、离场动画)`可选` */
transition?: {
/**
* @description
* @see {@link https://next.router.vuejs.org/guide/advanced/transitions.html#transitions}
*/
name?: string;
/** 进场动画 */
enterTransition?: string;
/** 离场动画 */
leaveTransition?: string;
};
// 是否不添加信息到标签页,(默认`false`
hiddenTag?: boolean;
/** 动态路由可打开的最大数量 `可选` */
dynamicLevel?: number;
};
/** 子路由配置项 */
children?: Array<RouteChildrenConfigsTable>;
}
/**
* @description
*/
interface RouteConfigsTable {
/** 路由地址 `必填` */
path: string;
/** 路由名字(保持唯一)`可选` */
name?: string;
/** `Layout`组件 `可选` */
component?: RouteComponent;
/** 路由重定向 `可选` */
redirect?: string;
meta?: {
/** 菜单名称(兼容国际化、非国际化,如何用国际化的写法就必须在根目录的`locales`文件夹下对应添加)`必填` */
title: string;
/** 菜单图标 `可选` */
icon?: string | FunctionalComponent;
/** 是否在菜单中显示(默认`true``可选` */
showLink?: boolean;
/** 菜单升序排序,值越高排的越后(只针对顶级路由)`可选` */
rank?: number;
};
/** 子路由配置项 */
children?: Array<RouteChildrenConfigsTable>;
}
/**
* 访
*/
interface GlobalPropertiesApi {
$echarts: ECharts; $echarts: ECharts;
$storage: ResponsiveStorage; $storage: ResponsiveStorage;
$config: ServerConfigs; $config: ServerConfigs;
} }
}
// 继承 @pureadmin/table 的 TableColumns方便全局直接调用 declare module "vue" {
declare interface TableColumnList extends Array<TableColumns> {} /**
* Volar Volar
function parseInt(s: string | number, radix?: number): number; */
export interface GlobalComponents {
function parseFloat(string: string | number): number; IconifyIconOffline: typeof import("../src/components/ReIcon")["IconifyIconOffline"];
IconifyIconOnline: typeof import("../src/components/ReIcon")["IconifyIconOnline"];
namespace JSX { FontIcon: typeof import("../src/components/ReIcon")["FontIcon"];
// tslint:disable no-empty-interface Auth: typeof import("../src/components/ReAuth")["Auth"];
type Element = VNode;
// tslint:disable no-empty-interface
type ElementClass = ComponentRenderProxy;
interface ElementAttributesProperty {
$props: any;
}
interface IntrinsicElements {
[elem: string]: any;
}
interface IntrinsicAttributes {
[elem: string]: any;
}
} }
} }

87
types/index.d.ts vendored
View File

@ -1,33 +1,74 @@
declare interface Fn<T = any, R = T> { // 此文件跟同级目录的 global.d.ts 文件一样也是全局类型声明,只不过这里存放一些零散的全局类型,无需引入直接在 .vue 、.ts 、.tsx 文件使用即可获得类型提示
(...arg: T[]): R;
}
declare interface PromiseFn<T = any, R = T> { type RefType<T> = T | null;
(...arg: T[]): Promise<R>;
}
declare type RefType<T> = T | null; type EmitType = (event: string, ...args: any[]) => void;
declare type LabelValueOptions = { type TargetContext = "_self" | "_blank";
label: string;
value: any;
}[];
declare type EmitType = (event: string, ...args: any[]) => void; type ComponentRef<T extends HTMLElement = HTMLDivElement> =
declare type TargetContext = "_self" | "_blank";
declare interface ComponentElRef<T extends HTMLElement = HTMLDivElement> {
$el: T;
}
declare type ComponentRef<T extends HTMLElement = HTMLDivElement> =
ComponentElRef<T> | null; ComponentElRef<T> | null;
declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>; type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>;
declare type ForDataType<T> = { type ForDataType<T> = {
[P in T]?: ForDataType<T[P]>; [P in T]?: ForDataType<T[P]>;
}; };
declare type AnyFunction<T> = (...args: any[]) => T; type AnyFunction<T> = (...args: any[]) => T;
type PropType<T> = VuePropType<T>;
type Writable<T> = {
-readonly [P in keyof T]: T[P];
};
type Nullable<T> = T | null;
type NonNullable<T> = T extends null | undefined ? never : T;
type Recordable<T = any> = Record<string, T>;
type ReadonlyRecordable<T = any> = {
readonly [key: string]: T;
};
type Indexable<T = any> = {
[key: string]: T;
};
type DeepPartial<T> = {
[P in keyof T]?: DeepPartial<T[P]>;
};
type TimeoutHandle = ReturnType<typeof setTimeout>;
type IntervalHandle = ReturnType<typeof setInterval>;
interface ChangeEvent extends Event {
target: HTMLInputElement;
}
interface WheelEvent {
path?: EventTarget[];
}
interface ImportMetaEnv extends ViteEnv {
__: unknown;
}
interface Fn<T = any, R = T> {
(...arg: T[]): R;
}
interface PromiseFn<T = any, R = T> {
(...arg: T[]): Promise<R>;
}
interface ComponentElRef<T extends HTMLElement = HTMLDivElement> {
$el: T;
}
function parseInt(s: string | number, radix?: number): number;
function parseFloat(string: string | number): number;

View File

@ -1,134 +0,0 @@
import { type FunctionalComponent } from "vue";
import { type RouteComponent } from "vue-router";
export interface StorageConfigs {
version?: string;
title?: string;
fixedHeader?: boolean;
hiddenSideBar?: boolean;
multiTagsCache?: boolean;
keepAlive?: boolean;
locale?: string;
layout?: string;
theme?: string;
darkMode?: boolean;
grey?: boolean;
weak?: boolean;
hideTabs?: boolean;
sidebarStatus?: boolean;
epThemeColor?: string;
showLogo?: boolean;
showModel?: string;
mapConfigure?: {
amapKey?: string;
options: {
resizeEnable?: boolean;
center?: number[];
zoom?: number;
};
};
username?: string;
}
export interface ResponsiveStorage {
locale: {
locale?: string;
};
layout: {
layout?: string;
theme?: string;
darkMode?: boolean;
sidebarStatus?: boolean;
epThemeColor?: string;
};
configure: {
grey?: boolean;
weak?: boolean;
hideTabs?: boolean;
showLogo?: boolean;
showModel?: string;
multiTagsCache?: boolean;
};
tags?: Array<any>;
}
export interface RouteChildrenConfigsTable {
/** 子路由地址 `必填` */
path: string;
/** 路由名字(对应不要重复,和当前组件的`name`保持一致)`必填` */
name?: string;
/** 路由重定向 `可选` */
redirect?: string;
/** 按需加载组件 `可选` */
component?: RouteComponent;
meta?: {
/** 菜单名称(兼容国际化、非国际化,如何用国际化的写法就必须在根目录的`locales`文件夹下对应添加) `必填` */
title: string;
/** 菜单图标 `可选` */
icon?: string | FunctionalComponent;
/** 菜单名称右侧的额外图标,支持`fontawesome`、`iconfont`、`element-plus-icon` `可选` */
extraIcon?: {
svg?: boolean;
name?: string;
};
/** 是否在菜单中显示(默认`true``可选` */
showLink?: boolean;
/** 是否显示父级菜单 `可选` */
showParent?: boolean;
/** 页面级别权限设置 `可选` */
roles?: Array<string>;
/** 按钮级别权限设置 `可选` */
auths?: Array<string>;
/** 路由组件缓存(开启 `true`、关闭 `false``可选` */
keepAlive?: boolean;
/** 内嵌的`iframe`链接 `可选` */
frameSrc?: string;
/** `iframe`页是否开启首次加载动画(默认`true``可选` */
frameLoading?: boolean;
/** 页面加载动画有两种形式一种直接采用vue内置的`transitions`动画,另一种是使用`animate.css`写进、离场动画)`可选` */
transition?: {
/**
* @description
* @see {@link https://next.router.vuejs.org/guide/advanced/transitions.html#transitions}
*/
name?: string;
/** 进场动画 */
enterTransition?: string;
/** 离场动画 */
leaveTransition?: string;
};
// 是否不添加信息到标签页,(默认`false`
hiddenTag?: boolean;
/** 动态路由可打开的最大数量 `可选` */
dynamicLevel?: number;
};
/** 子路由配置项 */
children?: Array<RouteChildrenConfigsTable>;
}
/**
* @description
* @see {@link https://yiming_chang.gitee.io/pure-admin-doc/pages/782b6e/#%E4%B8%80-%E9%85%8D%E7%BD%AE%E9%A1%B9}
*/
export interface RouteConfigsTable {
/** 路由地址 `必填` */
path: string;
/** 路由名字(保持唯一)`可选` */
name?: string;
/** `Layout`组件 `可选` */
component?: RouteComponent;
/** 路由重定向 `可选` */
redirect?: string;
meta?: {
/** 菜单名称(兼容国际化、非国际化,如何用国际化的写法就必须在根目录的`locales`文件夹下对应添加)`必填` */
title: string;
/** 菜单图标 `可选` */
icon?: string | FunctionalComponent;
/** 是否在菜单中显示(默认`true``可选` */
showLink?: boolean;
/** 菜单升序排序,值越高排的越后(只针对顶级路由)`可选` */
rank?: number;
};
/** 子路由配置项 */
children?: Array<RouteChildrenConfigsTable>;
}

View File

@ -9,8 +9,14 @@ declare global {
namespace JSX { namespace JSX {
interface Element extends VNode {} interface Element extends VNode {}
interface ElementClass extends Vue {} interface ElementClass extends Vue {}
interface ElementAttributesProperty {
$props: any;
}
interface IntrinsicElements { interface IntrinsicElements {
[elem: string]: any; [elem: string]: any;
} }
interface IntrinsicAttributes {
[elem: string]: any;
}
} }
} }