Refactor type annotations and router initialization
Standardized type annotations for interfaces in user.ts and improved type safety in webapi.ts. Updated all Express router initializations to explicitly declare the Router type. Added missing RequestHandler typings in uploader modules for better type checking.
This commit is contained in:
1 parent
772f07c58b
commit
01958d47a4
16 files changed
+123
-121
No files matched your search
@@ -13,6 +13,17 @@ import { createHash } from 'node:crypto';
|
|||||||
import { basename } from 'node:path';
|
import { basename } from 'node:path';
|
||||||
import { qunAlbumControl } from '../data/webapi';
|
import { qunAlbumControl } from '../data/webapi';
|
||||||
import { createAlbumCommentRequest, createAlbumFeedPublish, createAlbumMediaFeed } from '../data/album';
|
import { createAlbumCommentRequest, createAlbumFeedPublish, createAlbumMediaFeed } from '../data/album';
|
||||||
|
export interface SetNoticeRetSuccess {
|
||||||
|
ec: number;
|
||||||
|
em: string;
|
||||||
|
id: number;
|
||||||
|
ltsm: number;
|
||||||
|
new_fid: string;
|
||||||
|
read_only: number;
|
||||||
|
role: number;
|
||||||
|
srv_code: number;
|
||||||
|
}
|
||||||
|
|
||||||
export class NTQQWebApi {
|
export class NTQQWebApi {
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
core: NapCatCore;
|
core: NapCatCore;
|
||||||
@@ -25,12 +36,12 @@ export class NTQQWebApi {
|
|||||||
async shareDigest (groupCode: string, msgSeq: string, msgRandom: string, targetGroupCode: string) {
|
async shareDigest (groupCode: string, msgSeq: string, msgRandom: string, targetGroupCode: string) {
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
const url = `https://qun.qq.com/cgi-bin/group_digest/share_digest?${new URLSearchParams({
|
const url = `https://qun.qq.com/cgi-bin/group_digest/share_digest?${new URLSearchParams({
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
group_code: groupCode,
|
group_code: groupCode,
|
||||||
msg_seq: msgSeq,
|
msg_seq: msgSeq,
|
||||||
msg_random: msgRandom,
|
msg_random: msgRandom,
|
||||||
target_group_code: targetGroupCode,
|
target_group_code: targetGroupCode,
|
||||||
}).toString()}`;
|
}).toString()}`;
|
||||||
try {
|
try {
|
||||||
return RequestUtil.HttpGetText(url, 'GET', '', { Cookie: this.cookieToString(cookieObject) });
|
return RequestUtil.HttpGetText(url, 'GET', '', { Cookie: this.cookieToString(cookieObject) });
|
||||||
} catch {
|
} catch {
|
||||||
@@ -52,11 +63,11 @@ export class NTQQWebApi {
|
|||||||
async getGroupEssenceMsg (GroupCode: string, page_start: number = 0, page_limit: number = 50) {
|
async getGroupEssenceMsg (GroupCode: string, page_start: number = 0, page_limit: number = 50) {
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
const url = `https://qun.qq.com/cgi-bin/group_digest/digest_list?${new URLSearchParams({
|
const url = `https://qun.qq.com/cgi-bin/group_digest/digest_list?${new URLSearchParams({
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
page_start: page_start.toString(),
|
page_start: page_start.toString(),
|
||||||
page_limit: page_limit.toString(),
|
page_limit: page_limit.toString(),
|
||||||
group_code: GroupCode,
|
group_code: GroupCode,
|
||||||
}).toString()}`;
|
}).toString()}`;
|
||||||
try {
|
try {
|
||||||
const ret = await RequestUtil.HttpGetJson<GroupEssenceMsgRet>(
|
const ret = await RequestUtil.HttpGetJson<GroupEssenceMsgRet>(
|
||||||
url,
|
url,
|
||||||
@@ -76,16 +87,16 @@ export class NTQQWebApi {
|
|||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
const retList: Promise<WebApiGroupMemberRet>[] = [];
|
const retList: Promise<WebApiGroupMemberRet>[] = [];
|
||||||
const fastRet = await RequestUtil.HttpGetJson<WebApiGroupMemberRet>(
|
const fastRet = await RequestUtil.HttpGetJson<WebApiGroupMemberRet>(
|
||||||
`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
||||||
st: '0',
|
st: '0',
|
||||||
end: '40',
|
end: '40',
|
||||||
sort: '1',
|
sort: '1',
|
||||||
gc: GroupCode,
|
gc: GroupCode,
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
}).toString()}`,
|
}).toString()}`,
|
||||||
'POST',
|
'POST',
|
||||||
'',
|
'',
|
||||||
{ Cookie: this.cookieToString(cookieObject) }
|
{ Cookie: this.cookieToString(cookieObject) }
|
||||||
);
|
);
|
||||||
if (!fastRet?.count || fastRet?.errcode !== 0 || !fastRet?.mems) {
|
if (!fastRet?.count || fastRet?.errcode !== 0 || !fastRet?.mems) {
|
||||||
return [];
|
return [];
|
||||||
@@ -101,16 +112,16 @@ export class NTQQWebApi {
|
|||||||
// 遍历批量请求
|
// 遍历批量请求
|
||||||
for (let i = 2; i <= PageNum; i++) {
|
for (let i = 2; i <= PageNum; i++) {
|
||||||
const ret = RequestUtil.HttpGetJson<WebApiGroupMemberRet>(
|
const ret = RequestUtil.HttpGetJson<WebApiGroupMemberRet>(
|
||||||
`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
||||||
st: ((i - 1) * 40).toString(),
|
st: ((i - 1) * 40).toString(),
|
||||||
end: (i * 40).toString(),
|
end: (i * 40).toString(),
|
||||||
sort: '1',
|
sort: '1',
|
||||||
gc: GroupCode,
|
gc: GroupCode,
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
}).toString()}`,
|
}).toString()}`,
|
||||||
'POST',
|
'POST',
|
||||||
'',
|
'',
|
||||||
{ Cookie: this.cookieToString(cookieObject) }
|
{ Cookie: this.cookieToString(cookieObject) }
|
||||||
);
|
);
|
||||||
retList.push(ret);
|
retList.push(ret);
|
||||||
}
|
}
|
||||||
@@ -153,16 +164,7 @@ export class NTQQWebApi {
|
|||||||
imgWidth: number = 540,
|
imgWidth: number = 540,
|
||||||
imgHeight: number = 300
|
imgHeight: number = 300
|
||||||
) {
|
) {
|
||||||
interface SetNoticeRetSuccess {
|
|
||||||
ec: number;
|
|
||||||
em: string;
|
|
||||||
id: number;
|
|
||||||
ltsm: number;
|
|
||||||
new_fid: string;
|
|
||||||
read_only: number;
|
|
||||||
role: number;
|
|
||||||
srv_code: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
|
|
||||||
@@ -178,18 +180,18 @@ export class NTQQWebApi {
|
|||||||
imgHeight: imgHeight.toString(),
|
imgHeight: imgHeight.toString(),
|
||||||
};
|
};
|
||||||
const ret: SetNoticeRetSuccess = await RequestUtil.HttpGetJson<SetNoticeRetSuccess>(
|
const ret: SetNoticeRetSuccess = await RequestUtil.HttpGetJson<SetNoticeRetSuccess>(
|
||||||
`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?${new URLSearchParams({
|
`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?${new URLSearchParams({
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
qid: GroupCode,
|
qid: GroupCode,
|
||||||
text: Content,
|
text: Content,
|
||||||
pinned: pinned.toString(),
|
pinned: pinned.toString(),
|
||||||
type: type.toString(),
|
type: type.toString(),
|
||||||
settings,
|
settings,
|
||||||
...(picId === '' ? {} : externalParam),
|
...(picId === '' ? {} : externalParam),
|
||||||
}).toString()}`,
|
}).toString()}`,
|
||||||
'POST',
|
'POST',
|
||||||
'',
|
'',
|
||||||
{ Cookie: this.cookieToString(cookieObject) }
|
{ Cookie: this.cookieToString(cookieObject) }
|
||||||
);
|
);
|
||||||
return ret;
|
return ret;
|
||||||
} catch {
|
} catch {
|
||||||
@@ -201,20 +203,20 @@ export class NTQQWebApi {
|
|||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
try {
|
try {
|
||||||
const ret = await RequestUtil.HttpGetJson<WebApiGroupNoticeRet>(
|
const ret = await RequestUtil.HttpGetJson<WebApiGroupNoticeRet>(
|
||||||
`https://web.qun.qq.com/cgi-bin/announce/get_t_list?${new URLSearchParams({
|
`https://web.qun.qq.com/cgi-bin/announce/get_t_list?${new URLSearchParams({
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
qid: GroupCode,
|
qid: GroupCode,
|
||||||
ft: '23',
|
ft: '23',
|
||||||
ni: '1',
|
ni: '1',
|
||||||
n: '1',
|
n: '1',
|
||||||
i: '1',
|
i: '1',
|
||||||
log_read: '1',
|
log_read: '1',
|
||||||
platform: '1',
|
platform: '1',
|
||||||
s: '-1',
|
s: '-1',
|
||||||
}).toString()}&n=20`,
|
}).toString()}&n=20`,
|
||||||
'GET',
|
'GET',
|
||||||
'',
|
'',
|
||||||
{ Cookie: this.cookieToString(cookieObject) }
|
{ Cookie: this.cookieToString(cookieObject) }
|
||||||
);
|
);
|
||||||
return ret?.ec === 0 ? ret : undefined;
|
return ret?.ec === 0 ? ret : undefined;
|
||||||
} catch {
|
} catch {
|
||||||
@@ -222,17 +224,17 @@ export class NTQQWebApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getDataInternal (cookieObject: { [key: string]: string }, groupCode: string, type: number) {
|
private async getDataInternal (cookieObject: { [key: string]: string; }, groupCode: string, type: number) {
|
||||||
let resJson;
|
let resJson;
|
||||||
try {
|
try {
|
||||||
const res = await RequestUtil.HttpGetText(
|
const res = await RequestUtil.HttpGetText(
|
||||||
`https://qun.qq.com/interactive/honorlist?${new URLSearchParams({
|
`https://qun.qq.com/interactive/honorlist?${new URLSearchParams({
|
||||||
gc: groupCode,
|
gc: groupCode,
|
||||||
type: type.toString(),
|
type: type.toString(),
|
||||||
}).toString()}`,
|
}).toString()}`,
|
||||||
'GET',
|
'GET',
|
||||||
'',
|
'',
|
||||||
{ Cookie: this.cookieToString(cookieObject) }
|
{ Cookie: this.cookieToString(cookieObject) }
|
||||||
);
|
);
|
||||||
const match = /window\.__INITIAL_STATE__=(.*?);/.exec(res);
|
const match = /window\.__INITIAL_STATE__=(.*?);/.exec(res);
|
||||||
if (match?.[1]) {
|
if (match?.[1]) {
|
||||||
@@ -245,7 +247,7 @@ export class NTQQWebApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async getHonorList (cookieObject: { [key: string]: string }, groupCode: string, type: number) {
|
private async getHonorList (cookieObject: { [key: string]: string; }, groupCode: string, type: number) {
|
||||||
const data = await this.getDataInternal(cookieObject, groupCode, type);
|
const data = await this.getDataInternal(cookieObject, groupCode, type);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
this.context.logger.logError(`获取类型 ${type} 的荣誉信息失败`);
|
this.context.logger.logError(`获取类型 ${type} 的荣誉信息失败`);
|
||||||
@@ -304,11 +306,11 @@ export class NTQQWebApi {
|
|||||||
return HonorInfo;
|
return HonorInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private cookieToString (cookieObject: { [key: string]: string }) {
|
private cookieToString (cookieObject: { [key: string]: string; }) {
|
||||||
return Object.entries(cookieObject).map(([key, value]) => `${key}=${value}`).join('; ');
|
return Object.entries(cookieObject).map(([key, value]) => `${key}=${value}`).join('; ');
|
||||||
}
|
}
|
||||||
|
|
||||||
public getBknFromCookie (cookieObject: { [key: string]: string }) {
|
public getBknFromCookie (cookieObject: { [key: string]: string; }) {
|
||||||
const sKey = cookieObject['skey'] as string;
|
const sKey = cookieObject['skey'] as string;
|
||||||
|
|
||||||
let hash = 5381;
|
let hash = 5381;
|
||||||
@@ -361,7 +363,7 @@ export class NTQQWebApi {
|
|||||||
uin,
|
uin,
|
||||||
getMemberRole: '0',
|
getMemberRole: '0',
|
||||||
});
|
});
|
||||||
const response = await RequestUtil.HttpGetJson<{ data: { album: Array<{ id: string, title: string }> } }>(api + params.toString(), 'GET', '', {
|
const response = await RequestUtil.HttpGetJson<{ data: { album: Array<{ id: string, title: string; }>; }; }>(api + params.toString(), 'GET', '', {
|
||||||
Cookie: cookies,
|
Cookie: cookies,
|
||||||
});
|
});
|
||||||
return response.data.album;
|
return response.data.album;
|
||||||
@@ -384,7 +386,7 @@ export class NTQQWebApi {
|
|||||||
sAlbumID,
|
sAlbumID,
|
||||||
});
|
});
|
||||||
const api = `https://h5.qzone.qq.com/webapp/json/sliceUpload/FileBatchControl/${img_md5}?g_tk=${GTK}`;
|
const api = `https://h5.qzone.qq.com/webapp/json/sliceUpload/FileBatchControl/${img_md5}?g_tk=${GTK}`;
|
||||||
const post = await RequestUtil.HttpGetJson<{ data: { session: string }, ret: number, msg: string }>(api, 'POST', body, {
|
const post = await RequestUtil.HttpGetJson<{ data: { session: string; }, ret: number, msg: string; }>(api, 'POST', body, {
|
||||||
Cookie: cookie,
|
Cookie: cookie,
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
});
|
});
|
||||||
@@ -430,7 +432,7 @@ export class NTQQWebApi {
|
|||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const post = await response.json() as { ret: number, msg: string }; if (post.ret !== 0) {
|
const post = await response.json() as { ret: number, msg: string; }; if (post.ret !== 0) {
|
||||||
throw new Error(`分片 ${seq} 上传失败: ${post.msg}`);
|
throw new Error(`分片 ${seq} 上传失败: ${post.msg}`);
|
||||||
}
|
}
|
||||||
offset += chunk.length;
|
offset += chunk.length;
|
||||||
@@ -475,10 +477,10 @@ export class NTQQWebApi {
|
|||||||
const client_key = Date.now() * 1000;
|
const client_key = Date.now() * 1000;
|
||||||
return await this.context.session.getAlbumService().doQunComment(
|
return await this.context.session.getAlbumService().doQunComment(
|
||||||
random_seq, {
|
random_seq, {
|
||||||
map_info: [],
|
map_info: [],
|
||||||
map_bytes_info: [],
|
map_bytes_info: [],
|
||||||
map_user_account: [],
|
map_user_account: [],
|
||||||
},
|
},
|
||||||
qunId,
|
qunId,
|
||||||
2,
|
2,
|
||||||
createAlbumMediaFeed(uin, albumId, lloc),
|
createAlbumMediaFeed(uin, albumId, lloc),
|
||||||
@@ -509,13 +511,13 @@ export class NTQQWebApi {
|
|||||||
const uin = this.core.selfInfo.uin || '10001';
|
const uin = this.core.selfInfo.uin || '10001';
|
||||||
return await this.context.session.getAlbumService().doQunLike(
|
return await this.context.session.getAlbumService().doQunLike(
|
||||||
random_seq, {
|
random_seq, {
|
||||||
map_info: [],
|
map_info: [],
|
||||||
map_bytes_info: [],
|
map_bytes_info: [],
|
||||||
map_user_account: [],
|
map_user_account: [],
|
||||||
}, {
|
}, {
|
||||||
id,
|
id,
|
||||||
status: 1,
|
status: 1,
|
||||||
},
|
},
|
||||||
createAlbumFeedPublish(qunId, uin, albumId, lloc)
|
createAlbumFeedPublish(qunId, uin, albumId, lloc)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,24 +57,24 @@ export interface BaseInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 音乐信息
|
// 音乐信息
|
||||||
interface MusicInfo {
|
export interface MusicInfo {
|
||||||
buf: string;
|
buf: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 视频业务信息
|
// 视频业务信息
|
||||||
interface VideoBizInfo {
|
export interface VideoBizInfo {
|
||||||
cid: string;
|
cid: string;
|
||||||
tvUrl: string;
|
tvUrl: string;
|
||||||
synchType: string;
|
synchType: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 视频信息
|
// 视频信息
|
||||||
interface VideoInfo {
|
export interface VideoInfo {
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 扩展在线业务信息
|
// 扩展在线业务信息
|
||||||
interface ExtOnlineBusinessInfo {
|
export interface ExtOnlineBusinessInfo {
|
||||||
buf: string;
|
buf: string;
|
||||||
customStatus: unknown;
|
customStatus: unknown;
|
||||||
videoBizInfo: VideoBizInfo;
|
videoBizInfo: VideoBizInfo;
|
||||||
@@ -82,12 +82,12 @@ interface ExtOnlineBusinessInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 扩展缓冲区
|
// 扩展缓冲区
|
||||||
interface ExtBuffer {
|
export interface ExtBuffer {
|
||||||
buf: string;
|
buf: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户状态
|
// 用户状态
|
||||||
interface UserStatus {
|
export interface UserStatus {
|
||||||
uid: string;
|
uid: string;
|
||||||
uin: string;
|
uin: string;
|
||||||
status: number;
|
status: number;
|
||||||
@@ -109,14 +109,14 @@ interface UserStatus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 特权图标
|
// 特权图标
|
||||||
interface PrivilegeIcon {
|
export interface PrivilegeIcon {
|
||||||
jumpUrl: string;
|
jumpUrl: string;
|
||||||
openIconList: unknown[];
|
openIconList: unknown[];
|
||||||
closeIconList: unknown[];
|
closeIconList: unknown[];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 增值服务信息
|
// 增值服务信息
|
||||||
interface VasInfo {
|
export interface VasInfo {
|
||||||
vipFlag: boolean;
|
vipFlag: boolean;
|
||||||
yearVipFlag: boolean;
|
yearVipFlag: boolean;
|
||||||
svipFlag: boolean;
|
svipFlag: boolean;
|
||||||
@@ -149,7 +149,7 @@ interface VasInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 关系标志
|
// 关系标志
|
||||||
interface RelationFlags {
|
export interface RelationFlags {
|
||||||
topTime: string;
|
topTime: string;
|
||||||
isBlock: boolean;
|
isBlock: boolean;
|
||||||
isMsgDisturb: boolean;
|
isMsgDisturb: boolean;
|
||||||
@@ -167,7 +167,7 @@ interface RelationFlags {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 通用扩展信息
|
// 通用扩展信息
|
||||||
interface CommonExt {
|
export interface CommonExt {
|
||||||
constellation: number;
|
constellation: number;
|
||||||
shengXiao: number;
|
shengXiao: number;
|
||||||
kBloodType: number;
|
kBloodType: number;
|
||||||
@@ -193,14 +193,14 @@ export enum BuddyListReqType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 图片信息
|
// 图片信息
|
||||||
interface Pic {
|
export interface Pic {
|
||||||
picId: string;
|
picId: string;
|
||||||
picTime: number;
|
picTime: number;
|
||||||
picUrlMap: Record<string, string>;
|
picUrlMap: Record<string, string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 照片墙
|
// 照片墙
|
||||||
interface PhotoWall {
|
export interface PhotoWall {
|
||||||
picList: Pic[];
|
picList: Pic[];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ export interface ModifyProfileParams {
|
|||||||
nick: string;
|
nick: string;
|
||||||
longNick: string;
|
longNick: string;
|
||||||
sex: NTSex;
|
sex: NTSex;
|
||||||
birthday: { birthday_year: string, birthday_month: string, birthday_day: string };
|
birthday: { birthday_year: string, birthday_month: string, birthday_day: string; };
|
||||||
location: unknown;
|
location: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import json5 from 'json5';
|
|||||||
|
|
||||||
type ActionNameType = typeof ActionName[keyof typeof ActionName];
|
type ActionNameType = typeof ActionName[keyof typeof ActionName];
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
const DEFAULT_ADAPTER_NAME = 'debug-primary';
|
const DEFAULT_ADAPTER_NAME = 'debug-primary';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { GetThemeConfigHandler, GetNapCatVersion, QQVersionHandler, SetThemeConf
|
|||||||
import { StatusRealTimeHandler } from '@/napcat-webui-backend/src/api/Status';
|
import { StatusRealTimeHandler } from '@/napcat-webui-backend/src/api/Status';
|
||||||
import { GetProxyHandler } from '../api/Proxy';
|
import { GetProxyHandler } from '../api/Proxy';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
// router: 获取nc的package.json信息
|
// router: 获取nc的package.json信息
|
||||||
router.get('/QQVersion', QQVersionHandler);
|
router.get('/QQVersion', QQVersionHandler);
|
||||||
router.get('/GetNapCatVersion', GetNapCatVersion);
|
router.get('/GetNapCatVersion', GetNapCatVersion);
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
DeleteWebUIFontHandler, // 添加上传处理器
|
DeleteWebUIFontHandler, // 添加上传处理器
|
||||||
} from '../api/File';
|
} from '../api/File';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
const apiLimiter = rateLimit({
|
const apiLimiter = rateLimit({
|
||||||
windowMs: 1 * 60 * 1000, // 1分钟内
|
windowMs: 1 * 60 * 1000, // 1分钟内
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
CloseTerminalHandler,
|
CloseTerminalHandler,
|
||||||
} from '../api/Log';
|
} from '../api/Log';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
// 日志相关路由
|
// 日志相关路由
|
||||||
router.get('/GetLog', LogHandler);
|
router.get('/GetLog', LogHandler);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { Router } from 'express';
|
|||||||
|
|
||||||
import { OB11GetConfigHandler, OB11SetConfigHandler } from '@/napcat-webui-backend/src/api/OB11Config';
|
import { OB11GetConfigHandler, OB11SetConfigHandler } from '@/napcat-webui-backend/src/api/OB11Config';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
// router:读取配置
|
// router:读取配置
|
||||||
router.post('/GetConfig', OB11GetConfigHandler);
|
router.post('/GetConfig', OB11GetConfigHandler);
|
||||||
// router:写入配置
|
// router:写入配置
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
import { GetPluginListHandler, ReloadPluginHandler, SetPluginStatusHandler, UninstallPluginHandler } from '@/napcat-webui-backend/src/api/Plugin';
|
import { GetPluginListHandler, ReloadPluginHandler, SetPluginStatusHandler, UninstallPluginHandler } from '@/napcat-webui-backend/src/api/Plugin';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
router.get('/List', GetPluginListHandler);
|
router.get('/List', GetPluginListHandler);
|
||||||
router.post('/Reload', ReloadPluginHandler);
|
router.post('/Reload', ReloadPluginHandler);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
import { RestartProcessHandler } from '../api/Process';
|
import { RestartProcessHandler } from '../api/Process';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
// POST /api/Process/Restart - 重启进程
|
// POST /api/Process/Restart - 重启进程
|
||||||
router.post('/Restart', RestartProcessHandler);
|
router.post('/Restart', RestartProcessHandler);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
QQRefreshQRcodeHandler,
|
QQRefreshQRcodeHandler,
|
||||||
} from '@/napcat-webui-backend/src/api/QQLogin';
|
} from '@/napcat-webui-backend/src/api/QQLogin';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
// router:获取快速登录列表
|
// router:获取快速登录列表
|
||||||
router.all('/GetQuickLoginList', QQGetQuickLoginListHandler);
|
router.all('/GetQuickLoginList', QQGetQuickLoginListHandler);
|
||||||
// router:获取快速登录列表(新)
|
// router:获取快速登录列表(新)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import { Router } from 'express';
|
import { Router } from 'express';
|
||||||
import { UpdateNapCatHandler } from '@/napcat-webui-backend/src/api/UpdateNapCat';
|
import { UpdateNapCatHandler } from '@/napcat-webui-backend/src/api/UpdateNapCat';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
// POST /api/UpdateNapCat/update - 更新NapCat
|
// POST /api/UpdateNapCat/update - 更新NapCat
|
||||||
router.post('/update', UpdateNapCatHandler);
|
router.post('/update', UpdateNapCatHandler);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
UpdateWebUIConfigHandler,
|
UpdateWebUIConfigHandler,
|
||||||
} from '@/napcat-webui-backend/src/api/WebUIConfig';
|
} from '@/napcat-webui-backend/src/api/WebUIConfig';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
// 获取WebUI基础配置
|
// 获取WebUI基础配置
|
||||||
router.get('/GetConfig', GetWebUIConfigHandler);
|
router.get('/GetConfig', GetWebUIConfigHandler);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
VerifyPasskeyAuthenticationHandler,
|
VerifyPasskeyAuthenticationHandler,
|
||||||
} from '@/napcat-webui-backend/src/api/Auth';
|
} from '@/napcat-webui-backend/src/api/Auth';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
// router:登录
|
// router:登录
|
||||||
router.post('/login', LoginHandler);
|
router.post('/login', LoginHandler);
|
||||||
// router:检查登录状态
|
// router:检查登录状态
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import DebugRouter from '@/napcat-webui-backend/src/api/Debug';
|
|||||||
import { ProcessRouter } from './Process';
|
import { ProcessRouter } from './Process';
|
||||||
import { PluginRouter } from './Plugin';
|
import { PluginRouter } from './Plugin';
|
||||||
|
|
||||||
const router = Router();
|
const router: Router = Router();
|
||||||
|
|
||||||
// 鉴权中间件
|
// 鉴权中间件
|
||||||
router.use(auth);
|
router.use(auth);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import multer from 'multer';
|
import multer from 'multer';
|
||||||
import { Request, Response } from 'express';
|
import { Request, Response, RequestHandler } from 'express';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
@@ -65,7 +65,7 @@ export const createDiskStorage = (uploadPath: string) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createDiskUpload = (uploadPath: string) => {
|
export const createDiskUpload = (uploadPath: string): RequestHandler => {
|
||||||
const upload = multer({
|
const upload = multer({
|
||||||
storage: createDiskStorage(uploadPath),
|
storage: createDiskStorage(uploadPath),
|
||||||
limits: {
|
limits: {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import multer from 'multer';
|
import multer from 'multer';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import type { Request, Response } from 'express';
|
import type { Request, Response, RequestHandler } from 'express';
|
||||||
import { WebUiConfig } from '@/napcat-webui-backend/index';
|
import { WebUiConfig } from '@/napcat-webui-backend/index';
|
||||||
|
|
||||||
// 支持的字体格式
|
// 支持的字体格式
|
||||||
@@ -42,7 +42,7 @@ export const webUIFontStorage = multer.diskStorage({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const webUIFontUpload = multer({
|
export const webUIFontUpload: RequestHandler = multer({
|
||||||
storage: webUIFontStorage,
|
storage: webUIFontStorage,
|
||||||
fileFilter: (_, file, cb) => {
|
fileFilter: (_, file, cb) => {
|
||||||
// 验证文件类型
|
// 验证文件类型
|
||||||
|
|||||||
Reference in new issue
Block a user