baizonghao
2023-08-04 8fee5b265eaa379b7a1cc51cd060a368c046de46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import crypto from 'crypto'
 
export function rsaEncryptStr (publicKey, text) {
  let pubKey = '-----BEGIN PUBLIC KEY-----' + publicKey + '-----END PUBLIC KEY-----'
  let bufferText = Buffer.from(text, 'utf8')
  return crypto.publicEncrypt({ key: pubKey, padding: crypto.constants.RSA_PKCS1_PADDING }, bufferText).toString('base64')
}
 
export function formatSeconds (theTime) {
  let theTime1 = 0
  let theTime2 = 0
  if (theTime > 60) {
    theTime1 = parseInt(theTime / 60)
    theTime = parseInt(theTime % 60)
    if (theTime1 > 60) {
      theTime2 = parseInt(theTime1 / 60)
      theTime1 = parseInt(theTime1 % 60)
    }
  }
  let result = '' + parseInt(theTime) + '秒'
  if (theTime1 > 0) {
    result = '' + parseInt(theTime1) + '分' + result
  }
  if (theTime2 > 0) {
    result = '' + parseInt(theTime2) + '小时' + result
  }
  return result
}
 
export function disableEvent () {
  document.oncontextmenu = function () {
    return false
  }
  document.oncopy = function () {
    return false
  }
  document.onselectstart = function () {
    return false
  }
  document.onpaste = function () {
    return false
  }
  document.oncut = function () {
    return false
  }
}