|
|
@@ -1,24 +1,45 @@
|
|
|
<template>
|
|
|
|
|
|
- <div>{{useUserInfoStore.userInfo.account_name}}</div>
|
|
|
- <div>{{useUserInfoStore.userInfo.phone}}</div>
|
|
|
-
|
|
|
+ <template v-if="!show">
|
|
|
+ <div>{{useUserInfoStore.userInfo.account_name}}</div>
|
|
|
+ <div>{{useUserInfoStore.userInfo.phone}}</div>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <img :src="src" width="500px" height="500px"/>
|
|
|
+ <img :src="preview" width="500px" height="500px"/>
|
|
|
+ </template>
|
|
|
|
|
|
|
|
|
<div class="mb-4">
|
|
|
+
|
|
|
+ <el-button @click="showVideo">实时预览</el-button>
|
|
|
+ <el-button @click="hideVideo">关闭预览</el-button>
|
|
|
+ <el-button @click="takePictures">拍照</el-button>
|
|
|
+ <el-button @click="socketConnect">socket 连接</el-button>
|
|
|
+ <el-button @click="socketDisconnect">socket 断开</el-button>
|
|
|
+
|
|
|
+
|
|
|
<el-button @click="loginError">登录失败</el-button>
|
|
|
<el-button type="primary" @click="loginIn">登录成功</el-button>
|
|
|
- <el-button type="success">Success</el-button>
|
|
|
- <el-button type="info">Info</el-button>
|
|
|
- <el-button type="warning">Warning</el-button>
|
|
|
- <el-button type="danger">Danger</el-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+
|
|
|
+ <div class="mb-4">
|
|
|
+ <el-input v-model="paramsKey" placeholder="参数名称"></el-input>
|
|
|
+ <el-input v-model="paramsValue" placeholder="参数值"></el-input>
|
|
|
+ <el-button @click="setParams">保存</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
+import { ref } from 'vue'
|
|
|
import useUserInfo from "@/stores/modules/user";
|
|
|
const useUserInfoStore = useUserInfo();
|
|
|
import { login,getUserInfo } from '@/apis/user'
|
|
|
+import client from "@/stores/modules/client";
|
|
|
+import icpList from '@/utils/ipc'
|
|
|
+const clientStore = client();
|
|
|
+console.log(icpList);
|
|
|
|
|
|
|
|
|
async function loginIn() {
|
|
|
@@ -42,7 +63,6 @@ async function loginIn() {
|
|
|
|
|
|
}
|
|
|
async function loginError() {
|
|
|
- console.log('bbb')
|
|
|
const res = await login({
|
|
|
"site":1,
|
|
|
"username":"18679381902",
|
|
|
@@ -51,6 +71,123 @@ async function loginError() {
|
|
|
})
|
|
|
console.log(res)
|
|
|
}
|
|
|
+
|
|
|
+const show = ref(false)
|
|
|
+const imgKey = ref(0)
|
|
|
+const src = ref('http://localhost:5513/liveview.jpg')
|
|
|
+let interval:any = null
|
|
|
+function showVideo(){
|
|
|
+ if(clientStore.isClient){
|
|
|
+
|
|
|
+ console.log(clientStore.ipc)
|
|
|
+ clientStore.ipc.removeAllListeners(icpList.camera.PreviewShow);
|
|
|
+
|
|
|
+ clientStore.ipc.send(icpList.camera.PreviewShow);
|
|
|
+ clientStore.ipc.on(icpList.camera.PreviewShow, async (event, result) => {
|
|
|
+
|
|
|
+ show.value = true;
|
|
|
+ src.value = `http://localhost:5513/liveview.jpg?key=${imgKey.value}`
|
|
|
+ interval = setInterval(()=>{
|
|
|
+ imgKey.value++;
|
|
|
+ src.value = `http://localhost:5513/liveview.jpg?key=${imgKey.value}`
|
|
|
+ },100)
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const preview = ref('http://localhost:5513/preview.jpg')
|
|
|
+const previewKey = ref(0)
|
|
|
+
|
|
|
+function hideVideo(){
|
|
|
+ if(clientStore.isClient){
|
|
|
+
|
|
|
+ clientStore.ipc.removeAllListeners(icpList.camera.PreviewHide);
|
|
|
+
|
|
|
+ clientStore.ipc.send(icpList.camera.PreviewHide);
|
|
|
+ clientStore.ipc.on(icpList.camera.PreviewHide, async (event, result) => {
|
|
|
+ show.value = false;
|
|
|
+ if(interval) clearInterval(interval)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const paramsKey = ref('')
|
|
|
+const paramsValue = ref('')
|
|
|
+
|
|
|
+
|
|
|
+function setParams(){
|
|
|
+ if(clientStore.isClient){
|
|
|
+
|
|
|
+ clientStore.ipc.removeAllListeners(icpList.camera.setParams);
|
|
|
+
|
|
|
+ clientStore.ipc.send(icpList.camera.setParams,{
|
|
|
+ key:paramsKey.value,
|
|
|
+ value:paramsValue.value
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function takePictures(){
|
|
|
+ if(clientStore.isClient){
|
|
|
+
|
|
|
+ clientStore.ipc.removeAllListeners(icpList.camera.takePictures);
|
|
|
+
|
|
|
+ clientStore.ipc.send(icpList.camera.takePictures);
|
|
|
+
|
|
|
+ clientStore.ipc.on(icpList.camera.takePictures, async (event, result) => {
|
|
|
+
|
|
|
+
|
|
|
+ setTimeout(()=>{
|
|
|
+ previewKey.value++;
|
|
|
+ preview.value = `http://localhost:5513/preview.jpg?key=${previewKey.value}`
|
|
|
+ },1000)
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function socketConnect(){
|
|
|
+
|
|
|
+ if(clientStore.isClient){
|
|
|
+
|
|
|
+ clientStore.ipc.removeAllListeners(icpList.socket.connect);
|
|
|
+
|
|
|
+ clientStore.ipc.send(icpList.socket.connect);
|
|
|
+
|
|
|
+ clientStore.ipc.on(icpList.socket.connect, async (event, result) => {
|
|
|
+ console.log(result);
|
|
|
+ })
|
|
|
+
|
|
|
+ clientStore.ipc.on(icpList.socket.message, async (event, result) => {
|
|
|
+ console.log('message');
|
|
|
+ console.log(result);
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+function socketDisconnect(){
|
|
|
+
|
|
|
+ if(clientStore.isClient){
|
|
|
+
|
|
|
+ clientStore.ipc.removeAllListeners(icpList.socket.disconnect);
|
|
|
+
|
|
|
+ clientStore.ipc.send(icpList.socket.disconnect);
|
|
|
+
|
|
|
+ clientStore.ipc.on(icpList.socket.disconnect, async (event, result) => {
|
|
|
+ console.log(result);
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|