feat: 统一管理导出路径

This commit is contained in:
ningmengchongshui 2024-06-11 17:41:11 +08:00
parent c016648ad7
commit e1f53b1cc6
16 changed files with 95 additions and 35 deletions

View File

@ -4,12 +4,6 @@
* ********** * **********
*/ */
import './config/init.js' import './config/init.js'
/**
* **********
*
* *********
*/
import './global.js'
/** /**
* ********** * **********
* *
@ -25,7 +19,13 @@ import ListenerLoader from './core/events.loader.js'
/** /**
* *
*/ */
import { Client } from 'icqq' import { Client, segment } from 'icqq'
import { plugin } from './core/plugins/index.js'
/**
* global
*/
global.plugin = plugin
global.segment = segment
/** /**
* *
*/ */

View File

@ -1 +1,9 @@
export {} export { checkRun } from './check.js'
import config from './config.js'
export { checkInit, UpdateTitle as checkUpdateTitle } from './init.js'
export const ConfigController = config
import QQ from './qq.js'
export const createQQ = QQ
import RedisInit from './redis.js'
export const redisInit = RedisInit
export * from './system.js'

View File

@ -101,7 +101,7 @@ export default function setLog() {
} }
/** 全局变量 logger */ /** 全局变量 logger */
global.logger = createLog() global.logger = createLog() as any
logger.chalk = chalk logger.chalk = chalk
logger.red = chalk.red logger.red = chalk.red

View File

@ -56,7 +56,7 @@ export default async function redisInit() {
* *
* @returns * @returns
*/ */
export async function aarch64() { async function aarch64() {
if (process.platform == "win32") { if (process.platform == "win32") {
return "" return ""
} }

1
src/core/icqq.ts Normal file
View File

@ -0,0 +1 @@
export { Client, segment } from 'icqq'

View File

@ -1,3 +1,4 @@
export * from './plugins/index.js' export * from './plugins/index.js'
export * from './plugins/functional.js' export * from './plugins/functional.js'
export * from './plugins/types.js' export * from './plugins/types.js'
export * from './icqq.js'

View File

@ -1,4 +1,4 @@
import { Common } from '../../local.js' import { Common } from '../../miao.js'
import { EventType } from './types.js' import { EventType } from './types.js'
const stateArr = {} const stateArr = {}

View File

@ -1,5 +1,5 @@
import { Sequelize, DataTypes, Model } from 'sequelize' import { Sequelize, DataTypes, Model } from 'sequelize'
import { Data } from '../local.js' import { Data } from '../miao.js'
import { join } from 'path' import { join } from 'path'
/** /**

76
src/global.d.ts vendored
View File

@ -2,13 +2,75 @@ import { segment as se } from 'icqq'
import { RedisClientType } from 'redis' import { RedisClientType } from 'redis'
import { Yunzai } from './bot.js' import { Yunzai } from './bot.js'
import { plugin as p } from './core/index.js' import { plugin as p } from './core/index.js'
import chalk, { type ChalkInstance } from 'chalk'
/** /**
* *
*/ */
declare global { type LogType = string | Error | unknown
var redis: RedisClientType
var Bot: typeof Yunzai.prototype /**
var segment: typeof se *
var plugin: typeof p */
var logger: any type LoggerType = {
trace(...arg: LogType[]): any
debug(...arg: LogType[]): any
info(...arg: LogType[]): any
warn(...arg: LogType[]): any
error(...arg: LogType[]): any
fatal(...arg: LogType[]): any
mark(...arg: LogType[]): any
}
/**
* @deprecated 使
*/
type ChalkInstanceType = {
/**
* @deprecated 使
*/
red: ChalkInstance.red
/**
* @deprecated 使
*/
green: ChalkInstance.green
/**
* @deprecated 使
*/
blue: ChalkInstance.blue
/**
* @deprecated 使
*/
yellow: ChalkInstance.yellow
/**
* @deprecated 使
*/
magenta: ChalkInstance.magenta
/**
* @deprecated 使
*/
cyan: ChalkInstance.cyan
}
declare global {
/**
* @deprecated 使
*/
var redis: RedisClientType
/**
* @deprecated 使
*/
var Bot: typeof Yunzai.prototype
/**
* @deprecated 使
*/
var segment: typeof se
/**
* @deprecated 使
*/
var plugin: typeof p
var logger: LoggerType &
ChalkInstanceType & {
chalk: ChalkInstance
}
} }

View File

@ -1,7 +0,0 @@
import { segment } from 'icqq'
import { plugin } from './core/plugins/index.js'
/**
* global
*/
global.plugin = plugin
global.segment = segment

View File

@ -1,5 +0,0 @@
export * from './config/index.js'
export * from './core/index.js'
export * from './db/index.js'
export * from './mys/index.js'
export * from './utils/index.js'

View File

@ -15,7 +15,7 @@ import fetch from 'node-fetch'
import { MysUserDB } from '../db/index.js' import { MysUserDB } from '../db/index.js'
import { Data } from '../local.js' import { Data } from '../miao.js'
const tables = { const tables = {
// ltuid-uid 查询表 // ltuid-uid 查询表

View File

@ -1,4 +1,4 @@
import { Data } from '../local.js' import { Data } from '../miao.js'
/** /**
* *

View File

@ -3,7 +3,7 @@ import lodash from 'lodash'
import MysUser from './MysUser.js' import MysUser from './MysUser.js'
import MysUtil from './MysUtil.js' import MysUtil from './MysUtil.js'
import { UserDB } from '../db/index.js' import { UserDB } from '../db/index.js'
import { Data } from '../local.js' import { Data } from '../miao.js'
/** /**
* ******************* * *******************
* Bot实际User用户类 * Bot实际User用户类

View File

@ -4,7 +4,7 @@ import fs from 'node:fs'
import lodash from 'lodash' import lodash from 'lodash'
import MysInfo from './mysInfo.js' import MysInfo from './mysInfo.js'
import NoteUser from './NoteUser.js' import NoteUser from './NoteUser.js'
import { Character, Weapon } from '../local.js' import { Character, Weapon } from '../miao.js'
/** /**
* *********** * ***********