Skip to content

Commit e222bcb

Browse files
author
pompurin404
committed
complete theme config
1 parent 1750e05 commit e222bcb

File tree

4 files changed

+72
-11
lines changed

4 files changed

+72
-11
lines changed

src/renderer/src/main.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ init().then(() => {
1313
<NextUIProvider>
1414
<NextThemesProvider
1515
attribute="class"
16-
themes={['light', 'dark', 'gray', 'pink']}
16+
themes={['light', 'dark', 'gray', 'light-pink', 'dark-pink', 'gray-pink']}
1717
enableSystem
1818
defaultTheme="dark"
1919
>

src/renderer/src/pages/settings.tsx

+43-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
import { IoLogoGithub } from 'react-icons/io5'
1414
import { version } from '@renderer/utils/init'
1515
import useSWR from 'swr'
16-
import { useState } from 'react'
16+
import { Key, useState } from 'react'
1717
import debounce from '@renderer/utils/debounce'
1818
import { useTheme } from 'next-themes'
1919

@@ -41,6 +41,30 @@ const Settings: React.FC = () => {
4141
patchAppConfig({ userAgent: v })
4242
}, 500)
4343

44+
const onThemeChange = (key: Key, type: 'theme' | 'color'): void => {
45+
const [theme, color] = appTheme.split('-')
46+
47+
if (type === 'theme') {
48+
let themeStr = key.toString()
49+
if (key !== 'system') {
50+
if (color) {
51+
themeStr += `-${color}`
52+
}
53+
}
54+
setTheme(themeStr)
55+
patchAppConfig({ appTheme: themeStr as AppTheme })
56+
} else {
57+
let themeStr = theme
58+
if (theme !== 'system') {
59+
if (key !== 'blue') {
60+
themeStr += `-${key}`
61+
}
62+
setTheme(themeStr)
63+
patchAppConfig({ appTheme: themeStr as AppTheme })
64+
}
65+
}
66+
}
67+
4468
return (
4569
<BasePage
4670
title="应用设置"
@@ -89,25 +113,36 @@ const Settings: React.FC = () => {
89113
}}
90114
/>
91115
</SettingItem>
92-
<SettingItem title="应用主题">
116+
<SettingItem title="应用主题(亮度)" divider={appTheme !== 'system'}>
93117
<Tabs
94118
size="sm"
95119
color="primary"
96-
selectedKey={appTheme}
120+
selectedKey={appTheme.split('-')[0]}
97121
onSelectionChange={(key) => {
98-
console.log(key)
99-
setTheme(key as AppTheme)
100-
101-
patchAppConfig({ appTheme: key as AppTheme })
122+
onThemeChange(key, 'theme')
102123
}}
103124
>
104125
<Tab key="system" title="自动" />
105126
<Tab key="dark" title="深色" />
106127
<Tab key="gray" title="灰色" />
107-
<Tab key="pink" title="粉色" />
108128
<Tab key="light" title="浅色" />
109129
</Tabs>
110130
</SettingItem>
131+
{appTheme !== 'system' && (
132+
<SettingItem title="应用主题(颜色)">
133+
<Tabs
134+
size="sm"
135+
color="primary"
136+
selectedKey={appTheme.split('-')[1] || 'blue'}
137+
onSelectionChange={(key) => {
138+
onThemeChange(key, 'color')
139+
}}
140+
>
141+
<Tab key="blue" title="蓝色" />
142+
<Tab key="pink" title="粉色" />
143+
</Tabs>
144+
</SettingItem>
145+
)}
111146
</SettingCard>
112147
<SettingCard>
113148
<SettingItem title="订阅拉取 UA" divider>

src/shared/types.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type OutboundMode = 'rule' | 'global' | 'direct'
22
type LogLevel = 'info' | 'debug' | 'warning' | 'error' | 'silent'
33
type SysProxyMode = 'auto' | 'manual'
4-
type AppTheme = 'system' | 'light' | 'dark' | 'gray' | 'pink'
4+
type AppTheme = 'system' | 'light' | 'dark' | 'gray' | 'light-pink' | 'dark-pink' | 'gray-pink'
55
type MihomoGroupType = 'Selector' | 'URLTest' | 'LoadBalance' | 'Relay'
66
type MihomoProxyType =
77
| 'Direct'

tailwind.config.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,38 @@ module.exports = {
3030
}
3131
}
3232
},
33-
pink: {
33+
'light-pink': {
3434
extend: 'light',
3535
colors: {
3636
primary: '#ED9CC2',
3737
secondary: '#71CCAA'
3838
}
39+
},
40+
'dark-pink': {
41+
extend: 'dark',
42+
colors: {
43+
primary: '#ED9CC2',
44+
secondary: '#71CCAA'
45+
}
46+
},
47+
'gray-pink': {
48+
extend: 'dark',
49+
colors: {
50+
background: '#18181b',
51+
content1: '#27272a',
52+
content2: '#3f3f46',
53+
content3: '#52525b',
54+
default: {
55+
DEFAULT: '#52525b',
56+
50: '#27272a',
57+
100: '#3f3f46',
58+
200: '#52525b',
59+
300: '#71717a',
60+
400: '#a1a1aa'
61+
},
62+
primary: '#ED9CC2',
63+
secondary: '#71CCAA'
64+
}
3965
}
4066
}
4167
})

0 commit comments

Comments
 (0)