Commit b50971f0 authored by 沈翠玲's avatar 沈翠玲

欢迎页自适应

parent 96011e8a
...@@ -206,7 +206,9 @@ export async function getInitialState(): Promise<{ ...@@ -206,7 +206,9 @@ export async function getInitialState(): Promise<{
// 如果是登录页面,不执行 // 如果是登录页面,不执行
if (history.location.pathname !== loginPath) { if (history.location.pathname !== loginPath) {
const currentUser = await fetchUserInfo(); const currentUser = await fetchUserInfo();
console.log('currentUser', currentUser)
if (currentUser && currentUser.user.locale) { if (currentUser && currentUser.user.locale) {
console.log('locale', currentUser.user.locale)
setLocale(currentUser.user.locale) setLocale(currentUser.user.locale)
} }
return { return {
......
...@@ -8,14 +8,15 @@ ...@@ -8,14 +8,15 @@
} }
.container { .container {
width: 100%; width: 1920px;
display: flex; display: flex;
color: #fff; color: #fff;
overflow: hidden;
position: relative; position: relative;
flex-direction: column; flex-direction: column;
transform-origin: top left; transform-origin: top left;
align-items: center; align-items: center;
height: 100%; height: 1080px;
color: white; color: white;
background: #00204c; background: #00204c;
} }
......
import React, { useState,useEffect, useCallback } from 'react'; import React, { useState,useEffect, useCallback } from 'react';
import { useIntl, useModel } from 'umi'; import { useIntl, useModel } from 'umi';
import { useHistory } from 'react-router-dom'; import { useHistory } from 'react-router-dom';
import { delay, floor } from 'lodash';
import styles from './Welcome.less'; import styles from './Welcome.less';
import { logout as outLogin } from '@/services/mgr/api'; import { logout as outLogin } from '@/services/mgr/api';
const Welcome: React.FC = () => { const Welcome: React.FC = () => {
const intl = useIntl(); const intl = useIntl();
const { initialState, setInitialState } = useModel('@@initialState'); const { initialState, setInitialState } = useModel('@@initialState');
const [kanbanList, setkanbanList] = useState([]); const [kanbanList, setkanbanList] = useState([]);
const [scaleWidth, setScaleWidth] = useState(1);
const [scaleHeight, setScaleHeight] = useState(1);
const resetScale = () => {
setScaleWidth(floor(document.body.clientWidth / 1920, 4));
setScaleHeight(floor(document.body.clientHeight / 1080, 4));
delay(
() => {
setScaleWidth(floor(document.body.clientWidth / 1920, 4));
setScaleHeight(floor(document.body.clientHeight / 1080, 4));
},
1,
20,
);
};
useEffect(() => { useEffect(() => {
if (initialState?.menuList) { if (initialState?.menuList) {
console.log('sada', initialState?.menuList)
const menuList = initialState?.menuList const menuList = initialState?.menuList
const item = menuList.find(v => v.name === 'kanban') const item = menuList.find(v => v.name === 'kanban')
if (item?.children) { if (item?.children) {
setkanbanList(item?.children) setkanbanList(item?.children)
} }
} }
document.body.onresize = () => resetScale();
resetScale()
}, []); }, []);
const history = useHistory(); const history = useHistory();
// 跳转函数 // 跳转函数
...@@ -43,7 +56,9 @@ const Welcome: React.FC = () => { ...@@ -43,7 +56,9 @@ const Welcome: React.FC = () => {
} }
}, [setInitialState]); }, [setInitialState]);
return ( return (
<div className={styles.container}> <div className={styles.container} style={{
transform: `scale(${scaleWidth},${scaleHeight})`,
}}>
<div className={styles.logout} onClick={() => loginOut()}> <div className={styles.logout} onClick={() => loginOut()}>
{intl.formatMessage({id:'退出登录'})} {intl.formatMessage({id:'退出登录'})}
</div> </div>
......
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