snapshot of https://github.com/dream-num/univer.git (dev, 2026-09-16; blobs > 131072B omitted)
Some checks failed
📦 Build / build (push) Has been cancelled
🧪 CI Test / test shard (1/4) (push) Has been cancelled
🧪 CI Test / test shard (2/4) (push) Has been cancelled
🧪 CI Test / test shard (3/4) (push) Has been cancelled
🧪 CI Test / test shard (4/4) (push) Has been cancelled
🧪 CI Test / test (push) Has been cancelled
🧪 CI Test / eslint (push) Has been cancelled
🧪 CI Test / typecheck (push) Has been cancelled
🔫 Sync to Pro / dispatch-sync (push) Has been cancelled
🔮 Sync Mirror / sync (push) Has been cancelled
Some checks failed
📦 Build / build (push) Has been cancelled
🧪 CI Test / test shard (1/4) (push) Has been cancelled
🧪 CI Test / test shard (2/4) (push) Has been cancelled
🧪 CI Test / test shard (3/4) (push) Has been cancelled
🧪 CI Test / test shard (4/4) (push) Has been cancelled
🧪 CI Test / test (push) Has been cancelled
🧪 CI Test / eslint (push) Has been cancelled
🧪 CI Test / typecheck (push) Has been cancelled
🔫 Sync to Pro / dispatch-sync (push) Has been cancelled
🔮 Sync Mirror / sync (push) Has been cancelled
This commit is contained in:
77
common/debugger/src/views/use-theme.ts
Normal file
77
common/debugger/src/views/use-theme.ts
Normal file
@@ -0,0 +1,77 @@
|
||||
import { ThemeService } from '@univerjs/core';
|
||||
import {
|
||||
blueTheme,
|
||||
darkBlueTheme,
|
||||
greenTheme,
|
||||
orangeTheme,
|
||||
purpleTheme,
|
||||
redTheme,
|
||||
yellowTheme,
|
||||
} from '@univerjs/themes';
|
||||
import { useDependency } from '@univerjs/ui';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const themes = [
|
||||
{
|
||||
label: '🟢',
|
||||
value: greenTheme,
|
||||
},
|
||||
{
|
||||
label: '🔵',
|
||||
value: blueTheme,
|
||||
},
|
||||
{
|
||||
label: '🔵🌑',
|
||||
value: darkBlueTheme,
|
||||
},
|
||||
{
|
||||
label: '🟠',
|
||||
value: orangeTheme,
|
||||
},
|
||||
{
|
||||
label: '🔴',
|
||||
value: redTheme,
|
||||
},
|
||||
{
|
||||
label: '🟣',
|
||||
value: purpleTheme,
|
||||
},
|
||||
{
|
||||
label: '🟡',
|
||||
value: yellowTheme,
|
||||
},
|
||||
];
|
||||
|
||||
export function useTheme() {
|
||||
const themeService = useDependency(ThemeService);
|
||||
|
||||
useEffect(() => {
|
||||
const themeKey = localStorage.getItem('local.theme');
|
||||
|
||||
const theme = themes.find((theme) => theme.label === themeKey);
|
||||
|
||||
if (theme) {
|
||||
themeService.setTheme(theme.value);
|
||||
}
|
||||
}, [themeService]);
|
||||
|
||||
const onSelect = (value: string) => {
|
||||
localStorage.setItem('local.theme', value);
|
||||
|
||||
const theme = themes.find((theme) => theme.label === value);
|
||||
|
||||
if (theme) {
|
||||
themeService.setTheme(theme.value);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
type: 'subItem' as const,
|
||||
children: '🎨 Themes',
|
||||
options: themes.map((theme) => ({
|
||||
type: 'item' as const,
|
||||
children: theme.label,
|
||||
onSelect: () => onSelect(theme.label),
|
||||
})),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user