diff --git a/.github/scripts/lib/comment.ts b/.github/scripts/lib/comment.ts index 15065267..3bec634b 100644 --- a/.github/scripts/lib/comment.ts +++ b/.github/scripts/lib/comment.ts @@ -84,8 +84,8 @@ export function generateBuildingComment (prSha: string, targets: string[]): stri '', '## 📋 构建信息', '', - `| 项目 | 值 |`, - `| :--- | :--- |`, + '| 项目 | 值 |', + '| :--- | :--- |', `| 📝 提交 | \`${shortSha}\` |`, `| 🕐 开始时间 | ${time} |`, '', @@ -165,8 +165,8 @@ export function generateResultComment ( '', '## 📋 构建信息', '', - `| 项目 | 值 |`, - `| :--- | :--- |`, + '| 项目 | 值 |', + '| :--- | :--- |', ...(version ? [`| 🏷️ 版本号 | \`${version}\` |`] : []), `| 📝 提交 | \`${shortSha}\` |`, `| 🔗 构建日志 | [查看详情](${runUrl}) |`, @@ -179,7 +179,7 @@ export function generateResultComment ( lines.push('', '---', '', '## ⚠️ 错误详情', ''); for (const target of failedTargets) { lines.push( - `
`, + '
', `🔴 ${target.name} 构建错误`, '', '```', @@ -228,4 +228,3 @@ export function generateResultComment ( return lines.join('\n'); } - diff --git a/packages/napcat-common/src/file.ts b/packages/napcat-common/src/file.ts index 5d51e5ae..6411fa96 100644 --- a/packages/napcat-common/src/file.ts +++ b/packages/napcat-common/src/file.ts @@ -151,7 +151,7 @@ function httpDownloadWithProxy (url: string, headers: Record, pr const isTargetHttps = targetUrl.protocol === 'https:'; const proxyPort = parseInt(proxyUrl.port) || (proxyUrl.protocol === 'https:' ? 443 : 80); - + // 代理认证头 const proxyAuthHeader = proxyUrl.username && proxyUrl.password ? { 'Proxy-Authorization': 'Basic ' + Buffer.from(`${decodeURIComponent(proxyUrl.username)}:${decodeURIComponent(proxyUrl.password)}`).toString('base64') } @@ -165,7 +165,7 @@ function httpDownloadWithProxy (url: string, headers: Record, pr method: 'CONNECT', path: `${targetUrl.hostname}:${targetUrl.port || 443}`, headers: { - 'Host': `${targetUrl.hostname}:${targetUrl.port || 443}`, + Host: `${targetUrl.hostname}:${targetUrl.port || 443}`, ...proxyAuthHeader, }, }); @@ -179,7 +179,7 @@ function httpDownloadWithProxy (url: string, headers: Record, pr // 在隧道上建立 TLS 连接 const tlsSocket = tls.connect({ - socket: socket, + socket, servername: targetUrl.hostname, rejectUnauthorized: true, }, () => { @@ -187,14 +187,14 @@ function httpDownloadWithProxy (url: string, headers: Record, pr const requestPath = targetUrl.pathname + targetUrl.search; const requestHeaders = { ...headers, - 'Host': targetUrl.hostname, - 'Connection': 'close', + Host: targetUrl.hostname, + Connection: 'close', }; - + const headerLines = Object.entries(requestHeaders) .map(([key, value]) => `${key}: ${value}`) .join('\r\n'); - + const httpRequest = `GET ${requestPath} HTTP/1.1\r\n${headerLines}\r\n\r\n`; tlsSocket.write(httpRequest); }); @@ -209,19 +209,19 @@ function httpDownloadWithProxy (url: string, headers: Record, pr tlsSocket.on('data', (chunk: Buffer) => { responseData = Buffer.concat([responseData, chunk]); - + if (!headersParsed) { const headerEndIndex = responseData.indexOf('\r\n\r\n'); if (headerEndIndex !== -1) { headersParsed = true; const headerStr = responseData.subarray(0, headerEndIndex).toString(); const headerLines = headerStr.split('\r\n'); - + // 解析状态码 const statusLine = headerLines[0]; const statusMatch = statusLine?.match(/HTTP\/\d\.\d\s+(\d+)/); statusCode = statusMatch ? parseInt(statusMatch[1]!) : 0; - + // 解析响应头 for (const line of headerLines.slice(1)) { const [key, ...valueParts] = line.split(':'); @@ -232,7 +232,7 @@ function httpDownloadWithProxy (url: string, headers: Record, pr redirectLocation = value; } } - + bodyData = responseData.subarray(headerEndIndex + 4); } } else { @@ -243,18 +243,18 @@ function httpDownloadWithProxy (url: string, headers: Record, pr tlsSocket.on('end', () => { // 处理重定向 if (statusCode >= 300 && statusCode < 400 && redirectLocation) { - const redirectUrl = redirectLocation.startsWith('http') - ? redirectLocation + const redirectUrl = redirectLocation.startsWith('http') + ? redirectLocation : `${targetUrl.protocol}//${targetUrl.host}${redirectLocation}`; httpDownloadWithProxy(redirectUrl, headers, proxy).then(resolve).catch(reject); return; } - + if (statusCode !== 200) { reject(new Error(`下载失败: ${statusCode}`)); return; } - + // 处理 chunked 编码 if (isChunked) { resolve(parseChunkedBody(bodyData)); @@ -282,7 +282,7 @@ function httpDownloadWithProxy (url: string, headers: Record, pr path: url, // 完整 URL headers: { ...headers, - 'Host': targetUrl.hostname, + Host: targetUrl.hostname, ...proxyAuthHeader, }, }, (response) => { @@ -304,26 +304,26 @@ function httpDownloadWithProxy (url: string, headers: Record, pr function parseChunkedBody (data: Buffer): Buffer { const chunks: Buffer[] = []; let offset = 0; - + while (offset < data.length) { // 查找 chunk 大小行的结束 const lineEnd = data.indexOf('\r\n', offset); if (lineEnd === -1) break; - + const sizeStr = data.subarray(offset, lineEnd).toString().split(';')[0]; // 忽略 chunk 扩展 const chunkSize = parseInt(sizeStr!, 16); - + if (chunkSize === 0) break; // 最后一个 chunk - + const chunkStart = lineEnd + 2; const chunkEnd = chunkStart + chunkSize; - + if (chunkEnd > data.length) break; - + chunks.push(data.subarray(chunkStart, chunkEnd)); offset = chunkEnd + 2; // 跳过 chunk 数据后的 \r\n } - + return Buffer.concat(chunks); } diff --git a/packages/napcat-common/src/helper.ts b/packages/napcat-common/src/helper.ts index 94d898df..d9f2af04 100644 --- a/packages/napcat-common/src/helper.ts +++ b/packages/napcat-common/src/helper.ts @@ -253,7 +253,6 @@ export async function getAllTags (mirror?: string): Promise<{ tags: string[], mi return getAllTagsFromMirror('NapNeko', 'NapCatQQ', mirror); } - export async function getLatestTag (mirror?: string): Promise { const { tags } = await getAllTags(mirror); diff --git a/packages/napcat-common/src/log-interface.ts b/packages/napcat-common/src/log-interface.ts index 783887df..0c4376fc 100644 --- a/packages/napcat-common/src/log-interface.ts +++ b/packages/napcat-common/src/log-interface.ts @@ -21,4 +21,4 @@ export interface ILogWrapper { logWarn (...args: any[]): void; logFatal (...args: any[]): void; logMessage (msg: unknown, selfInfo: unknown): void; -} \ No newline at end of file +} diff --git a/packages/napcat-common/src/mirror.ts b/packages/napcat-common/src/mirror.ts index f6d4b59c..56df7036 100644 --- a/packages/napcat-common/src/mirror.ts +++ b/packages/napcat-common/src/mirror.ts @@ -1,7 +1,7 @@ /** * GitHub 镜像配置模块 * 提供统一的镜像源管理,支持复杂网络环境 - * + * * 镜像源测试时间: 2026-01-03 * 测试通过: 55/61 完全可用 */ @@ -17,7 +17,7 @@ import { PromiseTimer } from './helper'; * GitHub 文件加速镜像 * 用于加速 release assets 下载 * 按延迟排序,优先使用快速镜像 - * + * * 测试时间: 2026-01-03 * 镜像支持 301/302 重定向 * 懒加载测速:首次使用时自动测速,缓存 30 分钟 @@ -74,7 +74,7 @@ export const GITHUB_FILE_MIRRORS = [ * GitHub API 镜像 * 用于访问 GitHub API(作为备选方案) * 注:优先使用非 API 方法,减少对 API 的依赖 - * + * * 经测试,大部分代理镜像不支持 API 转发 * 建议使用 getLatestReleaseTag 等方法避免 API 调用 */ @@ -271,8 +271,6 @@ async function performMirrorTest (): Promise { .sort((a, b) => a.latency - b.latency) .map(r => r.mirror); - - // 至少返回原始 URL if (successfulMirrors.length === 0) { return ['']; @@ -287,7 +285,6 @@ async function performMirrorTest (): Promise { export function clearMirrorCache (): void { cachedFastMirrors = null; cacheTimestamp = 0; - } /** @@ -664,7 +661,7 @@ export function buildReleaseDownloadUrl ( /** * 获取 GitHub release 信息(优先使用非 API 方法) - * + * * 策略: * 1. 先通过 git refs 获取 tags * 2. 直接构建下载 URL,不依赖 API @@ -725,7 +722,7 @@ export async function getGitHubRelease ( const response = await PromiseTimer( RequestUtil.HttpGetJson(url, 'GET', undefined, { 'User-Agent': 'NapCat', - 'Accept': 'application/vnd.github.v3+json', + Accept: 'application/vnd.github.v3+json', }), currentConfig.timeout ); @@ -958,7 +955,7 @@ async function getWorkflowRunsFromHtml ( allRuns.push({ id, created_at: timeMatch[1], - title: title.trim() + title: title.trim(), }); } } @@ -994,7 +991,7 @@ async function getWorkflowRunsFromHtml ( /** * 通过 API 获取最新的 workflow runs,然后直接拼接 nightly.link 下载链接 * 无需解析 HTML,直接使用固定的 URL 格式 - * + * * 策略: * 1. 优先使用 GitHub API * 2. API 失败时,从 GitHub Actions HTML 页面解析 @@ -1042,7 +1039,6 @@ async function getArtifactsFromNightlyLink ( } } return { artifacts, mirror: runsMirror }; - } catch { return { artifacts: [], mirror: '' }; } @@ -1051,7 +1047,7 @@ async function getArtifactsFromNightlyLink ( /** * 获取 GitHub Action 最新运行的 artifacts * 用于下载 nightly/dev 版本 - * + * * 策略: * 1. 检查缓存(10分钟有效) * 2. 优先尝试从 nightly.link 获取(无需认证,更稳定) diff --git a/packages/napcat-common/src/subscription-interface.ts b/packages/napcat-common/src/subscription-interface.ts index 8f2978a6..28afc6d5 100644 --- a/packages/napcat-common/src/subscription-interface.ts +++ b/packages/napcat-common/src/subscription-interface.ts @@ -3,4 +3,4 @@ export interface ISubscription { subscribe (listener: LogListener): void; unsubscribe (listener: LogListener): void; notify (msg: string): void; -} \ No newline at end of file +} diff --git a/packages/napcat-core/apis/file.ts b/packages/napcat-core/apis/file.ts index a7acd3bc..2526b379 100644 --- a/packages/napcat-core/apis/file.ts +++ b/packages/napcat-core/apis/file.ts @@ -33,7 +33,7 @@ export class NTQQFileApi { 'http://ss.xingzhige.com/music_card/rkey', 'https://secret-service.bietiaop.com/rkeys', ], - this.context.logger + this.context.logger ); } diff --git a/packages/napcat-core/apis/online.ts b/packages/napcat-core/apis/online.ts index 4a89c61b..7a0207ad 100644 --- a/packages/napcat-core/apis/online.ts +++ b/packages/napcat-core/apis/online.ts @@ -114,7 +114,7 @@ export class NTQQOnlineApi { fileElement: { fileName: actualFolderName, filePath: folderPath, - fileSize: "", + fileSize: '', }, }; diff --git a/packages/napcat-core/apis/webapi.ts b/packages/napcat-core/apis/webapi.ts index ddf74a56..65a3aa78 100644 --- a/packages/napcat-core/apis/webapi.ts +++ b/packages/napcat-core/apis/webapi.ts @@ -164,8 +164,6 @@ export class NTQQWebApi { imgWidth: number = 540, imgHeight: number = 300 ) { - - const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com'); try { @@ -477,10 +475,10 @@ export class NTQQWebApi { const client_key = Date.now() * 1000; return await this.context.session.getAlbumService().doQunComment( random_seq, { - map_info: [], - map_bytes_info: [], - map_user_account: [], - }, + map_info: [], + map_bytes_info: [], + map_user_account: [], + }, qunId, 2, createAlbumMediaFeed(uin, albumId, lloc), @@ -511,13 +509,13 @@ export class NTQQWebApi { const uin = this.core.selfInfo.uin || '10001'; return await this.context.session.getAlbumService().doQunLike( random_seq, { - map_info: [], - map_bytes_info: [], - map_user_account: [], - }, { - id, - status: 1, - }, + map_info: [], + map_bytes_info: [], + map_user_account: [], + }, { + id, + status: 1, + }, createAlbumFeedPublish(qunId, uin, albumId, lloc) ); } diff --git a/packages/napcat-core/data/flash.ts b/packages/napcat-core/data/flash.ts index 83e5e31d..4636ecfc 100644 --- a/packages/napcat-core/data/flash.ts +++ b/packages/napcat-core/data/flash.ts @@ -212,7 +212,7 @@ export enum UploadSceneType { KUPLOADSCENEH5LAUNCHCLIENTSHORTCUTKEYCTRLCV, KUPLOADSCENEAIODRAG, KUPLOADSCENEAIOFILESELECTOR, - KUPLOADSCENEAIOSHORTCUTKEYCTRLCV + KUPLOADSCENEAIOSHORTCUTKEYCTRLCV, } export interface StartFlashTaskRequests { screen: number; // 1 PC-QQ @@ -237,7 +237,7 @@ export interface StartFlashTaskRequests { } export enum BusiScene { KBUSISCENEINVALID, - KBUSISCENEFLASHSCENE + KBUSISCENEFLASHSCENE, } export interface FileListInfoRequests { seq: number, // 0 @@ -274,7 +274,7 @@ export enum DownloadSceneType { KDOWNLOADSCENELINKOTHERINQQ, KDOWNLOADSCENESCANQRCODE, KDWONLOADSCENEFLASHTRANSFERCENTERCLIENT, - KDWONLOADSCENEFLASHTRANSFERCENTERSCHEMA + KDWONLOADSCENEFLASHTRANSFERCENTERSCHEMA, } export interface FlashFileSetInfo { fileSetId: string, diff --git a/packages/napcat-core/helper/audio.ts b/packages/napcat-core/helper/audio.ts index a4736d0e..96042161 100644 --- a/packages/napcat-core/helper/audio.ts +++ b/packages/napcat-core/helper/audio.ts @@ -22,7 +22,7 @@ export async function encodeSilk (filePath: string, TEMP_DIR: string, logger: Lo return { converted: true, path: pttPath, - duration: duration, + duration, }; } else { let duration = 0; diff --git a/packages/napcat-core/helper/ffmpeg/ffmpeg.ts b/packages/napcat-core/helper/ffmpeg/ffmpeg.ts index fdfe4365..5ea05739 100644 --- a/packages/napcat-core/helper/ffmpeg/ffmpeg.ts +++ b/packages/napcat-core/helper/ffmpeg/ffmpeg.ts @@ -64,10 +64,12 @@ export class FFmpegService { } return this.adapter; } + public static async convertToNTSilkTct (inputFile: string, outputFile: string): Promise { const adapter = await this.getAdapter(); await adapter.convertToNTSilkTct(inputFile, outputFile); } + /** * 设置 FFmpeg 路径并更新适配器 * @deprecated 建议使用 init() 方法初始化 diff --git a/packages/napcat-core/helper/forward-msg-builder.ts b/packages/napcat-core/helper/forward-msg-builder.ts index 6857df8d..09fbe396 100644 --- a/packages/napcat-core/helper/forward-msg-builder.ts +++ b/packages/napcat-core/helper/forward-msg-builder.ts @@ -112,11 +112,11 @@ export class ForwardMsgBuilder { preview: m.valid ? m.toPreview() : '[该消息类型暂不支持查看]', })), })), - source, - news, - summary, - prompt, - uuid, + source, + news, + summary, + prompt, + uuid ); } } diff --git a/packages/napcat-core/helper/session-proxy.ts b/packages/napcat-core/helper/session-proxy.ts index 920dab36..7e7f01ab 100644 --- a/packages/napcat-core/helper/session-proxy.ts +++ b/packages/napcat-core/helper/session-proxy.ts @@ -6,13 +6,13 @@ import { NTEventWrapper } from './event'; * 创建 Service 方法的代理 * 拦截所有方法调用,通过 EventWrapper 进行调用 */ -function createServiceMethodProxy( +function createServiceMethodProxy ( serviceName: S, originalService: ServiceNamingMapping[S], eventWrapper: NTEventWrapper ): ServiceNamingMapping[S] { return new Proxy(originalService as object, { - get(target, prop, receiver) { + get (target, prop, receiver) { const originalValue = Reflect.get(target, prop, receiver); // 如果不是函数,直接返回原始值 @@ -50,7 +50,7 @@ function createServiceMethodProxy( * 第一层:拦截 getXXXService 方法 * 第二层:拦截 Service 上的具体方法调用 */ -export function createSessionProxy( +export function createSessionProxy ( session: NodeIQQNTWrapperSession, eventWrapper: NTEventWrapper ): NodeIQQNTWrapperSession { @@ -58,7 +58,7 @@ export function createSessionProxy( const serviceProxyCache = new Map(); return new Proxy(session, { - get(target, prop, receiver) { + get (target, prop, receiver) { const propName = prop as string; // 检查是否是 getXXXService 方法 @@ -105,7 +105,7 @@ export function createSessionProxy( /** * 检查 Service 名称是否在已知的映射中 */ -function isKnownService(serviceName: string): serviceName is keyof ServiceNamingMapping { +function isKnownService (serviceName: string): serviceName is keyof ServiceNamingMapping { const knownServices: string[] = [ 'NodeIKernelAvatarService', 'NodeIKernelBuddyService', @@ -132,7 +132,7 @@ function isKnownService(serviceName: string): serviceName is keyof ServiceNaming * 创建带有 EventWrapper 集成的 InstanceContext * 这是推荐的使用方式,在创建 context 时自动代理 session */ -export function createProxiedSession( +export function createProxiedSession ( session: NodeIQQNTWrapperSession, eventWrapper: NTEventWrapper ): NodeIQQNTWrapperSession { diff --git a/packages/napcat-core/listeners/NodeIKernelLoginListener.ts b/packages/napcat-core/listeners/NodeIKernelLoginListener.ts index 3dc63be2..a9e85151 100644 --- a/packages/napcat-core/listeners/NodeIKernelLoginListener.ts +++ b/packages/napcat-core/listeners/NodeIKernelLoginListener.ts @@ -53,6 +53,7 @@ export class NodeIKernelLoginListener { onLoginState (..._args: any[]): any { } + onLoginRecordUpdate (..._args: any[]): any { } } diff --git a/packages/napcat-core/packet/context/operationContext.ts b/packages/napcat-core/packet/context/operationContext.ts index 34a2bde0..7c24492b 100644 --- a/packages/napcat-core/packet/context/operationContext.ts +++ b/packages/napcat-core/packet/context/operationContext.ts @@ -228,8 +228,9 @@ export class PacketOperationContext { const res = trans.UploadForwardMsg.parse(resp); return res.result.resId; } + async UploadForwardMsgV2 (msg: UploadForwardMsgParams[], groupUin: number = 0) { - //await this.SendPreprocess(msg, groupUin); + // await this.SendPreprocess(msg, groupUin); // 遍历上传资源 await Promise.allSettled(msg.map(async (item) => { return await this.SendPreprocess(item.actionMsg, groupUin); })); const req = trans.UploadForwardMsgV2.build(this.context.napcore.basicInfo.uid, msg, groupUin); @@ -237,6 +238,7 @@ export class PacketOperationContext { const res = trans.UploadForwardMsg.parse(resp); return res.result.resId; } + async MoveGroupFile ( groupUin: number, fileUUID: string, diff --git a/packages/napcat-core/packet/message/element.ts b/packages/napcat-core/packet/message/element.ts index d466391e..8c443eae 100644 --- a/packages/napcat-core/packet/message/element.ts +++ b/packages/napcat-core/packet/message/element.ts @@ -510,14 +510,14 @@ export class PacketMsgPttElement extends IPacketMsgElement { } override buildElement (): NapProtoEncodeStructType[] { - //return []; + // return []; if (!this.msgInfo) return []; return [{ commonElem: { serviceType: 48, pbElem: new NapProtoMsg(MsgInfo).encode(this.msgInfo), businessType: 22, - } + }, }]; } diff --git a/packages/napcat-core/packet/transformer/message/UploadForwardMsgV2.ts b/packages/napcat-core/packet/transformer/message/UploadForwardMsgV2.ts index 72348d34..ec8d5782 100644 --- a/packages/napcat-core/packet/transformer/message/UploadForwardMsgV2.ts +++ b/packages/napcat-core/packet/transformer/message/UploadForwardMsgV2.ts @@ -14,7 +14,7 @@ class UploadForwardMsgV2 extends PacketTransformer actionCommand: item.actionCommand, actionData: { msgBody: this.msgBuilder.buildFakeMsg(selfUid, item.actionMsg), - } + }, })); const longMsgResultData = new NapProtoMsg(proto.LongMsgResult).encode( { diff --git a/packages/napcat-core/packet/transformer/message/index.ts b/packages/napcat-core/packet/transformer/message/index.ts index d471b316..2fa1cc18 100644 --- a/packages/napcat-core/packet/transformer/message/index.ts +++ b/packages/napcat-core/packet/transformer/message/index.ts @@ -2,4 +2,4 @@ export { default as UploadForwardMsg } from './UploadForwardMsg'; export { default as FetchGroupMessage } from './FetchGroupMessage'; export { default as FetchC2CMessage } from './FetchC2CMessage'; export { default as DownloadForwardMsg } from './DownloadForwardMsg'; -export { default as UploadForwardMsgV2 } from './UploadForwardMsgV2'; \ No newline at end of file +export { default as UploadForwardMsgV2 } from './UploadForwardMsgV2'; diff --git a/packages/napcat-core/services/NodeIKernelMsgService.ts b/packages/napcat-core/services/NodeIKernelMsgService.ts index 3a33b799..b4b91a9e 100644 --- a/packages/napcat-core/services/NodeIKernelMsgService.ts +++ b/packages/napcat-core/services/NodeIKernelMsgService.ts @@ -687,14 +687,14 @@ export interface NodeIKernelMsgService { msgSeq: string; msgRandom: string; }>, DataMigrationResourceInfo: { - extraData: string; - filePath: string; - fileSize: string; - msgRandom: string; - msgSeq: string; - msgSubType: number; - msgType: number; - }): unknown; + extraData: string; + filePath: string; + fileSize: string; + msgRandom: string; + msgSeq: string; + msgSubType: number; + msgType: number; + }): unknown; dataMigrationGetResourceLocalDestinyPath (...args: unknown[]): unknown; diff --git a/packages/napcat-core/services/NodeIKernelStorageCleanService.ts b/packages/napcat-core/services/NodeIKernelStorageCleanService.ts index d0309658..7ccb798d 100644 --- a/packages/napcat-core/services/NodeIKernelStorageCleanService.ts +++ b/packages/napcat-core/services/NodeIKernelStorageCleanService.ts @@ -24,7 +24,7 @@ export interface NodeIKernelStorageCleanService { // "C:\\Users\\nanaeo\\AppData\\Roaming\\QQ\\Partitions\\qqnt_9212" // ] // ] - addCacheScanedPaths (paths: Map<`tmp` | `SilentCacheappSessionPartation9212` | `hotUpdate`, unknown>): unknown; + addCacheScanedPaths (paths: Map<'tmp' | 'SilentCacheappSessionPartation9212' | 'hotUpdate', unknown>): unknown; addFilesScanedPaths (arg: unknown): unknown; diff --git a/packages/napcat-develop/loadNapCat.cjs b/packages/napcat-develop/loadNapCat.cjs index df5c1686..4380dcc8 100644 --- a/packages/napcat-develop/loadNapCat.cjs +++ b/packages/napcat-develop/loadNapCat.cjs @@ -47,12 +47,12 @@ const itemsToCopy = [ 'package.json', 'QBar.dll', 'wrapper.node', - 'LightQuic.dll' + 'LightQuic.dll', ]; const win64ItemsToCopy = [ 'SSOShareInfoHelper64.dll', - 'parent-ipc-core-x64.dll' + 'parent-ipc-core-x64.dll', ]; async function copyAll () { diff --git a/packages/napcat-image-size/src/index.ts b/packages/napcat-image-size/src/index.ts index 8527dd05..e16f615d 100644 --- a/packages/napcat-image-size/src/index.ts +++ b/packages/napcat-image-size/src/index.ts @@ -158,7 +158,7 @@ function bufferToReadStream (buffer: Buffer): ReadStream { read () { this.push(buffer); this.push(null); - } + }, }); return readable as unknown as ReadStream; } diff --git a/packages/napcat-image-size/src/parser/JpegParser.ts b/packages/napcat-image-size/src/parser/JpegParser.ts index 042c899b..f4bdb40e 100644 --- a/packages/napcat-image-size/src/parser/JpegParser.ts +++ b/packages/napcat-image-size/src/parser/JpegParser.ts @@ -63,7 +63,6 @@ export class JpegParser implements ImageParser { const bufferSize = buffer.length; const MIN_REQUIRED_BYTES = 10; // SOF段最低字节数 - // 从JPEG头部后开始扫描 while (offset < bufferSize - MIN_REQUIRED_BYTES) { // 寻找FF标记 diff --git a/packages/napcat-onebot/action/OneBotAction.ts b/packages/napcat-onebot/action/OneBotAction.ts index 68f69457..75b6d0ed 100644 --- a/packages/napcat-onebot/action/OneBotAction.ts +++ b/packages/napcat-onebot/action/OneBotAction.ts @@ -10,9 +10,9 @@ export const ActionExamples = { errors: [ { code: 1400, description: '请求参数错误或业务逻辑执行失败' }, { code: 1401, description: '权限不足' }, - { code: 1404, description: '资源不存在' } - ] - } + { code: 1404, description: '资源不存在' }, + ], + }, }; export class OB11Response { diff --git a/packages/napcat-onebot/action/example/ExtendsActionsExamples.ts b/packages/napcat-onebot/action/example/ExtendsActionsExamples.ts index 0b72b34b..b59fe094 100644 --- a/packages/napcat-onebot/action/example/ExtendsActionsExamples.ts +++ b/packages/napcat-onebot/action/example/ExtendsActionsExamples.ts @@ -9,9 +9,9 @@ export const ExtendsActionsExamples = { { type: 'string', characters: [ - { character_id: 'id', character_name: 'name', preview_url: 'url' } - ] - } + { character_id: 'id', character_name: 'name', preview_url: 'url' }, + ], + }, ], }, GetClientkey: { diff --git a/packages/napcat-onebot/action/extends/ClickInlineKeyboardButton.ts b/packages/napcat-onebot/action/extends/ClickInlineKeyboardButton.ts index 7da559c9..f25123b0 100644 --- a/packages/napcat-onebot/action/extends/ClickInlineKeyboardButton.ts +++ b/packages/napcat-onebot/action/extends/ClickInlineKeyboardButton.ts @@ -27,10 +27,12 @@ export class ClickInlineKeyboardButton extends OneBotAction { override actionTags = ['扩展接口']; override payloadExample = { rawData: '收藏内容', - brief: '收藏标题' + brief: '收藏标题', }; + override returnExample = { result: 0, - errMsg: '' + errMsg: '', }; async _handle (payload: PayloadType) { diff --git a/packages/napcat-onebot/action/extends/DelGroupAlbumMedia.ts b/packages/napcat-onebot/action/extends/DelGroupAlbumMedia.ts index bc5fd595..cd52331b 100644 --- a/packages/napcat-onebot/action/extends/DelGroupAlbumMedia.ts +++ b/packages/napcat-onebot/action/extends/DelGroupAlbumMedia.ts @@ -23,9 +23,11 @@ export class DelGroupAlbumMedia extends OneBotAction { album_id: 'album_id_1', lloc: 'media_id_1', }; + override returnExample = { - result: {} + result: {}, }; + override payloadSchema = PayloadSchema; override returnSchema = ReturnSchema; diff --git a/packages/napcat-onebot/action/extends/DoGroupAlbumComment.ts b/packages/napcat-onebot/action/extends/DoGroupAlbumComment.ts index 54d73e20..e7aaf755 100644 --- a/packages/napcat-onebot/action/extends/DoGroupAlbumComment.ts +++ b/packages/napcat-onebot/action/extends/DoGroupAlbumComment.ts @@ -19,11 +19,13 @@ export class DoGroupAlbumComment extends OneBotAction { override actionSummary = '获取自定义表情'; override actionTags = ['系统扩展']; override payloadExample = { - count: 10 + count: 10, }; + override returnExample = [ - 'http://example.com/face1.png' + 'http://example.com/face1.png', ]; async _handle (payload: PayloadType) { @@ -30,4 +31,3 @@ export class FetchCustomFace extends OneBotAction { return ret.emojiInfoList.map(e => e.url); } } - diff --git a/packages/napcat-onebot/action/extends/FetchEmojiLike.ts b/packages/napcat-onebot/action/extends/FetchEmojiLike.ts index f619a303..a478150f 100644 --- a/packages/napcat-onebot/action/extends/FetchEmojiLike.ts +++ b/packages/napcat-onebot/action/extends/FetchEmojiLike.ts @@ -8,7 +8,7 @@ const PayloadSchema = Type.Object({ emojiId: Type.Union([Type.Number(), Type.String()], { description: '表情ID' }), emojiType: Type.Union([Type.Number(), Type.String()], { description: '表情类型' }), count: Type.Union([Type.Number(), Type.String()], { default: 20, description: '获取数量' }), - cookie: Type.String({ default: '', description: '分页Cookie' }) + cookie: Type.String({ default: '', description: '分页Cookie' }), }); type PayloadType = Static; @@ -37,22 +37,24 @@ export class FetchEmojiLike extends OneBotAction { emojiId: '123', emojiType: 1, count: 10, - cookie: '' + cookie: '', }; + override returnExample = { emojiLikesList: [ { tinyId: '123456', nickName: '测试用户', - headUrl: 'http://example.com/avatar.png' - } + headUrl: 'http://example.com/avatar.png', + }, ], cookie: '', isLastPage: true, isFirstPage: true, result: 0, - errMsg: '' + errMsg: '', }; + override payloadSchema = PayloadSchema; override returnSchema = ReturnSchema; diff --git a/packages/napcat-onebot/action/extends/GetCollectionList.ts b/packages/napcat-onebot/action/extends/GetCollectionList.ts index 3d5d2d72..062e9c81 100644 --- a/packages/napcat-onebot/action/extends/GetCollectionList.ts +++ b/packages/napcat-onebot/action/extends/GetCollectionList.ts @@ -21,32 +21,33 @@ export class GetCollectionList extends OneBotAction { override actionTags = ['系统扩展']; override payloadExample = { category: '0', - count: '50' + count: '50', }; + override returnExample = { errCode: 0, - errMsg: "", + errMsg: '', collectionSearchList: { collectionItemList: [ { - cid: "123456", + cid: '123456', type: 8, status: 1, author: { type: 2, - numId: "123456", - strId: "昵称", - groupId: "123456", - groupName: "群名", - uid: "123456" + numId: '123456', + strId: '昵称', + groupId: '123456', + groupName: '群名', + uid: '123456', }, bid: 1, category: 1, - createTime: "1769169157000", - collectTime: "1769413477691", - modifyTime: "1769413477691", - sequence: "1769413476735", - shareUrl: "", + createTime: '1769169157000', + collectTime: '1769413477691', + modifyTime: '1769413477691', + sequence: '1769413476735', + shareUrl: '', customGroupId: 0, securityBeat: false, summary: { @@ -58,21 +59,21 @@ export class GetCollectionList extends OneBotAction { fileSummary: null, locationSummary: null, richMediaSummary: { - title: "", - subTitle: "", - brief: "text", + title: '', + subTitle: '', + brief: 'text', picList: [], contentType: 1, - originalUri: "", - publisher: "", - richMediaVersion: 0 - } - } - } + originalUri: '', + publisher: '', + richMediaVersion: 0, + }, + }, + }, ], hasMore: false, - bottomTimeStamp: "1769413477691" - } + bottomTimeStamp: '1769413477691', + }, }; async _handle (payload: PayloadType) { diff --git a/packages/napcat-onebot/action/extends/GetEmojiLikes.ts b/packages/napcat-onebot/action/extends/GetEmojiLikes.ts index c63acc91..4806c2f1 100644 --- a/packages/napcat-onebot/action/extends/GetEmojiLikes.ts +++ b/packages/napcat-onebot/action/extends/GetEmojiLikes.ts @@ -30,16 +30,18 @@ export class GetEmojiLikes extends OneBotAction { override actionTags = ['消息扩展']; override payloadExample = { message_id: '12345', - emoji_id: '123' + emoji_id: '123', }; + override returnExample = { emoji_like_list: [ { user_id: '654321', - nick_name: '测试用户' - } - ] + nick_name: '测试用户', + }, + ], }; + override payloadSchema = PayloadSchema; override returnSchema = ReturnSchema; @@ -64,7 +66,7 @@ export class GetEmojiLikes extends OneBotAction { const emojiType = payload.emoji_type ?? (payload.emoji_id.length > 3 ? '2' : '1'); const emojiLikeList: Array<{ user_id: string; nick_name: string; }> = []; let cookie = ''; - let needFetchCount = payload.count == 0 ? 200 : Math.ceil(payload.count / 15); + const needFetchCount = payload.count === 0 ? 200 : Math.ceil(payload.count / 15); for (let page = 0; page < needFetchCount; page++) { const res = await this.core.apis.MsgApi.getMsgEmojiLikesList( peer, msg.msgSeq, payload.emoji_id.toString(), emojiType, cookie, 15 diff --git a/packages/napcat-onebot/action/extends/GetFriendWithCategory.ts b/packages/napcat-onebot/action/extends/GetFriendWithCategory.ts index e373bd48..d50d9431 100644 --- a/packages/napcat-onebot/action/extends/GetFriendWithCategory.ts +++ b/packages/napcat-onebot/action/extends/GetFriendWithCategory.ts @@ -28,8 +28,8 @@ export class GetFriendWithCategory extends OneBotAction { categoryId: 1, categoryName: '我的好友', categoryMbCount: 1, - buddyList: [] - } + buddyList: [], + }, ]; async _handle () { diff --git a/packages/napcat-onebot/action/extends/GetGroupAddRequest.ts b/packages/napcat-onebot/action/extends/GetGroupAddRequest.ts index ecea6ce6..5ad4bdd7 100644 --- a/packages/napcat-onebot/action/extends/GetGroupAddRequest.ts +++ b/packages/napcat-onebot/action/extends/GetGroupAddRequest.ts @@ -37,8 +37,8 @@ export default class GetGroupAddRequest extends OneBotAction { group_name: '群名称', checked: false, actor: 0, - requester_nick: '请求者' - } + requester_nick: '请求者', + }, ]; async _handle (): Promise { diff --git a/packages/napcat-onebot/action/extends/GetGroupAlbumMediaList.ts b/packages/napcat-onebot/action/extends/GetGroupAlbumMediaList.ts index cc9dce06..a65a71b1 100644 --- a/packages/napcat-onebot/action/extends/GetGroupAlbumMediaList.ts +++ b/packages/napcat-onebot/action/extends/GetGroupAlbumMediaList.ts @@ -22,11 +22,13 @@ export class GetGroupAlbumMediaList extends OneBotAction { override actionSummary = '获取群详细信息 (扩展)'; override actionTags = ['群组扩展']; override payloadExample = { - group_id: '123456' + group_id: '123456', }; + override returnExample = { - + }; + override payloadSchema = PayloadSchema; override returnSchema = ReturnSchema; diff --git a/packages/napcat-onebot/action/extends/GetMiniAppArk.ts b/packages/napcat-onebot/action/extends/GetMiniAppArk.ts index 647f45ad..2ea9c036 100644 --- a/packages/napcat-onebot/action/extends/GetMiniAppArk.ts +++ b/packages/napcat-onebot/action/extends/GetMiniAppArk.ts @@ -52,13 +52,15 @@ export class GetMiniAppArk extends GetPacketStatusDepends { override payloadExample = { user_id: '123456789', start: 0, - count: 10 + count: 10, }; + override returnExample = { uid: 'u_123', time: '1734567890', @@ -48,15 +49,15 @@ export class GetProfileLike extends OneBotAction { userInfos: [], total_count: 10, last_time: 1734567890, - today_count: 5 + today_count: 5, }, voteInfo: { total_count: 100, new_count: 2, new_nearby_count: 0, last_visit_time: 1734567890, - userInfos: [] - } + userInfos: [], + }, }; async _handle (payload: PayloadType): Promise { diff --git a/packages/napcat-onebot/action/extends/GetQunAlbumList.ts b/packages/napcat-onebot/action/extends/GetQunAlbumList.ts index c2d2cc12..8aa5884f 100644 --- a/packages/napcat-onebot/action/extends/GetQunAlbumList.ts +++ b/packages/napcat-onebot/action/extends/GetQunAlbumList.ts @@ -20,14 +20,16 @@ export class GetQunAlbumList extends OneBotAction { override payloadExample = {}; override returnExample = [ { - "key": "rkey_value", - "expired": 1734567890 - } + key: 'rkey_value', + expired: 1734567890, + }, ]; async _handle () { diff --git a/packages/napcat-onebot/action/extends/GetRobotUinRange.ts b/packages/napcat-onebot/action/extends/GetRobotUinRange.ts index d4395d15..f57ae19b 100644 --- a/packages/napcat-onebot/action/extends/GetRobotUinRange.ts +++ b/packages/napcat-onebot/action/extends/GetRobotUinRange.ts @@ -12,8 +12,9 @@ export class GetRobotUinRange extends OneBotAction { override actionTags = ['系统扩展']; override payloadExample = {}; override returnExample = [ - { minUin: '12345678', maxUin: '87654321' } + { minUin: '12345678', maxUin: '87654321' }, ]; + override payloadSchema = Type.Object({}); override returnSchema = ReturnSchema; diff --git a/packages/napcat-onebot/action/extends/GetUnidirectionalFriendList.ts b/packages/napcat-onebot/action/extends/GetUnidirectionalFriendList.ts index b958a7b1..91062efd 100644 --- a/packages/napcat-onebot/action/extends/GetUnidirectionalFriendList.ts +++ b/packages/napcat-onebot/action/extends/GetUnidirectionalFriendList.ts @@ -30,8 +30,8 @@ export class GetUnidirectionalFriendList extends OneBotAction uid: 'u_123', nick_name: '单向好友', age: 20, - source: '来源' - } + source: '来源', + }, ]; async pack_data (data: string): Promise { diff --git a/packages/napcat-onebot/action/extends/GetUserStatus.ts b/packages/napcat-onebot/action/extends/GetUserStatus.ts index 65860762..1ac7fcf5 100644 --- a/packages/napcat-onebot/action/extends/GetUserStatus.ts +++ b/packages/napcat-onebot/action/extends/GetUserStatus.ts @@ -22,11 +22,12 @@ export class GetUserStatus extends GetPacketStatusDepends override payloadExample = { cmd: 'Example.Cmd', data: '123456', - rsp: true + rsp: true, }; + override returnExample = '123456'; async _handle (payload: PayloadType) { diff --git a/packages/napcat-onebot/action/extends/SetDiyOnlineStatus.ts b/packages/napcat-onebot/action/extends/SetDiyOnlineStatus.ts index 1f211c13..fc9c36e1 100644 --- a/packages/napcat-onebot/action/extends/SetDiyOnlineStatus.ts +++ b/packages/napcat-onebot/action/extends/SetDiyOnlineStatus.ts @@ -23,8 +23,9 @@ export class SetDiyOnlineStatus extends OneBotAction { override payloadExample = { face_id: '123', face_type: '1', - wording: '自定义状态' + wording: '自定义状态', }; + override returnExample = ''; async _handle (payload: PayloadType) { const ret = await this.core.apis.UserApi.setDiySelfOnlineStatus( diff --git a/packages/napcat-onebot/action/extends/SetGroupAddOption.ts b/packages/napcat-onebot/action/extends/SetGroupAddOption.ts index fddd5ba2..deb1ff32 100644 --- a/packages/napcat-onebot/action/extends/SetGroupAddOption.ts +++ b/packages/napcat-onebot/action/extends/SetGroupAddOption.ts @@ -23,6 +23,7 @@ export default class SetGroupAddOption extends OneBotAction { diff --git a/packages/napcat-onebot/action/extends/SetGroupRobotAddOption.ts b/packages/napcat-onebot/action/extends/SetGroupRobotAddOption.ts index b0d56d9d..b79224df 100644 --- a/packages/napcat-onebot/action/extends/SetGroupRobotAddOption.ts +++ b/packages/napcat-onebot/action/extends/SetGroupRobotAddOption.ts @@ -19,8 +19,9 @@ export default class SetGroupRobotAddOption extends OneBotAction { override actionSummary = '群打卡'; override actionTags = ['群组扩展']; override payloadExample = { - group_id: '123456789' + group_id: '123456789', }; + override returnExample = null; async _handle (payload: PayloadType) { diff --git a/packages/napcat-onebot/action/extends/SetInputStatus.ts b/packages/napcat-onebot/action/extends/SetInputStatus.ts index 89a49f27..9d6d0849 100644 --- a/packages/napcat-onebot/action/extends/SetInputStatus.ts +++ b/packages/napcat-onebot/action/extends/SetInputStatus.ts @@ -22,8 +22,9 @@ export class SetInputStatus extends OneBotAction { override actionTags = ['系统扩展']; override payloadExample = { user_id: '123456789', - event_type: 1 + event_type: 1, }; + override returnExample = null; async _handle (payload: PayloadType) { diff --git a/packages/napcat-onebot/action/extends/SetOnlineStatus.ts b/packages/napcat-onebot/action/extends/SetOnlineStatus.ts index 1d0dddaf..ae143508 100644 --- a/packages/napcat-onebot/action/extends/SetOnlineStatus.ts +++ b/packages/napcat-onebot/action/extends/SetOnlineStatus.ts @@ -24,8 +24,9 @@ export class SetOnlineStatus extends OneBotAction { override payloadExample = { status: 11, ext_status: 0, - battery_status: 100 + battery_status: 100, }; + override returnExample = null; async _handle (payload: PayloadType) { @@ -252,4 +253,4 @@ const statusText = ` "battery_status": 0; } \`\`\` -`; \ No newline at end of file +`; diff --git a/packages/napcat-onebot/action/extends/ShareContact.ts b/packages/napcat-onebot/action/extends/ShareContact.ts index 31ed0df5..b30f0347 100644 --- a/packages/napcat-onebot/action/extends/ShareContact.ts +++ b/packages/napcat-onebot/action/extends/ShareContact.ts @@ -15,7 +15,6 @@ const ReturnSchema = Type.Any({ description: '分享结果' }); type ReturnType = Static; export class SharePeerBase extends OneBotAction { - override payloadSchema = PayloadSchema; override returnSchema = ReturnSchema; override actionSummary = '分享用户 (Ark)'; @@ -23,10 +22,11 @@ export class SharePeerBase extends OneBotAction { override actionTags = ['消息扩展']; override payloadExample = { user_id: '123456', - phone_number: '' + phone_number: '', }; + override returnExample = { - ark: '...' + ark: '...', }; async _handle (payload: PayloadType) { @@ -58,8 +58,9 @@ export class ShareGroupExBase extends OneBotAction { throw new Error('翻译失败'); } return { - words: ret.words + words: ret.words, }; } } diff --git a/packages/napcat-onebot/action/extends/UploadImageToQunAlbum.ts b/packages/napcat-onebot/action/extends/UploadImageToQunAlbum.ts index 486acd5b..9557a1a4 100644 --- a/packages/napcat-onebot/action/extends/UploadImageToQunAlbum.ts +++ b/packages/napcat-onebot/action/extends/UploadImageToQunAlbum.ts @@ -26,11 +26,13 @@ export class UploadImageToQunAlbum extends OneBotAction group_id: '123456', album_id: 'album_id_1', album_name: '相册1', - file: '/path/to/image.jpg' + file: '/path/to/image.jpg', }; + override returnExample = { - result: null + result: null, }; + override payloadSchema = PayloadSchema; override returnSchema = ReturnSchema; diff --git a/packages/napcat-onebot/action/file/flash/CreateFlashTask.ts b/packages/napcat-onebot/action/file/flash/CreateFlashTask.ts index f79a98a0..f760878c 100644 --- a/packages/napcat-onebot/action/file/flash/CreateFlashTask.ts +++ b/packages/napcat-onebot/action/file/flash/CreateFlashTask.ts @@ -26,10 +26,11 @@ export class CreateFlashTask extends OneBotAction { override actionTags = ['文件扩展']; override payloadExample = { files: 'C:\\test.jpg', - name: 'test_task' + name: 'test_task', }; + override returnExample = { - task_id: 'task_123' + task_id: 'task_123', }; async _handle (payload: CreateFlashTaskPayload) { diff --git a/packages/napcat-onebot/action/file/flash/DownloadFileset.ts b/packages/napcat-onebot/action/file/flash/DownloadFileset.ts index 6c770e77..0135ea9c 100644 --- a/packages/napcat-onebot/action/file/flash/DownloadFileset.ts +++ b/packages/napcat-onebot/action/file/flash/DownloadFileset.ts @@ -15,8 +15,9 @@ export class DownloadFileset extends OneBotAction { override actionSummary = '下载文件集'; override actionTags = ['文件扩展']; override payloadExample = { - fileset_id: 'set_123' + fileset_id: 'set_123', }; + override returnExample = null; async _handle (payload: DownloadFilesetPayload) { diff --git a/packages/napcat-onebot/action/file/flash/GetFilesetIdByCode.ts b/packages/napcat-onebot/action/file/flash/GetFilesetIdByCode.ts index ebd8a722..10cb5bd6 100644 --- a/packages/napcat-onebot/action/file/flash/GetFilesetIdByCode.ts +++ b/packages/napcat-onebot/action/file/flash/GetFilesetIdByCode.ts @@ -12,15 +12,17 @@ export class GetFilesetId extends OneBotAction { override actionSummary = '获取文件集信息'; override actionTags = ['文件扩展']; override payloadExample = { - fileset_id: 'set_123' + fileset_id: 'set_123', }; + override returnExample = { fileset_id: 'set_123', - file_list: [] + file_list: [], }; async _handle (payload: GetFilesetInfoPayload) { diff --git a/packages/napcat-onebot/action/file/flash/GetFlashFileList.ts b/packages/napcat-onebot/action/file/flash/GetFlashFileList.ts index 2ec8542c..b00661b7 100644 --- a/packages/napcat-onebot/action/file/flash/GetFlashFileList.ts +++ b/packages/napcat-onebot/action/file/flash/GetFlashFileList.ts @@ -15,13 +15,14 @@ export class GetFlashFileList extends OneBotAction override actionSummary = '获取闪传文件列表'; override actionTags = ['文件扩展']; override payloadExample = { - fileset_id: 'set_123' + fileset_id: 'set_123', }; + override returnExample = [ { file_name: 'test.jpg', - size: 1024 - } + size: 1024, + }, ]; async _handle (payload: GetFlashFileListPayload) { diff --git a/packages/napcat-onebot/action/file/flash/GetFlashFileUrl.ts b/packages/napcat-onebot/action/file/flash/GetFlashFileUrl.ts index 9e657bdd..3f56f11c 100644 --- a/packages/napcat-onebot/action/file/flash/GetFlashFileUrl.ts +++ b/packages/napcat-onebot/action/file/flash/GetFlashFileUrl.ts @@ -17,10 +17,11 @@ export class GetFlashFileUrl extends OneBotAction { override actionSummary = '获取闪传文件链接'; override actionTags = ['文件扩展']; override payloadExample = { - fileset_id: 'set_123' + fileset_id: 'set_123', }; + override returnExample = { - url: 'http://example.com/flash.jpg' + url: 'http://example.com/flash.jpg', }; async _handle (payload: GetFlashFileUrlPayload) { diff --git a/packages/napcat-onebot/action/file/flash/GetShareLink.ts b/packages/napcat-onebot/action/file/flash/GetShareLink.ts index 7598bb69..ba4ac86b 100644 --- a/packages/napcat-onebot/action/file/flash/GetShareLink.ts +++ b/packages/napcat-onebot/action/file/flash/GetShareLink.ts @@ -15,8 +15,9 @@ export class GetShareLink extends OneBotAction { override actionSummary = '获取文件分享链接'; override actionTags = ['文件扩展']; override payloadExample = { - fileset_id: 'set_123' + fileset_id: 'set_123', }; + override returnExample = 'http://example.com/share'; async _handle (payload: GetShareLinkPayload) { diff --git a/packages/napcat-onebot/action/file/flash/SendFlashMsg.ts b/packages/napcat-onebot/action/file/flash/SendFlashMsg.ts index 359343c7..1d82e31b 100644 --- a/packages/napcat-onebot/action/file/flash/SendFlashMsg.ts +++ b/packages/napcat-onebot/action/file/flash/SendFlashMsg.ts @@ -19,10 +19,11 @@ export class SendFlashMsg extends OneBotAction { override actionTags = ['文件扩展']; override payloadExample = { fileset_id: 'set_123', - user_id: '123456789' + user_id: '123456789', }; + override returnExample = { - message_id: 123456 + message_id: 123456, }; async _handle (payload: SendFlashMsgPayload) { diff --git a/packages/napcat-onebot/action/file/online/CancelOnlineFile.ts b/packages/napcat-onebot/action/file/online/CancelOnlineFile.ts index 4ab31d8d..6376228b 100644 --- a/packages/napcat-onebot/action/file/online/CancelOnlineFile.ts +++ b/packages/napcat-onebot/action/file/online/CancelOnlineFile.ts @@ -18,8 +18,9 @@ export class CancelOnlineFile extends OneBotAction override actionTags = ['文件扩展']; override payloadExample = { user_id: '123456789', - msg_id: '123' + msg_id: '123', }; + override returnExample = null; async _handle (payload: CancelOnlineFilePayload) { diff --git a/packages/napcat-onebot/action/file/online/GetOnlineFileMessages.ts b/packages/napcat-onebot/action/file/online/GetOnlineFileMessages.ts index d3bf26b1..64238c51 100644 --- a/packages/napcat-onebot/action/file/online/GetOnlineFileMessages.ts +++ b/packages/napcat-onebot/action/file/online/GetOnlineFileMessages.ts @@ -16,8 +16,9 @@ export class GetOnlineFileMessages extends OneBotAction override actionTags = ['文件扩展']; override payloadExample = { user_id: '123456789', - msg_id: '123' + msg_id: '123', }; + override returnExample = null; async _handle (payload: RefuseOnlineFilePayload) { diff --git a/packages/napcat-onebot/action/file/online/SendOnlineFile.ts b/packages/napcat-onebot/action/file/online/SendOnlineFile.ts index 8c0ba336..434c3bdd 100644 --- a/packages/napcat-onebot/action/file/online/SendOnlineFile.ts +++ b/packages/napcat-onebot/action/file/online/SendOnlineFile.ts @@ -20,8 +20,9 @@ export class SendOnlineFile extends OneBotAction { override payloadExample = { user_id: '123456789', file_path: 'C:\\path\\to\\file.txt', - file_name: 'test.txt' + file_name: 'test.txt', }; + override returnExample = null; async _handle (payload: SendOnlineFilePayload) { diff --git a/packages/napcat-onebot/action/file/online/SendOnlineFolder.ts b/packages/napcat-onebot/action/file/online/SendOnlineFolder.ts index 6a3d0a79..2ecc989f 100644 --- a/packages/napcat-onebot/action/file/online/SendOnlineFolder.ts +++ b/packages/napcat-onebot/action/file/online/SendOnlineFolder.ts @@ -19,8 +19,9 @@ export class SendOnlineFolder extends OneBotAction override actionTags = ['文件扩展']; override payloadExample = { user_id: '123456789', - folder_path: 'C:\\path\\to\\folder' + folder_path: 'C:\\path\\to\\folder', }; + override returnExample = null; async _handle (payload: SendOnlineFolderPayload) { diff --git a/packages/napcat-onebot/action/go-cqhttp/CreateGroupFileFolder.ts b/packages/napcat-onebot/action/go-cqhttp/CreateGroupFileFolder.ts index a02060b5..ee54675c 100644 --- a/packages/napcat-onebot/action/go-cqhttp/CreateGroupFileFolder.ts +++ b/packages/napcat-onebot/action/go-cqhttp/CreateGroupFileFolder.ts @@ -28,11 +28,12 @@ export class CreateGroupFileFolder extends OneBotAction override actionTags = ['Go-CQHTTP']; override payloadExample = { group_id: '123456789', - folder_name: '新建文件夹' + folder_name: '新建文件夹', }; + override returnExample = { result: {}, - groupItem: {} + groupItem: {}, }; async _handle (payload: PayloadType) { diff --git a/packages/napcat-onebot/action/go-cqhttp/GetForwardMsg.ts b/packages/napcat-onebot/action/go-cqhttp/GetForwardMsg.ts index bc09d448..4141d4d2 100644 --- a/packages/napcat-onebot/action/go-cqhttp/GetForwardMsg.ts +++ b/packages/napcat-onebot/action/go-cqhttp/GetForwardMsg.ts @@ -145,7 +145,7 @@ export class GoCQHTTPGetForwardMsgAction extends OneBotAction 0) { const singleMsg = data.msgList[0]; diff --git a/packages/napcat-onebot/action/go-cqhttp/SendForwardMsg.ts b/packages/napcat-onebot/action/go-cqhttp/SendForwardMsg.ts index abbe57bd..59de606f 100644 --- a/packages/napcat-onebot/action/go-cqhttp/SendForwardMsg.ts +++ b/packages/napcat-onebot/action/go-cqhttp/SendForwardMsg.ts @@ -18,10 +18,11 @@ export class GoCQHTTPSendForwardMsg extends GoCQHTTPSendForwardMsgBase { override actionTags = ['Go-CQHTTP']; override payloadExample = { group_id: '123456789', - messages: [] + messages: [], }; + override returnExample = { - message_id: 123456 + message_id: 123456, }; protected override async check (payload: GoCQHTTPSendForwardMsgPayload) { @@ -35,11 +36,13 @@ export class GoCQHTTPSendPrivateForwardMsg extends GoCQHTTPSendForwardMsgBase { override actionTags = ['Go-CQHTTP']; override payloadExample = { user_id: '123456789', - messages: [] + messages: [], }; + override returnExample = { - message_id: 123456 + message_id: 123456, }; + override async _handle (payload: GoCQHTTPSendForwardMsgPayload): Promise { return this.base_handle(payload, ContextMode.Private); } @@ -51,11 +54,13 @@ export class GoCQHTTPSendGroupForwardMsg extends GoCQHTTPSendForwardMsgBase { override actionTags = ['Go-CQHTTP']; override payloadExample = { group_id: '123456789', - messages: [] + messages: [], }; + override returnExample = { - message_id: 123456 + message_id: 123456, }; + override async _handle (payload: GoCQHTTPSendForwardMsgPayload): Promise { return this.base_handle(payload, ContextMode.Group); } diff --git a/packages/napcat-onebot/action/group/GetAiRecord.ts b/packages/napcat-onebot/action/group/GetAiRecord.ts index a0ea8e61..639c6b7b 100644 --- a/packages/napcat-onebot/action/group/GetAiRecord.ts +++ b/packages/napcat-onebot/action/group/GetAiRecord.ts @@ -25,8 +25,9 @@ export class GetAiRecord extends GetPacketStatusDepends override payloadExample = { character: 'ai_char_1', group_id: '123456', - text: '你好' + text: '你好', }; + override returnExample = 'http://example.com/ai_voice.silk'; async _handle (payload: PayloadType) { diff --git a/packages/napcat-onebot/action/group/GetGroupIgnoredNotifies.ts b/packages/napcat-onebot/action/group/GetGroupIgnoredNotifies.ts index 1c719dc7..9772055a 100644 --- a/packages/napcat-onebot/action/group/GetGroupIgnoredNotifies.ts +++ b/packages/napcat-onebot/action/group/GetGroupIgnoredNotifies.ts @@ -26,7 +26,7 @@ export class GetGroupIgnoredNotifies extends OneBotAction { diff --git a/packages/napcat-onebot/action/group/GetGroupNotice.ts b/packages/napcat-onebot/action/group/GetGroupNotice.ts index 8667e69f..42ad9f74 100644 --- a/packages/napcat-onebot/action/group/GetGroupNotice.ts +++ b/packages/napcat-onebot/action/group/GetGroupNotice.ts @@ -63,7 +63,7 @@ export class GetGroupNotice extends OneBotAction { images: image, }, settings: retApiNotice.settings, - read_num: retApiNotice.read_num + read_num: retApiNotice.read_num, }; retNotices.push(retNotice); } diff --git a/packages/napcat-onebot/action/group/GetGroupShutList.ts b/packages/napcat-onebot/action/group/GetGroupShutList.ts index c641bb69..6ccea3b9 100644 --- a/packages/napcat-onebot/action/group/GetGroupShutList.ts +++ b/packages/napcat-onebot/action/group/GetGroupShutList.ts @@ -19,14 +19,15 @@ export class GetGroupShutList extends OneBotAction { override actionSummary = '获取群禁言列表'; override actionTags = ['群组接口']; override payloadExample = { - group_id: '123456789' + group_id: '123456789', }; + override returnExample = [ { user_id: 123456789, nickname: '禁言用户', - shut_up_time: 1734567890 - } + shut_up_time: 1734567890, + }, ]; async _handle (payload: PayloadType) { diff --git a/packages/napcat-onebot/action/group/SendGroupAiRecord.ts b/packages/napcat-onebot/action/group/SendGroupAiRecord.ts index d1243c37..28b5bc75 100644 --- a/packages/napcat-onebot/action/group/SendGroupAiRecord.ts +++ b/packages/napcat-onebot/action/group/SendGroupAiRecord.ts @@ -27,8 +27,9 @@ export class SendGroupAiRecord extends GetPacketStatusDepends { override actionDescription = '撤回已发送的消息'; override actionTags = ['消息接口']; override payloadExample = { - message_id: 12345 + message_id: 12345, }; + override returnExample = null; async _handle (payload: PayloadType) { diff --git a/packages/napcat-onebot/action/msg/ForwardSingleMsg.ts b/packages/napcat-onebot/action/msg/ForwardSingleMsg.ts index d809c417..2f92d0e6 100644 --- a/packages/napcat-onebot/action/msg/ForwardSingleMsg.ts +++ b/packages/napcat-onebot/action/msg/ForwardSingleMsg.ts @@ -22,8 +22,9 @@ class ForwardSingleMsg extends OneBotAction { override actionTags = ['消息接口']; override payloadExample = { message_id: 12345, - group_id: '123456' + group_id: '123456', }; + override returnExample = null; protected async getTargetPeer (payload: PayloadType): Promise { diff --git a/packages/napcat-onebot/action/msg/GetMsg.ts b/packages/napcat-onebot/action/msg/GetMsg.ts index 313e730f..799cd7bc 100644 --- a/packages/napcat-onebot/action/msg/GetMsg.ts +++ b/packages/napcat-onebot/action/msg/GetMsg.ts @@ -60,6 +60,7 @@ class GetMsg extends OneBotAction { emoji_type: emoji.emojiType, likes_cnt: emoji.likesCnt, }); + return undefined; }); try { retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgId)!; diff --git a/packages/napcat-onebot/action/msg/MarkMsgAsRead.ts b/packages/napcat-onebot/action/msg/MarkMsgAsRead.ts index 6b565755..98f99b9d 100644 --- a/packages/napcat-onebot/action/msg/MarkMsgAsRead.ts +++ b/packages/napcat-onebot/action/msg/MarkMsgAsRead.ts @@ -21,8 +21,9 @@ class MarkMsgAsRead extends OneBotAction { override actionDescription = '标记指定渠道的消息为已读'; override actionTags = ['消息接口']; override payloadExample = { - message_id: 12345 + message_id: 12345, }; + override returnExample = null; async getPeer (payload: PayloadType): Promise { diff --git a/packages/napcat-onebot/action/msg/SendMsg.ts b/packages/napcat-onebot/action/msg/SendMsg.ts index 2c6afbc6..a38afbeb 100644 --- a/packages/napcat-onebot/action/msg/SendMsg.ts +++ b/packages/napcat-onebot/action/msg/SendMsg.ts @@ -219,7 +219,7 @@ export class SendMsgBase extends OneBotAction { } | null> { const packetMsg: PacketMsg[] = []; const delFiles: string[] = []; - const innerMsg: Array<{ uuid: string, packetMsg: PacketMsg[]; }> = new Array(); + const innerMsg: Array<{ uuid: string, packetMsg: PacketMsg[]; }> = []; for (const node of messageNodes) { if (dp >= 3) { this.core.context.logger.logWarn('转发消息深度超过3层,将停止解析!'); @@ -243,7 +243,6 @@ export class SendMsgBase extends OneBotAction { innerMsg.push({ uuid: m.uuid, packetMsg: m.packetMsg }); }); } - } else { const sendElementsCreateReturn = await this.obContext.apis.MsgApi.createSendElements(OB11Data, msgPeer); sendElements = sendElementsCreateReturn.sendElements; @@ -308,8 +307,8 @@ export class SendMsgBase extends OneBotAction { }, } as SendArkElement, res_id: resid, - uuid: uuid, - packetMsg: packetMsg, + uuid, + packetMsg, innerPacketMsg: innerMsg, }; } diff --git a/packages/napcat-onebot/action/msg/SendPrivateMsg.ts b/packages/napcat-onebot/action/msg/SendPrivateMsg.ts index 0800985e..6dfea512 100644 --- a/packages/napcat-onebot/action/msg/SendPrivateMsg.ts +++ b/packages/napcat-onebot/action/msg/SendPrivateMsg.ts @@ -9,10 +9,11 @@ class SendPrivateMsg extends SendMsgBase { override actionTags = ['消息接口']; override payloadExample = { user_id: '123456789', - message: 'hello' + message: 'hello', }; + override returnExample = { - message_id: 123456 + message_id: 123456, }; protected override async check (payload: SendMsgPayload): Promise { diff --git a/packages/napcat-onebot/action/msg/SetMsgEmojiLike.ts b/packages/napcat-onebot/action/msg/SetMsgEmojiLike.ts index 745bcff0..8cc0ddbb 100644 --- a/packages/napcat-onebot/action/msg/SetMsgEmojiLike.ts +++ b/packages/napcat-onebot/action/msg/SetMsgEmojiLike.ts @@ -22,11 +22,13 @@ export class SetMsgEmojiLike extends OneBotAction { override payloadExample = { message_id: 12345, emoji_id: '123', - set: true + set: true, }; + override returnExample = { - result: true + result: true, }; + override payloadSchema = PayloadSchema; override returnSchema = ReturnSchema; diff --git a/packages/napcat-onebot/action/new/SetDoubtFriendsAddRequest.ts b/packages/napcat-onebot/action/new/SetDoubtFriendsAddRequest.ts index cb77b40b..ef1bc1d0 100644 --- a/packages/napcat-onebot/action/new/SetDoubtFriendsAddRequest.ts +++ b/packages/napcat-onebot/action/new/SetDoubtFriendsAddRequest.ts @@ -20,8 +20,9 @@ export class SetDoubtFriendsAddRequest extends OneBotAction { type: 'private', rkey: 'rkey_123', created_at: 1734567890, - ttl: 3600 - } + ttl: 3600, + }, ]; async _handle () { diff --git a/packages/napcat-onebot/action/packet/GetRkeyServer.ts b/packages/napcat-onebot/action/packet/GetRkeyServer.ts index 527fcb72..9882a7ea 100644 --- a/packages/napcat-onebot/action/packet/GetRkeyServer.ts +++ b/packages/napcat-onebot/action/packet/GetRkeyServer.ts @@ -22,6 +22,7 @@ export class GetRkeyServer extends GetPacketStatusDepends { override actionTags = ['流式传输扩展']; override payloadExample = {}; override returnExample = { - message: 'success' + message: 'success', }; + override payloadSchema = Type.Object({}); override returnSchema = Type.Null(); diff --git a/packages/napcat-onebot/action/stream/DownloadFileImageStream.ts b/packages/napcat-onebot/action/stream/DownloadFileImageStream.ts index 5885fcb8..6a5afc6f 100644 --- a/packages/napcat-onebot/action/stream/DownloadFileImageStream.ts +++ b/packages/napcat-onebot/action/stream/DownloadFileImageStream.ts @@ -20,11 +20,13 @@ export class DownloadFileImageStream extends BaseDownloadStream> { diff --git a/packages/napcat-onebot/action/stream/TestStreamDownload.ts b/packages/napcat-onebot/action/stream/TestStreamDownload.ts index a3ac7f86..4b788dbc 100644 --- a/packages/napcat-onebot/action/stream/TestStreamDownload.ts +++ b/packages/napcat-onebot/action/stream/TestStreamDownload.ts @@ -15,11 +15,13 @@ export class TestDownloadStream extends OneBotAction(); diff --git a/packages/napcat-onebot/action/system/GetCSRF.ts b/packages/napcat-onebot/action/system/GetCSRF.ts index b01e2a99..f0959c92 100644 --- a/packages/napcat-onebot/action/system/GetCSRF.ts +++ b/packages/napcat-onebot/action/system/GetCSRF.ts @@ -17,7 +17,7 @@ export class GetCSRF extends OneBotAction { override actionTags = ['系统接口']; override payloadExample = {}; override returnExample = { - token: 123456789 + token: 123456789, }; async _handle () { diff --git a/packages/napcat-onebot/action/system/GetCredentials.ts b/packages/napcat-onebot/action/system/GetCredentials.ts index 5b35fbe1..547ec27f 100644 --- a/packages/napcat-onebot/action/system/GetCredentials.ts +++ b/packages/napcat-onebot/action/system/GetCredentials.ts @@ -23,11 +23,12 @@ export class GetCredentials extends OneBotAction { override returnExample = { online: true, good: true, - stat: {} + stat: {}, }; async _handle (): Promise { diff --git a/packages/napcat-onebot/action/system/GetSystemMsg.ts b/packages/napcat-onebot/action/system/GetSystemMsg.ts index 4d7a622d..dd70172a 100644 --- a/packages/napcat-onebot/action/system/GetSystemMsg.ts +++ b/packages/napcat-onebot/action/system/GetSystemMsg.ts @@ -26,12 +26,13 @@ export class GetGroupSystemMsg extends OneBotAction { diff --git a/packages/napcat-onebot/action/system/GetVersionInfo.ts b/packages/napcat-onebot/action/system/GetVersionInfo.ts index 44c92c6d..c2f15e9e 100644 --- a/packages/napcat-onebot/action/system/GetVersionInfo.ts +++ b/packages/napcat-onebot/action/system/GetVersionInfo.ts @@ -21,7 +21,7 @@ export default class GetVersionInfo extends OneBotAction { override returnExample = { app_name: 'NapCat.Onebot', protocol_version: 'v11', - app_version: '1.0.0' + app_version: '1.0.0', }; async _handle (): Promise { diff --git a/packages/napcat-onebot/action/user/GetCookies.ts b/packages/napcat-onebot/action/user/GetCookies.ts index 87bd4194..4f2badca 100644 --- a/packages/napcat-onebot/action/user/GetCookies.ts +++ b/packages/napcat-onebot/action/user/GetCookies.ts @@ -23,11 +23,12 @@ export class GetCookies extends OneBotAction { diff --git a/packages/napcat-onebot/action/user/SendLike.ts b/packages/napcat-onebot/action/user/SendLike.ts index 66b0863c..869bc919 100644 --- a/packages/napcat-onebot/action/user/SendLike.ts +++ b/packages/napcat-onebot/action/user/SendLike.ts @@ -17,11 +17,12 @@ export default class SendLike extends OneBotAction { override actionTags = ['用户接口']; override payloadExample = { user_id: '123456', - times: 10 + times: 10, }; + override returnExample = {}; override errorExamples = [ - { code: 1400, description: '点赞失败(频率过快或用户不存在)' } + { code: 1400, description: '点赞失败(频率过快或用户不存在)' }, ]; async _handle (payload: SendLikePayload): Promise { diff --git a/packages/napcat-onebot/action/user/SetFriendAddRequest.ts b/packages/napcat-onebot/action/user/SetFriendAddRequest.ts index e9f01d42..03c26d23 100644 --- a/packages/napcat-onebot/action/user/SetFriendAddRequest.ts +++ b/packages/napcat-onebot/action/user/SetFriendAddRequest.ts @@ -20,8 +20,9 @@ export default class SetFriendAddRequest extends OneBotAction { diff --git a/packages/napcat-onebot/action/user/SetFriendRemark.ts b/packages/napcat-onebot/action/user/SetFriendRemark.ts index 26442305..3536b412 100644 --- a/packages/napcat-onebot/action/user/SetFriendRemark.ts +++ b/packages/napcat-onebot/action/user/SetFriendRemark.ts @@ -2,7 +2,6 @@ import { OneBotAction } from '@/napcat-onebot/action/OneBotAction'; import { ActionName } from '@/napcat-onebot/action/router'; import { Static, Type } from '@sinclair/typebox'; - export const SetFriendRemarkPayloadSchema = Type.Object({ user_id: Type.String({ description: '对方 QQ 号' }), remark: Type.String({ description: '备注内容' }), @@ -19,11 +18,12 @@ export default class SetFriendRemark extends OneBotAction { diff --git a/packages/napcat-onebot/api/group.ts b/packages/napcat-onebot/api/group.ts index a959cc61..bc224943 100644 --- a/packages/napcat-onebot/api/group.ts +++ b/packages/napcat-onebot/api/group.ts @@ -207,6 +207,7 @@ export class OneBotGroupApi { } return undefined; } + async parseOtherJsonEvent (msg: RawMessage, jsonGrayTipElement: GrayTipElement['jsonGrayTipElement'], context: InstanceContext) { let json: { items?: { txt?: string; param?: string[] }[] }; try { diff --git a/packages/napcat-onebot/network/plugin/loader.ts b/packages/napcat-onebot/network/plugin/loader.ts index 424a8696..b511a728 100644 --- a/packages/napcat-onebot/network/plugin/loader.ts +++ b/packages/napcat-onebot/network/plugin/loader.ts @@ -1,7 +1,6 @@ import fs from 'fs'; import path from 'path'; import { createRequire } from 'module'; -const require = createRequire(import.meta.url); import { LogWrapper } from 'napcat-core/helper/log'; import { PluginPackageJson, @@ -9,6 +8,7 @@ import { PluginEntry, PluginStatusConfig, } from './types'; +const require = createRequire(import.meta.url); /** * 插件加载器 @@ -286,7 +286,7 @@ export class PluginLoader { if (pkg.name === pluginId) { return item.name; } - } catch (e) { } + } catch (_e) { } } // 如果目录名就是 ID @@ -297,6 +297,7 @@ export class PluginLoader { return null; } + /** * 清除插件文件的 require 缓存 * 用于确保卸载插件时清理 CJS 模块缓存 diff --git a/packages/napcat-onebot/network/plugin/types.ts b/packages/napcat-onebot/network/plugin/types.ts index 0465bffe..1c653ee9 100644 --- a/packages/napcat-onebot/network/plugin/types.ts +++ b/packages/napcat-onebot/network/plugin/types.ts @@ -144,7 +144,7 @@ export interface MemoryStaticFile { export interface PluginRouterRegistry { // ==================== API 路由注册(需要认证) ==================== - /** + /** * 注册单个 API 路由(需要认证,挂载到 /api/Plugin/ext/{pluginId}/) * @param method HTTP 方法 * @param path 路由路径 @@ -284,7 +284,7 @@ export interface NapCatPluginContext { pluginManager: IPluginManager; /** 插件日志器 - 自动添加插件名称前缀 */ logger: PluginLogger; - /** + /** * WebUI 路由注册器 * 用于注册插件的 HTTP API 路由,路由将挂载到 /api/Plugin/ext/{pluginId}/ * 静态资源将挂载到 /plugin/{pluginId}/files/{urlPath}/ @@ -317,7 +317,7 @@ export interface PluginModule C | Promise; plugin_set_config?: (ctx: NapCatPluginContext, config: C) => void | Promise; - /** + /** * 配置界面控制器 - 当配置界面打开时调用 * 返回清理函数,在界面关闭时调用 */ diff --git a/packages/napcat-plugin-builtin/index.ts b/packages/napcat-plugin-builtin/index.ts index b94315a5..c9a72b61 100644 --- a/packages/napcat-plugin-builtin/index.ts +++ b/packages/napcat-plugin-builtin/index.ts @@ -6,8 +6,7 @@ import fs from 'fs'; import path from 'path'; import { NetworkAdapterConfig } from 'napcat-types/napcat-onebot/config/config'; - -let startTime: number = Date.now(); +const startTime: number = Date.now(); let logger: PluginLogger | null = null; interface BuiltinPluginConfig { @@ -24,10 +23,9 @@ interface BuiltinPluginConfig { let currentConfig: BuiltinPluginConfig = { prefix: '#napcat', enableReply: true, - description: '这是一个内置插件的配置示例' + description: '这是一个内置插件的配置示例', }; - export let plugin_config_ui: PluginConfigSchema = []; const plugin_init: PluginModule['plugin_init'] = async (ctx) => { @@ -42,12 +40,12 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => { ctx.NapCatConfig.select('theme', 'Theme Selection', [ { label: 'Light Mode', value: 'light' }, { label: 'Dark Mode', value: 'dark' }, - { label: 'Auto', value: 'auto' } + { label: 'Auto', value: 'auto' }, ], 'light', 'Select a theme for the response (Demo purpose only)'), ctx.NapCatConfig.multiSelect('features', 'Enabled Features', [ { label: 'Version Info', value: 'version' }, { label: 'Status Report', value: 'status' }, - { label: 'Debug Log', value: 'debug' } + { label: 'Debug Log', value: 'debug' }, ], ['version'], 'Select features to enable'), ctx.NapCatConfig.text('description', 'Description', '这是一个内置插件的配置示例', 'A multi-line text area for notes') ); @@ -80,14 +78,14 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => { pluginName: ctx.pluginName, generatedAt: new Date().toISOString(), uptime: Date.now() - startTime, - config: currentConfig - }, null, 2) + config: currentConfig, + }, null, 2), }, { path: '/readme.txt', contentType: 'text/plain', - content: `NapCat Builtin Plugin\n=====================\nThis is a demonstration of the staticOnMem feature.\nPlugin: ${ctx.pluginName}\nPath: ${ctx.pluginPath}` - } + content: `NapCat Builtin Plugin\n=====================\nThis is a demonstration of the staticOnMem feature.\nPlugin: ${ctx.pluginName}\nPath: ${ctx.pluginPath}`, + }, ]); // 注册 API 路由(需要鉴权,挂载到 /api/Plugin/ext/{pluginId}/) @@ -101,15 +99,15 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => { uptimeFormatted: formatUptime(uptime), config: currentConfig, platform: process.platform, - arch: process.arch - } + arch: process.arch, + }, }); }); ctx.router.get('/config', (_req, res) => { res.json({ code: 0, - data: currentConfig + data: currentConfig, }); }); @@ -141,8 +139,8 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => { pluginName: ctx.pluginName, uptime, uptimeFormatted: formatUptime(uptime), - platform: process.platform - } + platform: process.platform, + }, }); }); @@ -152,8 +150,8 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => { code: 0, data: { status: 'ok', - timestamp: new Date().toISOString() - } + timestamp: new Date().toISOString(), + }, }); }); @@ -165,7 +163,7 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => { if (!pluginId) { res.status(400).json({ code: -1, - message: 'Plugin ID is required' + message: 'Plugin ID is required', }); return; } @@ -176,7 +174,7 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => { if (!targetPlugin) { res.status(404).json({ code: -1, - message: `Plugin '${pluginId}' not found or not loaded` + message: `Plugin '${pluginId}' not found or not loaded`, }); return; } @@ -192,7 +190,7 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => { hasCleanup: typeof targetPlugin.plugin_cleanup === 'function', hasConfigSchema: Array.isArray(targetPlugin.plugin_config_schema), hasConfigUI: Array.isArray(targetPlugin.plugin_config_ui), - } + }, }); }); @@ -202,7 +200,7 @@ const plugin_init: PluginModule['plugin_init'] = async (ctx) => { title: '插件仪表盘', icon: '📊', htmlFile: 'webui/dashboard.html', - description: '查看内置插件的运行状态和配置' + description: '查看内置插件的运行状态和配置', }); logger.info('WebUI 路由已注册:'); @@ -287,7 +285,7 @@ async function loadEndpointsForUrl (ui: PluginConfigUIController, apiUrl: string // 更新现有字段的选项 ui.updateField('apiEndpoints', { options: mockEndpoints, - description: `从 ${apiUrl} 加载的端点` + description: `从 ${apiUrl} 加载的端点`, }); } else { // 添加新字段 @@ -297,7 +295,7 @@ async function loadEndpointsForUrl (ui: PluginConfigUIController, apiUrl: string label: 'API Endpoints', description: `从 ${apiUrl} 加载的端点`, options: mockEndpoints, - default: [] + default: [], }, 'apiUrl'); } } @@ -328,7 +326,7 @@ async function getVersionInfo (actions: ActionMap, adapter: string, config: Netw if (!actions) return null; try { - const data = await actions.call('get_version_info', void 0, adapter, config); + const data = await actions.call('get_version_info', undefined, adapter, config); return { appName: data.app_name, appVersion: data.app_version, diff --git a/packages/napcat-protocol/action/index.ts b/packages/napcat-protocol/action/index.ts index bd87c17c..b2829547 100644 --- a/packages/napcat-protocol/action/index.ts +++ b/packages/napcat-protocol/action/index.ts @@ -40,7 +40,7 @@ export abstract class BaseAction { export type ActionMap = Map>; // 创建 Action 映射 -// eslint-disable-next-line @typescript-eslint/no-unused-vars + export function createActionMap (_adapter: NapCatProtocolAdapter, _core: NapCatCore): ActionMap { const actionMap = new Map>(); diff --git a/packages/napcat-protocol/api/index.ts b/packages/napcat-protocol/api/index.ts index 5c578c58..45e2d238 100644 --- a/packages/napcat-protocol/api/index.ts +++ b/packages/napcat-protocol/api/index.ts @@ -14,36 +14,24 @@ export abstract class NapCatProtocolApiBase { // 消息 API export class NapCatProtocolMsgApi extends NapCatProtocolApiBase { - constructor (adapter: NapCatProtocolAdapter, core: NapCatCore) { - super(adapter, core); - } // 消息相关 API 方法可以在这里实现 } // 用户 API export class NapCatProtocolUserApi extends NapCatProtocolApiBase { - constructor (adapter: NapCatProtocolAdapter, core: NapCatCore) { - super(adapter, core); - } // 用户相关 API 方法可以在这里实现 } // 群组 API export class NapCatProtocolGroupApi extends NapCatProtocolApiBase { - constructor (adapter: NapCatProtocolAdapter, core: NapCatCore) { - super(adapter, core); - } // 群组相关 API 方法可以在这里实现 } // 好友 API export class NapCatProtocolFriendApi extends NapCatProtocolApiBase { - constructor (adapter: NapCatProtocolAdapter, core: NapCatCore) { - super(adapter, core); - } // 好友相关 API 方法可以在这里实现 } diff --git a/packages/napcat-protocol/config/index.ts b/packages/napcat-protocol/config/index.ts index 646834f3..932cbbf5 100644 --- a/packages/napcat-protocol/config/index.ts +++ b/packages/napcat-protocol/config/index.ts @@ -1,5 +1,5 @@ -import { ConfigBase } from 'napcat-core'; -import { NapCatCore } from 'napcat-core'; +import { ConfigBase, NapCatCore } from 'napcat-core'; + import { NapCatProtocolConfig, NapCatProtocolConfigSchema } from './config'; export class NapCatProtocolConfigLoader extends ConfigBase { diff --git a/packages/napcat-pty/unixTerminal.ts b/packages/napcat-pty/unixTerminal.ts index 1d46fb81..481fa006 100644 --- a/packages/napcat-pty/unixTerminal.ts +++ b/packages/napcat-pty/unixTerminal.ts @@ -21,7 +21,7 @@ export const pty: any = new Proxy({}, { _pty = pty_loader(); } return _pty[prop]; - } + }, }); let helperPath: string; diff --git a/packages/napcat-rpc/src/client.ts b/packages/napcat-rpc/src/client.ts index 96a1548d..6592dc00 100644 --- a/packages/napcat-rpc/src/client.ts +++ b/packages/napcat-rpc/src/client.ts @@ -31,7 +31,7 @@ export function createDeepProxy (options: DeepProxyOptions): T { refId: rootRefId, // callbackTimeout 可供未来扩展使用 } = options; - void options.callbackTimeout; + // const _callbackTimeout = options.callbackTimeout; const callbackRegistry = new SimpleCallbackRegistry(); diff --git a/packages/napcat-rpc/src/transport.ts b/packages/napcat-rpc/src/transport.ts index ef7ef5ed..b08a1b45 100644 --- a/packages/napcat-rpc/src/transport.ts +++ b/packages/napcat-rpc/src/transport.ts @@ -67,6 +67,7 @@ export class MessageTransport implements RpcTransport { resolve: (response: RpcResponse) => void; reject: (error: Error) => void; }>(); + private callbackHandler?: (callbackId: string, args: SerializedValue[]) => Promise; private sendMessage: (message: string) => void | Promise; diff --git a/packages/napcat-schema/index.ts b/packages/napcat-schema/index.ts index c9eb7e20..eb98095c 100644 --- a/packages/napcat-schema/index.ts +++ b/packages/napcat-schema/index.ts @@ -75,15 +75,15 @@ const BaseResponseSchema: JsonObject = { stream: { type: 'string', description: '流式响应', - enum: ['stream-action', 'normal-action'] - } + enum: ['stream-action', 'normal-action'], + }, }, - required: ['status', 'retcode'] + required: ['status', 'retcode'], }; const EmptyDataSchema: JsonObject = { description: '无数据', - type: 'null' + type: 'null', }; const DEFAULT_SUCCESS_EXAMPLE_VALUE = { @@ -92,7 +92,7 @@ const DEFAULT_SUCCESS_EXAMPLE_VALUE = { data: {}, message: '', wording: '', - stream: 'normal-action' + stream: 'normal-action', } as const; const DEFAULT_ERROR_EXAMPLE_DEFINITIONS = ActionExamples.Common.errors; @@ -287,7 +287,7 @@ function sanitizeSchemaForOpenAPI (schema: T): T { ...new Set(currentType .filter((t): t is string => typeof t === 'string') .map(t => (t === 'void' || t === 'undefined') ? 'null' : t) - .concat('null')) + .concat('null')), ]; next['type'] = normalizedTypes.length === 1 ? normalizedTypes[0] : normalizedTypes; } else if (!('anyOf' in next) && !('oneOf' in next) && !('allOf' in next) && !('$ref' in next)) { @@ -298,18 +298,18 @@ function sanitizeSchemaForOpenAPI (schema: T): T { // 兜底:仅有描述/元信息但缺少 type 时,补 object,避免严格校验失败 if ( - !('type' in next) - && !('$ref' in next) - && !('anyOf' in next) - && !('oneOf' in next) - && !('allOf' in next) - && !('enum' in next) - && !('properties' in next) - && !('items' in next) + !('type' in next) && + !('$ref' in next) && + !('anyOf' in next) && + !('oneOf' in next) && + !('allOf' in next) && + !('enum' in next) && + !('properties' in next) && + !('items' in next) ) { const schemaMetaKeys = [ 'description', 'title', 'default', 'examples', 'example', - 'deprecated', 'readOnly', 'writeOnly', 'x-schema-id' + 'deprecated', 'readOnly', 'writeOnly', 'x-schema-id', ]; if (schemaMetaKeys.some(key => key in next)) { @@ -338,7 +338,7 @@ function registerSchemasFromModule ( source: Record, sourceName: string ) { - const components = ((openapi['components'] as JsonObject)['schemas'] as JsonObject); + const components = (openapi['components'] as JsonObject)['schemas'] as JsonObject; let registeredCount = 0; let duplicatedCount = 0; @@ -396,9 +396,9 @@ function replaceComponentInlineSchemasWithRefs (openapi: JsonObject) { const schemaId = obj['x-schema-id']; if ( - typeof schemaId === 'string' - && schemaId !== ownerSchemaId - && availableSchemaIds.has(schemaId) + typeof schemaId === 'string' && + schemaId !== ownerSchemaId && + availableSchemaIds.has(schemaId) ) { replacedCount += 1; return { $ref: `#/components/schemas/${schemaId}` }; @@ -490,7 +490,7 @@ export function initSchemas () { tags: action.actionTags, payloadExample: action.payloadExample, returnExample: action.returnExample, - errorExamples: action.errorExamples + errorExamples: action.errorExamples, }; }); @@ -509,7 +509,7 @@ export function initSchemas () { tags: action.actionTags, payloadExample: action.payloadExample, returnExample: action.returnExample, - errorExamples: action.errorExamples + errorExamples: action.errorExamples, }; }); } @@ -522,8 +522,8 @@ function createOpenAPIDocument (): Record { const componentExamples: Record = { [SUCCESS_DEFAULT_EXAMPLE_KEY]: { summary: '成功响应', - value: DEFAULT_SUCCESS_EXAMPLE_VALUE - } + value: DEFAULT_SUCCESS_EXAMPLE_VALUE, + }, }; DEFAULT_ERROR_EXAMPLE_DEFINITIONS.forEach(error => { @@ -535,8 +535,8 @@ function createOpenAPIDocument (): Record { data: null, message: error.description, wording: error.description, - stream: 'normal-action' - } + stream: 'normal-action', + }, }; }); @@ -545,27 +545,27 @@ function createOpenAPIDocument (): Record { info: { title: 'NapCat OneBot 11 HTTP API', description: 'NapCatOneBot11 HTTP POST 接口文档', - version: napCatVersion + version: napCatVersion, }, tags: [ { name: '消息接口', description: '发送、删除、获取消息相关接口' }, { name: '群组接口', description: '群组管理、成员管理相关接口' }, { name: '用户接口', description: '好友管理、个人信息相关接口' }, { name: '系统接口', description: '状态获取、重启、缓存清理相关接口' }, - { name: '文件接口', description: '文件上传下载、预览相关接口' } + { name: '文件接口', description: '文件上传下载、预览相关接口' }, ], paths: {} as Record, components: { schemas: { BaseResponse: BaseResponseSchema, - EmptyData: EmptyDataSchema + EmptyData: EmptyDataSchema, }, examples: componentExamples, responses: {}, - securitySchemes: {} + securitySchemes: {}, }, servers: [], - security: [] + security: [], }; } @@ -582,9 +582,9 @@ function buildResponseExamples (schemas: ActionSchemaInfo): Record) { examples: { Default: { summary: '默认请求示例', - value: schemas.payloadExample || {} - } - } - } - } + value: schemas.payloadExample || {}, + }, + }, + }, + }, }, responses: { - '200': { + 200: { description: '业务响应', content: { 'application/json': { @@ -665,19 +665,19 @@ function appendActionPaths (openapi: Record) { properties: { data: { ...(typeof cleanReturn === 'object' && cleanReturn ? cleanReturn : {}), - description: '业务数据' - } - } - } - ] + description: '业务数据', + }, + }, + }, + ], }, - examples: buildResponseExamples(schemas) - } - } - } + examples: buildResponseExamples(schemas), + }, + }, + }, }, - security: [] - } + security: [], + }, }; } } diff --git a/packages/napcat-schema/vite.config.ts b/packages/napcat-schema/vite.config.ts index bbe173d4..6690f2c0 100644 --- a/packages/napcat-schema/vite.config.ts +++ b/packages/napcat-schema/vite.config.ts @@ -7,7 +7,7 @@ import napcatVersion from 'napcat-vite/vite-plugin-version'; const external = [ 'ws', 'express', - 'electron' + 'electron', ]; const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat(); @@ -26,7 +26,7 @@ export default defineConfig({ }, plugins: [ nodeResolve(), - napcatVersion() + napcatVersion(), ], build: { target: 'esnext', @@ -41,8 +41,8 @@ export default defineConfig({ rollupOptions: { external: [ ...nodeModules, - ...external - ] + ...external, + ], }, }, }); diff --git a/packages/napcat-shell/napcat.ts b/packages/napcat-shell/napcat.ts index cc06b679..9c6857b5 100644 --- a/packages/napcat-shell/napcat.ts +++ b/packages/napcat-shell/napcat.ts @@ -17,7 +17,7 @@ const envPath = path.join(__dirname, 'config', '.env'); if (fs.existsSync(envPath)) { try { const data = fs.readFileSync(envPath, 'utf8'); - let loadedCount = 0; + // const _loadedCount = 0; data.split(/\r?\n/).forEach(line => { line = line.trim(); if (line && !line.startsWith('#')) { @@ -26,7 +26,7 @@ if (fs.existsSync(envPath)) { const value = parts.slice(1).join('=').trim(); if (key && value) { process.env[key] = value; - loadedCount++; + // loadedCount++; } } }); @@ -42,7 +42,6 @@ const ENV = { isPipeDisabled: process.env['NAPCAT_DISABLE_PIPE'] === '1', } as const; - // Worker 消息类型 interface WorkerMessage { type: 'restart' | 'restart-prepare' | 'shutdown'; @@ -50,7 +49,6 @@ interface WorkerMessage { port?: number; } - const logger = new LogWrapper(pathWrapper.logsPath); // 进程管理器和当前 Worker 进程引用 @@ -108,7 +106,7 @@ function forceKillProcess (pid: number): void { logger.logError(`[NapCat] [Process] 强制终止进程失败: PID ${pid}`); } } else { - logger.logError(`[NapCat] [Process] 强制终止进程失败:`, error); + logger.logError('[NapCat] [Process] 强制终止进程失败:', error); } } } @@ -365,7 +363,7 @@ async function startWorkerProcess (): Promise { logger.logError('[NapCat] [Process] 发送重启请求失败:', e); return { result: false, - message: '发送重启请求失败: ' + (e as Error).message + message: '发送重启请求失败: ' + (e as Error).message, }; } }); diff --git a/packages/napcat-shell/vite.config.ts b/packages/napcat-shell/vite.config.ts index 6b7daaf7..33a93a6e 100644 --- a/packages/napcat-shell/vite.config.ts +++ b/packages/napcat-shell/vite.config.ts @@ -11,7 +11,7 @@ import react from '@vitejs/plugin-react-swc'; const external = [ 'ws', 'express', - 'electron' + 'electron', ]; const nodeModules = [...builtinModules, builtinModules.map((m) => `node:${m}`)].flat(); diff --git a/packages/napcat-test/rpc.test.ts b/packages/napcat-test/rpc.test.ts index 6f9c0d7a..44bd8cd0 100644 --- a/packages/napcat-test/rpc.test.ts +++ b/packages/napcat-test/rpc.test.ts @@ -102,6 +102,7 @@ function createTestObject (): TestObject { greet () { return `Instance: ${this.name}`; } + getName () { return this.name; } @@ -609,8 +610,8 @@ describe('napcat-rpc RPC', () => { const transport = new LocalTransport(target); const proxy = createDeepProxy({ transport }); - const processor = vi.fn(async (x: number) => { - await new Promise(r => setTimeout(r, 1)); + const processor = vi.fn(async (_x: number) => { + await new Promise(_resolve => setTimeout(_resolve, 1)); return x * 10; }); @@ -779,8 +780,8 @@ describe('napcat-rpc RPC', () => { async fetchUser (id: number) { return { id, name: `User${id}` }; }, - async delay (ms: number) { - await new Promise(r => setTimeout(r, ms)); + async delay (_ms: number) { + await new Promise(_resolve => setTimeout(_resolve, _ms)); return 'done'; }, }); @@ -1441,6 +1442,7 @@ describe('napcat-rpc RPC', () => { { id: 2, name: 'item2' }, ]; } + getItem (index: number) { return { id: index, getValue: () => `item${index}` }; } diff --git a/packages/napcat-types/external-shims.d.ts b/packages/napcat-types/external-shims.d.ts index abb75cc8..8f1509ba 100644 --- a/packages/napcat-types/external-shims.d.ts +++ b/packages/napcat-types/external-shims.d.ts @@ -82,10 +82,10 @@ declare module 'napcat-protobuf' { encode (value: any): Uint8Array; } export function ProtoField (...args: any[]): any; - export type NapProtoEncodeStructType = any; - export type NapProtoDecodeStructType = any; - export type ScalarProtoFieldType = any; - export type MessageProtoFieldType = any; + export type NapProtoEncodeStructType = any; + export type NapProtoDecodeStructType = any; + export type ScalarProtoFieldType = any; + export type MessageProtoFieldType = any; export const ScalarType: { STRING: any; INT64: any; @@ -105,7 +105,7 @@ declare module 'inversify' { } export function injectable (...args: any[]): any; export function inject (...args: any[]): any; - export interface ServiceIdentifier { } + export interface ServiceIdentifier { } const _inversify_default: any; export default _inversify_default; } diff --git a/packages/napcat-types/scripts/copy-dist.mjs b/packages/napcat-types/scripts/copy-dist.mjs index 4cf85167..0f7be1ad 100644 --- a/packages/napcat-types/scripts/copy-dist.mjs +++ b/packages/napcat-types/scripts/copy-dist.mjs @@ -10,4 +10,4 @@ await copyFile( await copyFile( join(__dirname, 'README.md'), join(__dirname, 'dist', 'README.md') -); \ No newline at end of file +); diff --git a/packages/napcat-types/scripts/post-build.mjs b/packages/napcat-types/scripts/post-build.mjs index 6bc789c5..0f8030db 100644 --- a/packages/napcat-types/scripts/post-build.mjs +++ b/packages/napcat-types/scripts/post-build.mjs @@ -1,5 +1,5 @@ import { readdir, readFile, writeFile, rename } from 'node:fs/promises'; -import { join, extname, basename } from 'node:path'; +import { join } from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = fileURLToPath(new URL('../', import.meta.url)); @@ -12,6 +12,7 @@ const ALLOWED_PACKAGES = [ ]; // 外部包类型到 any 的映射 +// eslint-disable-next-line no-unused-vars const EXTERNAL_TYPE_REPLACEMENTS = { // winston 'winston.Logger': 'any', @@ -20,27 +21,27 @@ const EXTERNAL_TYPE_REPLACEMENTS = { 'express.Express': 'any', 'express.Application': 'any', 'express.Router': 'any', - 'Express': 'any', - 'Request': 'any', - 'Response': 'any', - 'NextFunction': 'any', + Express: 'any', + Request: 'any', + Response: 'any', + NextFunction: 'any', // ws - 'WebSocket': 'any', - 'WebSocketServer': 'any', - 'RawData': 'any', + WebSocket: 'any', + WebSocketServer: 'any', + RawData: 'any', // ajv - 'Ajv': 'any', - 'AnySchema': 'any', - 'ValidateFunction': 'any', + Ajv: 'any', + AnySchema: 'any', + ValidateFunction: 'any', 'ValidateFunction': 'any', // inversify - 'Container': 'any', + Container: 'any', // async-mutex - 'Mutex': 'any', - 'Semaphore': 'any', + Mutex: 'any', + Semaphore: 'any', // napcat-protobuf - 'NapProtoDecodeStructType': 'any', - 'NapProtoEncodeStructType': 'any', + NapProtoDecodeStructType: 'any', + NapProtoEncodeStructType: 'any', 'NapProtoDecodeStructType': 'any', 'NapProtoEncodeStructType': 'any', }; @@ -90,6 +91,7 @@ function replaceExternalTypes (content) { // 使用类型上下文的模式匹配 const typeContextPatterns = [ // : Type + // eslint-disable-next-line no-useless-escape /:\s*(WebSocket|WebSocketServer|RawData|Ajv|AnySchema|ValidateFunction|Container|Mutex|Semaphore|NapProtoDecodeStructType|NapProtoEncodeStructType|Express|Request|Response|NextFunction)(?=\s*[;,)\]\}|&]|$)/g, // /<(WebSocket|WebSocketServer|RawData|Ajv|AnySchema|ValidateFunction|Container|Mutex|Semaphore|NapProtoDecodeStructType|NapProtoEncodeStructType|Express|Request|Response|NextFunction)>/g, @@ -144,7 +146,7 @@ async function processFile (filePath) { const newPath = filePath.replace(/\.d\.ts$/, '.ts'); await rename(filePath, newPath); - //console.log(`Processed: ${basename(filePath)} -> ${basename(newPath)}`); + // console.log(`Processed: ${basename(filePath)} -> ${basename(newPath)}`); } console.log('Starting post-build processing...'); diff --git a/packages/napcat-types/test-dist.ts b/packages/napcat-types/test-dist.ts index 292ecf09..55bb40ea 100644 --- a/packages/napcat-types/test-dist.ts +++ b/packages/napcat-types/test-dist.ts @@ -16,15 +16,15 @@ console.log('ChatType.KCHATTYPEGROUP:', ChatType.KCHATTYPEGROUP); // 应输出 2 console.log('ElementType.TEXT:', ElementType.TEXT); // 应输出 1 // 2. 测试类型 (Core) -const coreStub = {} as NapCatCore; -const apiStub = {} as NTQQMsgApi; +const _coreStub = {} as NapCatCore; +const _apiStub = {} as NTQQMsgApi; console.log('Core types access check: OK'); // 3. 测试类和类型 (OneBot) -const obAdapterStub = {} as NapCatOneBot11Adapter; -const obMsgStub = {} as OB11Message; -const baseMessageEventStub = {} as OB11BaseMessageEvent; -const baseMetaEventStub = {} as OB11BaseMetaEvent; +const _obAdapterStub = {} as NapCatOneBot11Adapter; +const _obMsgStub = {} as OB11Message; +const _baseMessageEventStub = {} as OB11BaseMessageEvent; +const _baseMetaEventStub = {} as OB11BaseMetaEvent; console.log('OneBot types and events access check: OK'); // 4. 验证导出完整性 @@ -34,5 +34,3 @@ if (ChatType.KCHATTYPEGROUP === 2 && ElementType.TEXT === 1) { console.error('\n❌ TESTS FAILED: Enum value mismatch.'); throw new Error('Test Failed'); } - - diff --git a/packages/napcat-vite/vite-plugin-version.js b/packages/napcat-vite/vite-plugin-version.js index 4136500f..4c21f173 100644 --- a/packages/napcat-vite/vite-plugin-version.js +++ b/packages/napcat-vite/vite-plugin-version.js @@ -43,7 +43,7 @@ function validateVersion (version) { /** * NapCat Vite Plugin: fetches latest GitHub tag (not release) and injects into import.meta.env - * + * * 版本号来源优先级: * 1. 环境变量 NAPCAT_VERSION (用于 CI 构建) * 2. 缓存的 GitHub tag diff --git a/packages/napcat-webui-backend/index.ts b/packages/napcat-webui-backend/index.ts index 87481d6b..c6b88f14 100644 --- a/packages/napcat-webui-backend/index.ts +++ b/packages/napcat-webui-backend/index.ts @@ -13,7 +13,7 @@ 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 { join, dirname, resolve } from 'node:path'; import { terminalManager } from '@/napcat-webui-backend/src/terminal/terminal_manager'; import multer from 'multer'; import * as net from 'node:net'; @@ -26,7 +26,7 @@ import { handleDebugWebSocket } from '@/napcat-webui-backend/src/api/Debug'; import compression from 'compression'; import { napCatVersion } from 'napcat-common/src/version'; import { fileURLToPath } from 'node:url'; -import { dirname, resolve } from 'node:path'; + import { NapCatOneBot11Adapter } from '@/napcat-onebot/index'; import { OB11PluginMangerAdapter } from '@/napcat-onebot/network/plugin-manger'; diff --git a/packages/napcat-webui-backend/src/api/BackupConfig.ts b/packages/napcat-webui-backend/src/api/BackupConfig.ts index 075adb18..d82d43c0 100644 --- a/packages/napcat-webui-backend/src/api/BackupConfig.ts +++ b/packages/napcat-webui-backend/src/api/BackupConfig.ts @@ -52,7 +52,6 @@ export const BackupExportConfigHandler: RequestHandler = async (_req, res) => { sendError(res, '流式压缩失败'); } }); - } catch (error) { const msg = (error as Error).message; console.error('导出配置失败:', error); @@ -140,9 +139,8 @@ export const BackupImportConfigHandler: RequestHandler = async (req, res) => { return sendSuccess(res, { message: '配置导入成功,重启后生效~', filesImported: extractedFiles.size, - filesBackedUp: backupFiles.size + filesBackedUp: backupFiles.size, }); - } catch (error) { console.error('导入配置失败:', error); const msg = (error as Error).message; diff --git a/packages/napcat-webui-backend/src/api/BaseInfo.ts b/packages/napcat-webui-backend/src/api/BaseInfo.ts index 33e3a342..3f0cbd4a 100644 --- a/packages/napcat-webui-backend/src/api/BaseInfo.ts +++ b/packages/napcat-webui-backend/src/api/BaseInfo.ts @@ -151,9 +151,9 @@ export const getAllReleasesHandler: RequestHandler = async (req, res) => { total, totalPages, }, - mirror: usedMirror + mirror: usedMirror, }); - } catch (error) { + } catch (_error) { res.status(500).json({ error: 'Failed to fetch releases' }); } }; diff --git a/packages/napcat-webui-backend/src/api/Debug.ts b/packages/napcat-webui-backend/src/api/Debug.ts index a5d1b1d8..d413c338 100644 --- a/packages/napcat-webui-backend/src/api/Debug.ts +++ b/packages/napcat-webui-backend/src/api/Debug.ts @@ -3,7 +3,7 @@ import { WebSocket, WebSocketServer, RawData } from 'ws'; import { sendError, sendSuccess } from '@/napcat-webui-backend/src/utils/response'; import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data'; import { IncomingMessage } from 'http'; -import { OB11Response } from '@/napcat-onebot/action/OneBotAction'; +import { OB11Response, OneBotAction } from '@/napcat-onebot/action/OneBotAction'; import { ActionName } from '@/napcat-onebot/action/router'; import { OB11LifeCycleEvent, LifeCycleSubType } from '@/napcat-onebot/event/meta/OB11LifeCycleEvent'; import { IOB11NetworkAdapter } from '@/napcat-onebot/network/adapter'; @@ -12,7 +12,7 @@ import { ActionMap } from '@/napcat-onebot/action'; import { NapCatCore } from '@/napcat-core/index'; import { NapCatOneBot11Adapter } from '@/napcat-onebot/index'; import { OB11EmitEventContent, OB11NetworkReloadType } from '@/napcat-onebot/network/index'; -import { OneBotAction } from '@/napcat-onebot/action/OneBotAction'; + import json5 from 'json5'; type ActionNameType = typeof ActionName[keyof typeof ActionName]; @@ -82,7 +82,7 @@ class DebugAdapter extends IOB11NetworkAdapter { token: '', enableForcePushEvent: true, debug: true, - heartInterval: 0 + heartInterval: 0, }; super(`debug-${sessionId}`, config, core, obContext, actions); @@ -161,9 +161,9 @@ class DebugAdapter extends IOB11NetworkAdapter { this.updateActivity(); let receiveData: { action: ActionNameType, params?: Record, echo?: unknown; } = { action: ActionName.Unknown, - params: {} + params: {}, }; - let echo: unknown = undefined; + let echo: unknown; try { receiveData = json5.parse(message.toString()); @@ -332,7 +332,7 @@ router.post('/create', async (_req: Request, res: Response) => { */ const handleCallApi = async (req: Request, res: Response) => { try { - let adapterName = req.params['adapterName'] || req.body.adapterName || DEFAULT_ADAPTER_NAME; + const adapterName = req.params['adapterName'] || req.body.adapterName || DEFAULT_ADAPTER_NAME; let adapter = debugAdapterManager.getAdapter(adapterName); diff --git a/packages/napcat-webui-backend/src/api/Mirror.ts b/packages/napcat-webui-backend/src/api/Mirror.ts index 4480fff0..f8f74a4d 100644 --- a/packages/napcat-webui-backend/src/api/Mirror.ts +++ b/packages/napcat-webui-backend/src/api/Mirror.ts @@ -6,7 +6,7 @@ import { buildMirrorUrl, getMirrorConfig, setCustomMirror, - clearMirrorCache + clearMirrorCache, } from 'napcat-common/src/mirror'; import https from 'https'; import http from 'http'; diff --git a/packages/napcat-webui-backend/src/api/Plugin.ts b/packages/napcat-webui-backend/src/api/Plugin.ts index fd9e3a3e..f923f4f7 100644 --- a/packages/napcat-webui-backend/src/api/Plugin.ts +++ b/packages/napcat-webui-backend/src/api/Plugin.ts @@ -77,7 +77,7 @@ export const GetPluginListHandler: RequestHandler = async (_req, res) => { hasPages: boolean; homepage?: string; repository?: string; - }> = new Array(); + }> = []; // 收集所有插件的扩展页面 const extensionPages: Array<{ @@ -117,7 +117,7 @@ export const GetPluginListHandler: RequestHandler = async (_req, res) => { homepage: p.packageJson?.homepage, repository: typeof p.packageJson?.repository === 'string' ? p.packageJson.repository - : p.packageJson?.repository?.url + : p.packageJson?.repository?.url, }); // 收集插件的扩展页面 @@ -130,13 +130,12 @@ export const GetPluginListHandler: RequestHandler = async (_req, res) => { path: page.path, title: page.title, icon: page.icon, - description: page.description + description: page.description, }); } } } - return sendSuccess(res, { plugins: AllPlugins, pluginManagerNotFound: false, extensionPages }); }; @@ -202,7 +201,7 @@ export const GetPluginConfigHandler: RequestHandler = async (req, res) => { if (plugin.runtime.module?.plugin_get_config && plugin.runtime.context) { try { config = await plugin.runtime.module?.plugin_get_config(plugin.runtime.context); - } catch (e) { } + } catch (_e) { } } else { // Default behavior: read from default config path try { @@ -210,7 +209,7 @@ export const GetPluginConfigHandler: RequestHandler = async (req, res) => { if (fs.existsSync(configPath)) { config = JSON.parse(fs.readFileSync(configPath, 'utf-8')); } - } catch (e) { } + } catch (_e) { } } // 获取静态 schema @@ -268,7 +267,7 @@ export const PluginConfigSSEHandler: RequestHandler = (req, res): void => { if (initialConfigStr) { try { currentConfig = JSON.parse(initialConfigStr); - } catch (e) { } + } catch (_e) { } } // 发送 SSE 消息的辅助函数 @@ -297,7 +296,7 @@ export const PluginConfigSSEHandler: RequestHandler = (req, res): void => { hideField: (key: string) => { sendSSE('schema', { type: 'hideField', key }); }, - getCurrentConfig: () => currentConfig + getCurrentConfig: () => currentConfig, }; // 存储会话 @@ -343,7 +342,7 @@ export const PluginConfigSSEHandler: RequestHandler = (req, res): void => { if (session?.cleanup) { try { session.cleanup(); - } catch (e) { } + } catch (_e) { } } activeConfigSessions.delete(sessionId); }); @@ -378,30 +377,30 @@ export const PluginConfigChangeHandler: RequestHandler = async (req, res) => { if (plugin.runtime.module?.plugin_on_config_change) { const uiController = { updateSchema: (schema: any[]) => { - session.res.write(`event: schema\n`); + session.res.write('event: schema\n'); session.res.write(`data: ${JSON.stringify({ type: 'full', schema })}\n\n`); }, updateField: (fieldKey: string, field: any) => { - session.res.write(`event: schema\n`); + session.res.write('event: schema\n'); session.res.write(`data: ${JSON.stringify({ type: 'updateField', key: fieldKey, field })}\n\n`); }, removeField: (fieldKey: string) => { - session.res.write(`event: schema\n`); + session.res.write('event: schema\n'); session.res.write(`data: ${JSON.stringify({ type: 'removeField', key: fieldKey })}\n\n`); }, addField: (field: any, afterKey?: string) => { - session.res.write(`event: schema\n`); + session.res.write('event: schema\n'); session.res.write(`data: ${JSON.stringify({ type: 'addField', field, afterKey })}\n\n`); }, showField: (fieldKey: string) => { - session.res.write(`event: schema\n`); + session.res.write('event: schema\n'); session.res.write(`data: ${JSON.stringify({ type: 'showField', key: fieldKey })}\n\n`); }, hideField: (fieldKey: string) => { - session.res.write(`event: schema\n`); + session.res.write('event: schema\n'); session.res.write(`data: ${JSON.stringify({ type: 'hideField', key: fieldKey })}\n\n`); }, - getCurrentConfig: () => session.currentConfig + getCurrentConfig: () => session.currentConfig, }; try { @@ -415,7 +414,7 @@ export const PluginConfigChangeHandler: RequestHandler = async (req, res) => { ); } } catch (e: any) { - session.res.write(`event: error\n`); + session.res.write('event: error\n'); session.res.write(`data: ${JSON.stringify({ message: e.message })}\n\n`); } } diff --git a/packages/napcat-webui-backend/src/api/UpdateNapCat.ts b/packages/napcat-webui-backend/src/api/UpdateNapCat.ts index 274d4fc5..61959875 100644 --- a/packages/napcat-webui-backend/src/api/UpdateNapCat.ts +++ b/packages/napcat-webui-backend/src/api/UpdateNapCat.ts @@ -10,7 +10,7 @@ import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data'; import { NapCatCoreWorkingEnv } from '@/napcat-webui-backend/src/types'; import { getGitHubRelease, - findAvailableDownloadUrl + findAvailableDownloadUrl, } from '@/napcat-common/src/mirror'; import { ILogWrapper } from '@/napcat-common/src/log-interface'; @@ -39,7 +39,7 @@ interface UpdateConfig { // 需要跳过更新的文件 const SKIP_UPDATE_FILES = [ 'NapCatWinBootMain.exe', - 'NapCatWinBootHook.dll' + 'NapCatWinBootHook.dll', ]; /** @@ -67,7 +67,7 @@ function scanFilesRecursively (dirPath: string, basePath: string = dirPath): Arr } else if (stat.isFile()) { files.push({ sourcePath: fullPath, - relativePath: relativePath + relativePath, }); } } @@ -86,7 +86,7 @@ async function downloadFile (url: string, dest: string): Promise { return new Promise((resolve, reject) => { const request = https.get(url, { - headers: { 'User-Agent': 'NapCat-WebUI' } + headers: { 'User-Agent': 'NapCat-WebUI' }, }, (res) => { webUiLogger?.log('[NapCat Update] Response status:', res.statusCode); webUiLogger?.log('[NapCat Update] Content-Type:', res.headers['content-type']); @@ -169,9 +169,8 @@ export const UpdateNapCatHandler: RequestHandler = async (req, res) => { customMirror: mirror, }); webUiLogger?.log(`[NapCat Update] Using download URL: ${downloadUrl}`); - } catch (error) { - // 如果镜像都不可用,直接使用原始 URL - webUiLogger?.logWarn(`[NapCat Update] All nightly.link mirrors failed, using original URL`); + } catch (_error) { + webUiLogger?.logWarn('[NapCat Update] All nightly.link mirrors failed, using original URL'); downloadUrl = baseUrl; } } else { @@ -289,7 +288,7 @@ export const UpdateNapCatHandler: RequestHandler = async (req, res) => { webUiLogger?.logError(`[NapCat Update] Failed to update ${targetFilePath}, will retry on next startup:`, error); failedFiles.push({ sourcePath: fileInfo.sourcePath, - targetPath: targetFilePath + targetPath: targetFilePath, }); } } @@ -300,7 +299,7 @@ export const UpdateNapCatHandler: RequestHandler = async (req, res) => { version: actualVersion, updateTime: new Date().toISOString(), files: failedFiles, - changelog: '' + changelog: '', }; // 保存更新配置文件 @@ -317,14 +316,12 @@ export const UpdateNapCatHandler: RequestHandler = async (req, res) => { status: 'completed', message, newVersion: actualVersion, - failedFilesCount: failedFiles.length + failedFilesCount: failedFiles.length, }); - } catch (error) { webUiLogger?.logError('[NapCat Update] 更新失败:', error); sendError(res, '更新失败: ' + (error instanceof Error ? error.message : '未知错误')); } - } catch (error: any) { webUiLogger?.logError('[NapCat Update] 更新失败:', error); sendError(res, '更新失败: ' + error.message); @@ -340,7 +337,7 @@ export async function applyPendingUpdates (webUiPathWrapper: NapCatPathWrapper, const configPath = path.join(webUiPathWrapper.configPath, 'napcat-update.json'); if (!fs.existsSync(configPath)) { - //logger.log('[NapCat Update] No pending updates found'); + // logger.log('[NapCat Update] No pending updates found'); return; } @@ -373,7 +370,6 @@ export async function applyPendingUpdates (webUiPathWrapper: NapCatPathWrapper, } fs.copyFileSync(file.sourcePath, file.targetPath); logger.log(`[NapCat Update] Updated ${path.basename(file.targetPath)} on startup`); - } catch (error) { logger.logError(`[NapCat Update] Failed to update ${file.targetPath} on startup:`, error); // 如果仍然失败,保留在列表中 @@ -385,7 +381,7 @@ export async function applyPendingUpdates (webUiPathWrapper: NapCatPathWrapper, if (remainingFiles.length > 0) { const updatedConfig: UpdateConfig = { ...updateConfig, - files: remainingFiles + files: remainingFiles, }; fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2)); logger.log(`[NapCat Update] ${remainingFiles.length} files still pending update`); diff --git a/packages/napcat-webui-backend/src/assets/sw_template.js b/packages/napcat-webui-backend/src/assets/sw_template.js index 862b43f3..5ae6cd88 100644 --- a/packages/napcat-webui-backend/src/assets/sw_template.js +++ b/packages/napcat-webui-backend/src/assets/sw_template.js @@ -1,28 +1,29 @@ /** * NapCat WebUI Service Worker - * + * * 路由缓存策略设计: - * + * * 【永不缓存 - Network Only】 * - /api/* WebUI API * - /plugin/:id/api/* 插件 API * - /files/theme.css 动态主题 CSS * - /webui/fonts/CustomFont.woff 用户自定义字体 * - WebSocket / SSE 连接 - * + * * 【强缓存 - Cache First】 * - /webui/assets/* 前端静态资源(带 hash) * - /webui/fonts/* 内置字体(排除 CustomFont) * - q1.qlogo.cn QQ 头像 - * + * * 【网络优先 - Network First】 * - /webui/* (HTML 导航) SPA 页面 * - /plugin/:id/page/* 插件页面 * - /plugin/:id/files/* 插件文件系统静态资源 - * - * 【后台更新 - Stale-While-Revalidate】 + * + * 【后台更新 - Stale-While-Revalidate】 * - /plugin/:id/mem/* 插件内存静态资源 */ +/* global self, caches */ const CACHE_NAME = 'napcat-webui-v{{VERSION}}'; @@ -157,6 +158,7 @@ self.addEventListener('activate', (event) => { console.log('[SW] Deleting old cache:', cacheName); return caches.delete(cacheName); } + return Promise.resolve(); }) ); // 立即接管所有客户端 @@ -216,11 +218,10 @@ self.addEventListener('fetch', (event) => { // 8. 其他同源请求 - Network Only(避免意外缓存) if (url.origin === self.location.origin) { // 不缓存,直接穿透 - return; + } // 9. 其他外部请求 - Network Only - return; }); // ============ 缓存策略实现 ============ diff --git a/packages/napcat-webui-backend/src/middleware/auth.ts b/packages/napcat-webui-backend/src/middleware/auth.ts index f1e9bb39..03ffa66b 100644 --- a/packages/napcat-webui-backend/src/middleware/auth.ts +++ b/packages/napcat-webui-backend/src/middleware/auth.ts @@ -32,7 +32,7 @@ export async function auth (req: Request, res: Response, next: NextFunction) { } // 判断是否有Authorization头 if (hash) { - //if (!hash) return sendError(res, 'Unauthorized'); + // if (!hash) return sendError(res, 'Unauthorized'); // 解析token let Credential: WebUiCredentialJson; try { diff --git a/packages/napcat-webui-backend/src/middleware/cors.ts b/packages/napcat-webui-backend/src/middleware/cors.ts index 062f4b7c..f0485c48 100644 --- a/packages/napcat-webui-backend/src/middleware/cors.ts +++ b/packages/napcat-webui-backend/src/middleware/cors.ts @@ -121,7 +121,7 @@ function matchIPv6CIDR (ip: string, cidr: string): boolean { } return true; - } catch (error) { + } catch (_error) { return false; } } @@ -170,7 +170,7 @@ function expandIPv6 (ip: string): number[] | null { if (segments.length !== 8) return null; return segments.map(s => parseInt(s || '0', 16)); - } catch (error) { + } catch (_error) { return null; } } diff --git a/packages/napcat-webui-backend/src/router/Mirror.ts b/packages/napcat-webui-backend/src/router/Mirror.ts index d1bee4cb..9903a2f1 100644 --- a/packages/napcat-webui-backend/src/router/Mirror.ts +++ b/packages/napcat-webui-backend/src/router/Mirror.ts @@ -3,7 +3,7 @@ import { GetMirrorListHandler, SetCustomMirrorHandler, TestMirrorsSSEHandler, - TestSingleMirrorHandler + TestSingleMirrorHandler, } from '@/napcat-webui-backend/src/api/Mirror'; const router: Router = Router(); diff --git a/packages/napcat-webui-backend/src/router/OB11Config.ts b/packages/napcat-webui-backend/src/router/OB11Config.ts index d4dab3f9..ea06779c 100644 --- a/packages/napcat-webui-backend/src/router/OB11Config.ts +++ b/packages/napcat-webui-backend/src/router/OB11Config.ts @@ -8,7 +8,7 @@ const router: Router = Router(); // 使用内存存储,配合流式处理 const upload = multer({ - storage: multer.memoryStorage() + storage: multer.memoryStorage(), }); // router:读取配置 @@ -21,4 +21,3 @@ router.get('/ExportConfig', BackupExportConfigHandler); router.post('/ImportConfig', upload.single('configFile'), BackupImportConfigHandler); export { router as OB11ConfigRouter }; - diff --git a/packages/napcat-webui-backend/src/router/Plugin.ts b/packages/napcat-webui-backend/src/router/Plugin.ts index bb27847f..e3cd824d 100644 --- a/packages/napcat-webui-backend/src/router/Plugin.ts +++ b/packages/napcat-webui-backend/src/router/Plugin.ts @@ -12,13 +12,13 @@ import { RegisterPluginManagerHandler, PluginConfigSSEHandler, PluginConfigChangeHandler, - ImportLocalPluginHandler + ImportLocalPluginHandler, } from '@/napcat-webui-backend/src/api/Plugin'; import { GetPluginStoreListHandler, GetPluginStoreDetailHandler, InstallPluginFromStoreHandler, - InstallPluginFromStoreSSEHandler + InstallPluginFromStoreSSEHandler, } from '@/napcat-webui-backend/src/api/PluginStore'; import { WebUiDataRuntime } from '@/napcat-webui-backend/src/helper/Data'; import { NapCatOneBot11Adapter } from '@/napcat-onebot/index'; @@ -37,7 +37,7 @@ const storage = multer.diskStorage({ filename: (_req, file, cb) => { const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9); cb(null, uniqueSuffix + '-' + file.originalname); - } + }, }); const upload = multer({ @@ -54,7 +54,7 @@ const upload = multer({ } else { cb(new Error('Only .zip files are allowed')); } - } + }, }); const router: Router = Router(); diff --git a/packages/napcat-webui-backend/src/router/UpdateNapCat.ts b/packages/napcat-webui-backend/src/router/UpdateNapCat.ts index a0c0e01c..e5c53795 100644 --- a/packages/napcat-webui-backend/src/router/UpdateNapCat.ts +++ b/packages/napcat-webui-backend/src/router/UpdateNapCat.ts @@ -10,4 +10,4 @@ const router: Router = Router(); // POST /api/UpdateNapCat/update - 更新NapCat router.post('/update', UpdateNapCatHandler); -export { router as UpdateNapCatRouter }; \ No newline at end of file +export { router as UpdateNapCatRouter }; diff --git a/packages/napcat-webui-frontend/package.json b/packages/napcat-webui-frontend/package.json index 33cd8f68..7e3ba5d4 100644 --- a/packages/napcat-webui-frontend/package.json +++ b/packages/napcat-webui-frontend/package.json @@ -63,7 +63,7 @@ "@xterm/addon-web-links": "^0.11.0", "@xterm/xterm": "^5.5.0", "ahooks": "^3.8.4", - "axios": "^1.7.9", + "axios": "^1.13.5", "clsx": "^2.1.1", "crypto-js": "^4.2.0", "event-source-polyfill": "^1.0.31", diff --git a/packages/napcat-webui-frontend/scripts/fontmin.cjs b/packages/napcat-webui-frontend/scripts/fontmin.cjs index afd4d8d5..aae24982 100644 --- a/packages/napcat-webui-frontend/scripts/fontmin.cjs +++ b/packages/napcat-webui-frontend/scripts/fontmin.cjs @@ -43,7 +43,7 @@ function extractCharsFromSource () { // 匹配所有 .tsx, .ts, .jsx, .js, .css 文件 const files = glob.sync(`${SRC_DIR}/**/*.{tsx,ts,jsx,js,css}`, { - ignore: ['**/node_modules/**'] + ignore: ['**/node_modules/**'], }); // 中文字符正则 @@ -73,7 +73,7 @@ async function run () { console.log(`📝 Found ${text.length} unique characters`); // 检查源字体是否存在 - let sourceFont = SOURCE_FONT; + const sourceFont = SOURCE_FONT; if (!fs.existsSync(SOURCE_FONT)) { // 尝试查找原始 TTF 并复制(不重命名,保留原始) if (fs.existsSync(SOURCE_TTF_ORIGINAL)) { diff --git a/packages/napcat-webui-frontend/src/components/ColorPicker.tsx b/packages/napcat-webui-frontend/src/components/ColorPicker.tsx index 8c819f12..e9874879 100644 --- a/packages/napcat-webui-frontend/src/components/ColorPicker.tsx +++ b/packages/napcat-webui-frontend/src/components/ColorPicker.tsx @@ -1,6 +1,6 @@ -import { Input } from "@heroui/input"; -import { Popover, PopoverContent, PopoverTrigger } from "@heroui/popover"; -import React, { useCallback, useEffect, useRef, useState, memo } from "react"; +import { Input } from '@heroui/input'; +import { Popover, PopoverContent, PopoverTrigger } from '@heroui/popover'; +import React, { useCallback, useEffect, useRef, useState, memo } from 'react'; interface ColorPickerProps { color: string; @@ -18,25 +18,25 @@ const parseHsl = (hslStr: string) => { // 转换 HEX 到 HSL const hexToHsl = (hex: string) => { - let r = 0, g = 0, b = 0; + let r = 0; let g = 0; let b = 0; if (hex.length === 4) { - r = parseInt("0x" + hex[1] + hex[1]); - g = parseInt("0x" + hex[2] + hex[2]); - b = parseInt("0x" + hex[3] + hex[3]); + r = parseInt('0x' + hex[1] + hex[1]); + g = parseInt('0x' + hex[2] + hex[2]); + b = parseInt('0x' + hex[3] + hex[3]); } else if (hex.length === 7) { - r = parseInt("0x" + hex[1] + hex[2]); - g = parseInt("0x" + hex[3] + hex[4]); - b = parseInt("0x" + hex[5] + hex[6]); + r = parseInt('0x' + hex[1] + hex[2]); + g = parseInt('0x' + hex[3] + hex[4]); + b = parseInt('0x' + hex[5] + hex[6]); } r /= 255; g /= 255; b /= 255; - const cmin = Math.min(r, g, b), - cmax = Math.max(r, g, b), - delta = cmax - cmin; - let h = 0, - s = 0, - l = 0; + const cmin = Math.min(r, g, b); + const cmax = Math.max(r, g, b); + const delta = cmax - cmin; + let h = 0; + let s = 0; + let l = 0; if (delta === 0) h = 0; else if (cmax === r) h = ((g - b) / delta) % 6; @@ -61,19 +61,19 @@ const hslToHex = (h: number, s: number, l: number) => { const c = (1 - Math.abs(2 * l - 1)) * s; const x = c * (1 - Math.abs(((h / 60) % 2) - 1)); const m = l - c / 2; - let r = 0, g = 0, b = 0; + let r = 0; let g = 0; let b = 0; - if (0 <= h && h < 60) { + if (h >= 0 && h < 60) { r = c; g = x; b = 0; - } else if (60 <= h && h < 120) { + } else if (h >= 60 && h < 120) { r = x; g = c; b = 0; - } else if (120 <= h && h < 180) { + } else if (h >= 120 && h < 180) { r = 0; g = c; b = x; - } else if (180 <= h && h < 240) { + } else if (h >= 180 && h < 240) { r = 0; g = x; b = c; - } else if (240 <= h && h < 300) { + } else if (h >= 240 && h < 300) { r = x; g = 0; b = c; - } else if (300 <= h && h < 360) { + } else if (h >= 300 && h < 360) { r = c; g = 0; b = x; } r = Math.round((r + m) * 255); @@ -82,9 +82,9 @@ const hslToHex = (h: number, s: number, l: number) => { const toHex = (n: number) => { const hex = n.toString(16); - return hex.length === 1 ? "0" + hex : hex; + return hex.length === 1 ? '0' + hex : hex; }; - return "#" + toHex(r) + toHex(g) + toHex(b); + return '#' + toHex(r) + toHex(g) + toHex(b); }; interface PanelProps { @@ -109,7 +109,7 @@ const SatLightPanel = memo(({ hsl, onChange }: PanelProps) => { const s_hsv = x; const v_hsv = 1 - y; - let l_hsl = v_hsv * (1 - s_hsv / 2); + const l_hsl = v_hsv * (1 - s_hsv / 2); let s_hsl = 0; if (l_hsl === 0 || l_hsl === 1) { s_hsl = 0; @@ -157,16 +157,16 @@ const SatLightPanel = memo(({ hsl, onChange }: PanelProps) => { }; if (isDragging) { - window.addEventListener("mousemove", handleMouseMove); - window.addEventListener("mouseup", handleEnd); - window.addEventListener("touchmove", handleTouchMove, { passive: false }); - window.addEventListener("touchend", handleEnd); + window.addEventListener('mousemove', handleMouseMove); + window.addEventListener('mouseup', handleEnd); + window.addEventListener('touchmove', handleTouchMove, { passive: false }); + window.addEventListener('touchend', handleEnd); } return () => { - window.removeEventListener("mousemove", handleMouseMove); - window.removeEventListener("mouseup", handleEnd); - window.removeEventListener("touchmove", handleTouchMove); - window.removeEventListener("touchend", handleEnd); + window.removeEventListener('mousemove', handleMouseMove); + window.removeEventListener('mouseup', handleEnd); + window.removeEventListener('touchmove', handleTouchMove); + window.removeEventListener('touchend', handleEnd); }; }, [isDragging, updateColor]); @@ -181,27 +181,27 @@ const SatLightPanel = memo(({ hsl, onChange }: PanelProps) => { return (
); }); -SatLightPanel.displayName = "SatLightPanel"; +SatLightPanel.displayName = 'SatLightPanel'; const HueSlider = memo(({ hsl, onChange }: PanelProps) => { const sliderRef = useRef(null); @@ -255,38 +255,38 @@ const HueSlider = memo(({ hsl, onChange }: PanelProps) => { }; if (isDragging) { - window.addEventListener("mousemove", handleMouseMove); - window.addEventListener("mouseup", handleEnd); - window.addEventListener("touchmove", handleTouchMove, { passive: false }); - window.addEventListener("touchend", handleEnd); + window.addEventListener('mousemove', handleMouseMove); + window.addEventListener('mouseup', handleEnd); + window.addEventListener('touchmove', handleTouchMove, { passive: false }); + window.addEventListener('touchend', handleEnd); } return () => { - window.removeEventListener("mousemove", handleMouseMove); - window.removeEventListener("mouseup", handleEnd); - window.removeEventListener("touchmove", handleTouchMove); - window.removeEventListener("touchend", handleEnd); + window.removeEventListener('mousemove', handleMouseMove); + window.removeEventListener('mouseup', handleEnd); + window.removeEventListener('touchmove', handleTouchMove); + window.removeEventListener('touchend', handleEnd); }; }, [isDragging, updateHue]); return (
); }); -HueSlider.displayName = "HueSlider"; +HueSlider.displayName = 'HueSlider'; const ColorPicker: React.FC = ({ color, onChange }) => { const [hsl, setHsl] = useState(parseHsl(color)); @@ -305,7 +305,7 @@ const ColorPicker: React.FC = ({ color, onChange }) => { const handleHslChange = useCallback((newHsl: { h: number, s: number, l: number; }) => { setHsl(newHsl); setHex(hslToHex(newHsl.h, newHsl.s, newHsl.l)); - onChange("hsl(" + Math.round(newHsl.h) + ", " + Math.round(newHsl.s) + "%, " + Math.round(newHsl.l) + "%)"); + onChange('hsl(' + Math.round(newHsl.h) + ', ' + Math.round(newHsl.s) + '%, ' + Math.round(newHsl.l) + '%)'); }, [onChange]); const handleHexChange = (value: string) => { @@ -317,30 +317,31 @@ const ColorPicker: React.FC = ({ color, onChange }) => { }; return ( - + -
+
-
- {hex} - HSL({Math.round(hsl.h)}, {Math.round(hsl.s)}%, {Math.round(hsl.l)}%) +
+ {hex} + HSL({Math.round(hsl.h)}, {Math.round(hsl.s)}%, {Math.round(hsl.l)}%)
- { isDraggingRef.current = true; }} onMouseUpCapture={() => { isDraggingRef.current = false; }} onTouchStartCapture={() => { isDraggingRef.current = true; }} onTouchEndCapture={() => { isDraggingRef.current = false; }} > -
-
- 选择颜色 +
+
+ 选择颜色
@@ -348,53 +349,53 @@ const ColorPicker: React.FC = ({ color, onChange }) => { -
- HEX +
+ HEX handleHexChange(e.target.value)} - className="col-span-3 font-mono" + className='col-span-3 font-mono' classNames={{ - input: "text-xs uppercase", - inputWrapper: "h-8 min-h-8" + input: 'text-xs uppercase', + inputWrapper: 'h-8 min-h-8', }} />
-
- HSL -
+
+ HSL +
handleHslChange({ ...hsl, h: Number(e.target.value) })} - endContent={H} - classNames={{ input: "text-xs", inputWrapper: "h-8 min-h-8 px-1" }} + endContent={H} + classNames={{ input: 'text-xs', inputWrapper: 'h-8 min-h-8 px-1' }} /> handleHslChange({ ...hsl, s: Number(e.target.value) })} - endContent={S} - classNames={{ input: "text-xs", inputWrapper: "h-8 min-h-8 px-1" }} + endContent={S} + classNames={{ input: 'text-xs', inputWrapper: 'h-8 min-h-8 px-1' }} /> handleHslChange({ ...hsl, l: Number(e.target.value) })} - endContent={L} - classNames={{ input: "text-xs", inputWrapper: "h-8 min-h-8 px-1" }} + endContent={L} + classNames={{ input: 'text-xs', inputWrapper: 'h-8 min-h-8 px-1' }} />
-
- {["#006FEE", "#17C964", "#F5A524", "#F31260", "#7828C8", "#000000", "#FFFFFF"].map((c) => ( +
+ {['#006FEE', '#17C964', '#F5A524', '#F31260', '#7828C8', '#000000', '#FFFFFF'].map((c) => ( - )} + {children + ? children(onOpen) + : ( + + )} ((props, ref) => { const { isDark } = useTheme(); const chromeless = !!props.options?.chromeless; - // eslint-disable-next-line @typescript-eslint/no-unused-vars + const [val, setVal] = useState(props.value || props.defaultValue || ''); const internalRef = React.useRef(null); @@ -45,71 +45,71 @@ const CodeEditor = React.forwardRef((props, ref) getValue: () => { // Prefer getting dynamic value from view, fallback to state return internalRef.current?.view?.state.doc.toString() || val; - } + }, })); const customTheme = EditorView.theme({ - "&": { - fontSize: "14px", - height: "100% !important", + '&': { + fontSize: '14px', + height: '100% !important', backgroundColor: 'transparent !important', }, - "&.cm-editor": { + '&.cm-editor': { backgroundColor: 'transparent !important', }, - ".cm-scroller": { + '.cm-scroller': { fontFamily: "var(--font-family-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace)", - lineHeight: "1.6", - overflow: "auto !important", - height: "100% !important", + lineHeight: '1.6', + overflow: 'auto !important', + height: '100% !important', backgroundColor: 'transparent !important', }, - ".cm-gutters": { - backgroundColor: "transparent !important", - borderRight: "none", + '.cm-gutters': { + backgroundColor: 'transparent !important', + borderRight: 'none', color: isDark ? 'hsl(var(--heroui-foreground-500) / 0.75)' : 'hsl(var(--heroui-foreground-500) / 0.65)', }, - ".cm-gutterElement": { - paddingLeft: "12px", - paddingRight: "12px", + '.cm-gutterElement': { + paddingLeft: '12px', + paddingRight: '12px', }, - ".cm-activeLineGutter": { + '.cm-activeLineGutter': { backgroundColor: 'transparent !important', color: isDark ? 'hsl(var(--heroui-foreground) / 0.9) !important' : 'hsl(var(--heroui-foreground) / 0.8) !important', }, - ".cm-content": { + '.cm-content': { color: 'hsl(var(--heroui-foreground) / 0.9)', caretColor: 'hsl(var(--heroui-foreground) / 0.9)', - paddingTop: "12px", - paddingBottom: "12px", + paddingTop: '12px', + paddingBottom: '12px', backgroundColor: 'transparent !important', }, - ".cm-activeLine": { + '.cm-activeLine': { backgroundColor: isDark ? 'hsl(var(--heroui-foreground) / 0.08)' : 'hsl(var(--heroui-foreground) / 0.06)', }, - ".cm-selectionMatch": { + '.cm-selectionMatch': { backgroundColor: isDark ? 'hsl(var(--heroui-foreground) / 0.16)' : 'hsl(var(--heroui-foreground) / 0.12)', }, // Syntax highlighting overrides for better readability - ".ͼo": { + '.ͼo': { // JSON property names - use a softer primary color color: isDark ? 'hsl(var(--heroui-primary) / 0.85)' : 'hsl(var(--heroui-primary) / 0.75)', }, - ".ͼd": { + '.ͼd': { // Strings - softer green color: isDark ? '#98c379cc' : '#50a14fcc', }, - ".ͼc": { + '.ͼc': { // Numbers - softer orange color: isDark ? '#d19a66cc' : '#c18401cc', }, @@ -137,8 +137,8 @@ const CodeEditor = React.forwardRef((props, ref) { - const hay = `${c.id} ${c.title} ${c.subtitle ?? ''} ${c.group ?? ''}`.toLowerCase(); - return hay.includes(q); - }); + const hay = `${c.id} ${c.title} ${c.subtitle ?? ''} ${c.group ?? ''}`.toLowerCase(); + return hay.includes(q); + }); // 简单:优先 path 前缀命中 if (!q) return list; @@ -125,7 +125,8 @@ export default function CommandPalette (props: CommandPaletteProps) { + )} + > 命令面板 Ctrl/Cmd + K @@ -149,11 +150,13 @@ export default function CommandPalette (props: CommandPaletteProps) {
+ )} + >
+ )} + > {filtered.length === 0 && (
没有匹配的接口
)} diff --git a/packages/napcat-webui-frontend/src/components/display_network_item.tsx b/packages/napcat-webui-frontend/src/components/display_network_item.tsx index eb7a3e94..2e292359 100644 --- a/packages/napcat-webui-frontend/src/components/display_network_item.tsx +++ b/packages/napcat-webui-frontend/src/components/display_network_item.tsx @@ -3,8 +3,6 @@ import { useLocalStorage } from '@uidotdev/usehooks'; import clsx from 'clsx'; import key from '@/const/key'; - - export interface NetworkItemDisplayProps { count: number; label: string; diff --git a/packages/napcat-webui-frontend/src/components/file_manage/file_edit_modal.tsx b/packages/napcat-webui-frontend/src/components/file_manage/file_edit_modal.tsx index fc689834..0bca7cd3 100644 --- a/packages/napcat-webui-frontend/src/components/file_manage/file_edit_modal.tsx +++ b/packages/napcat-webui-frontend/src/components/file_manage/file_edit_modal.tsx @@ -63,22 +63,24 @@ export default function FileEditModal ({ }; return ( - - + + 编辑文件 {file?.path} -
- 按 Ctrl/Cmd + S 保存 +
+ 按 Ctrl/Cmd + S 保存
-
{ - if ((e.ctrlKey || e.metaKey) && e.key === 's') { - e.preventDefault(); - onSave(); - } - }}> +
{ + if ((e.ctrlKey || e.metaKey) && e.key === 's') { + e.preventDefault(); + onSave(); + } + }} + >
- + diff --git a/packages/napcat-webui-frontend/src/components/log_com/history.tsx b/packages/napcat-webui-frontend/src/components/log_com/history.tsx index f0ff6549..8734fb31 100644 --- a/packages/napcat-webui-frontend/src/components/log_com/history.tsx +++ b/packages/napcat-webui-frontend/src/components/log_com/history.tsx @@ -91,7 +91,8 @@ const HistoryLogs: React.FC = (props) => { + )} + > setHttpConfig({ ...httpConfig, url: e.target.value })} size='sm' variant='bordered' /> - setHttpConfig({ ...httpConfig, token: e.target.value })} size='sm' variant='bordered' /> + setHttpConfig({ ...httpConfig, url: e.target.value })} size='sm' variant='bordered' /> + setHttpConfig({ ...httpConfig, token: e.target.value })} size='sm' variant='bordered' />
@@ -296,7 +298,7 @@ const OneBotApiDebug = forwardRef((props size='sm' className='font-bold shadow-sm px-4' isLoading={isFetching} - startContent={!isFetching && } + startContent={!isFetching && } > 发送 @@ -310,43 +312,46 @@ const OneBotApiDebug = forwardRef((props
+ )} + > - - + +
{(onOpen) => ( - + )} - - @@ -355,38 +360,40 @@ const OneBotApiDebug = forwardRef((props {/* Content Area */}
- {activeTab === 'request' ? ( -
- setRequestBody(value ?? '')} - language='json' - options={{ - minimap: { enabled: false }, - fontSize: 13, - fontFamily: 'JetBrains Mono, monospace', - scrollBeyondLastLine: false, - wordWrap: 'on', - padding: { top: 16, bottom: 16 }, - lineNumbersMinChars: 3, - chromeless: true, - backgroundColor: 'transparent' - }} - /> -
- ) : ( -
-
-

Request Params

- -
-
-
-

Response Data

- -
-
- )} + {activeTab === 'request' + ? ( +
+ setRequestBody(value ?? '')} + language='json' + options={{ + minimap: { enabled: false }, + fontSize: 13, + fontFamily: 'JetBrains Mono, monospace', + scrollBeyondLastLine: false, + wordWrap: 'on', + padding: { top: 16, bottom: 16 }, + lineNumbersMinChars: 3, + chromeless: true, + backgroundColor: 'transparent', + }} + /> +
+ ) + : ( +
+
+

Request Params

+ +
+
+
+

Response Data

+ +
+
+ )}
@@ -407,7 +414,7 @@ const OneBotApiDebug = forwardRef((props {/* Invisible Draggable Area */} {responseExpanded && (
{ e.stopPropagation(); handleMouseDown(e); }} onTouchStart={(e) => { e.stopPropagation(); handleTouchStart(e); }} onClick={(e) => e.stopPropagation()} @@ -416,14 +423,16 @@ const OneBotApiDebug = forwardRef((props
- +
Response + )} + >Response + {responseStatus && ( - = 200 && responseStatus.code < 300 ? 'success' : 'danger'} className="h-5 text-[10px] font-mono border-none bg-transparent pl-0"> + = 200 && responseStatus.code < 300 ? 'success' : 'danger'} className='h-5 text-[10px] font-mono border-none bg-transparent pl-0'> {responseStatus.code} {responseStatus.text} )} @@ -436,9 +445,9 @@ const OneBotApiDebug = forwardRef((props {/* Response Editor */} {responseExpanded && ( -
+
-
+
((props padding: { top: 12, bottom: 12 }, renderLineHighlight: 'none', chromeless: true, - backgroundColor: 'transparent' + backgroundColor: 'transparent', }} />
diff --git a/packages/napcat-webui-frontend/src/components/onebot/send_modal.tsx b/packages/napcat-webui-frontend/src/components/onebot/send_modal.tsx index 446a4cf3..be9b0eb2 100644 --- a/packages/napcat-webui-frontend/src/components/onebot/send_modal.tsx +++ b/packages/napcat-webui-frontend/src/components/onebot/send_modal.tsx @@ -43,7 +43,7 @@ const OneBotSendModal: React.FC = (props) => { return ( <> - { return (
diff --git a/packages/napcat-webui-frontend/src/components/password_login.tsx b/packages/napcat-webui-frontend/src/components/password_login.tsx index 0f46f6ea..90ab3c63 100644 --- a/packages/napcat-webui-frontend/src/components/password_login.tsx +++ b/packages/napcat-webui-frontend/src/components/password_login.tsx @@ -41,28 +41,28 @@ const PasswordLogin: React.FC = ({ onSubmit, isLoading, qqLi radius='full' src={`https://q1.qlogo.cn/g?b=qq&nk=${uin || '0'}&s=100`} width={100} - alt="QQ Avatar" + alt='QQ Avatar' />
- setUin(key.toString())} > @@ -92,14 +92,14 @@ const PasswordLogin: React.FC = ({ onSubmit, isLoading, qqLi } />
diff --git a/packages/napcat-webui-frontend/src/components/sidebar/index.tsx b/packages/napcat-webui-frontend/src/components/sidebar/index.tsx index be9719fd..be7ae82f 100644 --- a/packages/napcat-webui-frontend/src/components/sidebar/index.tsx +++ b/packages/napcat-webui-frontend/src/components/sidebar/index.tsx @@ -69,11 +69,12 @@ const SideBar: React.FC = (props) => { >
-
+
+ )} + > NapCat
diff --git a/packages/napcat-webui-frontend/src/components/sidebar/menus.tsx b/packages/napcat-webui-frontend/src/components/sidebar/menus.tsx index 5f7b2192..76464bc3 100644 --- a/packages/napcat-webui-frontend/src/components/sidebar/menus.tsx +++ b/packages/napcat-webui-frontend/src/components/sidebar/menus.tsx @@ -102,7 +102,7 @@ const renderItems = (items: MenuItem[], children = false) => { ? 'bg-primary-500 animate-nav-spin' : 'bg-primary-200 dark:bg-white shadow-lg' )} - aria-hidden="true" + aria-hidden='true' /> ) } diff --git a/packages/napcat-webui-frontend/src/components/system_info.tsx b/packages/napcat-webui-frontend/src/components/system_info.tsx index ea79b3b6..e93a733a 100644 --- a/packages/napcat-webui-frontend/src/components/system_info.tsx +++ b/packages/napcat-webui-frontend/src/components/system_info.tsx @@ -26,7 +26,6 @@ import Modal from '@/components/modal'; import MirrorSelectorModal from '@/components/mirror_selector_modal'; import { hasNewVersion, compareVersion } from '@/utils/version'; - export interface SystemInfoItemProps { title: string; icon?: React.ReactNode; @@ -57,13 +56,15 @@ const SystemInfoItem: React.FC = ({ )} onClick={onClick} > -
{icon}
+
{icon}
{title}
{value}
-
{endContent}
+ )} + >{value} +
+
{endContent}
); }; @@ -85,28 +86,28 @@ const UpdateDialogContent: React.FC<{ return (
{/* 版本对比 */} -
-
- 当前版本 +
+
+ 当前版本 - + v{currentVersion}
-
-
- - +
+
+ +
-
- 最新版本 +
+ 最新版本 - + v{latestVersion} @@ -257,17 +258,17 @@ const NewVersionTip = (props: NewVersionTipProps) => { return ( -
+
- {updateStatus === 'updating' ? : 'New'} + {updateStatus === 'updating' ? : 'New'}
@@ -324,7 +325,8 @@ const VersionSelectDialogContent: React.FC = ({ } else { setMirrorLatency(null); } - } catch (e) { + } catch (error) { + console.log(error); setMirrorLatency(null); } finally { setMirrorTesting(false); @@ -362,7 +364,7 @@ const VersionSelectDialogContent: React.FC = ({ pageSize, type: activeTab, search: debouncedSearch, - mirror: selectedMirror + mirror: selectedMirror, }), { refreshDeps: [currentPage, activeTab, debouncedSearch, selectedMirror], @@ -517,7 +519,7 @@ const VersionSelectDialogContent: React.FC = ({
{releasesData?.mirror && (
- + 镜像: {releasesData.mirror}
)} @@ -544,50 +546,50 @@ const VersionSelectDialogContent: React.FC = ({ {/* 下载镜像状态卡片 */} - - -
-
- 镜像源: - {getMirrorDisplayName()} + + +
+
+ 镜像源: + {getMirrorDisplayName()} {mirrorLatency !== null && ( } > {formatLatency(mirrorLatency)} )} {mirrorLatency === null && !mirrorTesting && ( - + 未测试 )} {mirrorTesting && ( - + 测速中... )}
-
- +
+ - +
- {releasesLoading ? ( -
- - 加载版本列表... -
- ) : releasesError ? ( -
- 加载版本列表失败: {releasesError.message} -
- ) : filteredVersions.length === 0 ? ( -
- {searchQuery ? `未找到匹配 "${searchQuery}" 的版本` : '暂无可用版本'} -
- ) : ( - { + const selectedTag = Array.from(keys)[0] as string; + const version = filteredVersions.find(v => v.tag === selectedTag); + setSelectedVersion(version || null); + }} + classNames={{ + trigger: 'h-auto min-h-10', + }} > -
-
- - {version.type === 'action' - ? (version.workflowTitle || version.artifactName || version.tag) - : version.tag - } - - {version.type === 'prerelease' && ( - 预发布 - )} - {version.type === 'action' && ( - 临时 - )} - {isCurrent && ( - 当前 - )} - {downgrade && !isCurrent && version.type !== 'action' && ( - 降级 - )} -
- {version.type === 'action' && ( -
- {version.tag} - {version.headSha && {version.headSha.slice(0, 7)}} - {version.createdAt && {new Date(version.createdAt).toLocaleString()}} - {version.size && {(version.size / 1024 / 1024).toFixed(1)} MB} -
- )} -
- - ); - })} - - )} + {filteredVersions.map((version) => { + const isCurrent = version.tag.replace(/^v/, '') === currentVersion; + const downgrade = isDowngrade(version.tag); + return ( + +
+
+ + {version.type === 'action' + ? (version.workflowTitle || version.artifactName || version.tag) + : version.tag} + + {version.type === 'prerelease' && ( + 预发布 + )} + {version.type === 'action' && ( + 临时 + )} + {isCurrent && ( + 当前 + )} + {downgrade && !isCurrent && version.type !== 'action' && ( + 降级 + )} +
+ {version.type === 'action' && ( +
+ {version.tag} + {version.headSha && {version.headSha.slice(0, 7)}} + {version.createdAt && {new Date(version.createdAt).toLocaleString()}} + {version.size && {(version.size / 1024 / 1024).toFixed(1)} MB} +
+ )} +
+
+ ); + })} + + )}
{/* Action 版本提示 */} @@ -786,7 +793,7 @@ const VersionSelectDialogContent: React.FC = ({ setSelectedMirror(mirror || undefined); setMirrorLatency(null); }} - type="file" + type='file' />
); @@ -848,7 +855,7 @@ const NapCatVersion: React.FC = ({ hasBackground = false }) setIsVersionModalOpen(false)} content={ = (props) => { + )} + > + )} + > 系统信息 diff --git a/packages/napcat-webui-frontend/src/components/system_status_display.tsx b/packages/napcat-webui-frontend/src/components/system_status_display.tsx index dfbcb142..b24e2165 100644 --- a/packages/napcat-webui-frontend/src/components/system_status_display.tsx +++ b/packages/napcat-webui-frontend/src/components/system_status_display.tsx @@ -29,19 +29,22 @@ const SystemStatusItem: React.FC = ({
{title}
+ )} + >{title} +
+ )} + > {value} - {unit && {unit}} + {unit && {unit}}
); @@ -70,7 +73,8 @@ const SystemStatusDisplay: React.FC = ({ data }) => { + )} + >
= ({ data }) => {

+ )} + > CPU

