diff --git a/public/locales/ar-AR/dashboard.json b/public/locales/ar-AR/dashboard.json index 60056924..ddc72564 100644 --- a/public/locales/ar-AR/dashboard.json +++ b/public/locales/ar-AR/dashboard.json @@ -266,6 +266,8 @@ "fileIdVar": "معرف الملف", "userIdVar": "معرف المستخدم، يكون فارغًا في حالة عدم تسجيل الدخول.", "userDisplayNameVar": "اسم عرض المستخدم المرمز كعنوان URL.", + "themeVar": "السمة الحالية، \"light\" أو \"dark\".", + "darkVar": "ما إذا كانت السمة الداكنة مفعّلة، \"1\" أو \"0\".", "fileViewers": "تطبيقات الملفات", "viewerList": "قائمة التطبيقات", "defaultViewerApps": "التطبيقات الافتراضية", diff --git a/public/locales/de-DE/dashboard.json b/public/locales/de-DE/dashboard.json index a99f5e61..ba162936 100644 --- a/public/locales/de-DE/dashboard.json +++ b/public/locales/de-DE/dashboard.json @@ -267,6 +267,8 @@ "fileIdVar": "Datei-ID", "userIdVar": "Benutzer-ID, leer wenn nicht angemeldet.", "userDisplayNameVar": "URL-kodierter Benutzer-Anzeigename.", + "themeVar": "Aktuelles Design, \"light\" oder \"dark\".", + "darkVar": "Ob das dunkle Design aktiv ist, \"1\" oder \"0\".", "fileViewers": "Dateianwendungen", "viewerList": "Anwendungsliste", "defaultViewerApps": "Standardanwendungen", diff --git a/public/locales/en-US/dashboard.json b/public/locales/en-US/dashboard.json index 073473b7..b8028538 100644 --- a/public/locales/en-US/dashboard.json +++ b/public/locales/en-US/dashboard.json @@ -266,6 +266,8 @@ "fileIdVar": "File ID", "userIdVar": "User ID, empty when not logged in.", "userDisplayNameVar": "URL-encoded user display name.", + "themeVar": "Current theme, \"light\" or \"dark\".", + "darkVar": "Whether dark theme is active, \"1\" or \"0\".", "fileViewers": "File applications", "viewerList": "Application list", "defaultViewerApps": "Default applications", diff --git a/public/locales/es-ES/dashboard.json b/public/locales/es-ES/dashboard.json index 99543791..9fe60778 100644 --- a/public/locales/es-ES/dashboard.json +++ b/public/locales/es-ES/dashboard.json @@ -267,6 +267,8 @@ "fileIdVar": "ID de Archivo", "userIdVar": "ID de Usuario, vacío cuando no está conectado.", "userDisplayNameVar": "Nombre para mostrar del usuario codificado en URL.", + "themeVar": "Tema actual, \"light\" o \"dark\".", + "darkVar": "Si el tema oscuro está activo, \"1\" o \"0\".", "fileViewers": "Aplicaciones de archivos", "viewerList": "Lista de aplicaciones", "defaultViewerApps": "Aplicaciones predeterminadas", diff --git a/public/locales/fr-FR/dashboard.json b/public/locales/fr-FR/dashboard.json index 2e2c9938..856e1aff 100644 --- a/public/locales/fr-FR/dashboard.json +++ b/public/locales/fr-FR/dashboard.json @@ -267,6 +267,8 @@ "fileIdVar": "ID de fichier", "userIdVar": "ID utilisateur, vide lorsque non connecté.", "userDisplayNameVar": "Nom d'affichage utilisateur encodé en URL.", + "themeVar": "Thème actuel, \"light\" ou \"dark\".", + "darkVar": "Indique si le thème sombre est actif, \"1\" ou \"0\".", "fileViewers": "Applications de fichier", "viewerList": "Liste des applications", "defaultViewerApps": "Applications par défaut", diff --git a/public/locales/it-IT/dashboard.json b/public/locales/it-IT/dashboard.json index 8e0615fb..30f3d1e0 100644 --- a/public/locales/it-IT/dashboard.json +++ b/public/locales/it-IT/dashboard.json @@ -267,6 +267,8 @@ "fileIdVar": "ID File", "userIdVar": "ID Utente, vuoto quando non loggato.", "userDisplayNameVar": "Nome visualizzazione utente codificato URL.", + "themeVar": "Tema corrente, \"light\" o \"dark\".", + "darkVar": "Se il tema scuro è attivo, \"1\" o \"0\".", "fileViewers": "Applicazioni file", "viewerList": "Elenco applicazioni", "defaultViewerApps": "Applicazioni predefinite", diff --git a/public/locales/ja-JP/dashboard.json b/public/locales/ja-JP/dashboard.json index 7e48a63d..7e813701 100644 --- a/public/locales/ja-JP/dashboard.json +++ b/public/locales/ja-JP/dashboard.json @@ -266,6 +266,8 @@ "fileIdVar": "ファイルID", "userIdVar": "ユーザーID(ログインしていない場合は空欄です)。", "userDisplayNameVar": "URLエンコード済みのユーザーニックネーム", + "themeVar": "現在のテーマ(\"light\" または \"dark\")", + "darkVar": "ダークテーマが有効かどうか(\"1\" または \"0\")", "fileViewers": "ファイル閲覧アプリ", "viewerList": "アプリ一覧", "defaultViewerApps": "デフォルトアプリ", diff --git a/public/locales/ko-KR/dashboard.json b/public/locales/ko-KR/dashboard.json index 6ca7123f..a3c76b09 100644 --- a/public/locales/ko-KR/dashboard.json +++ b/public/locales/ko-KR/dashboard.json @@ -266,6 +266,8 @@ "fileIdVar": "파일 ID", "userIdVar": "사용자 ID, 로그인하지 않은 경우 비어있음", "userDisplayNameVar": "URL 인코딩된 사용자 닉네임", + "themeVar": "현재 테마, \"light\" 또는 \"dark\"", + "darkVar": "다크 테마 활성화 여부, \"1\" 또는 \"0\"", "fileViewers": "파일 브라우저 애플리케이션", "viewerList": "애플리케이션 목록", "defaultViewerApps": "기본 열기 방식", diff --git a/public/locales/pl-PL/dashboard.json b/public/locales/pl-PL/dashboard.json index 7b8ad4d0..6a6e246a 100644 --- a/public/locales/pl-PL/dashboard.json +++ b/public/locales/pl-PL/dashboard.json @@ -266,6 +266,8 @@ "fileIdVar": "ID pliku", "userIdVar": "ID użytkownika, puste gdy nie jest zalogowany.", "userDisplayNameVar": "Zakodowana w URL wyświetlana nazwa użytkownika.", + "themeVar": "Bieżący motyw, \"light\" lub \"dark\".", + "darkVar": "Czy ciemny motyw jest aktywny, \"1\" lub \"0\".", "fileViewers": "Aplikacje plików", "viewerList": "Lista aplikacji", "defaultViewerApps": "Domyślne aplikacje", diff --git a/public/locales/pt-BR/dashboard.json b/public/locales/pt-BR/dashboard.json index 4b5245be..f998a5d0 100644 --- a/public/locales/pt-BR/dashboard.json +++ b/public/locales/pt-BR/dashboard.json @@ -267,6 +267,8 @@ "fileIdVar": "ID do arquivo", "userIdVar": "ID do usuário, vazio quando não logado.", "userDisplayNameVar": "Nome de exibição do usuário codificado em URL.", + "themeVar": "Tema atual, \"light\" ou \"dark\".", + "darkVar": "Se o tema escuro está ativo, \"1\" ou \"0\".", "fileViewers": "Aplicações de arquivo", "viewerList": "Lista de aplicações", "defaultViewerApps": "Aplicações padrão", diff --git a/public/locales/ru-RU/dashboard.json b/public/locales/ru-RU/dashboard.json index b3a58181..847796e6 100644 --- a/public/locales/ru-RU/dashboard.json +++ b/public/locales/ru-RU/dashboard.json @@ -267,6 +267,8 @@ "fileIdVar": "ID файла", "userIdVar": "ID пользователя, пустой при отсутствии входа в систему.", "userDisplayNameVar": "URL-кодированное отображаемое имя пользователя.", + "themeVar": "Текущая тема, \"light\" или \"dark\".", + "darkVar": "Активна ли тёмная тема, \"1\" или \"0\".", "fileViewers": "Файловые приложения", "viewerList": "Список приложений", "defaultViewerApps": "Приложения по умолчанию", diff --git a/public/locales/zh-CN/dashboard.json b/public/locales/zh-CN/dashboard.json index 6d02fa63..8e8a18cf 100644 --- a/public/locales/zh-CN/dashboard.json +++ b/public/locales/zh-CN/dashboard.json @@ -266,6 +266,8 @@ "fileIdVar": "文件 ID", "userIdVar": "用户 ID,未登录时为空", "userDisplayNameVar": "经过 URL 编码后的用户昵称", + "themeVar": "当前主题,\"light\" 或 \"dark\"", + "darkVar": "是否为深色主题,\"1\" 或 \"0\"", "fileViewers": "文件浏览应用", "viewerList": "应用列表", "defaultViewerApps": "默认打开方式", diff --git a/public/locales/zh-TW/dashboard.json b/public/locales/zh-TW/dashboard.json index 3e7e436a..b7d58c50 100644 --- a/public/locales/zh-TW/dashboard.json +++ b/public/locales/zh-TW/dashboard.json @@ -266,6 +266,8 @@ "fileIdVar": "檔案 ID", "userIdVar": "使用者 ID,未登入時為空。", "userDisplayNameVar": "經過 URL 編碼後的使用者暱稱。", + "themeVar": "目前主題,\"light\" 或 \"dark\"。", + "darkVar": "是否為深色主題,\"1\" 或 \"0\"。", "fileViewers": "檔案瀏覽應用", "viewerList": "應用列表", "defaultViewerApps": "預設開啟方式", diff --git a/src/component/Admin/FileSystem/ViewerSetting/FileViewerEditDialog.tsx b/src/component/Admin/FileSystem/ViewerSetting/FileViewerEditDialog.tsx index d6f30e23..beab4f48 100644 --- a/src/component/Admin/FileSystem/ViewerSetting/FileViewerEditDialog.tsx +++ b/src/component/Admin/FileSystem/ViewerSetting/FileViewerEditDialog.tsx @@ -93,6 +93,16 @@ const magicVars: MagicVar[] = [ value: "settings.userDisplayNameVar", example: "Aaron%20Liu", }, + { + name: "{$theme}", + value: "settings.themeVar", + example: "dark", + }, + { + name: "{$dark}", + value: "settings.darkVar", + example: "1", + }, ]; const DND_TYPE = "template-row"; diff --git a/src/redux/thunks/viewer.ts b/src/redux/thunks/viewer.ts index f652536b..4ecd68d4 100644 --- a/src/redux/thunks/viewer.ts +++ b/src/redux/thunks/viewer.ts @@ -289,7 +289,7 @@ export function openViewer( } export function openCustomViewer(file: FileResponse, viewer: Viewer, preferredVersion?: string): AppThunk { - return async (dispatch, _getState) => { + return async (dispatch, getState) => { const entityUrl = await longRunningTaskWithSnackbar( dispatch( getFileEntityUrl({ @@ -303,6 +303,14 @@ export function openCustomViewer(file: FileResponse, viewer: Viewer, preferredVe const currentUser = SessionManager.currentUser(); + // Mirrors the fallback in useGeneratedTheme (App.tsx): explicit user + // preference wins, otherwise fall back to the OS/browser preference. + const darkModePreference = getState().globalState.darkMode; + const isDarkMode = + darkModePreference === undefined + ? window.matchMedia?.("(prefers-color-scheme: dark)").matches + : darkModePreference; + const vars: { [key: string]: string } = { src: encodeURIComponent(entityUrl.urls[0].url), src_raw: entityUrl.urls[0].url, @@ -312,6 +320,8 @@ export function openCustomViewer(file: FileResponse, viewer: Viewer, preferredVe id: file.id, user_id: currentUser?.id ?? "", user_display_name: encodeURIComponent(currentUser?.nickname ?? ""), + theme: isDarkMode ? "dark" : "light", + dark: isDarkMode ? "1" : "0", }; // replace variables in viewer.url