mirror of
https://github.com/sern-handler/gui
synced 2026-06-21 15:12:14 +00:00
feat: update checker, snowflakes and turkish translation
Co-authored-by: xxDeveloper <Murtatrxx@users.noreply.github.com>
This commit is contained in:
@@ -32,6 +32,7 @@ export default function LanguageSelector() {
|
||||
>
|
||||
<MenuItem value={'en'} className={'menuItems'} sx={{ fontFamily: 'Noto Color Emoji' }}>🇺🇸</MenuItem>
|
||||
<MenuItem value={'es'} className={'menuItems'} sx={{ fontFamily: 'Noto Color Emoji' }}>🇪🇸</MenuItem>
|
||||
<MenuItem value={'tr'} className={'menuItems'} sx={{ fontFamily: 'Noto Color Emoji' }}>🇹🇷</MenuItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
</div>
|
||||
|
||||
60
src/NewUpdate.tsx
Normal file
60
src/NewUpdate.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
const { shell, ipcRenderer } = window.require('electron');
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import React from 'react';
|
||||
import { Snackbar, Alert, Button, IconButton } from '@mui/material';
|
||||
import CloseIcon from '@mui/icons-material/Close';
|
||||
|
||||
const NewUpdate = () => {
|
||||
const { t } = useTranslation('translation', { keyPrefix: 'updateChecker' });
|
||||
const [updateArgs, setUpdateArgs] = useState<null | NewUpdateArgs>(null);
|
||||
const [snackbarOpen, setSnackbarOpen] = React.useState(true);
|
||||
const handleSnackbarClose = () => setSnackbarOpen(false);
|
||||
|
||||
useEffect(() => {
|
||||
ipcRenderer.send('updateAvailable');
|
||||
|
||||
ipcRenderer.on('updateAvailableResponse', (_event, args) => {
|
||||
setUpdateArgs(args);
|
||||
console.log('0gsafga')
|
||||
ipcRenderer.removeAllListeners('updateAvailableResponse');
|
||||
});
|
||||
}, []);
|
||||
|
||||
const snackbarAction = (
|
||||
<React.Fragment>
|
||||
<Button color="secondary" size="small" onClick={() => shell.openExternal(updateArgs!.url!)}>
|
||||
{t('viewRelease')}
|
||||
</Button>
|
||||
<IconButton
|
||||
size="small"
|
||||
aria-label="close"
|
||||
color="inherit"
|
||||
onClick={handleSnackbarClose}
|
||||
>
|
||||
<CloseIcon fontSize="small" />
|
||||
</IconButton>
|
||||
</React.Fragment>
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{updateArgs && (
|
||||
<div>
|
||||
<Snackbar open={snackbarOpen} autoHideDuration={5000} onClose={handleSnackbarClose} action={snackbarAction}>
|
||||
<Alert onClose={handleSnackbarClose} severity="success" sx={{ width: '100%' }} action={snackbarAction}>
|
||||
{t('updateAvailable', { version: updateArgs.version })}
|
||||
</Alert>
|
||||
</Snackbar>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default NewUpdate;
|
||||
|
||||
interface NewUpdateArgs {
|
||||
version: string;
|
||||
url: string;
|
||||
}
|
||||
6
src/SnowfallDecember.tsx
Normal file
6
src/SnowfallDecember.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import Snowfall from "react-snowfall";
|
||||
|
||||
export default function SnowfallDecember() {
|
||||
const time = new Date();
|
||||
return (time.getMonth() === 11 || (time.getMonth() === 0 && time.getDate() <= 7)) && <Snowfall speed={[1.0, 2.0]} snowflakeCount={100} />;
|
||||
}
|
||||
25
src/main.tsx
25
src/main.tsx
@@ -1,4 +1,3 @@
|
||||
import * as React from 'react';
|
||||
import * as ReactDOM from 'react-dom/client';
|
||||
import './main.css';
|
||||
import App from './App';
|
||||
@@ -6,17 +5,20 @@ import i18n from "i18next";
|
||||
import { initReactI18next } from "react-i18next";
|
||||
import enLocale from '../locales/en.json' assert { type: "json" };
|
||||
import esLocale from '../locales/es.json' assert { type: "json" };
|
||||
import trLocale from '../locales/tr.json' assert { type: "json" };
|
||||
import SnowfallDecember from './SnowfallDecember.js';
|
||||
import NewUpdate from './NewUpdate.js';
|
||||
|
||||
i18n
|
||||
.use(initReactI18next) // passes i18n down to react-i18next
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
resources: {
|
||||
en: enLocale,
|
||||
es: esLocale
|
||||
es: esLocale,
|
||||
tr: trLocale
|
||||
},
|
||||
lng: window.localStorage.getItem('lang') || 'en',
|
||||
fallbackLng: "en",
|
||||
|
||||
interpolation: {
|
||||
escapeValue: false
|
||||
}
|
||||
@@ -24,12 +26,9 @@ i18n
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root')!);
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>
|
||||
);
|
||||
|
||||
// If you want to start measuring performance in your app, pass a function
|
||||
// to log results (for example: reportWebVitals(console.log))
|
||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
||||
// reportWebVitals();
|
||||
<div>
|
||||
<SnowfallDecember />
|
||||
<NewUpdate />
|
||||
<App />
|
||||
</div>
|
||||
);
|
||||
Reference in New Issue
Block a user