what-is-surprise
Version:
translate tool
67 lines (66 loc) • 1.85 kB
TypeScript
import { Lang } from './constants';
import { IYoudaoFanyiConfig, YoudaoFanyiConfig } from './YoudaoFanyiConfig';
import { BaseFanyi, IBaseFanyi } from '../../BaseFanyi';
declare type WebResult = {
/** 查询的文本 */
key: string;
/** 翻译的文本列表 */
value: string[];
};
declare type BasicResult = {
phonetic: string;
/** 英式音标 */
"uk-phonetic": string;
/** 美式音标 */
"us-phonetic": string;
/** 英式发音 */
"uk-speech": string;
/** 美式发音 */
"us-speech": string;
explains: string[];
};
declare type YoudaoFanyiOptions = Partial<IYoudaoFanyiConfig & {
url: string;
}>;
export declare class YoudaoFanyi extends BaseFanyi<Lang> implements IBaseFanyi<YoudaoFanyiConfig> {
static DEFAULT_API_URL: "https://openapi.youdao.com/api";
config: YoudaoFanyiConfig;
url: string;
requestMethod: 'get' | 'post';
constructor(options?: YoudaoFanyiOptions);
static createTranslator(options?: YoudaoFanyiOptions): YoudaoFanyi;
setRequestMethod(method: 'get' | 'post'): this;
translate(): Promise<{
errorCode: "0";
query: string;
translation: string[];
basic?: BasicResult | undefined;
dict: {
url: string;
};
webdict: {
url: string;
};
/** 翻译语言配置, 如 "EN2zh-CHS" */
l: string;
tSpeakUrl: string;
speakUrl: string;
web?: WebResult[] | undefined;
} | {
errorCode: "0";
translation: string[];
dict: {
url: string;
};
webdict: {
url: string;
};
/** 翻译语言配置, 如 "EN2zh-CHS" */
l: string;
tSpeakUrl: string;
speakUrl: string;
} | {
errorCode: string;
}>;
}
export {};