From f6029c44093dcbe12397164d787c1466117047e7 Mon Sep 17 00:00:00 2001 From: yuanlei <18627959669@163.com> Date: Fri, 28 Mar 2025 17:00:46 +0800 Subject: [PATCH] 1 --- App.vue | 25 +++++++++++++++++++++++++ permission.js | 39 +-------------------------------------- utils/accessLog.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 38 deletions(-) create mode 100644 utils/accessLog.js diff --git a/App.vue b/App.vue index 101a6c1..ccaba33 100644 --- a/App.vue +++ b/App.vue @@ -2,6 +2,8 @@ import store from '@/store' import socketStore from '@/uni_modules/vrapile-im/store' import { getToken } from '@/utils/token' + import { setNodeId, getNodeId } from '@/utils/nodeId' + import { getLongRandom } from '@/utils/nineTool'; export default { globalData: { // appId @@ -40,6 +42,29 @@ } }); // #endif + // 终端 + this.globalData.terminal = "unine_other"; + // #ifdef MP-WEIXIN + this.globalData.terminal = "unine_wx"; + // #endif + // #ifdef H5 + this.globalData.terminal = "unine_h5"; + // #endif + // #ifdef APP-PLUS + this.globalData.terminal = "unine_app"; + // #endif + + // 节点 + let nodeId = getNodeId(); + if(!nodeId){ + nodeId = getLongRandom(24) + setNodeId(nodeId) + } + + // 扫码进来携带的数据 + if(options && options.query && options.query.invitee){ + this.globalData.invitee = options.query.invitee; + } }, initWebSocket(){ if(getToken()){ diff --git a/permission.js b/permission.js index 03ae2c4..501d689 100644 --- a/permission.js +++ b/permission.js @@ -1,8 +1,6 @@ import store from '@/store' import { getToken } from '@/utils/token' -import { setNodeId, getNodeId } from '@/utils/nodeId' -import { diyApi } from '@/utils/queryByDiy'; -import { getLongRandom } from '@/utils/nineTool'; +import { saveAccessLog } from '@/utils/accessLog' // 登录页面 const loginPage = "/pages/user/login" @@ -22,40 +20,6 @@ function checkWhite(url) { return whiteList.indexOf(path) !== -1 } -// 保存访问日志 -function saveAccessLog(to, f) { - // 开发环境不保存日志 - if(import.meta.env.VITE_APP_ENV == 'development'){ - return; - } - // 生成一个nodeId,用于记录日志 - let nodeId = getNodeId(); - if(!nodeId){ - nodeId = getLongRandom(24) - setNodeId(nodeId) - } - let flag = "udemo_im_other_" + f; - // #ifdef MP-WEIXIN - flag = "udemo_im_wx_" + f; - // #endif - // #ifdef H5 - flag = "udemo_im_h5_" + f; - // #endif - // #ifdef APP-PLUS - flag = "udemo_im_app_" + f; - // #endif - let data = { - flag: flag, - fullPath: to.url.split("?")[0], - allPath: to.url, - menuName: to.tabBarText, - userId: store.state.user.userInfo.userId, - userName: store.state.user.userInfo.userName, - nodeId: nodeId - } - diyApi("/system/log/insSysAccessLog", data); -} - // 页面跳转验证拦截器 let list = ["navigateTo", "redirectTo", "reLaunch", "switchTab"] list.forEach(item => { @@ -84,7 +48,6 @@ list.forEach(item => { }).then(() => { store.dispatch('GetInfo'); }) - return true } return true } diff --git a/utils/accessLog.js b/utils/accessLog.js new file mode 100644 index 0000000..82515c4 --- /dev/null +++ b/utils/accessLog.js @@ -0,0 +1,28 @@ +import store from '@/store' +import { diyApi } from '@/utils/queryByDiy'; +import { setNodeId, getNodeId } from '@/utils/nodeId' +import { getLongRandom } from '@/utils/nineTool'; + +export function saveAccessLog(to, f) { + // 开发环境不保存日志 + if(import.meta.env.VITE_APP_ENV == 'development'){ + return; + } + // 生成一个nodeId,用于记录日志 + let nodeId = getNodeId(); + if(!nodeId){ + nodeId = getLongRandom(24) + setNodeId(nodeId) + } + let flag = getApp().globalData.terminal + "_" + f; + let data = { + flag: flag, + fullPath: to.url.split("?")[0], + allPath: to.url, + menuName: to.tabBarText, + userId: store.state.user.userInfo.userId, + userName: store.state.user.userInfo.userName, + nodeId: nodeId + } + diyApi("/system/log/insSysAccessLog", data); +}