refactor(shell): update init log

This commit is contained in:
Il Harper 2024-03-10 02:35:43 +08:00
parent 2134ce4ac3
commit aa06467f84
No known key found for this signature in database
GPG Key ID: 4B71FCA698E7E8EC
4 changed files with 10 additions and 23 deletions

View File

@ -11,18 +11,22 @@ import { getSelfProfile, setSelfProfile } from './services/selfProfile'
import { uix } from './services/uix'
import { validate } from './services/validate'
import type { ChronocatContext, Engine } from './types'
import { bold, cyan, grey } from './utils/colors'
import { PLATFORM } from './utils/consts'
import { exists } from './utils/fs'
import { sleep, timeout } from './utils/time'
import { bgGrey, cyan, white } from './utils/colors'
import { STARTUP_TEXT } from './utils/startup'
import { sleep, timeout } from './utils/time'
export * from './satori/types'
export * from './services/config/configEntity'
export * from './types'
declare const __DEFINE_CHRONO_VERSION__: string
export const chronocat = () => {
l.write(STARTUP_TEXT)
l.info(`${cyan('Chronocat')} ${bold(__DEFINE_CHRONO_VERSION__)}`)
l.info(grey('当左侧错误指示灯亮起时,点击错误码以检查说明。'))
let ready: () => void
const readyPromise = new Promise<void>((res) => {
@ -83,7 +87,7 @@ export const chronocat = () => {
const outerContext = {
load: (x: Engine) => {
l.info(`加载引擎 ${cyan(x.name)} ${bgGrey(white(`v${x.version}`))}`)
l.info(`加载引擎 ${cyan(x.name)} ${grey(`v${x.version}`)}`)
try {
x.apply(ctx)
} catch (e) {

View File

@ -1,5 +1,5 @@
import type { Methods } from '../types'
import { bgMagenta, cyan, magenta, white } from '../utils/colors'
import { cyan, magenta } from '../utils/colors'
import { l } from './logger'
export type ApiImpl<M extends keyof Methods> = ((
@ -26,9 +26,7 @@ export type Api = {
const buildNotimpl = (name: string) => {
const fn = () =>
l.error(
new Error(
`没有引擎提供 ${bgMagenta(white(name))}。可能没有加载所需的引擎?`,
),
new Error(`没有引擎提供 ${magenta(name)}。可能没有加载所需的引擎?`),
{
code: 2159,
throw: true,

View File

@ -31,13 +31,4 @@ export const magenta = color('magenta')
export const cyan = color('cyan')
export const white = color('white')
export const bgGrey = bgColor('bgGrey')
export const bgRed = bgColor('bgRed')
export const bgGreen = bgColor('bgGreen')
export const bgYellow = bgColor('bgYellow')
export const bgBlue = bgColor('bgBlue')
export const bgMagenta = bgColor('bgMagenta')
export const bgCyan = bgColor('bgCyan')
export const bgWhite = bgColor('bgWhite')
export type ColorFormatter = ReturnType<typeof color>

View File

@ -1,6 +1,4 @@
import { cyan, grey, bold } from './colors'
declare const __DEFINE_CHRONO_VERSION__: string
import { cyan, grey } from './colors'
const backgroundStrings = [
'chronocat',
@ -46,8 +44,4 @@ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
.replace(/([^b])/g, cyan('$1'))
.replace(/b/g, () => grey(bgStr[i++ % bgStr.length]!))}
${cyan(' ChronoCat ')} ${bold(__DEFINE_CHRONO_VERSION__)}
${grey('[+] 点击形如 [CH2157] 的日志文本可以打开相应说明页面。')}
`