tsfunction createWindow() {
win = new BrowserWindow({
icon: path.join(process.env.VITE_PUBLIC, 'electron-vite.svg'),
webPreferences: {
preload: path.join(__dirname, 'preload.mjs'),
},
// 新增代码
autoHideMenuBar: true,
alwaysOnTop: true,
frame: false,
width: 200,
height: 200,
x: 0,
y: 0,
transparent: true,
center: true,
resizable: false,
})
// other code...
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
vue<script setup lang="ts">
import { onMounted, ref } from 'vue'
const videoRef = ref<HTMLVideoElement>()
const openCamera = async () => {
const stream = await navigator.mediaDevices.getUserMedia({
video: true,
audio: false,
})
videoRef.value!.srcObject = stream
}
onMounted(() => {
openCamera()
})
</script>
<template>
<video ref="videoRef" autoplay></video>
</template>
<style scoped lang="css">
video {
width: 200px;
height: 200px;
object-fit: cover;
border-radius: 50%;
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28