@@ -111,7 +116,8 @@ const SystemStatusDisplay: React.FC = ({ data }) => {

+ )} + > 内存

diff --git a/packages/napcat-webui-frontend/src/components/xterm.tsx b/packages/napcat-webui-frontend/src/components/xterm.tsx index c9d56663..21c1f1b7 100644 --- a/packages/napcat-webui-frontend/src/components/xterm.tsx +++ b/packages/napcat-webui-frontend/src/components/xterm.tsx @@ -55,7 +55,7 @@ const XTerm = forwardRef((props, ref) => { 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "JetBrains Mono", monospace', cursorInactiveStyle: 'outline', drawBoldTextInBrightColors: false, - fontSize: fontSize, + fontSize, lineHeight: 1.2, }); terminalRef.current = terminal; diff --git a/packages/napcat-webui-frontend/src/const/ob_api/index.ts b/packages/napcat-webui-frontend/src/const/ob_api/index.ts index 8cf0c2b9..06e5dfd4 100644 --- a/packages/napcat-webui-frontend/src/const/ob_api/index.ts +++ b/packages/napcat-webui-frontend/src/const/ob_api/index.ts @@ -16,8 +16,8 @@ export async function fetchOneBotHttpApi (): Promise { try { const response = await fetch('/api/Debug/schemas', { headers: { - 'Authorization': `Bearer ${localStorage.getItem('token')}` - } + Authorization: `Bearer ${localStorage.getItem('token')}`, + }, }); const data = await response.json(); if (data.code === 0) { @@ -37,4 +37,3 @@ export function getOneBotHttpApi () { export type OneBotHttpApiPath = string; export default oneBotHttpApi; - diff --git a/packages/napcat-webui-frontend/src/controllers/plugin_manager.ts b/packages/napcat-webui-frontend/src/controllers/plugin_manager.ts index cb015d54..de8115ee 100644 --- a/packages/napcat-webui-frontend/src/controllers/plugin_manager.ts +++ b/packages/napcat-webui-frontend/src/controllers/plugin_manager.ts @@ -182,7 +182,7 @@ export default class PluginManager { */ public static async getPluginConfig (id: string): Promise { const { data } = await serverRequest.get>('/Plugin/Config', { - params: { id } + params: { id }, }); return data.data; } @@ -216,7 +216,7 @@ export default class PluginManager { sessionId, key, value, - currentConfig + currentConfig, }); } diff --git a/packages/napcat-webui-frontend/src/pages/dashboard/about.tsx b/packages/napcat-webui-frontend/src/pages/dashboard/about.tsx index 9e184333..001a1ea5 100644 --- a/packages/napcat-webui-frontend/src/pages/dashboard/about.tsx +++ b/packages/napcat-webui-frontend/src/pages/dashboard/about.tsx @@ -12,7 +12,7 @@ import { BsGlobe, BsPlugin, BsTelegram, - BsTencentQq + BsTencentQq, } from 'react-icons/bs'; import { IoDocument, IoRocketSharp } from 'react-icons/io5'; @@ -24,16 +24,20 @@ function VersionInfo () { return (
- {error ? ( - {error.message} - ) : loading ? ( - - ) : ( -
- WebUI v0.0.6 - Core {data?.version} -
- )} + {error + ? ( + {error.message} + ) + : loading + ? ( + + ) + : ( +
+ WebUI v0.0.6 + Core {data?.version} +
+ )}
); } @@ -44,26 +48,26 @@ export default function AboutPage () { icon: , title: '高性能架构', desc: 'Node.js + Native 混合架构,资源占用低,响应速度快。', - className: 'bg-primary-50 text-primary' + className: 'bg-primary-50 text-primary', }, { icon: , title: '全平台支持', desc: '适配 Windows、Linux 及 Docker 环境。', - className: 'bg-success-50 text-success' + className: 'bg-success-50 text-success', }, { icon: , title: 'OneBot 11', desc: '深度集成标准协议,兼容现有生态。', - className: 'bg-warning-50 text-warning' + className: 'bg-warning-50 text-warning', }, { icon: , title: '极易扩展', desc: '提供丰富的 API 接口与 WebHook 支持。', - className: 'bg-secondary-50 text-secondary' - } + className: 'bg-secondary-50 text-secondary', + }, ]; const links = [ @@ -74,37 +78,37 @@ export default function AboutPage () { { icon: , name: '文档', href: 'https://napcat.napneko.icu/' }, ]; - const cardStyle = "bg-default/40 backdrop-blur-lg border-none shadow-none"; + const cardStyle = 'bg-default/40 backdrop-blur-lg border-none shadow-none'; return (
关于 - NapCat WebUI {/* 头部标题区 */} -
-

- NapCat Logo +
+

+ NapCat Logo 关于 NapCat

-
+

现代化、轻量级的 QQ 机器人框架

- +
- + {/* 主内容区:双栏布局 */} -
+
{/* 左侧:介绍与特性 */} -
- - -

项目简介

+
+ + +

项目简介

- +

NapCat (瞌睡猫) 是一个致力于打破 QQ 机器人开发壁垒的开源项目。我们利用 NTQQ 的底层能力, 构建了一个无需 GUI 即可在服务器端稳定运行的 Headless 框架。 @@ -116,16 +120,16 @@ export default function AboutPage () { -

+
{features.map((item, index) => ( - - + +
{item.icon}
-

{item.title}

-

{item.desc}

+

{item.title}

+

{item.desc}

@@ -134,41 +138,41 @@ export default function AboutPage () {
{/* 右侧:信息与链接 */} -
- - -

相关资源

+
+ + +

相关资源

- -
+ +
{links.map((link, idx) => ( - + {link.icon} {link.name} - 跳转 → + 跳转 → ))}
- - -

+ + +

技术栈

- -
+ +
{['TypeScript', 'React', 'Vite', 'Node.js', 'Electron', 'HeroUI'].map((tech) => ( - + {tech} ))} @@ -179,12 +183,12 @@ export default function AboutPage () {
{/* 底部版权 - 移出 grid 布局 */} -
-

- Made with ❤️ by NapCat Team +

+

+ Made with ❤️ by NapCat Team

MIT License © {new Date().getFullYear()}

); -} \ No newline at end of file +} diff --git a/packages/napcat-webui-frontend/src/pages/dashboard/config/backup.tsx b/packages/napcat-webui-frontend/src/pages/dashboard/config/backup.tsx index 50cd417f..f2129b4c 100644 --- a/packages/napcat-webui-frontend/src/pages/dashboard/config/backup.tsx +++ b/packages/napcat-webui-frontend/src/pages/dashboard/config/backup.tsx @@ -35,7 +35,6 @@ const handleImportConfig = async (event: React.ChangeEvent) => } else { toast.error(`配置导入失败: ${result.data?.message || '未知错误'}`); } - } catch (error) { const msg = (error as Error).message; toast.error(`导入配置失败: ${msg}`); @@ -88,26 +87,26 @@ const BackupConfigCard: React.FC = () => {
-