3 Commits
Author SHA1 Message Date
xsl b26022c94f ok 2026-03-12 20:21:10 +08:00
xsl a7ea59d201 save code 2026-03-12 19:35:01 +08:00
xsl 2fe10cd183 save code 2026-03-12 15:47:25 +08:00
20 changed files with 300 additions and 98 deletions
+4
View File
@@ -9,6 +9,10 @@
"customPlaygroundType" : "local",
"playground" : "custom",
"type" : "uni-app:app-ios"
},
{
"playground" : "custom",
"type" : "uni-app:app-android"
}
]
}
+10 -1
View File
@@ -58,7 +58,16 @@
"distribute": {
"modules": {},
"icons": {},
"splashScreens": {}
"splashScreens": {},
"privacyDescription": {
"NSPhotoLibraryUsageDescription": "读取相册",
"NSPhotoLibraryAddUsageDescription": "写入相册",
"NSCameraUsageDescription": "要摄像头",
"NSMicrophoneUsageDescription": "要麦克风",
"NSLocationWhenInUseUsageDescription": "要访问",
"NSLocationAlwaysUsageDescription": "要访问",
"NSLocationAlwaysAndWhenInUseUsageDescription": "要访问"
}
}
}
}
+60 -24
View File
@@ -1,41 +1,77 @@
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view>
<image class="logo" src="/static/logo.png"></image>
<text class="title">{{title}}</text>
<button @click="_takePhoto">拍照</button>
<xf-camera style="height:750rpx; background-color: red;" @error="onError" :flash="flash"
:position="device"></xf-camera>
<image v-if="imagePath" mode="aspectFit" :src="imagePath"></image>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script setup lang="uts">
const title = ref('Hello')
// 相机闪光灯状态('off' | 'on' | 'auto'
const flash = ref('off')
<script>
import {
takePhoto,
TakePhotoOption,
TakePhotoSuccessCallbackResult,
GeneralCallbackResult
} from '@/uni_modules/XF-cameraUTS'
// 相机朝向('front' | 'back'
const device = ref('back')
// 拍摄的图片路径
const imagePath = ref('')
export default {
data() {
return {
yanse: "red",
widthNum: 750,
heightNum: 200,
// 相机错误处理
const onError = (e : any) => {
console.log('相机错误:', e)
// 可在此添加用户提示,如 uni.showToast
flash: "on",
device: "front",
imagePath: "",
videoPath: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4"
}
},
onLoad() {
// let permissionNeed = ["android.permission.CAMERA", "android.permission.RECORD_AUDIO",
// "android.permission.WRITE_EXTERNAL_STORAGE"]
// // 请求权限
// UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permissionNeed, function (allRight : boolean, _ : string[]) {
// if (allRight) {
// // 权限请求成功
// } else {
// //用户拒绝了部分权限
// }
// }, function (_ : boolean, _ : string[]) {
// //用户拒绝了部分权限
// })
},
methods: {
onError(res : any) {
console.log(res)
},
_takePhoto() {
takePhoto({
success: (res : TakePhotoSuccessCallbackResult) => {
console.log('takePhoto', res)
this.imagePath = res.tempImagePath;
// _previewImage();
},
fail: (res : GeneralCallbackResult) => {
console.log('takePhoto', res)
}
} as TakePhotoOption)
}
}
}
</script>
<style>
.logo {
height: 100px;
width: 100px;
margin: 100px auto 25px auto;
}
.title {
font-size: 18px;
color: #8f8f94;
text-align: center;
.video {
width: 100%;
height: 200px;
}
</style>
-2
View File
@@ -1,2 +0,0 @@
## 1.0.0
初始化发布
-52
View File
@@ -1,52 +0,0 @@
# **概述**
Skin-cameraUTS封装了Android和iOS自定义相机预览的功能。
## **模块调用**
```js
<xf-camera style="height:750rpx; background-color: red;" @ready="ready" @error="onError" @stop="stop" :flash="flash" :position="device">
</xf-camera>
```
## 参数说明:
position
- 类型:字符串型
- 描述:(可选项)前置或者后置相机。(front前置 |back 后置)
flash
- 类型:字符串型
- 描述:(可选项)是否开启闪光灯。( auto, on, off, torch)
## **插件接口**
<div id="a0"></div>
# **takePhoto**
拍照
## uni-app x项目(uvue)中调用示例:
```js
import { takePhoto } from "@/uni_modules/Skin-cameraUTS";
import { TakePhotoOption, TakePhotoSuccessCallbackResult } from "@/uni_modules/Skin-cameraUTS/utssdk/interface.uts";
let options = {
success: (res : TakePhotoSuccessCallbackResult) => {
console.log(res)
}
} as TakePhotoOption;
takePhoto(options);
```
## 可用性
iOS、Android系统
可提供的1.0.0及更高版本
+24
View File
@@ -0,0 +1,24 @@
## 1.1.12025-10-15
修复监听持续返回事件问题。
## 1.1.02024-10-13
修改AndroidManifest.xml下的包名。
## 1.0.92024-10-12
删除takePhoto下的takeMode参数逻辑
## 1.0.82024-10-10
兼容处理uniapp无法切换相机和拍照的问题。
## 1.0.72024-10-09
修复uniapp环境下不能正常使用插件问题。
## 1.0.62024-09-13
去掉插件内部权限申请逻辑。
## 1.0.52024-08-10
修复Android不能正常录像的问题。
## 1.0.42024-08-08
修复iOS默认相机设置不生效的问题
## 1.0.32024-08-06
修改iOS拍照接口默认质量为原图。
## 1.0.22024-07-22
修复iOS编译问题。
## 1.0.12024-07-04
修复一些bug。
## 1.0.02024-07-04
初始化发布
@@ -1,8 +1,8 @@
{
"id": "Skin-cameraUTS",
"id": "XF-cameraUTS",
"displayName": "UTS实现自定义相机拍照和录像功能",
"version": "1.0.0",
"description": "封装了Android和iOS自定义相机预览的功能。",
"version": "1.1.1",
"description": "XF-cameraUTS封装了Android和iOS自定义相机预览的功能。",
"keywords": [
"相机",
"录像",
@@ -18,7 +18,7 @@
"type": "component-uts",
"sale": {
"regular": {
"price": "0.00"
"price": "168.00"
},
"sourcecode": {
"price": "0.00"
+183
View File
@@ -0,0 +1,183 @@
# **概述**
XF-cameraUTS封装了Android和iOS自定义相机预览的功能。
## **模块调用**
```js
<xf-camera style="height:750rpx; background-color: red;" @ready="ready" @error="onError" @stop="stop" :flash="flash" :position="device">
</xf-camera>
```
## 参数说明:
position
- 类型:字符串型
- 描述:(可选项)前置或者后置相机。(front前置 |back 后置)
flash
- 类型:字符串型
- 描述:(可选项)是否开启闪光灯。( auto, on, off, torch)
## **插件接口**
<div id="a0"></div>
# **takePhoto**
拍照
## uni-app项目中(nvue)调用示例:
```js
import { takePhoto } from "@/uni_modules/XF-cameraUTS"
takePhoto({
success: (res) => {
console.log(res)
}
});
```
## uni-app x项目(uvue)中调用示例:
```js
import { takePhoto } from "@/uni_modules/XF-cameraUTS";
import { TakePhotoOption, TakePhotoSuccessCallbackResult } from "@/uni_modules/XF-cameraUTS/utssdk/interface.uts";
let options = {
success: (res : TakePhotoSuccessCallbackResult) => {
console.log(res)
}
} as TakePhotoOption;
takePhoto(options);
```
## 可用性
iOS、Android系统
可提供的1.0.0及更高版本
<div id="a1"></div>
# **startRecord**
开始录像
## uni-app项目中(nvue)调用示例:
```js
import { startRecord } from "@/uni_modules/XF-cameraUTS"
startRecord({
success: (res) => {
console.log(res)
}
});
```
## uni-app x项目(uvue)中调用示例:
```js
import { startRecord } from "@/uni_modules/XF-cameraUTS";
import { CameraContextStartRecordOption, GeneralCallbackResult } from "@/uni_modules/XF-cameraUTS/utssdk/interface.uts";
let options = {
success: (res : GeneralCallbackResult) => {
console.log(res)
}
} as CameraContextStartRecordOption;
startRecord(options);
```
## 可用性
iOS、Android系统
可提供的1.0.0及更高版本
<div id="a2"></div>
# **stopRecord**
停止录像
## uni-app项目中(nvue)调用示例:
```js
import { stopRecord } from "@/uni_modules/XF-cameraUTS"
stopRecord({
success: (res) => {
console.log(res)
}
});
```
## uni-app x项目(uvue)中调用示例:
```js
import { stopRecord } from "@/uni_modules/XF-cameraUTS";
import { CameraContextStopRecordOption, StopRecordSuccessCallbackResult } from "@/uni_modules/XF-cameraUTS/utssdk/interface.uts";
let options = {
success: (res : StopRecordSuccessCallbackResult) => {
console.log(res)
}
} as CameraContextStopRecordOption;
stopRecord(options);
```
## 可用性
iOS、Android系统
可提供的1.0.0及更高版本
<div id="a3"></div>
# **switchCamera**
切换相机
## uni-app项目中(nvue)调用示例:
```js
import { switchCamera } from "@/uni_modules/XF-cameraUTS"
switchCamera({
position: 'back',
success: (res) => {
console.log(res)
}
});
```
## uni-app x项目(uvue)中调用示例:
```js
import { switchCamera } from "@/uni_modules/XF-cameraUTS";
import { SwitchOption, GeneralCallbackResult } from "@/uni_modules/XF-cameraUTS/utssdk/interface.uts";
let options = {
position: 'back',
success: (res : GeneralCallbackResult) => {
console.log(res)
}
} as SwitchOption;
switchCamera(options);
```
## 可用性
iOS、Android系统
可提供的1.0.8及更高版本