diff --git a/src/layout.tsx b/src/layout.tsx index f4ecb6f..ff82536 100644 --- a/src/layout.tsx +++ b/src/layout.tsx @@ -2,6 +2,7 @@ import { CLASS_PREFIX } from './const'; import { IRowConfigOptions, RowConfigMap, RowConfigMapRegExp, RowConfigMapRegExpCached } from './row-config'; import { syntaxHighlighter } from './highlighter'; import { IRecordInfo } from '@bluelovers/auto1111-pnginfo'; +import { logger } from './logger'; export function _addRowCoreOptions(key: string, value: any, infoData: ILayoutInfoData) { @@ -34,7 +35,14 @@ export async function _addRowCore(key: string, value: any, infoData: ILayoutInfo { if (opts.decode === true) { - value = JSON.parse(value) + try + { + value = JSON.parse(value) + } + catch (e) + { + logger.error(e) + } } else { diff --git a/src/logger.ts b/src/logger.ts index eb63b58..0fd843c 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -2,11 +2,20 @@ import { EXTENSION_NAME } from './const'; function initLogger() { - return (Object.keys(console) as (keyof typeof console)[]) + const list = [ + 'log', + 'error', + 'debug', + 'info', + 'warn', + // @ts-ignore + ] as const satisfies Extract; + + return (Object.keys(console) as Extract[]) .reduce((log, method) => { let fn = console[method]; - if (typeof fn === 'function') + if (typeof fn === 'function' && list.includes(method as any)) { // @ts-ignore log[method] = fn.bind(console, EXTENSION_NAME)