Commit 7fa62c3f authored by wuhao's avatar wuhao 🎯

asder

parent c7729c19
......@@ -8,12 +8,9 @@ import TagView from '@/components/TagView';
import SiderMenu from '@/components/SiderMenu';
import * as Ant4Icons from '@ant-design/icons';
import { createElement } from 'react';
import routes from '../config/authRoutes';
const { LinkOutlined } = Ant4Icons;
// const isDev = process.env.NODE_ENV === 'development';
const isDev = false;
//console.log(isDev);
const isDev = process.env.NODE_ENV === 'development';
const loginPath = '/user/login';
/**
......@@ -35,7 +32,7 @@ export async function getInitialState() {
const msg = await queryCurrentUser();
return msg.data;
} catch (error) {
// history.push(loginPath);
history.push(loginPath);
}
return undefined;
}; // 如果是登录页面,不执行
......@@ -48,23 +45,14 @@ export async function getInitialState() {
message.error(res.msg);
}
return undefined;
};
// 如果是登录页面,不执行
}; // 如果是登录页面,不执行
if (history.location.pathname !== loginPath && token) {
const currentUserData = await fetchUserInfo();
let menuData;
if (currentUserData?.data?.username) {
menuData = await getmenuData();
}
/* isdev */
if (isDev) {
menuData = {
recentUsePermList: [],
collectPerm: [],
userHavePermList: routes,
};
}
return {
fetchUserInfo,
currentUser: currentUserData?.data,
......@@ -74,23 +62,12 @@ export async function getInitialState() {
collapsed: false,
};
}
let menuData = {};
if (isDev) {
menuData = {
recentUsePermList: [],
collectPerm: [],
userHavePermList: routes,
};
}
return {
fetchUserInfo,
settings: defaultSettings,
getmenuData,
collapsed: false,
tagList: [],
newMenu: menuData,
};
}
......@@ -98,18 +75,6 @@ export async function getInitialState() {
export const layout = ({ initialState, setInitialState }) => {
let token = localStorage.getItem('TOKENES');
let menurender = isDev
? {}
: {
menuRender: (props, defaultDom) => {
if (props.isMobile) {
return defaultDom;
} else {
return <SiderMenu {...props} />;
}
},
};
return {
disableContentMargin: false,
waterMarkProps: {
......@@ -123,16 +88,16 @@ export const layout = ({ initialState, setInitialState }) => {
onPageChange: () => {
const { location } = history;
// 如果没有登录,重定向到 login
// if (!initialState?.currentUser && location.pathname !== loginPath) {
// history.push(loginPath);
// }
if (!initialState?.currentUser && location.pathname !== loginPath) {
history.push(loginPath);
}
},
links: isDev
? [
// <Link key="openapi" to="/umi/plugin/openapi" target="_blank">
// <LinkOutlined />
// <span>OpenAPI 文档</span>
// </Link>,
<Link key="openapi" to="/umi/plugin/openapi" target="_blank">
<LinkOutlined />
<span>OpenAPI 文档</span>
</Link>,
]
: [],
//接口获取菜单数据
......@@ -142,26 +107,25 @@ export const layout = ({ initialState, setInitialState }) => {
userId: initialState?.currentUser?.id,
},
request: (params, defaultMenuData) => {
//console.log(initialState);
let lastArr = initialState?.newMenu?.userHavePermList
? JSON.parse(JSON.stringify(initialState?.newMenu?.userHavePermList))
: [];
// newArr = [
// // {
// // path: '/welcome',
// // name: '首页',
// // icon: 'smile',
// // component: './Welcome',
// // haveChildren: false,
// // key: '000000',
// // parentKey: '0',
// // routes: [],
// // children: null,
// // title: null,
// // },
// ].concat(lastArr);
: [],
newArr = [
{
path: '/welcome',
name: '首页',
icon: 'smile',
component: './Welcome',
haveChildren: false,
key: '000000',
parentKey: '0',
routes: [],
children: null,
title: null,
},
].concat(lastArr);
return lastArr.map((item, index) => {
return newArr.map((item, index) => {
if (item.icon) {
const icon = strToHump(item.icon),
ItemIcon = Ant4Icons[icon];
......@@ -172,7 +136,13 @@ export const layout = ({ initialState, setInitialState }) => {
},
locale: false,
},
...menurender,
menuRender: (props, defaultDom) => {
if (props.isMobile) {
return defaultDom;
} else {
return <SiderMenu {...props} />;
}
},
// 自定义 403 页面
unAccessible: <div>unAccessible</div>,
noFound: <div>noFound</div>,
......
......@@ -13,7 +13,6 @@ function DrawerPro(props) {
fields: props.fields,
detailData: props.detailData,
};
return (
<Drawer
maskClosable={false}
......
......@@ -83,7 +83,8 @@ let FormRender = memo(({ fields = [], colProps, proformRef }) => {
);
});
function InitForm({
function InitForm(props) {
let {
formRef,
onFinish = (vals) => {
//console.log(vals);
......@@ -100,7 +101,9 @@ function InitForm({
onValuesChange = (changedValues, allValues) => {
//console.log(changedValues, allValues);
},
}) {
} = props;
console.log(props);
let proformRef = useRef();
proformRef = formRef ?? proformRef;
return (
......
......@@ -141,7 +141,7 @@ function SiderMenu({ logo, collapsed, onCollapse, fixSiderbar, theme, isMobile,
const collectList = useMemo(() => {
return collectPerm.map((item, i) => {
const icon = item.icon ?? strToHump(item.icon),
const icon = item.icon ? strToHump(item.icon) : 'ToolOutlined',
ItemIcon = icon ? Ant4Icons[icon] : Ant4Icons.ToolOutlined;
return {
key: item.path,
......@@ -316,7 +316,7 @@ function SiderMenu({ logo, collapsed, onCollapse, fixSiderbar, theme, isMobile,
<div className={styles.column}>
{getMenuData &&
filterMenu(getMenuData, search).map((item, i) => {
const icon = item.icon ?? strToHump(item.icon),
const icon = item.icon ? strToHump(item.icon) : 'ToolOutlined',
ItemIcon = icon ? Ant4Icons[icon] : Ant4Icons['ToolOutlined'];
return (
<div className={styles.item} key={i}>
......@@ -341,7 +341,7 @@ function SiderMenu({ logo, collapsed, onCollapse, fixSiderbar, theme, isMobile,
<div className={styles.rt}>
{getMenuData &&
getMenuData.map((item, i) => {
const icon = item.icon ?? strToHump(item.icon),
const icon = item.icon ? strToHump(item.icon) : 'ToolOutlined',
ItemIcon = icon ? Ant4Icons[icon] : Ant4Icons['ToolOutlined'];
return (
<p
......
......@@ -444,5 +444,23 @@ ol {
overflow: hidden !important;
> div {
height: 100%;
min-height: calc(100vh - 96px);
> div {
height: 100%;
}
}
.ant-drawer-content {
height: 100% !important;
}
}
// 横向滚动条
.scrollHoriz {
> div {
display: flex !important;
flex-wrap: nowrap !important;
align-items: center !important;
> div {
flex-shrink: 0 !important;
}
}
}
......@@ -2178,6 +2178,9 @@ function Model(props) {
}));
}}
{...drawer}
colProps={{
span: 8,
}}
>
{selectMoreDrawerType(drawer?.type)}
</DrawerPro>
......@@ -2192,6 +2195,9 @@ function Model(props) {
}));
}}
{...currDrawer}
colProps={{
span: 8,
}}
>
<ProDescriptions
title="设备信息"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment