diff --git a/package.json b/package.json index 164ec422..eb3abff7 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build:framework": "pnpm --filter napcat-framework run build || exit 1", "build:webui": "pnpm --filter napcat-webui-frontend run build || exit 1", "dev:shell": "pnpm --filter napcat-develop run dev || exit 1", - "typecheck": "pnpm -w -r --filter napcat-shell --filter napcat-framework run typecheck" + "typecheck": "pnpm -w -r --filter napcat-shell --filter napcat-framework --filter napcat-webui-backend --filter napcat-onebot --filter napcat-core --filter napcat-webui-frontend run typecheck" }, "devDependencies": { "@rollup/plugin-node-resolve": "^16.0.3", diff --git a/packages/napcat-common/package.json b/packages/napcat-common/package.json index f392d94f..35410787 100644 --- a/packages/napcat-common/package.json +++ b/packages/napcat-common/package.json @@ -4,6 +4,9 @@ "private": true, "type": "module", "main": "src/index.ts", + "scripts": { + "typecheck": "tsc --noEmit --skipLibCheck -p tsconfig.json" + }, "exports": { ".": { "import": "./src/index.ts" diff --git a/packages/napcat-common/src/audio.ts b/packages/napcat-common/src/audio.ts index b02657f4..8028e2ef 100644 --- a/packages/napcat-common/src/audio.ts +++ b/packages/napcat-common/src/audio.ts @@ -2,9 +2,9 @@ import fsPromise from 'fs/promises'; import path from 'node:path'; import { randomUUID } from 'crypto'; import { EncodeResult, getDuration, getWavFileInfo, isSilk, isWav } from 'silk-wasm'; -import { LogWrapper } from '@/napcat-common/log'; -import { EncodeArgs } from '@/napcat-common/audio-worker'; -import { FFmpegService } from '@/napcat-common/ffmpeg'; +import { LogWrapper } from '@/napcat-common/src/log'; +import { EncodeArgs } from '@/napcat-common/src/audio-worker'; +import { FFmpegService } from '@/napcat-common/src/ffmpeg'; import { runTask } from './worker'; import { fileURLToPath } from 'node:url'; diff --git a/packages/napcat-common/src/file.ts b/packages/napcat-common/src/file.ts index 698c6c7e..20748f16 100644 --- a/packages/napcat-common/src/file.ts +++ b/packages/napcat-common/src/file.ts @@ -2,7 +2,7 @@ import fs from 'fs'; import { stat } from 'fs/promises'; import crypto, { randomUUID } from 'crypto'; import path from 'node:path'; -import { solveProblem } from '@/napcat-common/helper'; +import { solveProblem } from '@/napcat-common/src/helper'; export interface HttpDownloadOptions { url: string; diff --git a/packages/napcat-common/src/proxy-handler.ts b/packages/napcat-common/src/proxy-handler.ts index 1454fb2e..e9ac271f 100644 --- a/packages/napcat-common/src/proxy-handler.ts +++ b/packages/napcat-common/src/proxy-handler.ts @@ -1,4 +1,4 @@ -import { LogWrapper } from '@/napcat-common/log'; +import { LogWrapper } from '@/napcat-common/src/log'; export function proxyHandlerOf (logger: LogWrapper) { return { diff --git a/packages/napcat-common/src/qq-basic-info.ts b/packages/napcat-common/src/qq-basic-info.ts index 5ed19579..4e359c67 100644 --- a/packages/napcat-common/src/qq-basic-info.ts +++ b/packages/napcat-common/src/qq-basic-info.ts @@ -1,8 +1,8 @@ import fs from 'node:fs'; -import { systemPlatform } from '@/napcat-common/system'; +import { systemPlatform } from '@/napcat-common/src/system'; import { getDefaultQQVersionConfigInfo, getQQPackageInfoPath, getQQVersionConfigPath, parseAppidFromMajor } from './helper'; import AppidTable from 'napcat-core/external/appid.json'; -import { LogWrapper } from '@/napcat-common/log'; +import { LogWrapper } from '@/napcat-common/src/log'; import { getMajorPath } from 'napcat-core'; import { QQAppidTableType, QQPackageInfoType, QQVersionConfigType } from './types'; diff --git a/packages/napcat-common/tsconfig.json b/packages/napcat-common/tsconfig.json index c7e4450f..7244a40b 100644 --- a/packages/napcat-common/tsconfig.json +++ b/packages/napcat-common/tsconfig.json @@ -36,8 +36,8 @@ "resolveJsonModule": true, "baseUrl": ".", "paths": { - "@/napcat-common/*": [ - "src/*" + "@/*": [ + "../*" ] }, "skipLibCheck": true, diff --git a/packages/napcat-core/apis/friend.ts b/packages/napcat-core/apis/friend.ts index 44a53538..22d4df96 100644 --- a/packages/napcat-core/apis/friend.ts +++ b/packages/napcat-core/apis/friend.ts @@ -1,5 +1,5 @@ -import { FriendRequest, FriendV2 } from 'napcat-core/types'; -import { BuddyListReqType, InstanceContext, NapCatCore } from 'napcat-core/index'; +import { FriendRequest, FriendV2 } from '@/napcat-core/types'; +import { BuddyListReqType, InstanceContext, NapCatCore } from '@/napcat-core/index'; import { LimitedHashTable } from 'napcat-common/src/message-unique'; export class NTQQFriendApi { diff --git a/packages/napcat-core/helper/event.ts b/packages/napcat-core/helper/event.ts new file mode 100644 index 00000000..1579dfce --- /dev/null +++ b/packages/napcat-core/helper/event.ts @@ -0,0 +1,272 @@ +import { NodeIQQNTWrapperSession } from '@/napcat-core/wrapper'; +import { randomUUID } from 'crypto'; +import { ListenerNamingMapping, ServiceNamingMapping } from '@/napcat-core/index'; + +interface InternalMapKey { + timeout: number; + createtime: number; + func: (...arg: any[]) => any; + checker: ((...args: any[]) => boolean) | undefined; +} + +type EnsureFunc = T extends (...args: any) => any ? T : never; + +type FuncKeys = Extract< + { + [K in keyof T]: EnsureFunc extends never ? never : K; + }[keyof T], + string +>; + +export type ListenerClassBase = Record; + +export class NTEventWrapper { + private readonly WrapperSession: NodeIQQNTWrapperSession | undefined; // WrapperSession + private readonly listenerManager: Map = new Map(); // ListenerName-Unique -> Listener实例 + private readonly EventTask = new Map>>(); // tasks ListenerMainName -> ListenerSubName-> uuid -> {timeout,createtime,func} + + constructor( + wrapperSession: NodeIQQNTWrapperSession + ) { + this.WrapperSession = wrapperSession; + } + + createProxyDispatch(ListenerMainName: string) { + const dispatcherListenerFunc = this.dispatcherListener.bind(this); + return new Proxy( + {}, + { + get(target: any, prop: any, receiver: any) { + if (typeof target[prop] === 'undefined') { + // 如果方法不存在,返回一个函数,这个函数调用existentMethod + return (...args: any[]) => { + dispatcherListenerFunc(ListenerMainName, prop, ...args).then(); + }; + } + // 如果方法存在,正常返回 + return Reflect.get(target, prop, receiver); + }, + } + ); + } + + createEventFunction< + Service extends keyof ServiceNamingMapping, + ServiceMethod extends FuncKeys, + T extends (...args: any) => any = EnsureFunc + >(eventName: `${Service}/${ServiceMethod}`): T | undefined { + const eventNameArr = eventName.split('/'); + type eventType = { + [key: string]: () => { [key: string]: (...params: Parameters) => Promise>; }; + }; + if (eventNameArr.length > 1) { + const serviceName = 'get' + (eventNameArr[0]?.replace('NodeIKernel', '') ?? ''); + const eventName = eventNameArr[1]; + const services = (this.WrapperSession as unknown as eventType)[serviceName]?.(); + if (!services || !eventName) { + return undefined; + } + let event = services[eventName]; + + // 重新绑定this + event = event?.bind(services); + if (event) { + return event as T; + } + return undefined; + } + return undefined; + } + + createListenerFunction (listenerMainName: string, uniqueCode: string = ''): T { + const existListener = this.listenerManager.get(listenerMainName + uniqueCode); + if (!existListener) { + const Listener = this.createProxyDispatch(listenerMainName); + const ServiceSubName = /^NodeIKernel(.*?)Listener$/.exec(listenerMainName)![1]; + const Service = `NodeIKernel${ServiceSubName}Service/addKernel${ServiceSubName}Listener`; + + // @ts-ignore + this.createEventFunction(Service)(Listener as T); + this.listenerManager.set(listenerMainName + uniqueCode, Listener); + return Listener as T; + } + return existListener as T; + } + + // 统一回调清理事件 + async dispatcherListener(ListenerMainName: string, ListenerSubName: string, ...args: any[]) { + this.EventTask.get(ListenerMainName) + ?.get(ListenerSubName) + ?.forEach((task, uuid) => { + if (task.createtime + task.timeout < Date.now()) { + this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.delete(uuid); + return; + } + if (task?.checker?.(...args)) { + task.func(...args); + } + }); + } + + async callNoListenerEvent< + Service extends keyof ServiceNamingMapping, + ServiceMethod extends FuncKeys, + EventType extends (...args: any) => any = EnsureFunc + >( + serviceAndMethod: `${Service}/${ServiceMethod}`, + ...args: Parameters + ): Promise>> { + return (this.createEventFunction(serviceAndMethod))!(...args); + } + + async registerListen< + Listener extends keyof ListenerNamingMapping, + ListenerMethod extends FuncKeys, + ListenerType extends (...args: any) => any = EnsureFunc + >( + listenerAndMethod: `${Listener}/${ListenerMethod}`, + checker: (...args: Parameters) => boolean, + waitTimes = 1, + timeout = 5000 + ) { + return new Promise>((resolve, reject) => { + const ListenerNameList = listenerAndMethod.split('/'); + const ListenerMainName = ListenerNameList[0] ?? ''; + const ListenerSubName = ListenerNameList[1] ?? ''; + const id = randomUUID(); + let complete = 0; + let retData: Parameters | undefined; + + function sendDataCallback() { + if (complete === 0) { + reject(new Error(' ListenerName:' + listenerAndMethod + ' timeout')); + } else { + resolve(retData!); + } + } + + const timeoutRef = setTimeout(sendDataCallback, timeout); + const eventCallback = { + timeout, + createtime: Date.now(), + checker, + func: (...args: Parameters) => { + complete++; + retData = args; + if (complete >= waitTimes) { + clearTimeout(timeoutRef); + sendDataCallback(); + } + }, + }; + if (!this.EventTask.get(ListenerMainName)) { + this.EventTask.set(ListenerMainName, new Map()); + } + if (!this.EventTask.get(ListenerMainName)?.get(ListenerSubName)) { + this.EventTask.get(ListenerMainName)?.set(ListenerSubName, new Map()); + } + this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.set(id, eventCallback); + this.createListenerFunction(ListenerMainName); + }); + } + + async callNormalEventV2< + Service extends keyof ServiceNamingMapping, + ServiceMethod extends FuncKeys, + Listener extends keyof ListenerNamingMapping, + ListenerMethod extends FuncKeys, + EventType extends (...args: any) => any = EnsureFunc, + ListenerType extends (...args: any) => any = EnsureFunc + >( + serviceAndMethod: `${Service}/${ServiceMethod}`, + listenerAndMethod: `${Listener}/${ListenerMethod}`, + args: Parameters, + checkerEvent: (ret: Awaited>) => boolean = () => true, + checkerListener: (...args: Parameters) => boolean = () => true, + callbackTimesToWait = 1, + timeout = 5000 + ) { + const id = randomUUID(); + let complete = 0; + let retData: Parameters | undefined; + let retEvent: any = {}; + + function sendDataCallback(resolve: any, reject: any) { + if (complete === 0) { + reject( + new Error( + 'Timeout: NTEvent serviceAndMethod:' + + serviceAndMethod + + ' ListenerName:' + + listenerAndMethod + + ' EventRet:\n' + + JSON.stringify(retEvent, null, 4) + + '\n' + ) + ); + } else { + resolve([retEvent as Awaited>, ...retData!]); + } + } + + const ListenerNameList = listenerAndMethod.split('/'); + const ListenerMainName = ListenerNameList[0] ?? ''; + const ListenerSubName = ListenerNameList[1] ?? ''; + + return new Promise<[EventRet: Awaited>, ...Parameters]>( + (resolve, reject) => { + const timeoutRef = setTimeout(() => sendDataCallback(resolve, reject), timeout); + + const eventCallback = { + timeout, + createtime: Date.now(), + checker: checkerListener, + func: (...args: any[]) => { + complete++; + retData = args as Parameters; + if (complete >= callbackTimesToWait) { + clearTimeout(timeoutRef); + sendDataCallback(resolve, reject); + } + }, + }; + if (!this.EventTask.get(ListenerMainName)) { + this.EventTask.set(ListenerMainName, new Map()); + } + if (!this.EventTask.get(ListenerMainName)?.get(ListenerSubName)) { + this.EventTask.get(ListenerMainName)?.set(ListenerSubName, new Map()); + } + this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.set(id, eventCallback); + this.createListenerFunction(ListenerMainName); + + const eventResult = this.createEventFunction(serviceAndMethod)!(...(args)); + + const eventRetHandle = (eventData: any) => { + retEvent = eventData; + if (!checkerEvent(retEvent) && timeoutRef.hasRef()) { + clearTimeout(timeoutRef); + reject( + new Error( + 'EventChecker Failed: NTEvent serviceAndMethod:' + + serviceAndMethod + + ' ListenerName:' + + listenerAndMethod + + ' EventRet:\n' + + JSON.stringify(retEvent, null, 4) + + '\n' + ) + ); + } + }; + if (eventResult instanceof Promise) { + eventResult.then((eventResult: any) => { + eventRetHandle(eventResult); + }) + .catch(reject); + } else { + eventRetHandle(eventResult); + } + } + ); + } +} diff --git a/packages/napcat-core/helper/qq-basic-info.ts b/packages/napcat-core/helper/qq-basic-info.ts new file mode 100644 index 00000000..c8273c52 --- /dev/null +++ b/packages/napcat-core/helper/qq-basic-info.ts @@ -0,0 +1,106 @@ +import fs from 'node:fs'; +import { systemPlatform } from 'napcat-common/src/system'; +import { getDefaultQQVersionConfigInfo, getQQPackageInfoPath, getQQVersionConfigPath, parseAppidFromMajor } from 'napcat-common/src/helper'; +import AppidTable from '@/napcat-core/external/appid.json'; +import { LogWrapper } from 'napcat-common/src/log'; +import { getMajorPath } from '@/napcat-core/index'; +import { QQAppidTableType, QQPackageInfoType, QQVersionConfigType } from 'napcat-common/src/types'; + +export class QQBasicInfoWrapper { + QQMainPath: string | undefined; + QQPackageInfoPath: string | undefined; + QQVersionConfigPath: string | undefined; + isQuickUpdate: boolean | undefined; + QQVersionConfig: QQVersionConfigType | undefined; + QQPackageInfo: QQPackageInfoType | undefined; + QQVersionAppid: string | undefined; + QQVersionQua: string | undefined; + context: { logger: LogWrapper; }; + + constructor (context: { logger: LogWrapper; }) { + // 基础目录获取 + this.context = context; + this.QQMainPath = process.execPath; + this.QQVersionConfigPath = getQQVersionConfigPath(this.QQMainPath); + + // 基础信息获取 无快更则启用默认模板填充 + this.isQuickUpdate = !!this.QQVersionConfigPath; + this.QQVersionConfig = this.isQuickUpdate + ? JSON.parse(fs.readFileSync(this.QQVersionConfigPath!).toString()) + : getDefaultQQVersionConfigInfo(); + + this.QQPackageInfoPath = getQQPackageInfoPath(this.QQMainPath, this.QQVersionConfig?.curVersion); + this.QQPackageInfo = JSON.parse(fs.readFileSync(this.QQPackageInfoPath).toString()); + const { appid: IQQVersionAppid, qua: IQQVersionQua } = this.getAppidV2(); + this.QQVersionAppid = IQQVersionAppid; + this.QQVersionQua = IQQVersionQua; + } + + // 基础函数 + getQQBuildStr () { + return this.QQVersionConfig?.curVersion.split('-')[1] ?? this.QQPackageInfo?.buildVersion; + } + + getFullQQVersion () { + const version = this.isQuickUpdate ? this.QQVersionConfig?.curVersion : this.QQPackageInfo?.version; + if (!version) throw new Error('QQ版本获取失败'); + return version; + } + + requireMinNTQQBuild (buildStr: string) { + const currentBuild = +(this.getQQBuildStr() ?? '0'); + if (currentBuild === 0) throw new Error('QQBuildStr获取失败'); + return currentBuild >= parseInt(buildStr); + } + + // 此方法不要直接使用 + getQUAFallback () { + const platformMapping: Partial> = { + win32: `V1_WIN_${this.getFullQQVersion()}_${this.getQQBuildStr()}_GW_B`, + darwin: `V1_MAC_${this.getFullQQVersion()}_${this.getQQBuildStr()}_GW_B`, + linux: `V1_LNX_${this.getFullQQVersion()}_${this.getQQBuildStr()}_GW_B`, + }; + return platformMapping[systemPlatform] ?? (platformMapping.win32)!; + } + + getAppIdFallback () { + const platformMapping: Partial> = { + win32: '537246092', + darwin: '537246140', + linux: '537246140', + }; + return platformMapping[systemPlatform] ?? '537246092'; + } + + getAppidV2 (): { appid: string; qua: string; } { + // 通过已有表 性能好 + const appidTbale = AppidTable as unknown as QQAppidTableType; + const fullVersion = this.getFullQQVersion(); + if (fullVersion) { + const data = appidTbale[fullVersion]; + if (data) { + return data; + } + } + // 通过Major拉取 性能差 + try { + const majorAppid = this.getAppidV2ByMajor(fullVersion); + if (majorAppid) { + this.context.logger.log('[QQ版本兼容性检测] 当前版本Appid未内置 通过Major获取 为了更好的性能请尝试更新NapCat'); + return { appid: majorAppid, qua: this.getQUAFallback() }; + } + } catch { + this.context.logger.log('[QQ版本兼容性检测] 通过Major 获取Appid异常 请检测NapCat/QQNT是否正常'); + } + // 最终兜底为老版本 + this.context.logger.log('[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常'); + this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`); + return { appid: this.getAppIdFallback(), qua: this.getQUAFallback() }; + } + + getAppidV2ByMajor (QQVersion: string) { + const majorPath = getMajorPath(QQVersion); + const appid = parseAppidFromMajor(majorPath); + return appid; + } +} diff --git a/packages/napcat-core/index.ts b/packages/napcat-core/index.ts index 93716f8f..ce93309c 100644 --- a/packages/napcat-core/index.ts +++ b/packages/napcat-core/index.ts @@ -6,7 +6,7 @@ import { NTQQSystemApi, NTQQUserApi, NTQQWebApi, -} from 'napcat-core/apis'; +} from '@/napcat-core/apis'; import { NTQQCollectionApi } from '@/napcat-core/apis/collection'; import { NodeIQQNTWrapperSession, diff --git a/packages/napcat-core/listeners/NodeIKernelMsgListener.ts b/packages/napcat-core/listeners/NodeIKernelMsgListener.ts index d2f1682c..21c79a21 100644 --- a/packages/napcat-core/listeners/NodeIKernelMsgListener.ts +++ b/packages/napcat-core/listeners/NodeIKernelMsgListener.ts @@ -1,5 +1,5 @@ import { ChatType, KickedOffLineInfo, RawMessage } from '@/napcat-core/types'; -import { CommonFileInfo } from 'napcat-core/index'; +import { CommonFileInfo } from '@/napcat-core/index'; export interface OnRichMediaDownloadCompleteParams { fileModelId: string, diff --git a/packages/napcat-core/package.json b/packages/napcat-core/package.json index 110a527b..d3c8af38 100644 --- a/packages/napcat-core/package.json +++ b/packages/napcat-core/package.json @@ -4,6 +4,9 @@ "private": true, "type": "module", "main": "index.ts", + "scripts": { + "typecheck": "tsc --noEmit --skipLibCheck -p tsconfig.json" + }, "exports": { ".": { "import": "./index.ts" diff --git a/packages/napcat-core/packet/context/operationContext.ts b/packages/napcat-core/packet/context/operationContext.ts index 5ba97a6d..b1312687 100644 --- a/packages/napcat-core/packet/context/operationContext.ts +++ b/packages/napcat-core/packet/context/operationContext.ts @@ -9,7 +9,7 @@ import { PacketMsgReplyElement, PacketMsgVideoElement, } from '@/napcat-core/packet/message/element'; -import { ChatType, MsgSourceType, NTMsgType, RawMessage } from 'napcat-core/index'; +import { ChatType, MsgSourceType, NTMsgType, RawMessage } from '@/napcat-core/index'; import { MiniAppRawData, MiniAppReqParams } from '@/napcat-core/packet/entities/miniApp'; import { AIVoiceChatType } from '@/napcat-core/packet/entities/aiChat'; import { NapProtoDecodeStructType, NapProtoEncodeStructType, NapProtoMsg } from 'napcat-protobuf'; diff --git a/packages/napcat-core/packet/context/packetContext.ts b/packages/napcat-core/packet/context/packetContext.ts index f224fa7c..80e4c8ae 100644 --- a/packages/napcat-core/packet/context/packetContext.ts +++ b/packages/napcat-core/packet/context/packetContext.ts @@ -1,5 +1,5 @@ import { PacketHighwayContext } from '@/napcat-core/packet/highway/highwayContext'; -import { NapCatCore } from 'napcat-core/index'; +import { NapCatCore } from '@/napcat-core/index'; import { PacketLogger } from '@/napcat-core/packet/context/loggerContext'; import { NapCoreContext } from '@/napcat-core/packet/context/napCoreContext'; import { PacketClientContext } from '@/napcat-core/packet/context/clientContext'; diff --git a/packages/napcat-core/packet/message/element.ts b/packages/napcat-core/packet/message/element.ts index a9839ada..54b0b97d 100644 --- a/packages/napcat-core/packet/message/element.ts +++ b/packages/napcat-core/packet/message/element.ts @@ -32,7 +32,7 @@ import { SendTextElement, SendVideoElement, Peer, -} from 'napcat-core/index'; +} from '@/napcat-core/index'; import { ForwardMsgBuilder } from 'napcat-common/src/forward-msg-builder'; import { PacketMsg, PacketSendMsgElement } from '@/napcat-core/packet/message/message'; diff --git a/packages/napcat-core/packet/message/message.ts b/packages/napcat-core/packet/message/message.ts index 4970d2a1..d36de8dd 100644 --- a/packages/napcat-core/packet/message/message.ts +++ b/packages/napcat-core/packet/message/message.ts @@ -1,5 +1,5 @@ import { IPacketMsgElement } from '@/napcat-core/packet/message/element'; -import { SendMessageElement, SendMultiForwardMsgElement } from 'napcat-core/index'; +import { SendMessageElement, SendMultiForwardMsgElement } from '@/napcat-core/index'; export type PacketSendMsgElement = SendMessageElement | SendMultiForwardMsgElement; diff --git a/packages/napcat-core/services/NodeIKernelProfileService.ts b/packages/napcat-core/services/NodeIKernelProfileService.ts index bc650791..b3edfd84 100644 --- a/packages/napcat-core/services/NodeIKernelProfileService.ts +++ b/packages/napcat-core/services/NodeIKernelProfileService.ts @@ -1,5 +1,5 @@ import { AnyCnameRecord } from 'node:dns'; -import { BizKey, ModifyProfileParams, NodeIKernelProfileListener, ProfileBizType, SimpleInfo, UserDetailInfoByUin, UserDetailInfoListenerArg, UserDetailSource } from 'napcat-core/index'; +import { BizKey, ModifyProfileParams, NodeIKernelProfileListener, ProfileBizType, SimpleInfo, UserDetailInfoByUin, UserDetailInfoListenerArg, UserDetailSource } from '@/napcat-core/index'; import { GeneralCallResult } from '@/napcat-core/services/common'; export interface NodeIKernelProfileService { diff --git a/packages/napcat-core/tsconfig.json b/packages/napcat-core/tsconfig.json index 793e19cb..a91bfe0a 100644 --- a/packages/napcat-core/tsconfig.json +++ b/packages/napcat-core/tsconfig.json @@ -36,8 +36,8 @@ "resolveJsonModule": true, "baseUrl": ".", "paths": { - "@/napcat-core/*": [ - "*" + "@/*": [ + "../*" ] }, "skipLibCheck": true, diff --git a/packages/napcat-framework/napcat.ts b/packages/napcat-framework/napcat.ts index 35642d26..6e950ce5 100644 --- a/packages/napcat-framework/napcat.ts +++ b/packages/napcat-framework/napcat.ts @@ -7,7 +7,7 @@ import { SelfInfo } from 'napcat-core/types'; import { NodeIKernelLoginListener } from 'napcat-core/listeners'; import { NodeIKernelLoginService } from 'napcat-core/services'; import { NodeIQQNTWrapperSession, WrapperNodeApi } from 'napcat-core/wrapper'; -import { InitWebUi, WebUiConfig, webUiRuntimePort } from 'napcat-webui-backend/src/index'; +import { InitWebUi, WebUiConfig, webUiRuntimePort } from 'napcat-webui-backend/index'; import { NapCatOneBot11Adapter } from 'napcat-onebot/index'; import { FFmpegService } from 'napcat-common/src/ffmpeg'; import { NativePacketHandler } from 'napcat-core/packet/handler/client'; diff --git a/packages/napcat-framework/tsconfig.json b/packages/napcat-framework/tsconfig.json index b1a09c97..a91bfe0a 100644 --- a/packages/napcat-framework/tsconfig.json +++ b/packages/napcat-framework/tsconfig.json @@ -36,10 +36,9 @@ "resolveJsonModule": true, "baseUrl": ".", "paths": { - "@/napcat-onebot/*": ["../napcat-onebot/*"], - "@/napcat-core/*": ["../napcat-core/*"], - "@/napcat-common/*": ["../napcat-common/src/*"], - "@/napcat-webui-backend/*": ["../napcat-webui-backend/src/*"] + "@/*": [ + "../*" + ] }, "skipLibCheck": true, "skipDefaultLibCheck": true diff --git a/packages/napcat-framework/vite.config.ts b/packages/napcat-framework/vite.config.ts index 65dab29c..6ada540d 100644 --- a/packages/napcat-framework/vite.config.ts +++ b/packages/napcat-framework/vite.config.ts @@ -46,10 +46,10 @@ const FrameworkBaseConfig = () => conditions: ['node', 'default'], alias: { '@/napcat-core': resolve(__dirname, '../napcat-core'), - '@/napcat-common': resolve(__dirname, '../napcat-common/src'), + '@/napcat-common': resolve(__dirname, '../napcat-common'), '@/napcat-onebot': resolve(__dirname, '../napcat-onebot'), '@/napcat-pty': resolve(__dirname, '../napcat-pty'), - '@/napcat-webui-backend': resolve(__dirname, '../napcat-webui-backend/src'), + '@/napcat-webui-backend': resolve(__dirname, '../napcat-webui-backend'), '@/image-size': resolve(__dirname, '../image-size'), }, }, diff --git a/packages/napcat-image-size/tsconfig.json b/packages/napcat-image-size/tsconfig.json index cfe58f59..7244a40b 100644 --- a/packages/napcat-image-size/tsconfig.json +++ b/packages/napcat-image-size/tsconfig.json @@ -36,8 +36,8 @@ "resolveJsonModule": true, "baseUrl": ".", "paths": { - "@/napcat-webui-backend/*": [ - "src/*" + "@/*": [ + "../*" ] }, "skipLibCheck": true, diff --git a/packages/napcat-onebot/api/group.ts b/packages/napcat-onebot/api/group.ts index 4a6f36c5..d18e2f14 100644 --- a/packages/napcat-onebot/api/group.ts +++ b/packages/napcat-onebot/api/group.ts @@ -11,7 +11,6 @@ import { TipGroupElement, TipGroupElementType, } from 'napcat-core'; -import { NapCatOneBot11Adapter } from '@/napcat-onebot/index'; import { OB11GroupBanEvent } from '@/napcat-onebot/event/notice/OB11GroupBanEvent'; import fastXmlParser from 'fast-xml-parser'; import { OB11GroupMsgEmojiLikeEvent } from '@/napcat-onebot/event/notice/OB11MsgEmojiLikeEvent'; @@ -26,6 +25,7 @@ import { FileNapCatOneBotUUID } from 'napcat-common/src/file-uuid'; import { OB11GroupIncreaseEvent } from '../event/notice/OB11GroupIncreaseEvent'; import { NapProtoMsg } from 'napcat-protobuf'; import { GroupReactNotify, PushMsg } from 'napcat-core/packet/transformer/proto'; +import { NapCatOneBot11Adapter } from '..'; export class OneBotGroupApi { obContext: NapCatOneBot11Adapter; diff --git a/packages/napcat-onebot/index.ts b/packages/napcat-onebot/index.ts index 0a74bfe6..4a92d743 100644 --- a/packages/napcat-onebot/index.ts +++ b/packages/napcat-onebot/index.ts @@ -17,7 +17,7 @@ import { NTMsgAtType, } from 'napcat-core'; import { OB11ConfigLoader } from '@/napcat-onebot/config'; -import { pendingTokenToSend } from 'napcat-webui-backend/src/index'; +import { pendingTokenToSend } from 'napcat-webui-backend/index'; import { OB11HttpClientAdapter, OB11WebSocketClientAdapter, diff --git a/packages/napcat-onebot/package.json b/packages/napcat-onebot/package.json index d0d3296a..a3417a0b 100644 --- a/packages/napcat-onebot/package.json +++ b/packages/napcat-onebot/package.json @@ -4,6 +4,9 @@ "private": true, "type": "module", "main": "index.ts", + "scripts": { + "typecheck": "tsc --noEmit --skipLibCheck -p tsconfig.json" + }, "exports": { ".": { "import": "./index.ts" diff --git a/packages/napcat-onebot/tsconfig.json b/packages/napcat-onebot/tsconfig.json index 3e37ac59..a91bfe0a 100644 --- a/packages/napcat-onebot/tsconfig.json +++ b/packages/napcat-onebot/tsconfig.json @@ -36,8 +36,8 @@ "resolveJsonModule": true, "baseUrl": ".", "paths": { - "@/napcat-onebot/*": [ - "*" + "@/*": [ + "../*" ] }, "skipLibCheck": true, diff --git a/packages/napcat-pty/package.json b/packages/napcat-pty/package.json index ff0c5a33..84293b19 100644 --- a/packages/napcat-pty/package.json +++ b/packages/napcat-pty/package.json @@ -14,12 +14,7 @@ } }, "dependencies": { - "@homebridge/node-pty-prebuilt-multiarch":"^0.12.0", - "napcat-core": "workspace:*", - "napcat-common": "workspace:*", - "napcat-onebot": "workspace:*", - "napcat-webui-backend": "workspace:*", - "napcat-qrcode": "workspace:*" + "@homebridge/node-pty-prebuilt-multiarch":"^0.12.0" }, "devDependencies": { diff --git a/packages/napcat-shell/base.ts b/packages/napcat-shell/base.ts index e0f331f5..b37b12cb 100644 --- a/packages/napcat-shell/base.ts +++ b/packages/napcat-shell/base.ts @@ -26,7 +26,7 @@ import os from 'os'; import { LoginListItem, NodeIKernelLoginService } from 'napcat-core/services'; import qrcode from 'napcat-qrcode/lib/main'; import { NapCatOneBot11Adapter } from 'napcat-onebot/index'; -import { InitWebUi } from 'napcat-webui-backend/src/index'; +import { InitWebUi } from 'napcat-webui-backend/index'; import { WebUiDataRuntime } from 'napcat-webui-backend/src/helper/Data'; import { napCatVersion } from 'napcat-common/src/version'; import { NodeIO3MiscListener } from 'napcat-core/listeners/NodeIO3MiscListener'; diff --git a/packages/napcat-shell/tsconfig.json b/packages/napcat-shell/tsconfig.json index b1a09c97..a91bfe0a 100644 --- a/packages/napcat-shell/tsconfig.json +++ b/packages/napcat-shell/tsconfig.json @@ -36,10 +36,9 @@ "resolveJsonModule": true, "baseUrl": ".", "paths": { - "@/napcat-onebot/*": ["../napcat-onebot/*"], - "@/napcat-core/*": ["../napcat-core/*"], - "@/napcat-common/*": ["../napcat-common/src/*"], - "@/napcat-webui-backend/*": ["../napcat-webui-backend/src/*"] + "@/*": [ + "../*" + ] }, "skipLibCheck": true, "skipDefaultLibCheck": true diff --git a/packages/napcat-shell/vite.config.ts b/packages/napcat-shell/vite.config.ts index 66609067..790ff370 100644 --- a/packages/napcat-shell/vite.config.ts +++ b/packages/napcat-shell/vite.config.ts @@ -41,10 +41,10 @@ const ShellBaseConfig = (source_map: boolean = false) => conditions: ['node', 'default'], alias: { '@/napcat-core': resolve(__dirname, '../napcat-core'), - '@/napcat-common': resolve(__dirname, '../napcat-common/src'), + '@/napcat-common': resolve(__dirname, '../napcat-common'), '@/napcat-onebot': resolve(__dirname, '../napcat-onebot'), '@/napcat-pty': resolve(__dirname, '../napcat-pty'), - '@/napcat-webui-backend': resolve(__dirname, '../napcat-webui-backend/src'), + '@/napcat-webui-backend': resolve(__dirname, '../napcat-webui-backend'), '@/image-size': resolve(__dirname, '../image-size'), }, }, diff --git a/packages/napcat-webui-backend/src/index.ts b/packages/napcat-webui-backend/index.ts similarity index 94% rename from packages/napcat-webui-backend/src/index.ts rename to packages/napcat-webui-backend/index.ts index 8fefe013..14549506 100644 --- a/packages/napcat-webui-backend/src/index.ts +++ b/packages/napcat-webui-backend/index.ts @@ -3,22 +3,22 @@ */ import express from 'express'; -import type { WebUiConfigType } from './types'; +import type { WebUiConfigType } from './src/types'; import { createServer } from 'http'; import { randomUUID } from 'node:crypto'; import { createServer as createHttpsServer } from 'https'; import { LogWrapper } from 'napcat-common/src/log'; import { NapCatPathWrapper } from 'napcat-common/src/path'; -import { WebUiConfigWrapper } from '@/napcat-webui-backend/helper/config'; -import { ALLRouter } from '@/napcat-webui-backend/router'; -import { cors } from '@/napcat-webui-backend/middleware/cors'; -import { createUrl, getRandomToken } from '@/napcat-webui-backend/utils/url'; -import { sendError } from '@/napcat-webui-backend/utils/response'; +import { WebUiConfigWrapper } from '@/napcat-webui-backend/src/helper/config'; +import { ALLRouter } from '@/napcat-webui-backend/src/router'; +import { cors } from '@/napcat-webui-backend/src/middleware/cors'; +import { createUrl, getRandomToken } from '@/napcat-webui-backend/src/utils/url'; +import { sendError } from '@/napcat-webui-backend/src/utils/response'; import { join } from 'node:path'; -import { terminalManager } from '@/napcat-webui-backend/terminal/terminal_manager'; +import { terminalManager } from '@/napcat-webui-backend/src/terminal/terminal_manager'; import multer from 'multer'; import * as net from 'node:net'; -import { WebUiDataRuntime } from './helper/Data'; +import { WebUiDataRuntime } from './src/helper/Data'; import { existsSync, readFileSync } from 'node:fs'; // 引入multer用于错误捕获 // 实例化Express diff --git a/packages/napcat-webui-backend/package.json b/packages/napcat-webui-backend/package.json index f3a0d78b..def0a219 100644 --- a/packages/napcat-webui-backend/package.json +++ b/packages/napcat-webui-backend/package.json @@ -3,7 +3,10 @@ "version": "0.0.1", "private": true, "type": "module", - "main": "src/index.ts", + "main": "index.ts", + "scripts": { + "typecheck": "tsc --noEmit --skipLibCheck -p tsconfig.json" + }, "exports": { ".": { "import": "./index.ts" diff --git a/packages/napcat-webui-backend/src/api/Auth.ts b/packages/napcat-webui-backend/src/api/Auth.ts index 2fcfabb8..9e2d46ae 100644 --- a/packages/napcat-webui-backend/src/api/Auth.ts +++ b/packages/napcat-webui-backend/src/api/Auth.ts @@ -1,12 +1,10 @@ import { RequestHandler } from 'express'; - +import { AuthHelper } from '@/napcat-webui-backend/src/helper/SignToken'; +import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data'; +import { sendSuccess, sendError } from '@/napcat-webui-backend/src/utils/response'; +import { isEmpty } from '@/napcat-webui-backend/src/utils/check'; import { WebUiConfig, getInitialWebUiToken, setInitialWebUiToken } from '@/napcat-webui-backend/index'; -import { AuthHelper } from '@/napcat-webui-backend/helper/SignToken'; -import { WebUiDataRuntime } from '@/napcat-webui-backend/helper/Data'; -import { sendSuccess, sendError } from '@/napcat-webui-backend/utils/response'; -import { isEmpty } from '@/napcat-webui-backend/utils/check'; - // 登录 export const LoginHandler: RequestHandler = async (req, res) => { // 获取WebUI配置 diff --git a/packages/napcat-webui-backend/src/api/BaseInfo.ts b/packages/napcat-webui-backend/src/api/BaseInfo.ts index 30c977c9..0cabb170 100644 --- a/packages/napcat-webui-backend/src/api/BaseInfo.ts +++ b/packages/napcat-webui-backend/src/api/BaseInfo.ts @@ -1,7 +1,7 @@ import { RequestHandler } from 'express'; -import { WebUiDataRuntime } from '@/napcat-webui-backend/helper/Data'; +import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data'; -import { sendSuccess } from '@/napcat-webui-backend/utils/response'; +import { sendSuccess } from '@/napcat-webui-backend/src/utils/response'; import { WebUiConfig } from '@/napcat-webui-backend/index'; export const GetNapCatVersion: RequestHandler = (_, res) => { diff --git a/packages/napcat-webui-backend/src/api/OB11Config.ts b/packages/napcat-webui-backend/src/api/OB11Config.ts index 6a124b5c..934172dc 100644 --- a/packages/napcat-webui-backend/src/api/OB11Config.ts +++ b/packages/napcat-webui-backend/src/api/OB11Config.ts @@ -3,9 +3,9 @@ import { existsSync, readFileSync } from 'node:fs'; import { resolve } from 'node:path'; import { loadConfig, OneBotConfig } from 'napcat-onebot/config/config'; import { webUiPathWrapper } from '@/napcat-webui-backend/index'; -import { WebUiDataRuntime } from '@/napcat-webui-backend/helper/Data'; -import { sendError, sendSuccess } from '@/napcat-webui-backend/utils/response'; -import { isEmpty } from '@/napcat-webui-backend/utils/check'; +import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data'; +import { sendError, sendSuccess } from '@/napcat-webui-backend/src/utils/response'; +import { isEmpty } from '@/napcat-webui-backend/src/utils/check'; import json5 from 'json5'; // 获取OneBot11配置 diff --git a/packages/napcat-webui-backend/src/api/QQLogin.ts b/packages/napcat-webui-backend/src/api/QQLogin.ts index bc0f8310..5d2328bc 100644 --- a/packages/napcat-webui-backend/src/api/QQLogin.ts +++ b/packages/napcat-webui-backend/src/api/QQLogin.ts @@ -1,8 +1,8 @@ import { RequestHandler } from 'express'; -import { WebUiDataRuntime } from '@/napcat-webui-backend/helper/Data'; -import { isEmpty } from '@/napcat-webui-backend/utils/check'; -import { sendError, sendSuccess } from '@/napcat-webui-backend/utils/response'; +import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data'; +import { isEmpty } from '@/napcat-webui-backend/src/utils/check'; +import { sendError, sendSuccess } from '@/napcat-webui-backend/src/utils/response'; import { WebUiConfig } from '@/napcat-webui-backend/index'; // 获取QQ登录二维码 diff --git a/packages/napcat-webui-backend/src/api/WebUIConfig.ts b/packages/napcat-webui-backend/src/api/WebUIConfig.ts index 2baada5e..f1f42bce 100644 --- a/packages/napcat-webui-backend/src/api/WebUIConfig.ts +++ b/packages/napcat-webui-backend/src/api/WebUIConfig.ts @@ -1,7 +1,7 @@ import { RequestHandler } from 'express'; import { WebUiConfig } from '@/napcat-webui-backend/index'; -import { sendError, sendSuccess } from '@/napcat-webui-backend/utils/response'; -import { isEmpty } from '@/napcat-webui-backend/utils/check'; +import { sendError, sendSuccess } from '@/napcat-webui-backend/src/utils/response'; +import { isEmpty } from '@/napcat-webui-backend/src/utils/check'; // 获取WebUI基础配置 export const GetWebUIConfigHandler: RequestHandler = async (_, res) => { diff --git a/packages/napcat-webui-backend/src/helper/SignToken.ts b/packages/napcat-webui-backend/src/helper/SignToken.ts index 78332afa..2d8fb6d9 100644 --- a/packages/napcat-webui-backend/src/helper/SignToken.ts +++ b/packages/napcat-webui-backend/src/helper/SignToken.ts @@ -1,6 +1,6 @@ import crypto from 'crypto'; import store from 'napcat-common/src/store'; -import type { WebUiCredentialJson, WebUiCredentialInnerJson } from '@/napcat-webui-backend/types'; +import type { WebUiCredentialJson, WebUiCredentialInnerJson } from '@/napcat-webui-backend/src/types'; export class AuthHelper { private static readonly secretKey = Math.random().toString(36).slice(2); diff --git a/packages/napcat-webui-backend/src/middleware/auth.ts b/packages/napcat-webui-backend/src/middleware/auth.ts index b570305a..c9d3c916 100644 --- a/packages/napcat-webui-backend/src/middleware/auth.ts +++ b/packages/napcat-webui-backend/src/middleware/auth.ts @@ -2,9 +2,9 @@ import { NextFunction, Request, Response } from 'express'; import { getInitialWebUiToken } from '@/napcat-webui-backend/index'; -import { AuthHelper } from '@/napcat-webui-backend/helper/SignToken'; -import { sendError } from '@/napcat-webui-backend/utils/response'; -import type { WebUiCredentialJson } from '@/napcat-webui-backend/types'; +import { AuthHelper } from '@/napcat-webui-backend/src/helper/SignToken'; +import { sendError } from '@/napcat-webui-backend/src/utils/response'; +import type { WebUiCredentialJson } from '@/napcat-webui-backend/src/types'; // 鉴权中间件 export async function auth (req: Request, res: Response, next: NextFunction) { diff --git a/packages/napcat-webui-backend/src/router/Base.ts b/packages/napcat-webui-backend/src/router/Base.ts index dec41c9a..e1935fea 100644 --- a/packages/napcat-webui-backend/src/router/Base.ts +++ b/packages/napcat-webui-backend/src/router/Base.ts @@ -1,6 +1,6 @@ import { Router } from 'express'; import { GetThemeConfigHandler, GetNapCatVersion, QQVersionHandler, SetThemeConfigHandler } from '../api/BaseInfo'; -import { StatusRealTimeHandler } from '@/napcat-webui-backend/api/Status'; +import { StatusRealTimeHandler } from '@/napcat-webui-backend/src/api/Status'; import { GetProxyHandler } from '../api/Proxy'; const router = Router(); diff --git a/packages/napcat-webui-backend/src/router/OB11Config.ts b/packages/napcat-webui-backend/src/router/OB11Config.ts index 0d649ff7..82277e12 100644 --- a/packages/napcat-webui-backend/src/router/OB11Config.ts +++ b/packages/napcat-webui-backend/src/router/OB11Config.ts @@ -1,6 +1,6 @@ import { Router } from 'express'; -import { OB11GetConfigHandler, OB11SetConfigHandler } from '@/napcat-webui-backend/api/OB11Config'; +import { OB11GetConfigHandler, OB11SetConfigHandler } from '@/napcat-webui-backend/src/api/OB11Config'; const router = Router(); // router:读取配置 diff --git a/packages/napcat-webui-backend/src/router/QQLogin.ts b/packages/napcat-webui-backend/src/router/QQLogin.ts index af4756f3..746e6f11 100644 --- a/packages/napcat-webui-backend/src/router/QQLogin.ts +++ b/packages/napcat-webui-backend/src/router/QQLogin.ts @@ -9,7 +9,7 @@ import { getQQLoginInfoHandler, getAutoLoginAccountHandler, setAutoLoginAccountHandler, -} from '@/napcat-webui-backend/api/QQLogin'; +} from '@/napcat-webui-backend/src/api/QQLogin'; const router = Router(); // router:获取快速登录列表 diff --git a/packages/napcat-webui-backend/src/router/WebUIConfig.ts b/packages/napcat-webui-backend/src/router/WebUIConfig.ts index 7adc2ab7..ccf80b7d 100644 --- a/packages/napcat-webui-backend/src/router/WebUIConfig.ts +++ b/packages/napcat-webui-backend/src/router/WebUIConfig.ts @@ -6,7 +6,7 @@ import { GetDisableNonLANAccessHandler, UpdateDisableNonLANAccessHandler, UpdateWebUIConfigHandler, -} from '@/napcat-webui-backend/api/WebUIConfig'; +} from '@/napcat-webui-backend/src/api/WebUIConfig'; const router = Router(); diff --git a/packages/napcat-webui-backend/src/router/auth.ts b/packages/napcat-webui-backend/src/router/auth.ts index 34d00814..830cf5a8 100644 --- a/packages/napcat-webui-backend/src/router/auth.ts +++ b/packages/napcat-webui-backend/src/router/auth.ts @@ -5,7 +5,7 @@ import { LoginHandler, LogoutHandler, UpdateTokenHandler, -} from '@/napcat-webui-backend/api/Auth'; +} from '@/napcat-webui-backend/src/api/Auth'; const router = Router(); // router:登录 diff --git a/packages/napcat-webui-backend/src/router/index.ts b/packages/napcat-webui-backend/src/router/index.ts index effdb7e3..a83c3c7b 100644 --- a/packages/napcat-webui-backend/src/router/index.ts +++ b/packages/napcat-webui-backend/src/router/index.ts @@ -4,14 +4,14 @@ import { Router } from 'express'; -import { OB11ConfigRouter } from '@/napcat-webui-backend/router/OB11Config'; -import { auth } from '@/napcat-webui-backend/middleware/auth'; -import { sendSuccess } from '@/napcat-webui-backend/utils/response'; +import { OB11ConfigRouter } from '@/napcat-webui-backend/src/router/OB11Config'; +import { auth } from '@/napcat-webui-backend/src/middleware/auth'; +import { sendSuccess } from '@/napcat-webui-backend/src/utils/response'; -import { QQLoginRouter } from '@/napcat-webui-backend/router/QQLogin'; -import { AuthRouter } from '@/napcat-webui-backend/router/auth'; -import { LogRouter } from '@/napcat-webui-backend/router/Log'; -import { BaseRouter } from '@/napcat-webui-backend/router/Base'; +import { QQLoginRouter } from '@/napcat-webui-backend/src/router/QQLogin'; +import { AuthRouter } from '@/napcat-webui-backend/src/router/auth'; +import { LogRouter } from '@/napcat-webui-backend/src/router/Log'; +import { BaseRouter } from '@/napcat-webui-backend/src/router/Base'; import { FileRouter } from './File'; import { WebUIConfigRouter } from './WebUIConfig'; diff --git a/packages/napcat-webui-backend/src/terminal/terminal_manager.ts b/packages/napcat-webui-backend/src/terminal/terminal_manager.ts index 76d698dd..5af29c3d 100644 --- a/packages/napcat-webui-backend/src/terminal/terminal_manager.ts +++ b/packages/napcat-webui-backend/src/terminal/terminal_manager.ts @@ -1,7 +1,7 @@ // import './init-dynamic-dirname'; -import { WebUiConfig } from '../index'; +import { WebUiConfig } from '../../index'; import { AuthHelper } from '../helper/SignToken'; -import type { WebUiCredentialJson } from '@/napcat-webui-backend/types'; +import type { WebUiCredentialJson } from '@/napcat-webui-backend/src/types'; import { LogWrapper } from 'napcat-common/src/log'; import { WebSocket, WebSocketServer } from 'ws'; import os from 'os'; diff --git a/packages/napcat-webui-backend/src/utils/response.ts b/packages/napcat-webui-backend/src/utils/response.ts index 0d0a80b5..c97d3d97 100644 --- a/packages/napcat-webui-backend/src/utils/response.ts +++ b/packages/napcat-webui-backend/src/utils/response.ts @@ -1,6 +1,6 @@ import type { Response } from 'express'; -import { ResponseCode, HttpStatusCode } from '@/napcat-webui-backend/const/status'; +import { ResponseCode, HttpStatusCode } from '@/napcat-webui-backend/src/const/status'; export const sendResponse = ( res: Response, diff --git a/packages/napcat-webui-backend/tsconfig.json b/packages/napcat-webui-backend/tsconfig.json index 9dd57e57..e499f9cc 100644 --- a/packages/napcat-webui-backend/tsconfig.json +++ b/packages/napcat-webui-backend/tsconfig.json @@ -11,7 +11,7 @@ ], "esModuleInterop": true, "outDir": "dist", - "rootDir": "src", + "rootDir": ".", "noEmit": false, "sourceMap": true, "strict": true, @@ -36,14 +36,15 @@ "resolveJsonModule": true, "baseUrl": ".", "paths": { - "@/napcat-webui-backend/*": [ - "src/*" + "@/*": [ + "../*" ] }, "skipLibCheck": true, "skipDefaultLibCheck": true }, "include": [ + "*.ts", "src/**/*.ts", "src/**/*.d.ts" ], diff --git a/packages/napcat-webui-frontend/package.json b/packages/napcat-webui-frontend/package.json index 798cecf7..2f9ed746 100644 --- a/packages/napcat-webui-frontend/package.json +++ b/packages/napcat-webui-frontend/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "vite --host=0.0.0.0", "build": "tsc && vite build", + "typecheck": "tsc --noEmit", "lint": "eslint -c eslint.config.mjs ./src/**/**/*.{ts,tsx} --fix", "preview": "vite preview" },