template中增加了debugPanel

This commit is contained in:
Xu Chang 2022-07-29 12:29:57 +08:00
parent 3cc18023ec
commit 2f8535fd8b
2 changed files with 44 additions and 4 deletions

View File

@ -112,7 +112,8 @@ function findLocaleFiles(json, path, name = '', buildPath, nodeEnv, platform) {
}
function listenerLocaleFiles(path, buildPath, nodeEnv, platform) {
fs.watch(path, { recursive: true }, (eventType, filename) => {
// todo linux下不支持recursive监控以后再说
fs.watch(path, process.platform !== 'linux' ? { recursive: true } : {}, (eventType, filename) => {
const fPath = Path.resolve(path, filename).replace(/\\/g, '/');
console.log('\nThe file', fPath, 'was modified!');
console.log('The type of change was:', eventType);

View File

@ -1,12 +1,15 @@
import React from 'react';
import React, { useState } from 'react';
import { Routes, Route } from 'react-router-dom';
import { Button, Drawer } from 'tdesign-react';
import { ChevronUpIcon } from 'tdesign-icons-react'
import './App.less';
import LazyLoad from './utils/lazyLoad';
const Console = LazyLoad(() => import('./template/console'));
const Frontend = LazyLoad(() => import('./template/frontend'));
const NotFound = LazyLoad(() => import('./template/notFound'));
const Message = LazyLoad(() =>import('@oak-general-business/components/message'));
const Message = LazyLoad(() => import('@oak-general-business/components/message'));
const DebugPanel = LazyLoad(() => import('@oak-general-business/components/Func/debugPanel'));
type Router = {
path: string;
@ -30,6 +33,14 @@ function getRoutes(routers2: Router[], namespace?: string) {
let routers: Router[] = [];
function App() {
const [visible, setVisible] = useState(false);
const handleClick = () => {
setVisible(true);
};
const handleClose = () => {
setVisible(false);
};
return (
<React.Fragment>
{Message}
@ -41,7 +52,35 @@ function App() {
{getRoutes(routers)}
</Route>
<Route path="*" element={NotFound} />
</Routes>
</Routes>
{
process.env.NODE_ENV === "development" && (
<React.Fragment>
<Button
variant="text"
shape="circle"
theme="primary"
icon={<ChevronUpIcon />}
style={{
position: 'absolute',
bottom: 0,
right: '45vw',
}}
onClick={handleClick}
/>
<Drawer
placement="bottom"
visible={visible}
onClose={handleClose}
header={<text>debug控制台</text>}
footer={<div/>}
>
{DebugPanel}
</Drawer>
</React.Fragment>
)
}
</React.Fragment>
);
}