From 768f4ce1141015ef79d9143fbf4754ffe5b0e8a9 Mon Sep 17 00:00:00 2001 From: duan Date: Mon, 29 Aug 2022 18:44:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(src/views/user):=20=E4=BA=BA=E8=84=B8?= =?UTF-8?q?=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 1 + .env.production | 1 + .env.staging | 1 + src/api/user/user.js | 48 ++++++++++++----- src/utils/index.js | 37 +++++++++++++- src/views/user/index.vue | 108 ++++++++++++++++++++------------------- 6 files changed, 129 insertions(+), 67 deletions(-) diff --git a/.env.development b/.env.development index 594e95f..f40f389 100644 --- a/.env.development +++ b/.env.development @@ -3,3 +3,4 @@ ENV = 'development' # base api VUE_APP_BASE_API = 'http://111.231.67.55:9001' +VUE_APP_FACE_API = 'http://127.0.0.1:5000' diff --git a/.env.production b/.env.production index 80c8103..b138f14 100644 --- a/.env.production +++ b/.env.production @@ -3,4 +3,5 @@ ENV = 'production' # base api VUE_APP_BASE_API = '/prod-api' +VUE_APP_FACE_API ='http://127.0.0.1:5000' diff --git a/.env.staging b/.env.staging index 183130f..d83a89f 100644 --- a/.env.staging +++ b/.env.staging @@ -5,4 +5,5 @@ ENV = 'staging' # base api VUE_APP_BASE_API = 'http://111.231.67.55:9001' +VUE_APP_FACE_API='http://127.0.0.1:5000' diff --git a/src/api/user/user.js b/src/api/user/user.js index 944898d..da08801 100644 --- a/src/api/user/user.js +++ b/src/api/user/user.js @@ -114,17 +114,37 @@ export function get_role_name_list(data) { data }) } -// export function getInfo(token) { -// return request({ -// url: '/vue-admin-template/userinfo/info', -// method: 'get', -// params: { token } -// }) -// } -// -// export function logout() { -// return request({ -// url: '/api/userinfo/logout', -// method: 'post' -// }) -// } + +export function faceStart() { + return request({ + url: '/face/startrecognition/', + method: 'get', + baseURL: process.env.VUE_APP_FACE_API + }) +} + +export function faceStop() { + return request({ + url: '/face/stoprecognition/', + method: 'get', + baseURL: process.env.VUE_APP_FACE_API + }) +} + +export function faceRecognition(data) { + return request({ + url: '/face/recognition/', + method: 'post', + baseURL: process.env.VUE_APP_FACE_API, + data + }) +} + +export function faceAdd(data) { + return request({ + url: '/face/add/', + method: 'post', + baseURL: process.env.VUE_APP_FACE_API, + data + }) +} diff --git a/src/utils/index.js b/src/utils/index.js index 2c6c40c..6f16d2a 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -48,7 +48,9 @@ export function parseTime(time, cFormat) { const time_str = format.replace(/{([ymdhisa])+}/g, (result, key) => { const value = formatObj[key] // Note: getDay() returns 0 on Sunday - if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] } + if (key === 'a') { + return ['日', '一', '二', '三', '四', '五', '六'][value] + } return value.toString().padStart(2, '0') }) return time_str @@ -208,3 +210,36 @@ export let userMedia = function(constraints, success, error) { userMedia(constraints, success, error) } +export const web_stream = { + get: function(url, callback) { + let webClient + + if (url.startsWith('http://')) { + webClient = require('http') + } else if (url.startsWith('https://')) { + webClient = require('https') + } else { + // eslint-disable-next-line no-throw-literal + throw 'Unsupported protocol.' + } + + const clientRequest = webClient.get(url, function(response) { + response.on('data', function(chunk) { + // let data = chunk.toString().split(/\r\n/); + callback(chunk) + }) + }) + + return { + url: url, + handler: clientRequest, + on: function(type, listener) { + clientRequest.on(type, listener) + }, + destroy: function() { + clientRequest.destroy() + } + } + } +} + diff --git a/src/views/user/index.vue b/src/views/user/index.vue index cb01efb..5c03948 100644 --- a/src/views/user/index.vue +++ b/src/views/user/index.vue @@ -183,13 +183,14 @@
-
程小红
@@ -205,11 +206,19 @@