From 8811d3b67923fd69563d81a7bb627e3ef8a95720 Mon Sep 17 00:00:00 2001 From: ousugo Date: Tue, 25 Feb 2025 13:11:35 +0800 Subject: [PATCH] feat: Add fullscreen mode notification with localized message --- src/renderer/src/App.tsx | 20 ++++++++++++++++++++ src/renderer/src/i18n/locales/en-us.json | 3 ++- src/renderer/src/i18n/locales/ja-jp.json | 3 ++- src/renderer/src/i18n/locales/ru-ru.json | 3 ++- src/renderer/src/i18n/locales/zh-cn.json | 3 ++- src/renderer/src/i18n/locales/zh-tw.json | 3 ++- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 84d877c658..b4c366272c 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -1,6 +1,8 @@ import '@renderer/databases' import store, { persistor } from '@renderer/store' +import { useEffect } from 'react' +import { useTranslation } from 'react-i18next' import { Provider } from 'react-redux' import { HashRouter, Route, Routes } from 'react-router-dom' import { PersistGate } from 'redux-persist/integration/react' @@ -21,6 +23,24 @@ import SettingsPage from './pages/settings/SettingsPage' import TranslatePage from './pages/translate/TranslatePage' 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 ( diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index 1feec72e8f..1fb6fdac0c 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -190,7 +190,8 @@ "select": "Select", "topics": "Topics", "warning": "Warning", - "you": "You" + "you": "You", + "fullscreen": "Entered fullscreen mode. Press F11 to exit" }, "docs": { "title": "Docs" diff --git a/src/renderer/src/i18n/locales/ja-jp.json b/src/renderer/src/i18n/locales/ja-jp.json index dbc480b4db..0e45993a41 100644 --- a/src/renderer/src/i18n/locales/ja-jp.json +++ b/src/renderer/src/i18n/locales/ja-jp.json @@ -190,7 +190,8 @@ "select": "選択", "topics": "トピック", "warning": "警告", - "you": "あなた" + "you": "あなた", + "fullscreen": "全画面モードに入りました。F11キーで終了します" }, "docs": { "title": "ドキュメント" diff --git a/src/renderer/src/i18n/locales/ru-ru.json b/src/renderer/src/i18n/locales/ru-ru.json index 520e0ace94..9396cf7c0e 100644 --- a/src/renderer/src/i18n/locales/ru-ru.json +++ b/src/renderer/src/i18n/locales/ru-ru.json @@ -190,7 +190,8 @@ "select": "Выбрать", "topics": "Топики", "warning": "Предупреждение", - "you": "Вы" + "you": "Вы", + "fullscreen": "Вы вошли в полноэкранный режим. Нажмите F11 для выхода" }, "docs": { "title": "Документация" diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index ac85fcd898..75a29f4bd4 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -190,7 +190,8 @@ "select": "选择", "topics": "话题", "warning": "警告", - "you": "用户" + "you": "用户", + "fullscreen": "已进入全屏模式,按 F11 退出" }, "docs": { "title": "帮助文档" diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index 78c7234aec..f97c10f084 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -190,7 +190,8 @@ "select": "選擇", "topics": "話題", "warning": "警告", - "you": "您" + "you": "您", + "fullscreen": "已進入全螢幕模式,按 F11 退出" }, "docs": { "title": "幫助文件"