You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by sh...@apache.org on 2024/01/16 03:58:17 UTC
(incubator-answer) 01/01: fix: dark mode optimiazation
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a commit to branch feat/1.2.5/ui
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit b3d64a963c8122216f797da4b3c2207409827d7c
Author: shuai <li...@sifou.com>
AuthorDate: Tue Jan 16 11:58:05 2024 +0800
fix: dark mode optimiazation
---
ui/src/common/color.scss | 4 ++++
ui/src/index.scss | 3 +++
ui/src/pages/Questions/EditAnswer/index.scss | 3 +++
ui/src/stores/loggedUserInfo.ts | 7 +++++++
ui/src/utils/common.ts | 2 +-
5 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/ui/src/common/color.scss b/ui/src/common/color.scss
index 01d2d08f..3b5feeea 100644
--- a/ui/src/common/color.scss
+++ b/ui/src/common/color.scss
@@ -49,4 +49,8 @@
.bg-light {
background-color: rgba(0, 0, 0, 0.5) !important;
}
+ .text-bg-dark {
+ color: #000 !important;
+ background-color: RGBA(255, 255, 255, var(--bs-bg-opacity, 1)) !important;
+ }
}
diff --git a/ui/src/index.scss b/ui/src/index.scss
index 0c618e80..8dd77087 100644
--- a/ui/src/index.scss
+++ b/ui/src/index.scss
@@ -276,6 +276,9 @@ img[src=""] {
word-break: initial;
}
}
+ ol ol,ol ul,ul ol,ul ul {
+ margin-bottom: 1rem;
+ }
}
.upload-img-wrap {
diff --git a/ui/src/pages/Questions/EditAnswer/index.scss b/ui/src/pages/Questions/EditAnswer/index.scss
index 68dfb023..0d7ce9c6 100644
--- a/ui/src/pages/Questions/EditAnswer/index.scss
+++ b/ui/src/pages/Questions/EditAnswer/index.scss
@@ -29,6 +29,9 @@
z-index: 1;
background: var(--an-white);
}
+ img {
+ max-width: 100%;
+ }
.scroll-bar {
height: 12px;
}
diff --git a/ui/src/stores/loggedUserInfo.ts b/ui/src/stores/loggedUserInfo.ts
index 1157e631..6b31606e 100644
--- a/ui/src/stores/loggedUserInfo.ts
+++ b/ui/src/stores/loggedUserInfo.ts
@@ -22,6 +22,7 @@ import create from 'zustand';
import type { UserInfoRes } from '@/common/interface';
import Storage from '@/utils/storage';
import { LOGGED_TOKEN_STORAGE_KEY } from '@/common/constants';
+import { changeTheme } from '@/utils/common';
interface UserInfoStore {
user: UserInfoRes;
@@ -57,6 +58,12 @@ const loggedUserInfo = create<UserInfoStore>((set) => ({
if (!params?.language) {
params.language = 'Default';
}
+ if (!params?.color_scheme) {
+ params.color_scheme = 'default';
+ changeTheme('default');
+ } else {
+ changeTheme(params.color_scheme);
+ }
set(() => {
Storage.set(LOGGED_TOKEN_STORAGE_KEY, params.access_token);
return { user: params };
diff --git a/ui/src/utils/common.ts b/ui/src/utils/common.ts
index 22452019..d2f0d0fd 100644
--- a/ui/src/utils/common.ts
+++ b/ui/src/utils/common.ts
@@ -246,7 +246,7 @@ function getUaType() {
return null;
}
-function changeTheme(mode: '' | 'light' | 'dark' | 'system') {
+function changeTheme(mode: 'default' | 'light' | 'dark' | 'system') {
const htmlTag = document.querySelector('html') as HTMLHtmlElement;
if (mode === 'system') {
const systemThemeQuery = window.matchMedia('(prefers-color-scheme: dark)');