From 28c4d88c074d3447ea9d60014d4bef3b1e0959b1 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Wed, 8 Dec 2021 15:33:07 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E7=9A=84=E5=8A=A0=E8=BD=BD=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=87=8F=E5=B0=91=E4=B8=8D=E5=BF=85=E8=A6=81?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/event/index.ts | 2 +- web/plugins/com.msgbyte.theme.genshin/src/index.ts | 9 +++++++-- web/plugins/com.msgbyte.theme.miku/src/index.ts | 9 +++++++-- 3 files changed, 15 insertions(+), 5 deletions(-) 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'); + } +});