index.uts 844 字节
Newer Older
lizhongyi_'s avatar
lizhongyi_ 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
/**
 * json参数格式定义
 */
export type inputJSON = {
	inputText: string,
	errCode: number
}
/**
 * json入参格式
 */
export type JsonParamOptions = {
	input: inputJSON;
	success: (res: inputJSON) => void;
	fail?: (res: string) => void;
	complete?: (res: string) => void;
};

/**
 * 导出无参的UTS函数
 * @param opts
 */
export function callWithoutParam(success: () => void) {
	success();
	return { name: "doSthWithCallback" };
}

/**
 * 导出一个字符串入参的UTS函数
 */
export function callWithStringParam(input: string, success: (res: string) => void) {
	success(input);
	return { name: "doSthWithCallback" };
}

/**
 * 导出一个JSON入参的UTS函数
 */
export function callWithJSONParam(opts: JsonParamOptions) {
	opts.input.errCode = 10;
	opts.success(opts.input);
	return { name: "doSthWithCallback" };
}