From dd114ee9825e4d89ffec00885013fc33270139b2 Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Fri, 30 May 2025 01:33:57 +0300 Subject: [PATCH] [common] refactoring --- apps/common/main/lib/controller/Themes.js | 11 ++++------- apps/common/main/lib/util/htmlutils.js | 6 +----- apps/common/main/lib/util/themeinit.js | 5 ++++- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/apps/common/main/lib/controller/Themes.js b/apps/common/main/lib/controller/Themes.js index b0bef13e25..7d6e143836 100644 --- a/apps/common/main/lib/controller/Themes.js +++ b/apps/common/main/lib/controller/Themes.js @@ -186,9 +186,6 @@ define([ }, } - var id_default_light_theme = 'theme-white', - id_default_dark_theme = 'theme-dark'; - var name_colors = [ "toolbar-header-document", "toolbar-header-spreadsheet", @@ -514,7 +511,7 @@ define([ } const get_system_default_theme = function () { const id = get_system_theme_type() == THEME_TYPE_DARK ? - id_default_dark_theme : id_default_light_theme; + window.uitheme.DEFAULT_DARK_THEME_ID : window.uitheme.DEFAULT_LIGHT_THEME_ID; return {id: id, info: themes_map[id]}; }; @@ -677,7 +674,7 @@ define([ }, currentThemeId: function () { - return !!themes_map[window.uitheme.id] ? window.uitheme.id : id_default_light_theme; + return !!themes_map[window.uitheme.id] ? window.uitheme.id : window.uitheme.DEFAULT_LIGHT_THEME_ID; }, currentThemeColor: function (token) { @@ -685,7 +682,7 @@ define([ }, defaultThemeId: function (type) { - return type == 'dark' ? id_default_dark_theme : id_default_light_theme; + return type == 'dark' ? window.uitheme.DEFAULT_LIGHT_THEME_ID : window.uitheme.DEFAULT_LIGHT_THEME_ID; }, defaultTheme: function (type) { @@ -747,7 +744,7 @@ define([ }, toggleTheme: function () { - this.setTheme( this.isDarkTheme() ? id_default_light_theme : id_default_dark_theme ); + // this.setTheme( this.isDarkTheme() ? id_default_light_theme : id_default_dark_theme ); }, getThemeColors: function() { diff --git a/apps/common/main/lib/util/htmlutils.js b/apps/common/main/lib/util/htmlutils.js index 4b6c5184f3..bd816bc6dc 100644 --- a/apps/common/main/lib/util/htmlutils.js +++ b/apps/common/main/lib/util/htmlutils.js @@ -167,11 +167,7 @@ if ( !window.uitheme.id && !!params.uitheme ) { } if ( !window.uitheme.id ) { - // TODO: because there are no new dark theme, default theme is "theme-white" - // for all system color scheme - // window.uitheme.adapt_to_system_theme(); - window.uitheme.id = "theme-white"; - window.uitheme.type = "light"; + window.uitheme.adapt_to_system_theme(); } else { !window.uitheme.type && params.uitheme && (window.uitheme.type = params.uithemetype); } diff --git a/apps/common/main/lib/util/themeinit.js b/apps/common/main/lib/util/themeinit.js index 608b78489d..5509ad720e 100644 --- a/apps/common/main/lib/util/themeinit.js +++ b/apps/common/main/lib/util/themeinit.js @@ -46,6 +46,9 @@ !window.uitheme && (window.uitheme = {}); + window.uitheme.DEFAULT_LIGHT_THEME_ID = 'theme-white'; + window.uitheme.DEFAULT_DARK_THEME_ID = 'theme-night'; + window.uitheme.set_id = function (id) { if ( id == 'theme-system' ) this.adapt_to_system_theme(); @@ -63,7 +66,7 @@ window.uitheme.relevant_theme_id = function () { if ( this.is_theme_system() ) - return this.is_system_theme_dark() ? 'theme-night' : 'theme-white'; + return this.is_system_theme_dark() ? window.uitheme.DEFAULT_DARK_THEME_ID : window.uitheme.DEFAULT_LIGHT_THEME_ID; return this.id; }