Commit 7fa62c3f authored by wuhao's avatar wuhao 🎯

asder

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