mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
style: 强类型大法
This commit is contained in:
@@ -3,6 +3,7 @@ import { ActionName } from '@/onebot/action/router';
|
||||
import { checkFileExist, uriToLocalFile } from '@/common/file';
|
||||
import fs from 'fs';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
import { GeneralCallResultStatus } from '@/core';
|
||||
|
||||
const SchemaData = Type.Object({
|
||||
image: Type.String(),
|
||||
@@ -10,8 +11,8 @@ const SchemaData = Type.Object({
|
||||
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
class OCRImageBase extends OneBotAction<Payload, any> {
|
||||
payloadSchema = SchemaData;
|
||||
class OCRImageBase extends OneBotAction<Payload, GeneralCallResultStatus> {
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const { path, success } = await uriToLocalFile(this.core.NapCatTempPath, payload.image);
|
||||
@@ -35,9 +36,9 @@ class OCRImageBase extends OneBotAction<Payload, any> {
|
||||
}
|
||||
|
||||
export class OCRImage extends OCRImageBase {
|
||||
actionName = ActionName.OCRImage;
|
||||
override actionName = ActionName.OCRImage;
|
||||
}
|
||||
|
||||
export class IOCRImage extends OCRImageBase {
|
||||
actionName = ActionName.IOCRImage;
|
||||
override actionName = ActionName.IOCRImage;
|
||||
}
|
||||
Reference in New Issue
Block a user