feat: Add fullscreen mode notification with localized message

This commit is contained in:
ousugo 2025-02-25 13:11:35 +08:00 committed by 亢奋猫
parent 947b7047a0
commit 04ac04c94d
6 changed files with 30 additions and 5 deletions

View File

@ -1,6 +1,8 @@
import '@renderer/databases' import '@renderer/databases'
import store, { persistor } from '@renderer/store' import store, { persistor } from '@renderer/store'
import { useEffect } from 'react'
import { useTranslation } from 'react-i18next'
import { Provider } from 'react-redux' import { Provider } from 'react-redux'
import { HashRouter, Route, Routes } from 'react-router-dom' import { HashRouter, Route, Routes } from 'react-router-dom'
import { PersistGate } from 'redux-persist/integration/react' import { PersistGate } from 'redux-persist/integration/react'
@ -21,6 +23,24 @@ import SettingsPage from './pages/settings/SettingsPage'
import TranslatePage from './pages/translate/TranslatePage' import TranslatePage from './pages/translate/TranslatePage'
function App(): JSX.Element { function App(): JSX.Element {
const { t } = useTranslation()
useEffect(() => {
const cleanup = window.electron.ipcRenderer.on('fullscreen-status-changed', (_, isFullscreen) => {
if (isFullscreen) {
window.message.info({
content: t('common.fullscreen'),
duration: 3,
key: 'fullscreen-notification'
})
}
})
return () => {
cleanup()
}
}, [t])
return ( return (
<Provider store={store}> <Provider store={store}>
<ThemeProvider> <ThemeProvider>

View File

@ -190,7 +190,8 @@
"select": "Select", "select": "Select",
"topics": "Topics", "topics": "Topics",
"warning": "Warning", "warning": "Warning",
"you": "You" "you": "You",
"fullscreen": "Entered fullscreen mode. Press F11 to exit"
}, },
"docs": { "docs": {
"title": "Docs" "title": "Docs"

View File

@ -190,7 +190,8 @@
"select": "選択", "select": "選択",
"topics": "トピック", "topics": "トピック",
"warning": "警告", "warning": "警告",
"you": "あなた" "you": "あなた",
"fullscreen": "全画面モードに入りました。F11キーで終了します"
}, },
"docs": { "docs": {
"title": "ドキュメント" "title": "ドキュメント"

View File

@ -190,7 +190,8 @@
"select": "Выбрать", "select": "Выбрать",
"topics": "Топики", "topics": "Топики",
"warning": "Предупреждение", "warning": "Предупреждение",
"you": "Вы" "you": "Вы",
"fullscreen": "Вы вошли в полноэкранный режим. Нажмите F11 для выхода"
}, },
"docs": { "docs": {
"title": "Документация" "title": "Документация"

View File

@ -190,7 +190,8 @@
"select": "选择", "select": "选择",
"topics": "话题", "topics": "话题",
"warning": "警告", "warning": "警告",
"you": "用户" "you": "用户",
"fullscreen": "已进入全屏模式,按 F11 退出"
}, },
"docs": { "docs": {
"title": "帮助文档" "title": "帮助文档"

View File

@ -190,7 +190,8 @@
"select": "選擇", "select": "選擇",
"topics": "話題", "topics": "話題",
"warning": "警告", "warning": "警告",
"you": "您" "you": "您",
"fullscreen": "已進入全螢幕模式,按 F11 退出"
}, },
"docs": { "docs": {
"title": "幫助文件" "title": "幫助文件"