import BaseAction from '../BaseAction'; import { ActionName } from '../types'; import { FromSchema, JSONSchema } from 'json-schema-to-ts'; const SchemaData = { type: 'object', properties: { words: { type: 'array', items: { type: 'string' }, }, }, required: ['words'], } as const satisfies JSONSchema; type Payload = FromSchema; export class TranslateEnWordToZn extends BaseAction | null> { actionName = ActionName.TranslateEnWordToZn; payloadSchema = SchemaData; async _handle(payload: Payload) { const ret = await this.core.apis.SystemApi.translateEnWordToZn(payload.words); if (ret.result !== 0) { throw new Error('翻译失败'); } return ret.words; } }