From e0d7ecd92b4711b37e43bc9aa097515d8e891fa0 Mon Sep 17 00:00:00 2001 From: tiejiaxiaobao <2922035952@qq.com> Date: Tue, 12 Mar 2024 16:31:13 +0800 Subject: [PATCH 1/9] add system-config theme params --- web-app/src/assets/i18n/en-US.json | 1 + web-app/src/assets/i18n/zh-CN.json | 4 ++++ web-app/src/assets/i18n/zh-TW.json | 1 + 3 files changed, 6 insertions(+) diff --git a/web-app/src/assets/i18n/en-US.json b/web-app/src/assets/i18n/en-US.json index 7129e142170..d13b75cf596 100644 --- a/web-app/src/assets/i18n/en-US.json +++ b/web-app/src/assets/i18n/en-US.json @@ -528,6 +528,7 @@ "settings.system-config.locale.zh_TW": "Traditional Chinese(zh_TW)", "settings.system-config.locale.en_US": "English(en_US)", "settings.system-config.timezone": "System Time Zone", + "settings.system-config.theme": "System Theme", "settings.system-config.ok": "Confirm Update", "settings.object-store": "File Server Configuration", "settings.object-store.type": "File Server Provider", diff --git a/web-app/src/assets/i18n/zh-CN.json b/web-app/src/assets/i18n/zh-CN.json index 7e3043a2ff6..73e12080544 100644 --- a/web-app/src/assets/i18n/zh-CN.json +++ b/web-app/src/assets/i18n/zh-CN.json @@ -527,6 +527,10 @@ "settings.system-config.locale.zh_TW": "繁体中文(zh_TW)", "settings.system-config.locale.en_US": "英语(en_US)", "settings.system-config.timezone": "系统时区", + "settings.system-config.theme": "系统主题", + "settings.system-config.theme.default": "浅色主题", + "settings.system-config.theme.dark": "深色主题", + "settings.system-config.theme.compact": "紧凑主题", "settings.system-config.ok": "确认更新", "settings.object-store": "文件服务配置", "settings.object-store.type": "文件服务提供商", diff --git a/web-app/src/assets/i18n/zh-TW.json b/web-app/src/assets/i18n/zh-TW.json index d9e8835e891..18bb4593486 100644 --- a/web-app/src/assets/i18n/zh-TW.json +++ b/web-app/src/assets/i18n/zh-TW.json @@ -526,6 +526,7 @@ "settings.system-config.locale.zh_TW": "繁體中文(zh_TW)", "settings.system-config.locale.en_US": "英語(en_US)", "settings.system-config.timezone": "系統時區", + "settings.system-config.theme": "系統主題", "settings.system-config.ok": "確認更新", "settings.object-store": "文件服務配置", "settings.object-store.type": "文件服務提供商", From c3851cba38ca136bb62015d38ef61ae3b6a86109 Mon Sep 17 00:00:00 2001 From: tiejiaxiaobao <2922035952@qq.com> Date: Tue, 12 Mar 2024 16:55:03 +0800 Subject: [PATCH 2/9] odified:system config theme location --- web-app/src/app/layout/basic/basic.component.ts | 7 ------- .../system-config/system-config.component.html | 12 ++++++++++++ web-app/src/assets/i18n/en-US.json | 3 +++ web-app/src/assets/i18n/zh-TW.json | 3 +++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/web-app/src/app/layout/basic/basic.component.ts b/web-app/src/app/layout/basic/basic.component.ts index 897a0d2d213..fe1e5498a4c 100644 --- a/web-app/src/app/layout/basic/basic.component.ts +++ b/web-app/src/app/layout/basic/basic.component.ts @@ -88,13 +88,6 @@ import { CONSTANTS } from '../../shared/constants'; - ` }) export class LayoutBasicComponent { diff --git a/web-app/src/app/routes/setting/settings/system-config/system-config.component.html b/web-app/src/app/routes/setting/settings/system-config/system-config.component.html index 733ffd8bc8d..2e71b3479d1 100644 --- a/web-app/src/app/routes/setting/settings/system-config/system-config.component.html +++ b/web-app/src/app/routes/setting/settings/system-config/system-config.component.html @@ -49,6 +49,18 @@ + + + + + + + diff --git a/web-app/src/assets/i18n/en-US.json b/web-app/src/assets/i18n/en-US.json index d13b75cf596..4e25b9794a8 100644 --- a/web-app/src/assets/i18n/en-US.json +++ b/web-app/src/assets/i18n/en-US.json @@ -529,6 +529,9 @@ "settings.system-config.locale.en_US": "English(en_US)", "settings.system-config.timezone": "System Time Zone", "settings.system-config.theme": "System Theme", + "settings.system-config.theme.default": "Default Theme", + "settings.system-config.theme.dark": "Dark Theme", + "settings.system-config.theme.compact": "Compact Theme", "settings.system-config.ok": "Confirm Update", "settings.object-store": "File Server Configuration", "settings.object-store.type": "File Server Provider", diff --git a/web-app/src/assets/i18n/zh-TW.json b/web-app/src/assets/i18n/zh-TW.json index 18bb4593486..4244df73c63 100644 --- a/web-app/src/assets/i18n/zh-TW.json +++ b/web-app/src/assets/i18n/zh-TW.json @@ -527,6 +527,9 @@ "settings.system-config.locale.en_US": "英語(en_US)", "settings.system-config.timezone": "系統時區", "settings.system-config.theme": "系統主題", + "settings.system-config.theme.default": "淺色主題", + "settings.system-config.theme.dark": "深色主題", + "settings.system-config.theme.compact": "緊湊主題", "settings.system-config.ok": "確認更新", "settings.object-store": "文件服務配置", "settings.object-store.type": "文件服務提供商", From 8270ca9f3ec47e8068bf407a65a78760b5621f9e Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Tue, 12 Mar 2024 20:27:51 +0800 Subject: [PATCH 3/9] fix save theme prop Signed-off-by: tomsun28 --- home/i18n/zh-cn/docusaurus-plugin-content-docs/current.json | 2 +- home/sidebars.json | 1 - web-app/src/app/pojo/SystemConfig.ts | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current.json b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current.json index 25013d9ec3e..b81e463e664 100644 --- a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current.json +++ b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current.json @@ -1,6 +1,6 @@ { "version.label": { - "message": "v1.4.x", + "message": "v1.5.x", "description": "The label for version current" }, "sidebar.docs.category.quickstart": { diff --git a/home/sidebars.json b/home/sidebars.json index 5530de2b695..3d9425ce90a 100644 --- a/home/sidebars.json +++ b/home/sidebars.json @@ -235,7 +235,6 @@ "others/contact", "others/design", "others/sponsor", - "others/private", "others/resource" ] } diff --git a/web-app/src/app/pojo/SystemConfig.ts b/web-app/src/app/pojo/SystemConfig.ts index dc27a7ef441..ac9bbf0df76 100644 --- a/web-app/src/app/pojo/SystemConfig.ts +++ b/web-app/src/app/pojo/SystemConfig.ts @@ -1,4 +1,5 @@ export class SystemConfig { timeZoneId!: string; locale!: string; + theme!: string; } From 2ea3c6363a87be7e6274940e988374a8aefa212c Mon Sep 17 00:00:00 2001 From: tiejiaxiaobao <2922035952@qq.com> Date: Sat, 16 Mar 2024 23:17:55 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=8C=89=E9=94=AE=EF=BC=8C=E7=AD=89=E5=BE=85?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8C=81=E4=B9=85=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system-config/system-config.component.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts index de920befb7e..f3c48ec7f80 100644 --- a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts +++ b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts @@ -67,10 +67,13 @@ export class SystemConfigComponent implements OnInit { .subscribe( message => { if (message.code === 0) { + // 保存系统配置成功后保存主题设置 + this.changeTheme(this.config.theme); this.notifySvc.success(this.i18nSvc.fanyi('common.notify.apply-success'), ''); let language = this.config.locale.replace('_', '-'); this.i18nSvc.loadLangData(language).subscribe(res => { this.i18nSvc.use(language, res); + this.settings.setLayout('lang', language); setTimeout(() => this.doc.location.reload()); }); @@ -83,4 +86,27 @@ export class SystemConfigComponent implements OnInit { } ); } + changeTheme(theme: string): void { + //const el = this.doc.querySelector('#dark-theme'); + const style = this.doc.createElement('link'); + style.type = 'text/css'; + style.rel = 'stylesheet'; + if (theme == 'dark') { + //if (el) return; + style.id = 'dark-theme'; + style.href = 'assets/style.dark.css'; + } else if (theme == 'compact') { + style.id = 'compact-theme'; + style.href = 'assets/style.compact.css'; + } + else { + const dom = document.getElementById('dark-theme'); + if (dom) { + dom.remove(); + } + } + // this.doc.head.appendChild(style); + localStorage.setItem("theme", theme) + this.doc.body.append(style); + } } From 22bec5d3d79a1bd2dbbddf6c52cfd47a96527a3b Mon Sep 17 00:00:00 2001 From: tiejiaxiaobao <2922035952@qq.com> Date: Sat, 16 Mar 2024 23:36:07 +0800 Subject: [PATCH 5/9] Implement theme switching function button --- .../settings/system-config/system-config.component.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts index f3c48ec7f80..1e7a1f04da1 100644 --- a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts +++ b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts @@ -37,6 +37,7 @@ export class SystemConfigComponent implements OnInit { if (message.code === 0) { if (message.data) { this.config = message.data; + this.changeTheme(this.config.theme) // 刷新后更新主题 } else { this.config = new SystemConfig(); } @@ -67,8 +68,6 @@ export class SystemConfigComponent implements OnInit { .subscribe( message => { if (message.code === 0) { - // 保存系统配置成功后保存主题设置 - this.changeTheme(this.config.theme); this.notifySvc.success(this.i18nSvc.fanyi('common.notify.apply-success'), ''); let language = this.config.locale.replace('_', '-'); this.i18nSvc.loadLangData(language).subscribe(res => { @@ -87,12 +86,10 @@ export class SystemConfigComponent implements OnInit { ); } changeTheme(theme: string): void { - //const el = this.doc.querySelector('#dark-theme'); const style = this.doc.createElement('link'); style.type = 'text/css'; style.rel = 'stylesheet'; if (theme == 'dark') { - //if (el) return; style.id = 'dark-theme'; style.href = 'assets/style.dark.css'; } else if (theme == 'compact') { @@ -105,7 +102,6 @@ export class SystemConfigComponent implements OnInit { dom.remove(); } } - // this.doc.head.appendChild(style); localStorage.setItem("theme", theme) this.doc.body.append(style); } From 922c0c6c9b6a631c86242617f0c7d70eaceb2686 Mon Sep 17 00:00:00 2001 From: tiejiaxiaobao <2922035952@qq.com> Date: Sat, 16 Mar 2024 23:40:01 +0800 Subject: [PATCH 6/9] Fix compilation failure problem --- .../setting/settings/system-config/system-config.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts index 1e7a1f04da1..cab77bbc7dd 100644 --- a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts +++ b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts @@ -37,7 +37,7 @@ export class SystemConfigComponent implements OnInit { if (message.code === 0) { if (message.data) { this.config = message.data; - this.changeTheme(this.config.theme) // 刷新后更新主题 + this.changeTheme(this.config.theme); // 刷新后更新主题 } else { this.config = new SystemConfig(); } @@ -102,7 +102,6 @@ export class SystemConfigComponent implements OnInit { dom.remove(); } } - localStorage.setItem("theme", theme) this.doc.body.append(style); } } From c9b42dac0a05616b3edb717761f910a017472d80 Mon Sep 17 00:00:00 2001 From: tiejiaxiaobao <2922035952@qq.com> Date: Sat, 16 Mar 2024 23:44:34 +0800 Subject: [PATCH 7/9] Fix compilation failure problem --- .../setting/settings/system-config/system-config.component.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts index cab77bbc7dd..3120ef2bb80 100644 --- a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts +++ b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts @@ -95,8 +95,7 @@ export class SystemConfigComponent implements OnInit { } else if (theme == 'compact') { style.id = 'compact-theme'; style.href = 'assets/style.compact.css'; - } - else { + } else { const dom = document.getElementById('dark-theme'); if (dom) { dom.remove(); From 4418b15fea64d12d778869151892012d2cd8b6ad Mon Sep 17 00:00:00 2001 From: tiejiaxiaobao <2922035952@qq.com> Date: Sat, 16 Mar 2024 23:48:29 +0800 Subject: [PATCH 8/9] Adjust code standards --- .../setting/settings/system-config/system-config.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts index 3120ef2bb80..f6a25c49c28 100644 --- a/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts +++ b/web-app/src/app/routes/setting/settings/system-config/system-config.component.ts @@ -72,7 +72,6 @@ export class SystemConfigComponent implements OnInit { let language = this.config.locale.replace('_', '-'); this.i18nSvc.loadLangData(language).subscribe(res => { this.i18nSvc.use(language, res); - this.settings.setLayout('lang', language); setTimeout(() => this.doc.location.reload()); }); From 90bb41f7358c89ca21164fdbfadc54a9073a7836 Mon Sep 17 00:00:00 2001 From: tiejiaxiaobao <2922035952@qq.com> Date: Sun, 17 Mar 2024 11:59:21 +0800 Subject: [PATCH 9/9] Fix the problem of color conflict when changing theme background --- web-app/src/app/routes/setting/settings/settings.component.less | 1 - 1 file changed, 1 deletion(-) diff --git a/web-app/src/app/routes/setting/settings/settings.component.less b/web-app/src/app/routes/setting/settings/settings.component.less index be10ab1a011..bcfd722978e 100644 --- a/web-app/src/app/routes/setting/settings/settings.component.less +++ b/web-app/src/app/routes/setting/settings/settings.component.less @@ -10,7 +10,6 @@ padding-top: 16px; padding-bottom: 16px; overflow: auto; - background-color: #fff; } .menu {