Manually check for updates

This commit is contained in:
tk103331
2023-01-04 12:43:26 +08:00
parent b8614e73ff
commit c19698bc41
4 changed files with 94 additions and 3 deletions

View File

@@ -7,7 +7,10 @@
height: 48px;
}
}
.chat-info {
text-align: center;
font-weight: bold;
}
.ant-layout-sider-trigger {
user-select: none;
-webkit-user-select: none;

30
src/layout/index.tsx vendored
View File

@@ -1,12 +1,19 @@
import { FC, useState } from 'react';
import { Layout, Menu } from 'antd';
import {Layout, Menu, Button, Tooltip, message} from 'antd';
import { SyncOutlined } from '@ant-design/icons';
import { useNavigate, useLocation } from 'react-router-dom';
import { getName, getVersion } from '@tauri-apps/api/app';
import { checkUpdate, installUpdate } from '@tauri-apps/api/updater';
import { relaunch } from '@tauri-apps/api/process';
import Routes, { menuItems } from '@/routes';
import './index.scss';
const { Content, Footer, Sider } = Layout;
const appName = await getName();
const appVersion = await getVersion();
interface ChatLayoutProps {
children?: React.ReactNode;
}
@@ -16,6 +23,14 @@ const ChatLayout: FC<ChatLayoutProps> = ({ children }) => {
const location = useLocation();
const go = useNavigate();
const checkAppUpdate = async () => {
try {
await checkUpdate();
}catch (e) {
console.log(e)
}
}
return (
<Layout style={{ minHeight: '100vh' }} hasSider>
<Sider
@@ -34,6 +49,19 @@ const ChatLayout: FC<ChatLayoutProps> = ({ children }) => {
}}
>
<div className="chat-logo"><img src="/logo.png" /></div>
<div className="chat-info">
<span>{appName}</span>
</div>
<div className="chat-info">
<span>{appVersion}</span>
<span> </span>
{
<Tooltip title="click to check update">
<a onClick={checkAppUpdate}><SyncOutlined /></a>
</Tooltip>
}
</div>
<Menu
defaultSelectedKeys={[location.pathname]}
mode="inline"