Skip to content

Commit 91e675a

Browse files
committed
feat: 默认主题色
1 parent 8354e7f commit 91e675a

2 files changed

Lines changed: 39 additions & 17 deletions

File tree

chat2db-client/src/blocks/Setting/BaseSetting/index.tsx

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ import styles from './index.less';
1515
const { Option } = Select;
1616

1717
const themeList = [
18-
{
19-
code: ThemeType.Dark,
20-
name: i18n('setting.text.dark'),
21-
img: themeDarkImg,
22-
},
2318
{
2419
code: ThemeType.Light,
2520
name: i18n('setting.text.light'),
2621
img: themeLightImg,
2722
},
23+
{
24+
code: ThemeType.Dark,
25+
name: i18n('setting.text.dark'),
26+
img: themeDarkImg,
27+
},
2828
{
2929
code: ThemeType.FollowOs,
3030
name: i18n('setting.text.followOS'),
@@ -38,26 +38,26 @@ const themeList = [
3838
];
3939

4040
const colorList = [
41-
{
42-
code: 'polar-blue',
43-
name: i18n('setting.label.blue'),
44-
color: '#1a90ff',
45-
},
46-
{
47-
code: 'polar-green',
48-
name: i18n('setting.label.green'),
49-
color: '#039e74',
50-
},
5141
{
5242
code: 'golden-purple',
5343
name: i18n('setting.label.violet'),
5444
color: '#9373ee',
5545
},
46+
{
47+
code: 'polar-blue',
48+
name: i18n('setting.label.blue'),
49+
color: '#1a90ff',
50+
},
5651
{
5752
code: 'blue2',
5853
name: i18n('setting.label.violet'),
5954
color: '#00c3ee',
6055
},
56+
{
57+
code: 'polar-green',
58+
name: i18n('setting.label.green'),
59+
color: '#039e74',
60+
},
6161
{
6262
code: 'gold',
6363
name: i18n('setting.label.violet'),
@@ -152,6 +152,16 @@ export default function BaseSetting() {
152152
</div>
153153
);
154154
})}
155+
{/* <ColorPicker placement='bottomLeft' onChange={setCustomColor}>
156+
<div className={classnames(styles.themeColorItem, styles.customColorItem) }>
157+
<div
158+
className={styles.colorLump}
159+
onClick={()=>{}}
160+
>
161+
自定义
162+
</div>
163+
</div>
164+
</ColorPicker> */}
155165
</ul>
156166
</>
157167
);

chat2db-client/src/utils/localStorage.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,27 @@ export function setLang(lang: LangType) {
1010
}
1111

1212
export function getTheme(): ThemeType {
13-
return (localStorage.getItem('theme') as ThemeType) || ThemeType.Light;
13+
const themeColor:any = localStorage.getItem('theme') as ThemeType
14+
if(themeColor){
15+
return themeColor
16+
}
17+
localStorage.setItem('theme', ThemeType.Light)
18+
// 默认主题色
19+
return ThemeType.Light
1420
}
1521

1622
export function setTheme(theme: ThemeType) {
1723
return localStorage.setItem('theme', theme);
1824
}
1925

2026
export function getPrimaryColor(): PrimaryColorType {
21-
return (localStorage.getItem('primary-color') as PrimaryColorType) || PrimaryColorType.Polar_Blue;
27+
const primaryColor = localStorage.getItem('primary-color') as PrimaryColorType
28+
if(primaryColor){
29+
return primaryColor
30+
}
31+
localStorage.setItem('primary-color', PrimaryColorType.Golden_Purple)
32+
// 默认主题色
33+
return PrimaryColorType.Golden_Purple
2234
}
2335

2436
export function setPrimaryColor(primaryColor: PrimaryColorType) {

0 commit comments

Comments
 (0)