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

同步代码@HBuilderX4.34

上级 cc64cc0a
......@@ -158,6 +158,9 @@ function fingerPrintAvailable() {
userAuth.getAvailableStatus(userAuth.UserAuthType.FINGERPRINT, userAuth.AuthTrustLevel.ATL1);
return true
} catch (error) {
if ([userAuth.UserAuthResultCode.NOT_ENROLLED, userAuth.UserAuthResultCode.PIN_EXPIRED].includes((error as BusinessError).code)) {
return true
}
return false
}
}
......@@ -167,6 +170,9 @@ function faceAvailable() {
userAuth.getAvailableStatus(userAuth.UserAuthType.FACE, userAuth.AuthTrustLevel.ATL1);
return true
} catch (error) {
if ([userAuth.UserAuthResultCode.NOT_ENROLLED, userAuth.UserAuthResultCode.PIN_EXPIRED].includes((error as BusinessError).code)) {
return true
}
return false
}
}
......
{
"id": "uni-chooseLocation",
"displayName": "uni-chooseLocation",
"version": "1.0.0",
"description": "uni-chooseLocation",
"keywords": [
"uni-chooseLocation"
],
"repository": "",
"engines": {
"HBuilderX": "^3.6.8"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "",
"data": "",
"permissions": ""
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [
"uni-framework",
"uni-theme",
"uni-getSystemInfo",
"uni-getLocation",
"uni-cloud-client",
"uni-getLocation",
"uni-map-tencent"
],
"uni-ext-api": {
"uni": {
"chooseLocation": {
"name": "chooseLocation",
"app": {
"js": true,
"kotlin": true,
"swift": true,
"arkts": false
}
}
}
},
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "u",
"aliyun": "u"
},
"client": {
"Vue": {
"vue2": "u",
"vue3": "u"
},
"App": {
"app-android": "u",
"app-ios": "u"
},
"H5-mobile": {
"Safari": "u",
"Android Browser": "u",
"微信浏览器(Android)": "u",
"QQ浏览器(Android)": "u"
},
"H5-pc": {
"Chrome": "u",
"IE": "u",
"Edge": "u",
"Firefox": "u",
"Safari": "u"
},
"小程序": {
"微信": "u",
"阿里": "u",
"百度": "u",
"字节跳动": "u",
"QQ": "u",
"钉钉": "u",
"快手": "u",
"飞书": "u",
"京东": "u"
},
"快应用": {
"华为": "u",
"联盟": "u"
}
}
}
}
}
# uni-actionSheet
### 开发文档
[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html)
[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html)
[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html)
[Hello UTS](https://gitcode.net/dcloud/hello-uts)
\ No newline at end of file
import { registerSystemRoute } from "@dcloudio/uni-runtime";
import uniChooseLocationPage from "@/uni_modules/uni-chooseLocation/pages/chooseLocation/chooseLocation.vue";
import {
ChooseLocation,
ChooseLocationOptions,
ChooseLocationSuccessImpl,
ChooseLocationFailImpl
} from "../interface.uts";
export const chooseLocation: ChooseLocation = function (options: ChooseLocationOptions) {
registerSystemRoute("uni:chooseLocation", uniChooseLocationPage);
const uuid = Date.now() + '' + Math.floor(Math.random() * 1e7)
const baseEventName = `uni_choose_location_${uuid}`
const readyEventName = `${baseEventName}_ready`
const optionsEventName = `${baseEventName}_options`
const successEventName = `${baseEventName}_success`
const failEventName = `${baseEventName}_fail`
uni.$on(readyEventName, () => {
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)));
})
uni.$on(successEventName, (result: UTSJSONObject) => {
let name = result['name'] as string;
let address = result['address'] as string;
let latitude = result.getNumber('latitude') as number;
let longitude = result.getNumber('longitude') as number;
options.success?.(new ChooseLocationSuccessImpl(name, address, latitude, longitude))
})
uni.$on(failEventName, () => {
options.fail?.(new ChooseLocationFailImpl())
})
uni.openDialogPage({
url: `uni:chooseLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
fail(err) {
options.fail?.(new ChooseLocationFailImpl(`showActionSheet failed, ${err.errMsg}`, 4))
uni.$off(readyEventName)
uni.$off(successEventName)
uni.$off(failEventName)
}
})
};
import { defineAsyncApi, registerSystemRoute } from "@dcloudio/uni-runtime";
import uniChooseLocationPage from "@/uni_modules/uni-chooseLocation/pages/chooseLocation/chooseLocation.vue";
import { ChooseLocation, ChooseLocationOptions, ChooseLocationSuccess } from "../interface.uts"
export const chooseLocation: ChooseLocation = defineAsyncApi('chooseLocation', (
options: ChooseLocationOptions, { resolve, reject }
) => {
registerSystemRoute("uni:chooseLocation", uniChooseLocationPage, {
disableSwipeBack: false
});
const uuid = Date.now() + '' + Math.floor(Math.random() * 1e7)
const baseEventName = `uni_choose_location_${uuid}`
const readyEventName = `${baseEventName}_ready`
const optionsEventName = `${baseEventName}_options`
const successEventName = `${baseEventName}_success`
const failEventName = `${baseEventName}_fail`
uni.$on(readyEventName, () => {
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)))
})
uni.$on(successEventName, (result: ChooseLocationSuccess) => {
resolve(result)
})
uni.$on(failEventName, () => {
reject('cancel', {
errCode: 1
})
})
uni.openDialogPage({
url: `uni:chooseLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
fail(err) {
options.fail?.({ errMsg: `chooseLocation:fail ${err.errMsg}`, errCode: 4 })
uni.$off(readyEventName)
uni.$off(successEventName)
uni.$off(failEventName)
}
})
});
/**
* 错误码
*/
export type ChooseLocationErrorCode =
/**
* 取消
*/
1 |
/**
* 框架内部错误
*/
4;
export interface ChooseLocationSuccess extends AsyncApiSuccessResult {
name : string,
address : string,
latitude : number,
longitude : number
}
type ChooseLocationSuccessCallback = (result : ChooseLocationSuccess) => void
export interface ChooseLocationFail extends IUniError {
errCode : ChooseLocationErrorCode
}
type ChooseLocationFailCallback = (result : ChooseLocationFail) => void
export type ChooseLocationComplete = AsyncApiResult
type ChooseLocationCompleteCallback = (result : ChooseLocationComplete) => void
/**
* uni.chooseLocation函数参数定义
*/
export type ChooseLocationOptions = {
/**
* 指示位置的经度
*/
latitude ?: number | null,
/**
* 指示位置的纬度
*/
longitude ?: number | null,
/**
* 指示位置的名称
*/
keyword ?: string | null,
/**
* 接口调用成功的回调函数
*/
success ?: ChooseLocationSuccessCallback | null,
/**
* 接口调用失败的回调函数
*/
fail ?: ChooseLocationFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
*/
complete ?: ChooseLocationCompleteCallback | null
};
/**
* 打开地图选择位置
*
* @param {ChooseLocationOptions} options
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/prompt.html#chooselocation
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.11"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
export type ChooseLocation = (options : ChooseLocationOptions) => void;
export interface Uni {
/**
* @description 打开地图选择位置
* @example
* ```typescript
uni.chooseLocation({
success: (res) => {
console.log('res: ', res)
},
fail: (err) => {
console.log('err: ', err)
},
complete: (res) => {
console.log('complete: ', res)
}
});
* ```
* @tutorial https://doc.dcloud.net.cn/uni-app-x/api/choose-location.html
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "5.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "ios": {
* "osVer": "12.0",
* "uniVer": "√",
* "unixVer": "4.33"
* },
* "harmony": {
* "osVer": "3.0",
* "uniVer": "4.23",
* "unixVer": "x"
* }
* },
* "web": {
* "uniVer": "√",
* "unixVer": "4.0"
* }
* }
*/
chooseLocation(options : ChooseLocationOptions) : void;
}
// #ifdef APP-ANDROID
// @ts-expect-error
export class ChooseLocationSuccessImpl extends AsyncApiSuccessResult implements ChooseLocationSuccess {
name : string
address : string
latitude : number
longitude : number
// @ts-expect-error
override errMsg : string
constructor(name : string, address : string, latitude : number, longitude : number, errMsg : string = 'chooseLocation:ok') {
super()
this.errMsg = errMsg
this.name = name
this.address = address
this.latitude = latitude
this.longitude = longitude
}
}
export class ChooseLocationFailImpl extends UniError implements ChooseLocationFail {
override errCode : ChooseLocationErrorCode
constructor(errMsg : string = 'chooseLocation:fail cancel', errCode : ChooseLocationErrorCode = 4) {
super(errMsg)
this.errCode = errCode
}
}
// #endif
import { defineAsyncApi, registerSystemRoute } from "@dcloudio/uni-runtime";
import uniChooseLocationPage from "@/uni_modules/uni-chooseLocation/pages/chooseLocation/chooseLocation.vue";
import { ChooseLocation, ChooseLocationOptions, ChooseLocationSuccess, ChooseLocationFail } from "../interface.uts"
export const chooseLocation: ChooseLocation = defineAsyncApi('chooseLocation', (
options: ChooseLocationOptions, { resolve, reject }
) => {
registerSystemRoute("uni:chooseLocation", uniChooseLocationPage);
const uuid = Date.now() + '' + Math.floor(Math.random() * 1e7)
const baseEventName = `uni_choose_location_${uuid}`
const readyEventName = `${baseEventName}_ready`
const optionsEventName = `${baseEventName}_options`
const successEventName = `${baseEventName}_success`
const failEventName = `${baseEventName}_fail`
uni.$on(readyEventName, () => {
uni.$emit(optionsEventName, JSON.parse(JSON.stringify(options)))
})
uni.$on(successEventName, (result: ChooseLocationSuccess) => {
resolve(result)
})
uni.$on(failEventName, () => {
reject('cancel', {
errCode: 1
})
})
uni.openDialogPage({
url: `uni:chooseLocation?readyEventName=${readyEventName}&optionsEventName=${optionsEventName}&successEventName=${successEventName}&failEventName=${failEventName}`,
fail(err) {
options.fail?.({ errMsg: `chooseLocation:fail ${err.errMsg}`, errCode: 4 } as ChooseLocationFail)
uni.$off(readyEventName)
uni.$off(successEventName)
uni.$off(failEventName)
}
})
});
......@@ -37,7 +37,7 @@
"name": "createInnerAudioContext",
"app": {
"js": false,
"kotlin": false,
"kotlin": true,
"swift": false,
"arkts": true
}
......
{
"dependencies": [
"com.google.android.exoplayer:exoplayer-core:2.18.0"
]
}
\ No newline at end of file
import { InnerAudioContext, CreateInnerAudioContext } from "../interface.uts"
export { CreateInnerAudioContextFailImpl } from '../unierror.uts'
export const createInnerAudioContext : CreateInnerAudioContext = function () : InnerAudioContext {
let player = new AudioPlayer()
return player
}
\ No newline at end of file
import { media } from '@kit.MediaKit';
import { audio } from '@kit.AudioKit';
import { InnerAudioContext, CreateInnerAudioContext } from '../interface.uts';
import { InnerAudioContext, CreateInnerAudioContext, type ICreateInnerAudioContextFail } from '../interface.uts';
import { API_CREATE_INNER_AUDIO_CONTEXT } from '../protocol.uts';
import { getFdFromUriOrSandBoxPath, isFileUri, isSandboxPath, AudioPlayerCallback, AudioPlayerError } from './utils.uts';
......@@ -254,7 +254,7 @@ class AudioPlayer implements InnerAudioContext {
onTimeUpdate(callback: (result: any) => void): void {
this.audioPlayerCallback.onTimeUpdate(callback)
}
onError(callback: (result: any) => void): void {
onError(callback: (result: ICreateInnerAudioContextFail) => void): void {
this.audioPlayerCallback.onError(callback)
}
onWaiting(callback: (result: any) => void): void {
......@@ -284,7 +284,7 @@ class AudioPlayer implements InnerAudioContext {
offTimeUpdate(callback: (result: any) => void): void {
this.audioPlayerCallback.offTimeUpdate(callback)
}
offError(callback: (result: any) => void): void {
offError(callback: (result: ICreateInnerAudioContextFail) => void): void {
this.audioPlayerCallback.offError(callback)
}
offWaiting(callback: (result: any) => void): void {
......
import { CreateInnerAudioContextErrorCode, ICreateInnerAudioContextFail } from "./interface.uts"
/**
* 错误主题
*/
export const CreateInnerAudioUniErrorSubject = 'uni-createInnerAudioContext';
/**
* 错误码
* @UniError
*/
export const CreateInnerAudioContextUniErrors : Map<CreateInnerAudioContextErrorCode, string> = new Map([
/**
* 系统错误
*/
[1107601, 'system error.'],
/**
* 网络错误
*/
[1107602, 'network error.'],
/**
* 文件错误
*/
[1107603, 'file error.'],
/**
* 格式错误
*/
[1107604, 'format error.'],
/**
* 未知错误
*/
[1107605, 'unknown error.'],
/**
* 播放路径不能为空
*/
[1107609, 'empty src.'],
]);
export class CreateInnerAudioContextFailImpl extends UniError implements ICreateInnerAudioContextFail {
constructor(errCode : CreateInnerAudioContextErrorCode) {
super();
this.errSubject = CreateInnerAudioUniErrorSubject;
this.errCode = errCode;
this.errMsg = CreateInnerAudioContextUniErrors[errCode] ?? "";
}
}
\ No newline at end of file
此差异已折叠。
......@@ -39,7 +39,7 @@
"app": {
"js": true,
"kotlin": true,
"swift": false,
"swift": true,
"arkts": true
}
}
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册