人脸比对

This commit is contained in:
2023-09-26 19:29:11 +08:00
parent a4dda571ab
commit 0b51d7c0b7
11 changed files with 1066 additions and 940 deletions

View File

@@ -0,0 +1,17 @@
2023-09-26 09:28:26 -Starting AppServiceApplication on luojie with PID 35820 (E:\workplace\huashi_project\im-system\hs-im-app-server\target\classes started by coolp in E:\workplace\huashi_project\im-system\hs-im-app-server)
2023-09-26 09:28:26 -The following profiles are active: dev
2023-09-26 09:28:26 -Tomcat initialized with port(s): 8989 (http)
2023-09-26 09:28:26 -Initializing ProtocolHandler ["http-nio-8989"]
2023-09-26 09:28:26 -Starting service [Tomcat]
2023-09-26 09:28:26 -Starting Servlet engine: [Apache Tomcat/9.0.37]
2023-09-26 09:28:26 -Initializing Spring embedded WebApplicationContext
2023-09-26 09:28:26 -Root WebApplicationContext: initialization completed in 683 ms
2023-09-26 09:28:28 -Initializing ExecutorService 'applicationTaskExecutor'
2023-09-26 09:28:28 -Starting ProtocolHandler ["http-nio-8989"]
2023-09-26 09:28:28 -Tomcat started on port(s): 8989 (http) with context path ''
2023-09-26 09:28:28 -Started AppServiceApplication in 3.161 seconds (JVM running for 4.084)
2023-09-26 09:28:49 -Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-09-26 09:28:49 -Initializing Servlet 'dispatcherServlet'
2023-09-26 09:28:49 -Completed initialization in 2 ms
2023-09-26 09:28:49 -HikariPool-1 - Starting...
2023-09-26 09:28:50 -HikariPool-1 - Start completed.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,33 +1,116 @@
import fc from '@/common/publicFc.js' import config from "@/common/config.js"
let timer=null let timer = null
let retimer=null let retimer = null
import * as sdk from "@/common/imSdk/lim-sdk.js";
import lim from "@/common/imSdk/sdk-bridge.js";
export default { export default {
socketTask:null, socketTask: null,
// 连接WebSocket // 连接WebSocket
connectSocket() { connectSocket() {
this.socketTask=uni.connectSocket({
const ListenerMap = {
onSocketConnectEvent: (option, status, data) => {
console.log("已建立连接:" + JSON.stringify(status));
},
onSocketErrorEvent: (error) => {
console.log("连接出现错误:" + userId);
},
onSocketReConnectEvent: () => {
console.log("正在重连:");
},
onSocketCloseEvent: () => {
console.log("连接关闭:");
},
onSocketReConnectSuccessEvent: () => {
console.log("重连成功");
},
onTestMessage: (e) => {
console.log("onTestMessage " + e);
},
onP2PMessage: (e) => {
console.log("onP2PMessage " + e);
e = JSON.parse(e)
e.pushType="TEXT"
uni.$emit('onP2PMessage', e.data);
},
onLogin: (uid) => {
console.log("用户" + uid + "登陆sdk成功");
}
};
const userId = uni.getStorageSync("userId")
const imUserSign = uni.getStorageSync("imUserSign")
var listeners = {};
for (const v in ListenerMap) {
listeners[v] = ListenerMap[v];
}
console.log(lim)
if (this.socketTask != null) {
return false
}
lim.lim.im.init(config.getImApiUrl(), config.getImAppId(), userId, imUserSign, listeners, (
sdk) => {
if (sdk) {
console.warn("====================")
this.socketTask = sdk;
console.log(this.socketTask)
console.log('sdk 成功连接的回调, 可以使用 sdk 请求数据了.');
sdk.getAllFriend().then(res => {
console.warn(res)
})
sdk.getUserSequence().then(res => {
console.warn(res)
})
sdk.getUserConversationList(0).then(res => {
console.warn(res)
})
return uni.switchTab({
url: "/pages/tabbar/index/index"
})
} else {
console.log('sdk 初始化失败.');
}
})
/*
this.socketTask = uni.connectSocket({
url: 'wss://im-api.q3z3.com/ws?Authorization=' + uni.getStorageSync('Authorization'), url: 'wss://im-api.q3z3.com/ws?Authorization=' + uni.getStorageSync('Authorization'),
complete: () => {} complete: () => {}
}); });
this.socketTask.onOpen(res => { this.socketTask.onOpen(res => {
console.log('WebSocket连接已打开'); console.log('WebSocket连接已打开');
// 设置心跳 // 设置心跳
timer=setInterval(()=>{ timer = setInterval(() => {
uni.sendSocketMessage({ uni.sendSocketMessage({
data:'isConnact', data: 'isConnact',
success:res=>{ success: res => {
if(res.errMsg=='sendSocketMessage:ok'){ if (res.errMsg == 'sendSocketMessage:ok') {
console.log('WebSocket已连接') console.log('WebSocket已连接')
}else{ } else {
this.connectSocket() this.connectSocket()
} }
} }
}) })
},5000) }, 5000)
}) })
// 监听接收 // 监听接收
this.socketTask.onMessage(res => { this.socketTask.onMessage(res => {
if(res.data=='ok'){ if (res.data == 'ok') {
return return
} }
var data = JSON.parse(res.data); var data = JSON.parse(res.data);
@@ -37,34 +120,35 @@ export default {
// 监听关闭 // 监听关闭
this.socketTask.onClose(res => { this.socketTask.onClose(res => {
console.log('WebSocket连接已关闭'); console.log('WebSocket连接已关闭');
let token= uni.getStorageSync('Authorization'); let token = uni.getStorageSync('Authorization');
if(this.socketTask&&token){ if (this.socketTask && token) {
this.socketTaskClose() this.socketTaskClose()
retimer=setTimeout(()=>{ retimer = setTimeout(() => {
this.connectSocket() this.connectSocket()
},5000) }, 5000)
} }
}) })
// 监听异常 // 监听异常
this.socketTask.onError(res => { this.socketTask.onError(res => {
console.log('WebSocket连接打开失败正在尝试重新打开'); console.log('WebSocket连接打开失败正在尝试重新打开');
if(this.socketTask){ if (this.socketTask) {
this.socketTaskClose() this.socketTaskClose()
retimer=setTimeout(()=>{ retimer = setTimeout(() => {
this.connectSocket() this.connectSocket()
},5000) }, 5000)
} }
}); });
*/
}, },
// 关闭WebSocket // 关闭WebSocket
socketTaskClose() { socketTaskClose() {
if(this.socketTask){ if (this.socketTask) {
this.socketTask.close() this.socketTask.close()
clearInterval(timer) clearInterval(timer)
clearTimeout(retimer) clearTimeout(retimer)
console.log('关闭WebSocket'); console.log('关闭WebSocket');
} }
}, },
} }

View File

@@ -2,9 +2,6 @@ import http from '@/common/request'
import store from './store' import store from './store'
import md5 from "@/common/md5.js"; import md5 from "@/common/md5.js";
import * as sdk from "@/common/imSdk/lim-sdk.js";
import lim from "@/common/imSdk/sdk-bridge.js";
import publicFc from "@/common/publicFc.js"; import publicFc from "@/common/publicFc.js";
@@ -21,6 +18,9 @@ import App from './App'
Vue.config.productionTip = false Vue.config.productionTip = false
Vue.prototype.$socketTask = socketTask;
Vue.prototype.$http = http Vue.prototype.$http = http
Vue.prototype.$store = store Vue.prototype.$store = store
Vue.prototype.$fc = publicFc; Vue.prototype.$fc = publicFc;
@@ -28,7 +28,7 @@ Vue.prototype.$md5 = md5
Vue.prototype.$zmmFormCheck = zmmFormCheck; Vue.prototype.$zmmFormCheck = zmmFormCheck;
Vue.prototype.$pinyin = pinyin; Vue.prototype.$pinyin = pinyin;
// #ifdef H5 // #ifdef H5
Vue.prototype.$socketTask = socketTask;
// uni.lim = lim; // uni.lim = lim;
@@ -50,15 +50,15 @@ import { createSSRApp } from 'vue'
import App from './App.vue' import App from './App.vue'
export function createApp() { export function createApp() {
const app = createSSRApp(App) const app = createSSRApp(App)
app.config.globalProperties.$socketTask = socketTask
app.config.globalProperties.$http = http app.config.globalProperties.$http = http
app.config.globalProperties.$fc = publicFc app.config.globalProperties.$fc = publicFc
app.config.globalProperties.$md5 = md5 app.config.globalProperties.$md5 = md5
app.config.globalProperties.$zmmFormCheck = zmmFormCheck app.config.globalProperties.$zmmFormCheck = zmmFormCheck
app.config.globalProperties.$pinyin = pinyin app.config.globalProperties.$pinyin = pinyin
// #ifdef H5 // #ifdef H5
app.config.globalProperties.$socketTask = socketTask
app.config.globalProperties.imsdk = lim
// #endif // #endif
app.use(store); app.use(store);

View File

@@ -132,11 +132,12 @@ import { createStore } from 'vuex'
uni.setStorageSync(context.state.userInfo.userId+'_'+'chatlistData', JSON.stringify(data2)); uni.setStorageSync(context.state.userInfo.userId+'_'+'chatlistData', JSON.stringify(data2));
// 初始化聊天数据 // 初始化聊天数据
var data1=publicFc.getKeyObjectStorage(context.state.userInfo.userId+'_'+'chatData') var data1=publicFc.getKeyObjectStorage(context.state.userInfo.userId+'_'+'chatData')
return new Promise(function(resolve, reject) { return new Promise((resolve, reject)=>{
if(!data1[userId]){ if(!data1[userId]){
console.log('初始化聊天') console.log('初始化聊天')
switch (windowType){ switch (windowType){
case 'SINGLE': case 'SINGLE':
http.request({ http.request({
url: '/friend/info/'+userId, url: '/friend/info/'+userId,
complete:(res)=>{ complete:(res)=>{

File diff suppressed because it is too large Load Diff

View File

@@ -45,9 +45,7 @@
</template> </template>
<script> <script>
// #ifdef APP-PLUS
const TUICalling = uni.requireNativePlugin("TUICallingUniPlugin-TUICallingModule");
// #endif
export default { export default {
data() { data() {
return { return {
@@ -223,7 +221,9 @@
uni.setStorageSync('appId', data.appId); uni.setStorageSync('appId', data.appId);
uni.setStorageSync('userId', data.userId); uni.setStorageSync('userId', data.userId);
uni.setStorageSync('imUserSign', data.imUserSign); uni.setStorageSync('imUserSign', data.imUserSign);
uni.setStorageSync('userSign', data.userSign); uni.setStorageSync('userCSign', data.userSign);
this.$socketTask.connectSocket()
uni.reLaunch({ uni.reLaunch({
url: '../tabbar1/index' url: '../tabbar1/index'

View File

@@ -21,39 +21,7 @@
</template> </template>
<script> <script>
import config from "@/common/config.js"
const ListenerMap = {
onSocketConnectEvent: (option, status, data) => {
console.log("已建立连接:" + JSON.stringify(status));
},
onSocketErrorEvent: (error) => {
console.log("连接出现错误:" + userId);
},
onSocketReConnectEvent: () => {
console.log("正在重连:");
},
onSocketCloseEvent: () => {
console.log("连接关闭:");
},
onSocketReConnectSuccessEvent: () => {
console.log("重连成功");
},
onTestMessage: (e) => {
console.log("onTestMessage " + e);
},
onP2PMessage: (e) => {
console.log("onP2PMessage " + e);
e = JSON.parse(e)
uni.$emit('P2PMessage', e.data);
},
onLogin: (uid) => {
console.log("用户" + uid + "登陆sdk成功");
}
};
export default { export default {
@@ -191,43 +159,10 @@
}, },
mounted() { mounted() {
console.log(this.imsdk)
this.$socketTask.connectSocket()
var listeners = {};
for (const v in ListenerMap) {
listeners[v] = ListenerMap[v];
}
const userId=uni.getStorageSync("userId")
const imUserSign=uni.getStorageSync("imUserSign")
console.log(this.imsdk)
this.imsdk.lim.im.init(config.getImApiUrl(),config.getImAppId(),userId,imUserSign, listeners, function(
sdk) {
if (sdk) {
console.log('sdk 成功连接的回调, 可以使用 sdk 请求数据了.');
sdk.getAllFriend().then(res=>{
console.warn(res)
})
sdk.getUserSequence().then(res=>{
console.warn(res)
})
sdk.getUserConversationList(0).then(res=>{
console.warn(res)
})
return uni.switchTab({
url: "/pages/tabbar/index/index"
})
} else {
console.log('sdk 初始化失败.');
}
})
}, },
methods: { methods: {

View File

@@ -27,7 +27,7 @@
}) })
*/ */
uni.navigateTo({ uni.navigateTo({
url: '../chatWindow/index?userId=' + e.item.data.userId + '&windowType=' + e.windowType url: '../chatWindow/index?userId=' + e.item.data.userId + '&windowType=' + "SINGLE"
}); });
}, },
getflist(){ getflist(){

View File

@@ -296,7 +296,6 @@ export class ImClient {
}) })
} }
// 2、心跳 // 2、心跳
private heartbeatLoop(conn) { private heartbeatLoop(conn) {
let start = Date.now() let start = Date.now()
@@ -306,7 +305,7 @@ export class ImClient {
return return
} }
if (Date.now() - start >= heartbeatInterval) { if (Date.now() - start >= heartbeatInterval) {
log.info(`>>> send ping ;`) // log.info(`>>> send ping ;`)
start = Date.now() start = Date.now()
let pingPack = imClient.buildMessagePack(SystemCommand.PING, {}); let pingPack = imClient.buildMessagePack(SystemCommand.PING, {});
conn.send(pingPack.pack(false)); conn.send(pingPack.pack(false));