import { isBrowser } from './browser'; export enum LogType { graphql = 'graphql', fiat = 'fiat', contractQueue = 'contractQueue', } export const clogKey = '__log'; // 使用之前设置一下:sessionStorage.setItem('__log', 'graphql'); export function clog(type: LogType, ...optionalParams: any[]) { if (!isBrowser) { return; } const searchType = sessionStorage.getItem(clogKey); if (searchType) { const searchTypeArr = searchType.split(',') as LogType[]; if (searchTypeArr.includes(type)) { // eslint-disable-next-line no-console console.log(`[clog-${type}]`, ...optionalParams); } } } clog.type = LogType;