UNPKG

@uiw-admin/plugins

Version:
21 lines (20 loc) 985 B
// 模板 export default ((routeStr, iconsList, isType) => { var reactTemp = "import React from \"react\""; var iconStr = createIcons(iconsList); if (['js', 'ts'].includes(isType)) { // 1. 判断是否 已经存在 from "react" var isReact = !/\/\/(.+|)import React.+ from "react"/.test(routeStr); return "\n// @ts-nocheck\n" + (!isReact && reactTemp || '') + "\nimport {Exceptions404,Exceptions403,Exceptions500 } from \"@uiw-admin/exceptions\"\n" + iconStr + "\n" + routeStr + "; \n "; } return "\n// @ts-nocheck\nimport React from \"react\";\n" + iconStr + "\nimport {Exceptions404,Exceptions403,Exceptions500 } from \"@uiw-admin/exceptions\"\nexport default " + routeStr + ";\n"; }); // 创建 icon 图标 export var createIcons = iconsList => { var iconStr = ''; iconsList.forEach(key => { var [icon] = key.split('_'); iconStr += "import { " + icon + " as " + key + " } from \"@uiw/icons/lib/" + icon + "\";\n"; }); return iconStr; };