添加新版本提醒

This commit is contained in:
hanhh 2021-10-06 16:22:53 +08:00
parent ec529bfca6
commit a3006af7b8

View File

@ -15,7 +15,7 @@ import './index.less';
import vhCheck from 'vh-check'; import vhCheck from 'vh-check';
import { version, changeLog } from '../version'; import { version, changeLog } from '../version';
import { useCtx, useTheme } from '@/utils/hooks'; import { useCtx, useTheme } from '@/utils/hooks';
import { message } from 'antd'; import { message, Badge, Typography } from 'antd';
export default function (props: any) { export default function (props: any) {
const ctx = useCtx(); const ctx = useCtx();
@ -32,7 +32,9 @@ export default function (props: any) {
}; };
const getSystemInfo = () => { const getSystemInfo = () => {
request.get(`${config.apiPrefix}system`).then(({ code, data }) => { request
.get(`${config.apiPrefix}system`)
.then(({ code, data }) => {
if (code === 200) { if (code === 200) {
setSystemInfo(data); setSystemInfo(data);
if (!data.isInitialized) { if (!data.isInitialized) {
@ -44,15 +46,19 @@ export default function (props: any) {
} else { } else {
message.error(data); message.error(data);
} }
})
.catch((error) => {
console.log(error);
}); });
}; };
const getUser = (needLoading = true) => { const getUser = (needLoading = true) => {
needLoading && setLoading(true); needLoading && setLoading(true);
request.get(`${config.apiPrefix}user`).then(({ code, data }) => { request
.get(`${config.apiPrefix}user`)
.then(({ code, data }) => {
if (code === 200 && data.username) { if (code === 200 && data.username) {
setUser(data); setUser(data);
localStorage.setItem('isLogin', 'true');
if (props.location.pathname === '/') { if (props.location.pathname === '/') {
history.push('/crontab'); history.push('/crontab');
} }
@ -60,6 +66,9 @@ export default function (props: any) {
message.error(data); message.error(data);
} }
needLoading && setLoading(false); needLoading && setLoading(false);
})
.catch((error) => {
console.log(error);
}); });
}; };
@ -135,7 +144,29 @@ export default function (props: any) {
title={ title={
<> <>
<a href={changeLog} target="_blank" rel="noopener noreferrer"> <span
onClick={() => {
alert('yes');
}}
>
<Badge
count={'new'}
size="small"
offset={[15, 0]}
style={{
fontSize: isFirefox ? 9 : 12,
zoom: isSafari ? 0.66 : 0.8,
padding: '0 5px',
}}
>
<a
href={changeLog}
target="_blank"
rel="noopener noreferrer"
onClick={(e) => {
e.stopPropagation();
}}
>
<span <span
style={{ style={{
fontSize: isFirefox ? 9 : 12, fontSize: isFirefox ? 9 : 12,
@ -148,6 +179,8 @@ export default function (props: any) {
{version} {version}
</span> </span>
</a> </a>
</Badge>
</span>
</> </>
} }
menuItemRender={(menuItemProps: any, defaultDom: any) => { menuItemRender={(menuItemProps: any, defaultDom: any) => {