53 lines
1.3 KiB
Vue
53 lines
1.3 KiB
Vue
<template>
|
|
<van-image :src="src" />
|
|
<pre>DEBUG: {{ debug }}</pre>
|
|
<van-button type="primary" @click="takePicture">
|
|
Make photo naxuy
|
|
</van-button>
|
|
|
|
<!-- <van-uploader :after-read="afterRead" /> -->
|
|
<!-- <van-image :src="imageUrl" /> -->
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera'
|
|
|
|
// const file = ref()
|
|
//
|
|
const src = ref()
|
|
const debug = ref('')
|
|
|
|
async function takePicture() {
|
|
const photo = await Camera.getPhoto({
|
|
resultType: CameraResultType.Uri,
|
|
source: CameraSource.Photos,
|
|
width: 200,
|
|
height: 200,
|
|
quality: 90,
|
|
})
|
|
debug.value = photo
|
|
src.value = photo.webPath
|
|
|
|
// const requestResult = await Camera.requestPermissions({ permissions: ['photos'] })
|
|
//
|
|
// if (requestResult.state === 'granted') {
|
|
// try {
|
|
// const {photos} = await Camera.pickImages({ width: 200, height: 200, quality: 90, limit: 1 })
|
|
// debug.value = photos
|
|
// src.value = photos[0].webPath
|
|
// }
|
|
// catch (e) {
|
|
// debug.value = e
|
|
// }
|
|
// }
|
|
}
|
|
|
|
// const imageUrl = ref('')
|
|
// function afterRead(file) {
|
|
// // Создаем URL из файла
|
|
// const url = URL.createObjectURL(file.file)
|
|
// // Обновляем реактивную ссылку
|
|
// imageUrl.value = url
|
|
// }
|
|
</script>
|