前端和后端源码,合并到一个git仓库中,方便用户下载,避免前后端不匹配的问题

This commit is contained in:
JEECG
2024-06-23 10:39:52 +08:00
parent bb918b742e
commit 0325e34dcb
1439 changed files with 171106 additions and 0 deletions

View File

@ -0,0 +1,47 @@
import type { App } from 'vue';
import { warn } from '/@/utils/log';
import { registerDynamicRouter } from '/@/utils/monorepo/dynamicRouter';
// 引入模块
import PACKAGE_TEST_JEECG_ONLINE from '@jeecg/online';
export function registerPackages(app: App) {
use(app, PACKAGE_TEST_JEECG_ONLINE);
}
// noinspection JSUnusedGlobalSymbols
const installOptions = {
baseImport,
};
/** 注册模块 */
function use(app: App, pkg) {
app.use(pkg, installOptions);
registerDynamicRouter(pkg.getViews);
}
// 模块里可使用的import
const importGlobs = [import.meta.glob('../../utils/**/*.{ts,js,tsx}'), import.meta.glob('../../hooks/**/*.{ts,js,tsx}')];
/**
* 基础项目导包
* 目前支持导入如下
* /@/utils/**
* /@/hooks/**
*
* @param path 文件路径ts无需输入后缀名。如/@/utils/common/compUtils
*/
async function baseImport(path: string) {
if (path) {
// 将 /@/ 替换成 ../../
path = path.replace(/^\/@\//, '../../');
for (const glob of importGlobs) {
for (const key of Object.keys(glob)) {
if (path === key || `${path}.ts` === key || `${path}.tsx` === key) {
return glob[key]();
}
}
}
warn(`引入失败:${path} 不存在`);
}
return null;
}