袁磊 3 weeks ago
parent
commit
f6029c4409
  1. 25
      App.vue
  2. 39
      permission.js
  3. 28
      utils/accessLog.js

25
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()){

39
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
}

28
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);
}
Loading…
Cancel
Save