yangjie #49

Merged
yangqiang merged 71 commits from yangjie into master 2025-03-10 14:21:26 +08:00
4 changed files with 55 additions and 10 deletions
Showing only changes of commit 2b4a3cdbca - Show all commits

12
main.js
View File

@ -517,6 +517,11 @@ app.on('ready', () => {
downloadUpdate() downloadUpdate()
} else if (data === '2') { // 下载完成 点击安装 } else if (data === '2') { // 下载完成 点击安装
quitAndInstall() quitAndInstall()
} else if (data === '3') { // 打开弹窗
let message = JSON.stringify({
type: '3',
})
sendUpdateMessage(message)
} }
}); });
// 选择文件夹 // 选择文件夹
@ -766,9 +771,14 @@ function updateHandle() {
autoUpdater.on('update-available', function (info) { autoUpdater.on('update-available', function (info) {
let messageStr = JSON.stringify({ type: '0' }) let messageStr = JSON.stringify({ type: '0' })
sendUpdateMessage(messageStr) sendUpdateMessage(messageStr)
mainWindow.webContents.send('changeLocalStorage', {
isUpdate: true,
});
}) })
autoUpdater.on('update-not-available', function (info) { autoUpdater.on('update-not-available', function (info) {
mainWindow.webContents.send('changeLocalStorage', {
isUpdate: false,
});
}) })
// 更新下载进度事件 // 更新下载进度事件
autoUpdater.on('download-progress', function (progressObj) { autoUpdater.on('download-progress', function (progressObj) {

View File

@ -4,7 +4,7 @@ import { getUpdateUrl } from '@/utils/package/public';
import { Button, Flex, Modal, Progress } from 'antd'; import { Button, Flex, Modal, Progress } from 'antd';
import { forwardRef, useImperativeHandle, useState, memo } from "react"; import { forwardRef, useImperativeHandle, useState, memo } from "react";
const UpdateModal = forwardRef((props: any, ref: any) => { const UpdateModal = forwardRef((_props: any, ref: any) => {
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
changeModal: (data: any) => { changeModal: (data: any) => {
try { try {
@ -30,6 +30,9 @@ const UpdateModal = forwardRef((props: any, ref: any) => {
setIsUpdateModal(true) setIsUpdateModal(true)
} }
setProgress(100) setProgress(100)
} else if (dataJson.type === '3') {
getContent()
setIsUpdateModal(true)
} }
} catch (error) { } catch (error) {
@ -51,9 +54,9 @@ const UpdateModal = forwardRef((props: any, ref: any) => {
} }
throw new Error('Network response was not ok.'); throw new Error('Network response was not ok.');
}) })
.then(textContent => { .then(_textContent => {
}) })
.catch(error => { .catch(_error => {
}); });
} }

View File

@ -120,8 +120,25 @@
@else if $i ==4 { @else if $i ==4 {
flex-shrink: 0; flex-shrink: 0;
>div:nth-child(1) {
color: #ccc; color: #ccc;
font-size: 16px; font-size: 16px;
display: flex;
justify-content: space-between;
align-items: center;
>span:nth-child(2) {
background-color: red;
padding: 2px 8px;
border-radius: 10px;
}
}
>div:nth-child(2) {
width: 100%;
margin-top: 10px;
}
} }
@else if $i ==5 { @else if $i ==5 {

View File

@ -1,7 +1,7 @@
import styles from '@/page/Home/index.module.scss' import styles from '@/page/Home/index.module.scss'
import { useEffect, useState, useRef } from "react"; import { useEffect, useState, useRef } from "react";
import { Outlet, useNavigate } from 'react-router-dom'; import { Outlet, useNavigate } from 'react-router-dom';
import { Popconfirm, Popover } from 'antd'; import { Button, Popconfirm, Popover } from 'antd';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn' import 'dayjs/locale/zh-cn'
import { storage } from '@/utils'; import { storage } from '@/utils';
@ -45,6 +45,7 @@ const Home: React.FC = () => {
]); ]);
const [userInfo, setUserInfo] = useState<any>({}) const [userInfo, setUserInfo] = useState<any>({})
const [version, setVersion] = useState<string>('') const [version, setVersion] = useState<string>('')
const [update, setUpdate] = useState(false)
const [dateInfo, setDateInfo] = useState<{ const [dateInfo, setDateInfo] = useState<{
work: string; work: string;
time: string; time: string;
@ -67,11 +68,18 @@ const Home: React.FC = () => {
}) })
}; };
const timer = setInterval(updateTime, 1000); const timer = setInterval(updateTime, 1000);
window.addEventListener('customStorageChange', handleCustomStorageChange);
return () => { return () => {
window.removeEventListener('customStorageChange', handleCustomStorageChange);
clearInterval(timer); clearInterval(timer);
}; };
}, []); }, []);
const handleCustomStorageChange = (e: any): void => {
if (e.key === 'isUpdate') {
setUpdate(e.value)
}
};
const changtNavList = (index: number, bool?: boolean): void => { const changtNavList = (index: number, bool?: boolean): void => {
const newNavList = [...navList]; const newNavList = [...navList];
if (typeof bool === 'boolean') { if (typeof bool === 'boolean') {
@ -126,9 +134,16 @@ const Home: React.FC = () => {
) )
})} })}
</div> </div>
<div className='drag'>
<div> <div>
<span>:{version}</span> <span>:{version}</span>
{/* <span>new</span> */} {update ? <span>new</span> : null}
</div>
{update ? <div>
<Button type="primary" className='m-ant-btn' style={{ width: '100%' }} onClick={() => {
window.electron.onDownload('3')
}}></Button>
</div> : null}
</div> </div>
<div> <div>
<Popover <Popover