提交 71712828 编写于 作者: DCloud-yyl's avatar DCloud-yyl

Merge branch 'alpha'

{ {
"name": "uni-api", "name": "uni-api",
"appid": "__UNI__ED9218B", "appid": "__UNI__8BF79AC",
"description": "uts插件示例", "description": "uts插件示例",
"versionName": "1.0.0", "versionName": "1.0.0",
"versionCode": "100", "versionCode": "100",
......
import { ExitOptions, ExitFailCallback, ExitCompleteCallback, Exit} from "../interface.uts" import { ExitOptions, ExitFailCallback, ExitCompleteCallback, Exit} from "../interface.uts"
import { UniErrorSubject, UniErrors } from "../unierror.uts" import { ExitFailImpl } from "../unierror.uts"
/** /**
...@@ -7,7 +7,7 @@ import { UniErrorSubject, UniErrors } from "../unierror.uts" ...@@ -7,7 +7,7 @@ import { UniErrorSubject, UniErrors } from "../unierror.uts"
* iOS平台不支持,触发错误回调 * iOS平台不支持,触发错误回调
*/ */
export const exit : Exit = function (options: ExitOptions | null) { export const exit : Exit = function (options: ExitOptions | null) {
let err = new UniError(UniErrorSubject, 12001, UniErrors.get(12001)!); let err = new ExitFailImpl(12001);
options?.fail?.(err) options?.fail?.(err)
options?.complete?.(err) options?.complete?.(err)
} }
...@@ -5,6 +5,21 @@ export type ExitSuccess = { ...@@ -5,6 +5,21 @@ export type ExitSuccess = {
errMsg: string errMsg: string
} }
/**
* 错误码
* - 12001: 系统不支持
* - 12002: 未知错误
*/
export type ExitErrorCode = 12001 | 12002
/**
* uni.exit失败回调参数
*/
export interface IExitError extends IUniError {
errCode: ExitErrorCode
}
export type ExitFail = IExitError
/** /**
* uni.exit成功回调函数定义 * uni.exit成功回调函数定义
*/ */
...@@ -12,7 +27,7 @@ export type ExitSuccessCallback = (res: ExitSuccess) => void ...@@ -12,7 +27,7 @@ export type ExitSuccessCallback = (res: ExitSuccess) => void
/** /**
* uni.exit失败回调函数定义 * uni.exit失败回调函数定义
*/ */
export type ExitFailCallback = (res: UniError) => void export type ExitFailCallback = (res: ExitFail) => void
/** /**
* uni.exit完成回调函数定义 * uni.exit完成回调函数定义
*/ */
......
import { ExitErrorCode, IExitError } from "./interface.uts"
/** /**
* 错误主题 * 错误主题
*/ */
...@@ -18,3 +20,17 @@ export const UniErrors:Map<number, string> = new Map([ ...@@ -18,3 +20,17 @@ export const UniErrors:Map<number, string> = new Map([
*/ */
[12002, 'unknown error'] [12002, 'unknown error']
]); ]);
/**
* ExitFail的实现
*/
export class ExitFailImpl extends UniError implements IExitError {
constructor (
errCode: ExitErrorCode
) {
super()
this.errSubject = UniErrorSubject
this.errCode = errCode
this.errMsg = UniErrors[errCode] ?? "";
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册