feat: 初始化项目结构并添加核心功能模块
- 新增文档模板和导航结构 - 实现服务器基础API路由和控制器 - 添加扩展插件配置和前端框架 - 引入多租户和权限管理模块 - 集成日志和数据库配置 - 添加核心业务模型和类型定义
This commit is contained in:
88
dashboard/.umi/testBrowser.tsx
Normal file
88
dashboard/.umi/testBrowser.tsx
Normal file
@@ -0,0 +1,88 @@
|
||||
// @ts-nocheck
|
||||
// This file is generated by Umi automatically
|
||||
// DO NOT CHANGE IT MANUALLY!
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { ApplyPluginsType } from 'umi';
|
||||
import { renderClient, RenderClientOpts } from 'D:/trae_projects/makemd/makemd/dashboard/node_modules/@umijs/renderer-react';
|
||||
import { createHistory } from './core/history';
|
||||
import { createPluginManager } from './core/plugin';
|
||||
import { getRoutes } from './core/route';
|
||||
import type { Location } from 'history';
|
||||
|
||||
|
||||
|
||||
const publicPath = '/';
|
||||
const runtimePublicPath = false;
|
||||
|
||||
type TestBrowserProps = {
|
||||
location?: Partial<Location>;
|
||||
historyRef?: React.MutableRefObject<Location>;
|
||||
};
|
||||
|
||||
export function TestBrowser(props: TestBrowserProps) {
|
||||
const pluginManager = createPluginManager();
|
||||
const [context, setContext] = useState<RenderClientOpts | undefined>(
|
||||
undefined
|
||||
);
|
||||
useEffect(() => {
|
||||
const genContext = async () => {
|
||||
const { routes, routeComponents } = await getRoutes(pluginManager);
|
||||
// allow user to extend routes
|
||||
await pluginManager.applyPlugins({
|
||||
key: 'patchRoutes',
|
||||
type: ApplyPluginsType.event,
|
||||
args: {
|
||||
routes,
|
||||
routeComponents,
|
||||
},
|
||||
});
|
||||
const contextOpts = pluginManager.applyPlugins({
|
||||
key: 'modifyContextOpts',
|
||||
type: ApplyPluginsType.modify,
|
||||
initialValue: {},
|
||||
});
|
||||
const basename = contextOpts.basename || '/';
|
||||
const history = createHistory({
|
||||
type: 'memory',
|
||||
basename,
|
||||
});
|
||||
const context = {
|
||||
routes,
|
||||
routeComponents,
|
||||
pluginManager,
|
||||
rootElement: contextOpts.rootElement || document.getElementById('root'),
|
||||
publicPath,
|
||||
runtimePublicPath,
|
||||
history,
|
||||
basename,
|
||||
components: true,
|
||||
};
|
||||
const modifiedContext = pluginManager.applyPlugins({
|
||||
key: 'modifyClientRenderOpts',
|
||||
type: ApplyPluginsType.modify,
|
||||
initialValue: context,
|
||||
});
|
||||
return modifiedContext;
|
||||
};
|
||||
genContext().then((context) => {
|
||||
setContext(context);
|
||||
if (props.location) {
|
||||
context?.history?.push(props.location);
|
||||
}
|
||||
if (props.historyRef) {
|
||||
props.historyRef.current = context?.history;
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
if (context === undefined) {
|
||||
return <div id="loading" />;
|
||||
}
|
||||
|
||||
const Children = renderClient(context);
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Children />
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user