diff --git a/src/renderer/src/main.tsx b/src/renderer/src/main.tsx index 20755d5..21da369 100644 --- a/src/renderer/src/main.tsx +++ b/src/renderer/src/main.tsx @@ -13,7 +13,7 @@ init().then(() => { diff --git a/src/renderer/src/pages/settings.tsx b/src/renderer/src/pages/settings.tsx index 729457d..d648c56 100644 --- a/src/renderer/src/pages/settings.tsx +++ b/src/renderer/src/pages/settings.tsx @@ -13,7 +13,7 @@ import { import { IoLogoGithub } from 'react-icons/io5' import { version } from '@renderer/utils/init' import useSWR from 'swr' -import { useState } from 'react' +import { Key, useState } from 'react' import debounce from '@renderer/utils/debounce' import { useTheme } from 'next-themes' @@ -41,6 +41,30 @@ const Settings: React.FC = () => { patchAppConfig({ userAgent: v }) }, 500) + const onThemeChange = (key: Key, type: 'theme' | 'color'): void => { + const [theme, color] = appTheme.split('-') + + if (type === 'theme') { + let themeStr = key.toString() + if (key !== 'system') { + if (color) { + themeStr += `-${color}` + } + } + setTheme(themeStr) + patchAppConfig({ appTheme: themeStr as AppTheme }) + } else { + let themeStr = theme + if (theme !== 'system') { + if (key !== 'blue') { + themeStr += `-${key}` + } + setTheme(themeStr) + patchAppConfig({ appTheme: themeStr as AppTheme }) + } + } + } + return ( { }} /> - + { - console.log(key) - setTheme(key as AppTheme) - - patchAppConfig({ appTheme: key as AppTheme }) + onThemeChange(key, 'theme') }} > - + {appTheme !== 'system' && ( + + { + onThemeChange(key, 'color') + }} + > + + + + + )} diff --git a/src/shared/types.d.ts b/src/shared/types.d.ts index 49c0e82..af44678 100644 --- a/src/shared/types.d.ts +++ b/src/shared/types.d.ts @@ -1,7 +1,7 @@ type OutboundMode = 'rule' | 'global' | 'direct' type LogLevel = 'info' | 'debug' | 'warning' | 'error' | 'silent' type SysProxyMode = 'auto' | 'manual' -type AppTheme = 'system' | 'light' | 'dark' | 'gray' | 'pink' +type AppTheme = 'system' | 'light' | 'dark' | 'gray' | 'light-pink' | 'dark-pink' | 'gray-pink' type MihomoGroupType = 'Selector' | 'URLTest' | 'LoadBalance' | 'Relay' type MihomoProxyType = | 'Direct' diff --git a/tailwind.config.js b/tailwind.config.js index 902e6f5..f8f93a7 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -30,12 +30,38 @@ module.exports = { } } }, - pink: { + 'light-pink': { extend: 'light', colors: { primary: '#ED9CC2', secondary: '#71CCAA' } + }, + 'dark-pink': { + extend: 'dark', + colors: { + primary: '#ED9CC2', + secondary: '#71CCAA' + } + }, + 'gray-pink': { + extend: 'dark', + colors: { + background: '#18181b', + content1: '#27272a', + content2: '#3f3f46', + content3: '#52525b', + default: { + DEFAULT: '#52525b', + 50: '#27272a', + 100: '#3f3f46', + 200: '#52525b', + 300: '#71717a', + 400: '#a1a1aa' + }, + primary: '#ED9CC2', + secondary: '#71CCAA' + } } } })