Files
NapCatQQ/packages/napcat-webui-frontend/src/controllers/qq_manager.ts
Qiao 39a2a4028b feat(webui): 添加QQ掉线时重启进程提示
- 后端 CheckLoginStatus API 新增 isOffline 字段区分掉线与未登录状态
- 后端 GetQQLoginInfo API 新增返回 online 和 avatarUrl 字段
- 前端掉线时弹窗提示用户是否重启进程
- 修正 isLogin 类型从 string 改为 boolean
2026-02-05 11:07:02 +08:00

105 lines
2.7 KiB
TypeScript

import { AxiosRequestConfig } from 'axios';
import { serverRequest } from '@/utils/request';
import { SelfInfo } from '@/types/user';
export default class QQManager {
public static async getOB11Config () {
const data = await serverRequest.post<ServerResponse<OneBotConfig>>(
'/OB11Config/GetConfig'
);
return data.data.data;
}
public static async setOB11Config (config: OneBotConfig) {
await serverRequest.post<ServerResponse<null>>('/OB11Config/SetConfig', {
config: JSON.stringify(config),
});
}
public static async checkQQLoginStatus () {
const data = await serverRequest.post<
ServerResponse<{
isLogin: boolean;
isOffline?: boolean;
qrcodeurl: string;
}>
>('/QQLogin/CheckLoginStatus');
return data.data.data;
}
public static async checkQQLoginStatusWithQrcode () {
const data = await serverRequest.post<
ServerResponse<{ qrcodeurl: string; isLogin: boolean; isOffline?: boolean; loginError?: string; }>
>('/QQLogin/CheckLoginStatus');
return data.data.data;
}
public static async refreshQRCode () {
await serverRequest.post<ServerResponse<null>>('/QQLogin/RefreshQRcode');
}
public static async getQQLoginQrcode () {
const data = await serverRequest.post<
ServerResponse<{
qrcode: string;
}>
>('/QQLogin/GetQQLoginQrcode');
return data.data.data.qrcode;
}
public static async getQQQuickLoginList () {
const data = await serverRequest.post<ServerResponse<string[]>>(
'/QQLogin/GetQuickLoginList'
);
return data.data.data;
}
public static async getQQQuickLoginListNew () {
const data = await serverRequest.post<ServerResponse<LoginListItem[]>>(
'/QQLogin/GetQuickLoginListNew'
);
return data.data.data;
}
public static async setQuickLogin (uin: string) {
await serverRequest.post<ServerResponse<null>>('/QQLogin/SetQuickLogin', {
uin,
});
}
public static async getQQLoginInfo (config?: AxiosRequestConfig) {
const data = await serverRequest.post<ServerResponse<SelfInfo>>(
'/QQLogin/GetQQLoginInfo',
{},
config
);
return data.data.data;
}
public static async getQuickLoginQQ () {
const { data } = await serverRequest.post<ServerResponse<string>>(
'/QQLogin/GetQuickLoginQQ'
);
return data.data;
}
public static async setQuickLoginQQ (uin: string) {
await serverRequest.post<ServerResponse<null>>('/QQLogin/SetQuickLoginQQ', {
uin,
});
}
public static async passwordLogin (uin: string, passwordMd5: string) {
await serverRequest.post<ServerResponse<null>>('/QQLogin/PasswordLogin', {
uin,
passwordMd5,
});
}
}