更新0.1.1版本

This commit is contained in:
Ah jung
2021-07-07 10:26:14 +08:00
parent b74b6e61a4
commit d423f27e94
174 changed files with 15966 additions and 0 deletions

42
src/utils/index.ts Normal file
View File

@@ -0,0 +1,42 @@
import { h } from 'vue';
import { NIcon } from 'naive-ui'
/**
* render 图标
* */
export function renderIcon(icon) {
return () => h(NIcon, null, { default: () => h(icon) })
}
/**
* 递归组装菜单格式
*/
export function generatorMenu(routerMap: Array<any>, parent?: object) {
return routerMap.filter(item => {
return item.meta.hidden != true && !['/:path(.*)*', '/', '/redirect', '/login'].includes(item.path)
}).map(item => {
const currentMenu = {
...item,
...item.meta,
label: item.meta.title,
key: item.name
}
// 是否有子菜单,并递归处理
if (item.children && item.children.length > 0) {
// Recursion
currentMenu.children = generatorMenu(item.children, currentMenu)
}
return currentMenu
})
}
export const withInstall = <T>(component: T, alias?: string) => {
const comp = component as any;
comp.install = (app: App) => {
app.component(comp.name || comp.displayName, component);
if (alias) {
app.config.globalProperties[alias] = component;
}
};
return component as T & Plugin;
};