log.js 1.37 KB
import api from './index';
import baseurl from './baseUrl';
import moment from "moment";
let oplogurl = `${baseurl}/api/v1/log_serv/user_oper_logs`
let userlogurl = `${baseurl}/api/v1/log_serv/system_logs/`

let servicename = {
  serv_task:"任务设置",
  serv_scene:"场景设置",
  serv_store:"存储配置",
  serv_auth:"用户管理",
  serv_system:"系统管理",
  serv_serch:"数据查询"
}
const oplogs = function(data,service,action) {
  //开启日志模式才进行日志收集
  if(window.config.logstatus) {
    let username =  localStorage.getItem('uname');
    let baseData = {
      "dt": moment().locale('zh-cn'),      
      "username": username,       
      "api_type": "http",          
      "verb":     "1",           
      "path":     "***" ,
      "params":  {"*":'*'},            
      "ecode": 0,                  
      "enote": "ok",
      "remark":action,
      "serv_type":service
    }
    api.post(oplogurl,baseData).then(res =>{
      console.log(res)
    });
  }
}
export const syslogs =function(){
  if(config.logstatus) {
    api.post(oplogurl,data).then(res =>{

    });
  }
}
const loglist = {oplogs,syslogs}
const install = function(Vue) {
  if (install.installed) {
    return;
  }
  install.installed = true;
  Object.defineProperties(Vue.prototype, {
    $logs: {
      get() {
        return loglist;
      }
    }
  });
};

export default {
  install
};