2025-12-11 10:40:55 +01:00
|
|
|
/*
|
2026-01-12 15:00:36 +01:00
|
|
|
* Copyright (c) 2026 by Christian Kellner.
|
2025-12-11 10:40:55 +01:00
|
|
|
* Licensed under Apache-2.0 with Commons Clause and Attribution/Naming Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2026-03-16 10:37:36 +01:00
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { Banner, Button, Modal, Tag, Space, Typography, Descriptions, MarkdownRender } from '@douyinfe/semi-ui-19';
|
|
|
|
|
import { IconAlertCircle, IconArrowRight } from '@douyinfe/semi-icons';
|
2025-09-20 19:37:27 +02:00
|
|
|
import { useSelector } from '../../services/state/store.js';
|
|
|
|
|
|
|
|
|
|
import './VersionBanner.less';
|
2026-06-04 10:35:42 +02:00
|
|
|
import { useTranslation } from '../../services/i18n/i18n.jsx';
|
2025-09-20 19:37:27 +02:00
|
|
|
|
2026-03-16 10:37:36 +01:00
|
|
|
const { Text } = Typography;
|
|
|
|
|
|
2025-09-20 19:37:27 +02:00
|
|
|
export default function VersionBanner() {
|
2026-06-04 10:35:42 +02:00
|
|
|
const t = useTranslation();
|
2026-03-16 10:37:36 +01:00
|
|
|
const [modalVisible, setModalVisible] = useState(false);
|
2025-09-20 19:37:27 +02:00
|
|
|
const versionUpdate = useSelector((state) => state.versionUpdate.versionUpdate);
|
2026-03-16 10:37:36 +01:00
|
|
|
|
2025-09-20 19:37:27 +02:00
|
|
|
return (
|
2026-03-16 10:37:36 +01:00
|
|
|
<>
|
|
|
|
|
<Banner
|
|
|
|
|
className="versionBanner"
|
|
|
|
|
type="warning"
|
|
|
|
|
bordered
|
|
|
|
|
closeIcon={null}
|
|
|
|
|
description={
|
|
|
|
|
<div className="versionBanner__bar">
|
|
|
|
|
<Space spacing={8} align="center">
|
|
|
|
|
<IconAlertCircle size="small" />
|
|
|
|
|
<Text strong size="small">
|
2026-06-04 10:35:42 +02:00
|
|
|
{t('version.newVersionAvailable')}
|
2026-03-16 10:37:36 +01:00
|
|
|
</Text>
|
|
|
|
|
<Tag color="amber" size="small" shape="circle">
|
|
|
|
|
{versionUpdate.version}
|
|
|
|
|
</Tag>
|
|
|
|
|
<Text type="tertiary" size="small">
|
2026-06-04 10:35:42 +02:00
|
|
|
{t('version.currentLabel', { version: versionUpdate.localFredyVersion })}
|
2026-03-16 10:37:36 +01:00
|
|
|
</Text>
|
|
|
|
|
</Space>
|
|
|
|
|
<Button
|
|
|
|
|
theme="borderless"
|
|
|
|
|
size="small"
|
|
|
|
|
icon={<IconArrowRight />}
|
|
|
|
|
iconPosition="right"
|
|
|
|
|
onClick={() => setModalVisible(true)}
|
|
|
|
|
>
|
2026-06-04 10:35:42 +02:00
|
|
|
{t('version.releaseNotes')}
|
2026-03-16 10:37:36 +01:00
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<Modal
|
|
|
|
|
title={
|
|
|
|
|
<Space spacing={8} align="center">
|
|
|
|
|
<Text strong>Fredy {versionUpdate.version}</Text>
|
|
|
|
|
<Tag color="amber" size="small">
|
2026-06-04 10:35:42 +02:00
|
|
|
{t('version.newBadge')}
|
2026-03-16 10:37:36 +01:00
|
|
|
</Tag>
|
|
|
|
|
</Space>
|
|
|
|
|
}
|
|
|
|
|
visible={modalVisible}
|
|
|
|
|
onCancel={() => setModalVisible(false)}
|
|
|
|
|
width={640}
|
|
|
|
|
footer={
|
|
|
|
|
<Space>
|
2026-06-04 10:35:42 +02:00
|
|
|
<Button onClick={() => setModalVisible(false)}>{t('version.modalClose')}</Button>
|
2026-03-16 10:37:36 +01:00
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
icon={<IconArrowRight />}
|
|
|
|
|
iconPosition="right"
|
|
|
|
|
onClick={() => window.open(versionUpdate.url, '_blank')}
|
|
|
|
|
>
|
2026-06-04 10:35:42 +02:00
|
|
|
{t('version.viewOnGithub')}
|
2026-03-16 10:37:36 +01:00
|
|
|
</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<Descriptions row size="small" className="versionBanner__details">
|
2026-06-04 10:35:42 +02:00
|
|
|
<Descriptions.Item itemKey={t('version.yourVersion')}>{versionUpdate.localFredyVersion}</Descriptions.Item>
|
|
|
|
|
<Descriptions.Item itemKey={t('version.latestVersion')}>{versionUpdate.version}</Descriptions.Item>
|
2026-03-16 10:37:36 +01:00
|
|
|
</Descriptions>
|
|
|
|
|
<div className="versionBanner__notes">
|
2025-09-29 20:36:56 +02:00
|
|
|
<MarkdownRender raw={versionUpdate.body} />
|
2025-09-20 19:37:27 +02:00
|
|
|
</div>
|
2026-03-16 10:37:36 +01:00
|
|
|
</Modal>
|
|
|
|
|
</>
|
2025-09-20 19:37:27 +02:00
|
|
|
);
|
|
|
|
|
}
|