feat: 主题切换

This commit is contained in:
streakingman
2022-09-19 03:02:32 +08:00
parent 6906dec65e
commit 968f9d6c39
21 changed files with 173 additions and 36 deletions
+40
View File
@@ -0,0 +1,40 @@
import { Theme } from '../interface';
const icons = <const>[
`🎨`,
`🌈`,
`⚙️`,
`💻`,
`📚`,
`🐯`,
`🐤`,
`🐼`,
`🐏`,
`🍀`,
];
export type DefaultSoundNames = 'button-click' | 'triple';
import soundButtonClickUrl from './sounds/sound-button-click.mp3';
import soundTripleUrl from './sounds/sound-triple.mp3';
export const defaultSounds: Theme<DefaultSoundNames>['sounds'] = [
{
name: 'button-click',
src: soundButtonClickUrl,
},
{
name: 'triple',
src: soundTripleUrl,
},
];
export const defaultTheme: Theme<DefaultSoundNames> = {
name: '默认',
icons: icons.map((icon) => ({
name: icon,
content: icon,
clickSound: 'button-click',
tripleSound: 'triple',
})),
sounds: defaultSounds,
};
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

+27
View File
@@ -0,0 +1,27 @@
// 钓鱼佬主题
import React from 'react';
import { Theme } from '../interface';
import { DefaultSoundNames, defaultSounds } from '../default';
const imagesUrls = import.meta.glob('./images/*.png', {
import: 'default',
eager: true,
});
const fishes = Object.entries(imagesUrls).map(([key, value]) => ({
name: key.slice(9, -4),
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
content: <img src={value} alt="" />,
}));
export const fishermanTheme: Theme<DefaultSoundNames> = {
name: '钓鱼佬',
icons: fishes.map(({ name, content }) => ({
name,
content,
clickSound: 'button-click',
tripleSound: 'triple',
})),
sounds: defaultSounds,
};
+19
View File
@@ -0,0 +1,19 @@
import { ReactNode } from 'react';
export interface Icon<T = string> {
name: string;
content: ReactNode;
clickSound: T;
tripleSound: T;
}
interface Sound<T = string> {
name: T;
src: string;
}
export interface Theme<SoundNames> {
name: string;
icons: Icon<SoundNames>[];
sounds: Sound<SoundNames>[];
}