diff --git a/shared/event/index.ts b/shared/event/index.ts index 32ff2eff..17e90266 100644 --- a/shared/event/index.ts +++ b/shared/event/index.ts @@ -7,7 +7,7 @@ export interface SharedEventMap { /** * 修改配色方案 */ - loadColorScheme: (scheme: string) => void; + loadColorScheme: (schemeName: string) => void; } export type SharedEventType = keyof SharedEventMap; diff --git a/web/plugins/com.msgbyte.theme.genshin/src/index.ts b/web/plugins/com.msgbyte.theme.genshin/src/index.ts index 52c2441d..82ce5969 100644 --- a/web/plugins/com.msgbyte.theme.genshin/src/index.ts +++ b/web/plugins/com.msgbyte.theme.genshin/src/index.ts @@ -1,4 +1,4 @@ -import { regPluginColorScheme } from '@capital/common'; +import { regPluginColorScheme, sharedEvent } from '@capital/common'; regPluginColorScheme({ label: '原神-胡桃', @@ -8,4 +8,9 @@ regPluginColorScheme({ /** * 异步加载以防止入口文件过大阻塞主应用加载(因为有图片) */ -import('./hutao/theme.less'); +sharedEvent.on('loadColorScheme', (colorSchemeName) => { + if (colorSchemeName === 'light+genshin-hutao') { + console.log('正在加载胡桃主题...'); + import('./hutao/theme.less'); + } +}); diff --git a/web/plugins/com.msgbyte.theme.miku/src/index.ts b/web/plugins/com.msgbyte.theme.miku/src/index.ts index 1298f91f..b6ec9e2f 100644 --- a/web/plugins/com.msgbyte.theme.miku/src/index.ts +++ b/web/plugins/com.msgbyte.theme.miku/src/index.ts @@ -1,4 +1,4 @@ -import { regPluginColorScheme } from '@capital/common'; +import { regPluginColorScheme, sharedEvent } from '@capital/common'; regPluginColorScheme({ label: 'Miku 葱', @@ -13,4 +13,9 @@ regPluginColorScheme({ /** * 异步加载以防止入口文件过大阻塞主应用加载(因为有图片) */ -import('./theme.less'); +sharedEvent.on('loadColorScheme', (colorSchemeName) => { + if (colorSchemeName === 'light+miku' || colorSchemeName === 'dark+miku') { + console.log('正在加载初音未来主题...'); + import('./theme.less'); + } +});