From 9d8b9c0c2da3537884549ffbb96efc1096d2c55a Mon Sep 17 00:00:00 2001 From: Il Harper Date: Sun, 28 Jan 2024 15:48:35 +0800 Subject: [PATCH] fix(plugin): fix enhance 2 --- packages/plugin/clients/enhance/client/index.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/plugin/clients/enhance/client/index.ts b/packages/plugin/clients/enhance/client/index.ts index 3ac340c..0fae211 100644 --- a/packages/plugin/clients/enhance/client/index.ts +++ b/packages/plugin/clients/enhance/client/index.ts @@ -1,5 +1,5 @@ import { Config, Context, Schema, useConfig } from '@koishijs/client' -import { RemovableRef } from '@vueuse/core' +import type { RemovableRef } from '@vueuse/core' import * as colorString from 'color-string' declare global { @@ -114,7 +114,7 @@ const send = (message: string) => { const syncStyleSheet = (config: RemovableRef) => { if (!styleSheet) return - switch (config.value.desktop.enhance) { + switch (config.value.desktop?.enhance) { case 'enhanceColor': styleSheet.innerHTML = baseCSS + enhanceColorCSS break @@ -128,7 +128,7 @@ const syncStyleSheet = (config: RemovableRef) => { } const syncTheme = (config: RemovableRef) => { - switch (config.value.desktop.enhance) { + switch (config.value.desktop?.enhance) { case 'enhanceColor': send( `T${ @@ -195,7 +195,7 @@ const disposeEnhance = () => { declare module '@koishijs/client' { interface Config { - desktop: { + desktop?: { enhance: 'off' | 'enhance' | 'enhanceColor' | 'enhanceTrans' } } @@ -234,7 +234,7 @@ export default (ctx: Context) => { ctx.on('ready', () => { const config = useConfig() - if (config?.value?.desktop?.enhance !== 'off') { + if (config.value.desktop?.enhance !== 'off') { enhance(config) ctx.on('dispose', disposeEnhance) }