mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
import { rebootWithNormolLogin, rebootWithQuickLogin } from '@/common/utils/reboot';
|
|
import BaseAction from '../BaseAction';
|
|
import { ActionName } from '../types';
|
|
import { selfInfo } from '@/core/data';
|
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
|
|
const SchemaData = {
|
|
type: 'object',
|
|
properties: {
|
|
delay: { type: 'number' }
|
|
}
|
|
} as const satisfies JSONSchema;
|
|
|
|
type Payload = FromSchema<typeof SchemaData>;
|
|
|
|
export class Reboot extends BaseAction<Payload, null> {
|
|
actionName = ActionName.Reboot;
|
|
|
|
protected async _handle(payload: Payload): Promise<null> {
|
|
if (payload.delay) {
|
|
setTimeout(() => {
|
|
rebootWithQuickLogin(selfInfo.uin);
|
|
}, payload.delay);
|
|
} else {
|
|
rebootWithQuickLogin(selfInfo.uin);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
export class RebootNormal extends BaseAction<Payload, null> {
|
|
actionName = ActionName.RebootNormal;
|
|
|
|
protected async _handle(payload: Payload): Promise<null> {
|
|
if (payload.delay) {
|
|
setTimeout(() => {
|
|
rebootWithNormolLogin();
|
|
}, payload.delay);
|
|
} else {
|
|
rebootWithNormolLogin();
|
|
}
|
|
return null;
|
|
}
|
|
}
|