Browse Source

10.28

master
lichong 5 months ago
parent
commit
a0847885d1
  1. 1
      src/main/index.js
  2. 29
      src/renderer/src/components/formcomponent.vue

1
src/main/index.js

@ -11,6 +11,7 @@ function createWindow() {
minWidth: 1366, minWidth: 1366,
minHeight: 900, minHeight: 900,
height: 1260, height: 1260,
width: 1730,
show: false, show: false,
autoHideMenuBar: true, autoHideMenuBar: true,
icon: logoIcon, icon: logoIcon,

29
src/renderer/src/components/formcomponent.vue

@ -24,19 +24,23 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<video :ref="`${formItem.prop}video`" style="width: 200px;height: 200px;border: 1px solid #ccc;" <video :ref="`${formItem.prop}video`"
autoplay playsinline v-show="!formData[formItem.prop]"></video> :style="`width: ${width}px;height: ${height}px;border: 1px solid #ccc;`" autoplay playsinline
<canvas :ref="`${formItem.prop}canvas`" width="202" height="202" style="display: none;"></canvas> v-show="!formData[formItem.prop]"></video>
<img v-if="formData[formItem.prop]" :src="formData[formItem.prop]" alt="Captured Photo" /> <canvas :ref="`${formItem.prop}canvas`" :width="width" :height="height"
style="display: none;"></canvas>
<el-image v-if="formData[formItem.prop]" :src="formData[formItem.prop]" :zoom-rate="1.2"
:max-scale="7" :min-scale="0.2" :preview-src-list="[formData[formItem.prop]]" :initial-index="4"
fit="cover" :style="`width: ${width}px;height: ${height}px;`" />
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
<div v-else> <div v-else>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-image style="width: 100px; height: 100px" :src="formData[formItem.prop]" :zoom-rate="1.2" <el-image :style="`width: ${width}px;height: ${height}px;`" :src="formData[formItem.prop]"
:max-scale="7" :min-scale="0.2" :preview-src-list="[formData[formItem.prop]]" :initial-index="4" :zoom-rate="1.2" :max-scale="7" :min-scale="0.2" :preview-src-list="[formData[formItem.prop]]"
fit="cover" /> :initial-index="4" fit="cover" />
</el-col> </el-col>
</el-row> </el-row>
</div> </div>
@ -80,18 +84,20 @@ export default {
return { return {
_: _, _: _,
dayjs: dayjs, dayjs: dayjs,
width: 569,
height: 320,
} }
}, },
methods: { methods: {
async openVedio(formItem) { async openVedio(formItem) {
let that = this
try { try {
this.formData[formItem.prop] = "" this.formData[formItem.prop] = ""
let stream = await navigator.mediaDevices.getUserMedia({ let stream = await navigator.mediaDevices.getUserMedia({
video: { video: {
width: { ideal: 200 }, width: { ideal: that.width },
height: { ideal: 200 } height: { ideal: that.height }
}, },
}); });
this.$refs[`${formItem.prop}video`][0].srcObject = stream; this.$refs[`${formItem.prop}video`][0].srcObject = stream;
} catch (e) { } catch (e) {
@ -103,10 +109,11 @@ export default {
} }
}, },
takePhoto(formItem) { takePhoto(formItem) {
let that = this
let video = this.$refs[`${formItem.prop}video`][0] let video = this.$refs[`${formItem.prop}video`][0]
let canvas = this.$refs[`${formItem.prop}canvas`][0] let canvas = this.$refs[`${formItem.prop}canvas`][0]
let context = canvas.getContext('2d'); let context = canvas.getContext('2d');
context.drawImage(video, 0, 0, 202, 202); context.drawImage(video, 0, 0, that.width, that.height);
this.formData[formItem.prop] = canvas.toDataURL('image/png'); this.formData[formItem.prop] = canvas.toDataURL('image/png');
}, },
// //

Loading…
Cancel
Save