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

修改bug

parent d6c32192
import type { Settings as LayoutSettings } from '@ant-design/pro-layout'; import type { Settings as LayoutSettings } from '@ant-design/pro-layout';
import { setLocale } from 'umi';
import { PageLoading } from '@ant-design/pro-layout'; import { PageLoading } from '@ant-design/pro-layout';
import type { RunTimeLayoutConfig, RequestConfig } from 'umi'; import type { RunTimeLayoutConfig, RequestConfig } from 'umi';
import { history, Link, matchPath } from 'umi'; import { history, Link, matchPath } from 'umi';
...@@ -192,7 +191,6 @@ export async function getInitialState(): Promise<{ ...@@ -192,7 +191,6 @@ export async function getInitialState(): Promise<{
const fetchUserInfo = async () => { const fetchUserInfo = async () => {
try { try {
const msg = await queryCurrentUser(); const msg = await queryCurrentUser();
console.log('msgmsg', msg)
if (msg && msg.code === 200) { if (msg && msg.code === 200) {
return msg; return msg;
} else { } else {
...@@ -203,14 +201,10 @@ export async function getInitialState(): Promise<{ ...@@ -203,14 +201,10 @@ export async function getInitialState(): Promise<{
} }
return undefined; return undefined;
}; };
// 如果是登录页面,不执行 // 如果是登录页面,不执行
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) {
console.log('locale', currentUser.user.locale)
setLocale(currentUser.user.locale)
}
return { return {
fetchUserInfo, fetchUserInfo,
currentUser, currentUser,
......
import moment from 'moment'; import moment from 'moment';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import styles from './index.less'; import styles from './index.less';
import { getIntl } from 'umi'; import { useIntl } from 'umi';
export type Style1Props = { export type Style1Props = {
autoResize: boolean; autoResize: boolean;
headerText: string; headerText: string;
onHeaderClick?: () => void; onHeaderClick?: () => void;
}; };
const intl = getIntl();
const weekList = [intl.formatMessage({id:'星期日'}), intl.formatMessage({id:'星期一'}), intl.formatMessage({id:'星期二'}), intl.formatMessage({id:'星期三'}), intl.formatMessage({id:'星期四'}), intl.formatMessage({id:'星期五'}), intl.formatMessage({id:'星期六'})];
function getWeekDayString(weekDay: number) {
return weekList[weekDay];
}
const Style1: React.FC<Style1Props> = ({ autoResize, headerText, children, onHeaderClick }) => { const Style1: React.FC<Style1Props> = ({ autoResize, headerText, children, onHeaderClick }) => {
const [scaleWidth, setScaleWidth] = useState(1); const [scaleWidth, setScaleWidth] = useState(1);
const [scaleHeight, setScaleHeight] = useState(1); const [scaleHeight, setScaleHeight] = useState(1);
const [currentDate, setCurrentDate] = useState(''); const [currentDate, setCurrentDate] = useState('');
const [currentWeek, setCurrentWeek] = useState(''); const [currentWeek, setCurrentWeek] = useState('');
const [currentTime, setCurrentTime] = useState(''); const [currentTime, setCurrentTime] = useState('');
const intl = useIntl();
function getWeekDayString(weekDay: number) {
const weekList = [intl.formatMessage({id:'星期日'}), intl.formatMessage({id:'星期一'}), intl.formatMessage({id:'星期二'}), intl.formatMessage({id:'星期三'}), intl.formatMessage({id:'星期四'}), intl.formatMessage({id:'星期五'}), intl.formatMessage({id:'星期六'})];
return weekList[weekDay];
}
const resetScale = (ar: boolean) => { const resetScale = (ar: boolean) => {
if (ar === true) { if (ar === true) {
setScaleWidth(document.body.clientWidth / 1920); setScaleWidth(document.body.clientWidth / 1920);
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
} }
.leftheader { .leftheader {
width: 210px; width: 220px;
padding: 26px 0 0 50px; padding: 26px 0 0 50px;
color: #fff; color: #fff;
font-size: 21px; font-size: 21px;
......
...@@ -2,7 +2,7 @@ import moment from 'moment'; ...@@ -2,7 +2,7 @@ import moment from 'moment';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import styles from './index.less'; import styles from './index.less';
import { delay, floor } from 'lodash'; import { delay, floor } from 'lodash';
import { getIntl } from 'umi'; import { useIntl } from 'umi';
export type Style1Props = { export type Style1Props = {
autoResize: boolean; autoResize: boolean;
headerText: string; headerText: string;
...@@ -11,11 +11,6 @@ export type Style1Props = { ...@@ -11,11 +11,6 @@ export type Style1Props = {
style?: object; style?: object;
onHeaderClick?: () => void; onHeaderClick?: () => void;
}; };
const intl = getIntl();
const weekList = [intl.formatMessage({id:'星期日'}), intl.formatMessage({id:'星期一'}), intl.formatMessage({id:'星期二'}), intl.formatMessage({id:'星期三'}), intl.formatMessage({id:'星期四'}), intl.formatMessage({id:'星期五'}), intl.formatMessage({id:'星期六'})];
function getWeekDayString(weekDay: number) {
return weekList[weekDay];
}
const Style1: React.FC<Style1Props> = ({ const Style1: React.FC<Style1Props> = ({
autoResize, autoResize,
...@@ -26,6 +21,11 @@ const Style1: React.FC<Style1Props> = ({ ...@@ -26,6 +21,11 @@ const Style1: React.FC<Style1Props> = ({
children, children,
onHeaderClick, onHeaderClick,
}) => { }) => {
const intl = useIntl();
function getWeekDayString(weekDay: number) {
const weekList = [intl.formatMessage({id:'星期日'}), intl.formatMessage({id:'星期一'}), intl.formatMessage({id:'星期二'}), intl.formatMessage({id:'星期三'}), intl.formatMessage({id:'星期四'}), intl.formatMessage({id:'星期五'}), intl.formatMessage({id:'星期六'})];
return weekList[weekDay];
}
const [scaleWidth, setScaleWidth] = useState(1); const [scaleWidth, setScaleWidth] = useState(1);
const [scaleHeight, setScaleHeight] = useState(1); const [scaleHeight, setScaleHeight] = useState(1);
const [currentDate, setCurrentDate] = useState(''); const [currentDate, setCurrentDate] = useState('');
......
import moment from 'moment'; import moment from 'moment';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import styles from './index.less'; import styles from './index.less';
import { getIntl } from 'umi'; import { useIntl } from 'umi';
export type Style1Props = { export type Style1Props = {
autoResize: boolean; autoResize: boolean;
headerText: string; headerText: string;
onHeaderClick?: () => void; onHeaderClick?: () => void;
}; };
const intl = getIntl();
const weekList = [intl.formatMessage({id:'星期日'}), intl.formatMessage({id:'星期一'}), intl.formatMessage({id:'星期二'}), intl.formatMessage({id:'星期三'}), intl.formatMessage({id:'星期四'}), intl.formatMessage({id:'星期五'}), intl.formatMessage({id:'星期六'})];
function getWeekDayString(weekDay: number) {
return weekList[weekDay];
}
const Style1: React.FC<Style1Props> = ({ autoResize, headerText, children, onHeaderClick }) => { const Style1: React.FC<Style1Props> = ({ autoResize, headerText, children, onHeaderClick }) => {
const [scaleWidth, setScaleWidth] = useState(1); const [scaleWidth, setScaleWidth] = useState(1);
...@@ -19,7 +15,11 @@ const Style1: React.FC<Style1Props> = ({ autoResize, headerText, children, onHea ...@@ -19,7 +15,11 @@ const Style1: React.FC<Style1Props> = ({ autoResize, headerText, children, onHea
const [currentDate, setCurrentDate] = useState(''); const [currentDate, setCurrentDate] = useState('');
const [currentWeek, setCurrentWeek] = useState(''); const [currentWeek, setCurrentWeek] = useState('');
const [currentTime, setCurrentTime] = useState(''); const [currentTime, setCurrentTime] = useState('');
const intl = useIntl();
function getWeekDayString(weekDay: number) {
const weekList = [intl.formatMessage({id:'星期日'}), intl.formatMessage({id:'星期一'}), intl.formatMessage({id:'星期二'}), intl.formatMessage({id:'星期三'}), intl.formatMessage({id:'星期四'}), intl.formatMessage({id:'星期五'}), intl.formatMessage({id:'星期六'})];
return weekList[weekDay];
}
const resetScale = (ar: boolean) => { const resetScale = (ar: boolean) => {
if (ar === true) { if (ar === true) {
setScaleWidth(document.body.clientWidth / 3840); setScaleWidth(document.body.clientWidth / 3840);
......
...@@ -6,6 +6,8 @@ import ProForm, { ProFormText, ProFormCheckbox } from '@ant-design/pro-form'; ...@@ -6,6 +6,8 @@ import ProForm, { ProFormText, ProFormCheckbox } from '@ant-design/pro-form';
import { UserOutlined, LockOutlined, CloseCircleOutlined } from '@ant-design/icons'; import { UserOutlined, LockOutlined, CloseCircleOutlined } from '@ant-design/icons';
import Footer from '@/components/Footer'; import Footer from '@/components/Footer';
import { login } from '@/services/mgr/api'; import { login } from '@/services/mgr/api';
import { setLocale } from 'umi';
const LoginMessage: React.FC = ({ children }) => ( const LoginMessage: React.FC = ({ children }) => (
<Alert <Alert
...@@ -38,6 +40,11 @@ const Login: React.FC = () => { ...@@ -38,6 +40,11 @@ const Login: React.FC = () => {
const fetchUserInfo = async () => { const fetchUserInfo = async () => {
const resp = await initialState?.fetchUserInfo?.(); const resp = await initialState?.fetchUserInfo?.();
if (resp) { if (resp) {
if (resp.user.locale) {
console.log('locale', resp.user.locale)
setLocale(resp.user.locale, false)
}
await setInitialState((s) => ({ await setInitialState((s) => ({
...s, ...s,
currentUser: resp, currentUser: resp,
...@@ -88,12 +95,10 @@ const Login: React.FC = () => { ...@@ -88,12 +95,10 @@ const Login: React.FC = () => {
<div className={styles.content}> <div className={styles.content}>
<div className={styles.top}> <div className={styles.top}>
<div className={styles.header}> <div className={styles.header}>
<Link to="/"> <img alt="logo" className={styles.logo} src="logo.png" />
<img alt="logo" className={styles.logo} src="logo.png" /> <span className={styles.title}>
<span className={styles.title}> <FormattedMessage id="看板系统" defaultMessage="看板系统" />
<FormattedMessage id="看板系统" defaultMessage="看板系统" /> </span>
</span>
</Link>
</div> </div>
</div> </div>
<div className={styles.main}> <div className={styles.main}>
......
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