diff --git a/.github/scripts/lib/comment.ts b/.github/scripts/lib/comment.ts index 15065267e..3bec634b7 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 5d51e5aed..6411fa966 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 94d898df9..d9f2af04d 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 783887df3..0c4376fcd 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 f6d4b59c5..56df70361 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 8f2978a65..28afc6d51 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 a7acd3bc7..2526b3797 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 4a89c61be..7a0207adb 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 c14b8d8f1..6825fca44 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 83e5e31d8..4636ecfc9 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 a4736d0eb..960421611 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 fdfe43655..5ea057393 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 6857df8dd..09fbe3961 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 920dab36f..7e7f01ab1 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 3dc63be23..a9e851517 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 cb40e83f2..0f219495b 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.filter(item => item.actionMsg).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 5ae5f80a6..92a1e6dcc 100644 --- a/packages/napcat-core/packet/message/element.ts +++ b/packages/napcat-core/packet/message/element.ts @@ -511,14 +511,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 f7ad161fd..e2ef83955 100644 --- a/packages/napcat-core/packet/transformer/message/UploadForwardMsgV2.ts +++ b/packages/napcat-core/packet/transformer/message/UploadForwardMsgV2.ts @@ -15,7 +15,7 @@ class UploadForwardMsgV2 extends PacketTransformer actionCommand: item.actionCommand, actionData: { msgBody: item.actionMsgBody ?? 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 d471b3167..2fa1cc18e 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/NodeIKernelGroupService.ts b/packages/napcat-core/services/NodeIKernelGroupService.ts index ac68c23e4..c7c65fd6e 100644 --- a/packages/napcat-core/services/NodeIKernelGroupService.ts +++ b/packages/napcat-core/services/NodeIKernelGroupService.ts @@ -32,7 +32,7 @@ export interface NodeIKernelGroupService { getAllGroupPrivilegeFlag (troopUinList: string[], serviceType: number): Promise; // <--- getGroupExt0xEF0Info (enableGroupCodes: string[], bannedGroupCodes: string[], filter: GroupExt0xEF0InfoFilter, forceFetch: boolean): - Promise; }; }>; + Promise; }; }>; kickMemberV2 (param: KickMemberV2Req): Promise; diff --git a/packages/napcat-core/services/NodeIKernelMsgService.ts b/packages/napcat-core/services/NodeIKernelMsgService.ts index 899a336c4..adfece679 100644 --- a/packages/napcat-core/services/NodeIKernelMsgService.ts +++ b/packages/napcat-core/services/NodeIKernelMsgService.ts @@ -688,14 +688,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 (arg: unknown): unknown; diff --git a/packages/napcat-core/services/NodeIKernelStorageCleanService.ts b/packages/napcat-core/services/NodeIKernelStorageCleanService.ts index ff3911200..8ba81ce73 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-database/src/reader.ts b/packages/napcat-database/src/reader.ts index c55a19003..feacd04c2 100644 --- a/packages/napcat-database/src/reader.ts +++ b/packages/napcat-database/src/reader.ts @@ -10,7 +10,6 @@ type SQLInputValue = import('node:sqlite').SQLInputValue; let _DatabaseSync: DatabaseSyncCtor | null = null; let _sqliteChecked = false; - async function loadSqlite (): Promise { if (_sqliteChecked) return _DatabaseSync; _sqliteChecked = true; @@ -299,7 +298,6 @@ export function listTablesFromFile (filePath: string): TableInfo[] { } } - export function listTablesFromBuffer (data: Buffer): TableInfo[] { const tmpPath = path.join(os.tmpdir(), `napcat_db_${Date.now()}_${Math.random().toString(36).slice(2)}.db`); try { diff --git a/packages/napcat-develop/loadNapCat.cjs b/packages/napcat-develop/loadNapCat.cjs index df5c16867..4380dcc89 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-framework/napcat.ts b/packages/napcat-framework/napcat.ts index 853c3fde6..3f5e0b547 100644 --- a/packages/napcat-framework/napcat.ts +++ b/packages/napcat-framework/napcat.ts @@ -46,7 +46,7 @@ export async function NCoreInitFramework ( const nativePacketHandler = new NativePacketHandler({ logger }); // 初始化 NativePacketHandler 用于后续使用 const napi2nativeLoader = new Napi2NativeLoader({ logger }); // 初始化 Napi2NativeLoader 用于后续使用 const napcatConfig = loadNapcatConfig(pathWrapper.configPath); - //console.log('[NapCat] [Napi2NativeLoader]', napi2nativeLoader.nativeExports.enableAllBypasses?.()); + // console.log('[NapCat] [Napi2NativeLoader]', napi2nativeLoader.nativeExports.enableAllBypasses?.()); if (process.env['NAPCAT_DISABLE_BYPASS'] !== '1') { const bypassOptions = napcatConfig.bypass ?? {}; const bypassEnabled = napi2nativeLoader.nativeExports.enableAllBypasses?.(bypassOptions); @@ -60,7 +60,7 @@ export async function NCoreInitFramework ( // nativePacketHandler.onAll((packet) => { // console.log('[Packet]', packet.uin, packet.cmd, packet.hex_data); // }); - await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion(), napcatConfig.o3HookMode === 1 ? true : false); + await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion(), napcatConfig.o3HookMode === 1); // 在 init 之后注册监听器 // 登录前监听 OidbSvcTrpcTcp.0xcde_2 数据包,获取数据库 passphrase diff --git a/packages/napcat-image-size/src/index.ts b/packages/napcat-image-size/src/index.ts index 8527dd054..e16f615d4 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 042c899b6..f4bdb40e5 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 68f69457a..75b6d0ed3 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 0b72b34bb..b59fe094f 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 7da559c9d..f25123b0d 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 bc5fd5958..cd52331bb 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 54d73e203..e7aaf755c 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 f619a3033..a478150f9 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 3d5d2d72f..062e9c81e 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 c63acc915..920086c88 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 e373bd48c..d50d9431b 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 ecea6ce6f..5ad4bdd75 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 cc9dce06c..a65a71b1e 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 647f45adf..2ea9c036b 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 1578dae22..1583fbed4 100644 --- a/packages/napcat-onebot/action/extends/GetQunAlbumList.ts +++ b/packages/napcat-onebot/action/extends/GetQunAlbumList.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'; - const PayloadSchema = Type.Object({ group_id: Type.String({ description: '群号' }), attach_info: Type.String({ default: '', description: '附加信息(用于分页,从上一次返回结果中获取)' }), @@ -26,18 +25,20 @@ 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 d4395d152..f57ae19b3 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 b958a7b1d..91062efd5 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 658607626..1ac7fcf54 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 1f211c133..fc9c36e16 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 fddd5ba24..deb1ff32c 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 b0d56d9dd..b79224dff 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 89a49f27e..9d6d08496 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 1d0dddaf7..ae143508a 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 31ed0df5a..b30f0347d 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 486acd5bb..9557a1a4d 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 f79a98a01..f760878c9 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 6c770e775..0135ea9c3 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 ebd8a7223..10cb5bd66 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 2ec8542c0..b00661b7d 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 9e657bddc..3f56f11c8 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 7598bb69f..ba4ac86b6 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 359343c75..1d82e31b7 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 4ab31d8dd..6376228b8 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 d3bf26b17..64238c51c 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 8c0ba3365..434c3bdd5 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 6a3d0a796..2ecc989fc 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 a02060b50..ee54675c4 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 bc09d4487..4141d4d24 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 abbe57bd8..59de606f3 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 a0ea8e612..639c6b7b7 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 1c719dc7d..9772055ae 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 8667e69f9..42ad9f74f 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 c641bb695..6ccea3b91 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 d1243c37d..28b5bc759 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 d809c4179..2f92d0e62 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/MarkMsgAsRead.ts b/packages/napcat-onebot/action/msg/MarkMsgAsRead.ts index 6b565755a..98f99b9d9 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 60694ad5a..ee20652fa 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[], actionMsgBody?: UploadForwardMsgParams['actionMsgBody']; }> = new Array(); + const innerMsg: Array<{ uuid: string, packetMsg?: PacketMsg[], actionMsgBody?: UploadForwardMsgParams['actionMsgBody']; }> = []; 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(m); }); } - } else { const sendElementsCreateReturn = await this.obContext.apis.MsgApi.createSendElements(OB11Data, msgPeer); sendElements = sendElementsCreateReturn.sendElements; @@ -340,8 +339,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 0800985e4..6dfea5122 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 745bcff0c..8cc0ddbb0 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 cb77b40bf..ef1bc1d0a 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 527fcb72a..9882a7eaa 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 5885fcb89..6a5afc6f3 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 a3ac7f86c..4b788dbc1 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 b01e2a993..f0959c926 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 5b35fbe18..547ec27fb 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 4d7a622d4..dd70172a8 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 44c92c6d4..c2f15e9e9 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 87bd41949..4f2badca7 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 66b0863c0..869bc919e 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 e9f01d420..03c26d23b 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 26442305c..3536b4121 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 a959cc614..bc2249430 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 424a86968..ec24ec775 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); /** * 插件加载器 @@ -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 900b299dc..17621adcd 100644 --- a/packages/napcat-onebot/network/plugin/types.ts +++ b/packages/napcat-onebot/network/plugin/types.ts @@ -145,7 +145,7 @@ export interface MemoryStaticFile { export interface PluginRouterRegistry { // ==================== API 路由注册(需要认证) ==================== - /** + /** * 注册单个 API 路由(需要认证,挂载到 /api/Plugin/ext/{pluginId}/) * @param method HTTP 方法 * @param path 路由路径 @@ -285,7 +285,7 @@ export interface NapCatPluginContext { pluginManager: IPluginManager; /** 插件日志器 - 自动添加插件名称前缀 */ logger: PluginLogger; - /** + /** * WebUI 路由注册器 * 用于注册插件的 HTTP API 路由,路由将挂载到 /api/Plugin/ext/{pluginId}/ * 静态资源将挂载到 /plugin/{pluginId}/files/{urlPath}/ @@ -318,7 +318,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 b94315a58..8a0205c29 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'); } } diff --git a/packages/napcat-protocol/action/index.ts b/packages/napcat-protocol/action/index.ts index bd87c17c4..b28295479 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/config/index.ts b/packages/napcat-protocol/config/index.ts index 646834f3b..932cbbf5c 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 1d46fb81b..481fa0061 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-schema/index.ts b/packages/napcat-schema/index.ts index c9eb7e20c..eb98095cf 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 4719ddf34..c18cf5588 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}`), 'node:sqlite'].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/base.ts b/packages/napcat-shell/base.ts index 4f8ca9485..10a4c6895 100644 --- a/packages/napcat-shell/base.ts +++ b/packages/napcat-shell/base.ts @@ -601,7 +601,7 @@ export async function NCoreInitShell () { const wrapper = loadQQWrapper(basicInfoWrapper.QQMainPath, basicInfoWrapper.getFullQQVersion()); // wrapper.node 加载后再初始化 hook,按 schema 读取配置 const napcatConfig = loadNapcatConfig(pathWrapper.configPath); - await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion(), napcatConfig.o3HookMode === 1 ? true : false); + await nativePacketHandler.init(basicInfoWrapper.getFullQQVersion(), napcatConfig.o3HookMode === 1); // 登录前监听 OidbSvcTrpcTcp.0xcde_2 数据包,获取数据库 passphrase let dbPassphrase: string | undefined; diff --git a/packages/napcat-shell/napcat.ts b/packages/napcat-shell/napcat.ts index 945ef3142..abcb5b076 100644 --- a/packages/napcat-shell/napcat.ts +++ b/packages/napcat-shell/napcat.ts @@ -42,7 +42,6 @@ const ENV = { isPipeDisabled: process.env['NAPCAT_DISABLE_PIPE'] === '1', } as const; - // Worker 消息类型 interface WorkerMessage { type: 'restart' | 'restart-prepare' | 'shutdown' | 'login-success'; @@ -50,7 +49,6 @@ interface WorkerMessage { port?: number; } - const logger = new LogWrapper(pathWrapper.logsPath); if (!ENV.isWorkerProcess && !ENV.isMultiProcessDisabled) { logger.setFileLogEnabled(false); @@ -68,7 +66,6 @@ const recentCrashTimestamps: number[] = []; const CRASH_TIME_WINDOW = 10000; // 10秒时间窗口 const MAX_CRASHES_IN_WINDOW = 3; // 最大崩溃次数 - /** * 获取进程类型名称(用于日志) */ @@ -112,7 +109,7 @@ function forceKillProcess (pid: number): void { logger.logError(`[NapCat] [Process] 强制终止进程失败: PID ${pid}`); } } else { - logger.logError(`[NapCat] [Process] 强制终止进程失败:`, error); + logger.logError('[NapCat] [Process] 强制终止进程失败:', error); } } } @@ -414,7 +411,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 4686d584b..33e47b9bb 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}`), 'node:sqlite'].flat(); diff --git a/packages/napcat-test/rpc.test.ts b/packages/napcat-test/rpc.test.ts index 6f9c0d7a6..cb00d6657 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; } @@ -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/scripts/copy-dist.mjs b/packages/napcat-types/scripts/copy-dist.mjs index 4cf851671..0f7be1ad2 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 47ce34d4d..7186cde93 100644 --- a/packages/napcat-types/scripts/post-build.mjs +++ b/packages/napcat-types/scripts/post-build.mjs @@ -20,24 +20,24 @@ 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', // napcat-protobuf - 'NapProtoDecodeStructType': 'any', - 'NapProtoEncodeStructType': 'any', + NapProtoDecodeStructType: 'any', + NapProtoEncodeStructType: 'any', 'NapProtoDecodeStructType': 'any', 'NapProtoEncodeStructType': 'any', }; @@ -141,7 +141,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 292ecf095..9d6daaa96 100644 --- a/packages/napcat-types/test-dist.ts +++ b/packages/napcat-types/test-dist.ts @@ -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 4136500fa..4c21f1734 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 ddff5d8c7..01d83af1d 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,6 @@ 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 075adb186..d82d43c08 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 0869b6a89..a4bc09d3e 100644 --- a/packages/napcat-webui-backend/src/api/BaseInfo.ts +++ b/packages/napcat-webui-backend/src/api/BaseInfo.ts @@ -154,7 +154,7 @@ export const getAllReleasesHandler: RequestHandler = async (req, res) => { total, totalPages, }, - mirror: usedMirror + mirror: usedMirror, }); } 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 a5d1b1d88..d413c3387 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 4480fff00..f8f74a4d9 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 6904624cf..fd64287e0 100644 --- a/packages/napcat-webui-backend/src/api/Plugin.ts +++ b/packages/napcat-webui-backend/src/api/Plugin.ts @@ -121,7 +121,7 @@ export const GetPluginListHandler: RequestHandler = async (_req, res) => { homepage?: string; repository?: string; icon?: string; - }> = new Array(); + }> = []; // 收集所有插件的扩展页面 const extensionPages: Array<{ @@ -175,13 +175,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 }); }; @@ -342,7 +341,7 @@ export const PluginConfigSSEHandler: RequestHandler = (req, res): void => { hideField: (key: string) => { sendSSE('schema', { type: 'hideField', key }); }, - getCurrentConfig: () => currentConfig + getCurrentConfig: () => currentConfig, }; // 存储会话 @@ -423,30 +422,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 { @@ -460,7 +459,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/QQLogin.ts b/packages/napcat-webui-backend/src/api/QQLogin.ts index 92ff9addd..63cd38ade 100644 --- a/packages/napcat-webui-backend/src/api/QQLogin.ts +++ b/packages/napcat-webui-backend/src/api/QQLogin.ts @@ -20,7 +20,7 @@ function oidbRequest (uid: string, body: Record): Promise { let data = ''; @@ -554,5 +554,3 @@ export const QQPollNewDeviceQRHandler: RequestHandler = async (req, res) => { return sendError(res, `Failed to poll QR status: ${(e as Error).message}`); } }; - - diff --git a/packages/napcat-webui-backend/src/api/UpdateNapCat.ts b/packages/napcat-webui-backend/src/api/UpdateNapCat.ts index 274d4fc5e..356e285b8 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']); @@ -171,7 +171,7 @@ export const UpdateNapCatHandler: RequestHandler = async (req, res) => { webUiLogger?.log(`[NapCat Update] Using download URL: ${downloadUrl}`); } catch (error) { // 如果镜像都不可用,直接使用原始 URL - webUiLogger?.logWarn(`[NapCat Update] All nightly.link mirrors failed, using original URL`); + webUiLogger?.logWarn('[NapCat Update] All nightly.link mirrors failed, using original URL'); downloadUrl = baseUrl; } } else { @@ -289,7 +289,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 +300,7 @@ export const UpdateNapCatHandler: RequestHandler = async (req, res) => { version: actualVersion, updateTime: new Date().toISOString(), files: failedFiles, - changelog: '' + changelog: '', }; // 保存更新配置文件 @@ -317,14 +317,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 +338,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 +371,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 +382,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 862b43f36..247cff765 100644 --- a/packages/napcat-webui-backend/src/assets/sw_template.js +++ b/packages/napcat-webui-backend/src/assets/sw_template.js @@ -1,26 +1,26 @@ /** * 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/* 插件内存静态资源 */ @@ -216,11 +216,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 f1e9bb39a..03ffa66bb 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/router/Mirror.ts b/packages/napcat-webui-backend/src/router/Mirror.ts index d1bee4cb8..9903a2f16 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 d4dab3f91..ea06779c6 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 b40097369..3c1b6cac9 100644 --- a/packages/napcat-webui-backend/src/router/Plugin.ts +++ b/packages/napcat-webui-backend/src/router/Plugin.ts @@ -13,13 +13,13 @@ import { PluginConfigSSEHandler, PluginConfigChangeHandler, // ImportLocalPluginHandler, - GetPluginIconHandler + GetPluginIconHandler, } 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'; diff --git a/packages/napcat-webui-backend/src/router/UpdateNapCat.ts b/packages/napcat-webui-backend/src/router/UpdateNapCat.ts index a0c0e01c8..e5c53795d 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/scripts/fontmin.cjs b/packages/napcat-webui-frontend/scripts/fontmin.cjs index afd4d8d52..aae249825 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 8c819f126..e98748796 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 eb7a3e943..2e2923596 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 fc6898349..0bca7cd3a 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/guid_manager.tsx b/packages/napcat-webui-frontend/src/components/guid_manager.tsx index b53ba6844..39dc22c38 100644 --- a/packages/napcat-webui-frontend/src/components/guid_manager.tsx +++ b/packages/napcat-webui-frontend/src/components/guid_manager.tsx @@ -363,15 +363,17 @@ const GUIDManager: React.FC = ({ showRestart = true, compact =
当前设备 GUID
- {currentLinuxGUID ? ( - - {currentLinuxGUID} - - ) : ( - - 未设置 / 不存在 - - )} + {currentLinuxGUID + ? ( + + {currentLinuxGUID} + + ) + : ( + + 未设置 / 不存在 + + )} {currentLinuxGUID && (
@@ -296,7 +297,7 @@ const OneBotApiDebug = forwardRef((props size='sm' className='font-bold shadow-sm px-4' isLoading={isFetching} - startContent={!isFetching && } + startContent={!isFetching && } > 发送 @@ -310,43 +311,46 @@ const OneBotApiDebug = forwardRef((props
+ )} + > - - + +
{(onOpen) => ( - + )} - - @@ -355,38 +359,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 +413,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 +422,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 +444,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 446a4cf38..be9b0eb2b 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 e2a98932a..1fe40660a 100644 --- a/packages/napcat-webui-frontend/src/components/password_login.tsx +++ b/packages/napcat-webui-frontend/src/components/password_login.tsx @@ -54,80 +54,86 @@ const PasswordLogin: React.FC = ({ onSubmit, onCaptchaSubmit return (
- {captchaState?.needCaptcha && captchaState.proofWaterUrl ? ( -
- {captchaVerifying ? ( - <> -

验证码已提交,正在等待服务器验证结果...

-
- -
- - ) : ( - <> -

登录需要安全验证,请完成验证码

- { - onCaptchaSubmit?.(captchaState.uin, captchaState.password, data); - }} - onCancel={onCaptchaCancel} - /> - - )} - -
- ) : newDeviceState?.needNewDevice && newDeviceState.jumpUrl ? ( - onNewDeviceVerified?.(token)} - onCancel={onNewDeviceCancel} - /> - ) : ( - <> -
- QQ Avatar + {captchaState?.needCaptcha && captchaState.proofWaterUrl + ? ( +
+ {captchaVerifying + ? ( + <> +

验证码已提交,正在等待服务器验证结果...

+
+ +
+ + ) + : ( + <> +

登录需要安全验证,请完成验证码

+ { + onCaptchaSubmit?.(captchaState.uin, captchaState.password, data); + }} + onCancel={onCaptchaCancel} + /> + + )} +
-
- - - - - setUin(key.toString())} - > - {(item) => ( - -
+ ) + : newDeviceState?.needNewDevice && newDeviceState.jumpUrl + ? ( + onNewDeviceVerified?.(token)} + onCancel={onNewDeviceCancel} + /> + ) + : ( + <> +
+ QQ Avatar +
+
+ + + + + setUin(key.toString())} + > + {(item) => ( + +
= ({ onSubmit, onCaptchaSubmit : item.uin}
- - )} - - + + )} + + } - /> - -
-
- -
- - )} + /> + +
+
+ +
+ + )}
); }; diff --git a/packages/napcat-webui-frontend/src/components/sidebar/index.tsx b/packages/napcat-webui-frontend/src/components/sidebar/index.tsx index be9719fd0..be7ae82f7 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 5f7b2192b..76464bc3f 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 ea79b3b6c..7a646a705 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'}
@@ -362,7 +363,7 @@ const VersionSelectDialogContent: React.FC = ({ pageSize, type: activeTab, search: debouncedSearch, - mirror: selectedMirror + mirror: selectedMirror, }), { refreshDeps: [currentPage, activeTab, debouncedSearch, selectedMirror], @@ -517,7 +518,7 @@ const VersionSelectDialogContent: React.FC = ({
{releasesData?.mirror && (
- + 镜像: {releasesData.mirror}
)} @@ -544,50 +545,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 +792,7 @@ const VersionSelectDialogContent: React.FC = ({ setSelectedMirror(mirror || undefined); setMirrorLatency(null); }} - type="file" + type='file' />
); @@ -848,7 +854,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 dfbcb1425..b24e21659 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/tencent_captcha.tsx b/packages/napcat-webui-frontend/src/components/tencent_captcha.tsx index 85fe181a3..2ffc299bb 100644 --- a/packages/napcat-webui-frontend/src/components/tencent_captcha.tsx +++ b/packages/napcat-webui-frontend/src/components/tencent_captcha.tsx @@ -156,9 +156,9 @@ const TencentCaptchaModal: React.FC = ({ }, [proofWaterUrl, handleResult]); return ( -
- - 正在加载验证码... +
+ + 正在加载验证码...
); }; diff --git a/packages/napcat-webui-frontend/src/components/xterm.tsx b/packages/napcat-webui-frontend/src/components/xterm.tsx index c9d566636..21c1f1b75 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 8cf0c2b97..06e5dfd47 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 36d948cc0..eca01f2b4 100644 --- a/packages/napcat-webui-frontend/src/controllers/plugin_manager.ts +++ b/packages/napcat-webui-frontend/src/controllers/plugin_manager.ts @@ -184,7 +184,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; } @@ -218,7 +218,7 @@ export default class PluginManager { sessionId, key, value, - currentConfig + currentConfig, }); } diff --git a/packages/napcat-webui-frontend/src/controllers/qq_manager.ts b/packages/napcat-webui-frontend/src/controllers/qq_manager.ts index 8431e67ca..715fadb4a 100644 --- a/packages/napcat-webui-frontend/src/controllers/qq_manager.ts +++ b/packages/napcat-webui-frontend/src/controllers/qq_manager.ts @@ -296,4 +296,3 @@ export default class QQManager { ); } } - diff --git a/packages/napcat-webui-frontend/src/pages/dashboard/about.tsx b/packages/napcat-webui-frontend/src/pages/dashboard/about.tsx index b76f13436..d4a6d846c 100644 --- a/packages/napcat-webui-frontend/src/pages/dashboard/about.tsx +++ b/packages/napcat-webui-frontend/src/pages/dashboard/about.tsx @@ -16,7 +16,7 @@ import { BsGlobe, BsPlugin, BsTelegram, - BsTencentQq + BsTencentQq, } from 'react-icons/bs'; import { IoDocument, IoRocketSharp } from 'react-icons/io5'; @@ -31,16 +31,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} +
+ )}
); } @@ -75,7 +79,7 @@ function NapCatFileHash () { if (!isLoginAccountInList) { accounts.push({ uin: String(loginData.uin), - label: loginData.nick ? `${loginData.nick}(${loginData.uin})` : String(loginData.uin) + label: loginData.nick ? `${loginData.nick}(${loginData.uin})` : String(loginData.uin), }); } } @@ -101,53 +105,59 @@ function NapCatFileHash () { : null; return ( -
-
+
+
入群密码 - {loading && } + {loading && }
- {error ? ( - 无法计算:{(error as Error).message} - ) : loading ? null : accounts.length > 0 ? ( -
- {accounts.length > 1 && ( - - )} + {error + ? ( + 无法计算:{(error as Error).message} + ) + : loading + ? null + : accounts.length > 0 + ? ( +
+ {accounts.length > 1 && ( + + )} - {password && ( -
- {accounts.length === 1 &&

{currentAccount.label}

} - - - {password} - - -
- )} -

入群密钥绑定QQ,使用对应QQ申请入群即可。

-
- ) : null} + {password && ( +
+ {accounts.length === 1 &&

{currentAccount.label}

} + + + {password} + + +
+ )} +

入群密钥绑定QQ,使用对应QQ申请入群即可。

+
+ ) + : null}
); } @@ -158,26 +168,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 = [ @@ -190,37 +200,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 框架。 @@ -232,16 +242,16 @@ export default function AboutPage () { -

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

{item.title}

-

{item.desc}

+

{item.title}

+

{item.desc}

@@ -250,42 +260,42 @@ export default function AboutPage () {
{/* 右侧:信息与链接 */} -
- - -

相关资源

+
+ + +

相关资源

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

+ + +

技术栈

- -
+ +
{['TypeScript', 'React', 'Vite', 'Node.js', 'Electron', 'HeroUI'].map((tech) => ( - + {tech} ))} @@ -296,12 +306,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 50cd417fd..f2129b4cb 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 = () => {
-