king
2024-02-01 416b7c8bc2d9095b17e7a3c5fc239e1a5f107a30
大接口加密
2个文件已修改
70 ■■■■ 已修改文件
src/utils/utils-datamanage.js 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils.js 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils-datamanage.js
@@ -568,8 +568,6 @@
  let param = {
    func: 'sPC_Get_structured_data',
    LText: _LText.join(' union all '),
    LText_field: LText_field.join(' union all '),
    BID: BID,
    username: sessionStorage.getItem('User_Name') || '',
    fullName: sessionStorage.getItem('Full_Name') || ''
@@ -579,12 +577,13 @@
    param.menuname = config.MenuName
  }
  let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
  param.LText1 = LText1
  param.LText = LText
  param.LText2 = LText2
  param.LText_field = Utils.formatOptions(param.LText_field)
  param.exec_type = 'y'
  param.LText = Utils.formatOptions(_LText.join(' union all '))
  param.custom_script = Utils.formatOptions(LText_field.join(' union all '))
  // param.LText1 = LText1
  // param.LText = LText
  // param.LText2 = LText2
  // param.LText_field = Utils.formatOptions(param.LText_field)
  if (config.cacheUseful === 'true') {
    param.time_type = config.timeUnit
@@ -596,7 +595,7 @@
  }
  param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
  param.secretkey = Utils.encrypt(param.LText, param.timestamp)
  param.secretkey = Utils.encrypt('', param.timestamp)
  return param
}
src/utils/utils.js
@@ -171,59 +171,6 @@
  // }
  /**
   * @description sPC_TableData_InUpDe sql加密
   * @return {String}  value
   */
  static sPCInUpDeFormatOptions (value) {
    if (!value) return {LText: '', LText1: '', LText2: ''}
    let salt = 'minKe' // 盐值
    value = value.replace(/\n/ig, ' \n ')
    // 替换关键字
    formatKeys.forEach(item => {
      let reg = new RegExp('(^|\\s)' + item.key + '(\\s|$)', 'ig')
      value = value.replace(reg, item.value)
    })
    // 1、替换%符(数据库中解析后sql报错)
    value = value.replace(/%/ig, ' mpercent ')
    // 外联数据库替换
    if (window.GLOB.externalDatabase !== null) {
      value = value.replace(/@db@/ig, window.GLOB.externalDatabase)
    }
    let encodesql = (val) => {
      if (!val) return ''
      let _value = window.btoa(window.encodeURIComponent(val))
      // 插入字符
      let index = Math.floor(_value.length / 2)
      _value = _value.slice(0, index) + salt + _value.slice(index)
      // base64加密
      return window.btoa(_value)
    }
    let len = value.length
    // 注:LText 与 LText1 顺序颠倒
    if (len > 1000) {
      let limit = Math.floor(len / 3)
      return {
        LText1: encodesql(value.substring(0, limit)),
        LText: encodesql(value.substring(limit, limit * 2)),
        LText2: encodesql(value.substring(limit * 2))
      }
    } else {
      return {
        LText1: '',
        LText: encodesql(value),
        LText2: ''
      }
    }
  }
  /**
   * @description 初始化搜索条件初始值
   * @param {Array}   searches     搜索条件
   */