Commit 143939686153b2dd624cdf8bee151b937258b2f0

Authored by ww
1 parent 17a3a771

feat: add crypto-js

Too many changes to show.

To preserve performance only 14 of 15 files are displayed.

No preview for this file type
No preview for this file type
... ... @@ -4,7 +4,7 @@
4 4 "main": "src/main/webapp/index.html",
5 5 "scripts": {
6 6 "start": "cd src/main/webapp && serve",
7   - "build": "cd etc/build && ant"
  7 + "build": "cd etc/build && ant war"
8 8 },
9 9 "license": "MIT",
10 10 "dependencies": {
... ...
No preview for this file type
No preview for this file type
... ... @@ -2,7 +2,8 @@
2 2 <!DOCTYPE html>
3 3 <html>
4 4 <head>
5   - <title>Flowchart Maker &amp; Online Diagram Software</title>
  5 +<!-- <title>Flowchart Maker &amp; Online Diagram Software</title>-->
  6 + <title>thingskit 云组态</title>
6 7 <meta charset="utf-8">
7 8 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8 9 <meta name="Description" content="diagrams.net is free online diagram software for making flowcharts, process diagrams, org charts, UML, ER and network diagrams">
... ... @@ -16,6 +17,15 @@
16 17 <meta name="msapplication-config" content="images/browserconfig.xml">
17 18 <meta name="mobile-web-app-capable" content="yes">
18 19 <meta name="theme-color" content="#d89000">
  20 + <!-- crypto-js -->
  21 + <script src="./js/plugin/crypto-js/crypto-js.js"></script>
  22 +<!-- <script src="./js/plugin/crypto-js/aes.js"></script>-->
  23 +<!-- <script src="./js/plugin/crypto-js/enc-utf8.js"></script>-->
  24 +<!-- <script src="./js/plugin/crypto-js/pad-pkcs7.js"></script>-->
  25 +<!-- <script src="./js/plugin/crypto-js/mode-ecb.js"></script>-->
  26 +<!-- <script src="./js/plugin/crypto-js/md5.js"></script>-->
  27 +<!-- <script src="./js/plugin/crypto-js/enc-utf8.js"></script>-->
  28 +<!-- <script src="./js/plugin/crypto-js/enc-base64.js"></script>-->
19 29 <!-- 全局变量 -->
20 30 <script src="./js/const/const.js"></script>
21 31
... ... @@ -39,7 +49,7 @@
39 49 <!-- <script type="text/javascript" src="./js/jquery.select.zTree.v1.5.min.js"></script>-->
40 50
41 51 <!-- Axios -->
42   - <script src="./plugins/defHttp.js"></script>
  52 + <script src="./plugins/DefHttp.js"></script>
43 53
44 54 <script src="./js/api/index.js"></script>
45 55
... ... @@ -386,15 +396,18 @@
386 396 </script>
387 397 <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/plgmlhohecdddhbmmkncjdmlhcmaachm">
388 398 <link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png">
389   - <link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
  399 +<!-- <link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">-->
  400 + <link rel="icon" type="image/png" sizes="32x32" href="images/logo-32x32.png">
390 401 <link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
  402 +<!-- <link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">-->
391 403 <link rel="mask-icon" href="images/safari-pinned-tab.svg" color="#d89000">
392 404 <link rel="stylesheet" type="text/css" href="styles/grapheditor.css">
393 405 <link rel="stylesheet" type="text/css" href="styles/easyui.css">
394 406 <link rel="preconnect" href="https://storage.googleapis.com">
395 407 <link rel="canonical" href="https://app.diagrams.net">
396 408 <link rel="manifest" href="images/manifest.json">
397   - <link rel="shortcut icon" href="favicon.ico">
  409 +<!-- <link rel="shortcut icon" href="favicon.ico">-->
  410 + <link rel="shortcut icon" href="images/logo-16x16.ico">
398 411 <style type="text/css">
399 412 body { overflow:hidden; }
400 413 div.picker { z-index: 10007; }
... ...
No preview for this file type
1   -const GLOBAL_TOKEN = JSON.parse(localStorage.getItem("UNDEFINED__DEVELOPMENT__2.7.1__COMMON__LOCAL__KEY__")).value.JWT_TOKEN.value
  1 +// const { encrypt, decrypt } = CryptoJS.AES
  2 +// const parse = CryptoJS.enc.Utf8;
  3 +// const pkcs7 = CryptoJS.pad.Pkcs7;
  4 +// const ECB = CryptoJS.mode.ECB;
  5 +// const UTF8 = CryptoJS.enc.Utf8;
  6 +//
  7 +// const cacheCipher = {
  8 +// key: '_11111000001111@',
  9 +// iv: '@11111000001111_',
  10 +// }
  11 +//
  12 +// const DEFAULT_CACHE_TIME = 60 * 60 * 24 * 7;
  13 +//
  14 +// const isNullOrUnDef = (val) => typeof val === 'undefined' || val === null
  15 +//
  16 +// class AesEncryption {
  17 +// key;
  18 +// iv;
  19 +//
  20 +// constructor(opt = {}) {
  21 +// const { key, iv } = opt;
  22 +// if (key) {
  23 +// this.key = parse(key);
  24 +// }
  25 +// if (iv) {
  26 +// this.iv = parse(iv);
  27 +// }
  28 +// }
  29 +//
  30 +// get getOptions() {
  31 +// return {
  32 +// mode: ECB,
  33 +// padding: pkcs7,
  34 +// iv: this.iv,
  35 +// };
  36 +// }
  37 +//
  38 +// encryptByAES(cipherText) {
  39 +// return encrypt(cipherText, this.key, this.getOptions).toString();
  40 +// }
  41 +//
  42 +// decryptByAES(cipherText) {
  43 +// return decrypt(cipherText, this.key, this.getOptions).toString(UTF8);
  44 +// }
  45 +// }
  46 +//
  47 +//
  48 +// const createStorage = (
  49 +// {
  50 +// prefixKey = '',
  51 +// storage = sessionStorage,
  52 +// key = cacheCipher.key,
  53 +// iv = cacheCipher.iv,
  54 +// timeout = null,
  55 +// hasEncrypt = true,
  56 +// } = {}) => {
  57 +// if (hasEncrypt && [ key.length, iv.length ].some((item) => item !== 16)) {
  58 +// throw new Error('When hasEncrypt is true, the key or iv must be 16 bits!');
  59 +// }
  60 +//
  61 +// const encryption = new AesEncryption({ key, iv });
  62 +//
  63 +// /**
  64 +// *Cache class
  65 +// *Construction parameters can be passed into sessionStorage, localStorage,
  66 +// * @class Cache
  67 +// * @example
  68 +// */
  69 +// const WebStorage = class WebStorage {
  70 +// storage
  71 +// prefixKey
  72 +// encryption
  73 +// hasEncrypt
  74 +//
  75 +// /**
  76 +// *
  77 +// * @param {*} storage
  78 +// */
  79 +// constructor() {
  80 +// this.storage = storage;
  81 +// this.prefixKey = prefixKey;
  82 +// this.encryption = encryption;
  83 +// this.hasEncrypt = hasEncrypt;
  84 +// }
  85 +//
  86 +// getKey(key) {
  87 +// return `${ this.prefixKey }${ key }`.toUpperCase();
  88 +// }
  89 +//
  90 +// /**
  91 +// *
  92 +// * Set cache
  93 +// * @param {string} key
  94 +// * @param {*} value
  95 +// * @param {*} expire
  96 +// * @expire Expiration time in seconds
  97 +// * @memberof Cache
  98 +// */
  99 +// set(key, value, expire = timeout) {
  100 +// const stringData = JSON.stringify({
  101 +// value,
  102 +// time: Date.now(),
  103 +// expire: !isNullOrUnDef(expire) ? new Date().getTime() + expire * 1000 : null,
  104 +// });
  105 +// const stringifyValue = this.hasEncrypt
  106 +// ? this.encryption.encryptByAES(stringData)
  107 +// : stringData;
  108 +// this.storage.setItem(this.getKey(key), stringifyValue);
  109 +// }
  110 +//
  111 +// /**
  112 +// *Read cache
  113 +// * @param {string} key
  114 +// * @param {any} [def=null] def
  115 +// * @memberof Cache
  116 +// */
  117 +// get(key, def = null) {
  118 +// const val = this.storage.getItem(this.getKey(key));
  119 +// if (!val) return def;
  120 +//
  121 +// try {
  122 +// const decVal = this.hasEncrypt ? this.encryption.decryptByAES(val) : val;
  123 +// const data = JSON.parse(decVal);
  124 +// const { value, expire } = data;
  125 +// if (isNullOrUnDef(expire) || expire >= new Date().getTime()) {
  126 +// return value;
  127 +// }
  128 +// this.remove(key);
  129 +// } catch (e) {
  130 +// return def;
  131 +// }
  132 +// }
  133 +//
  134 +// /**
  135 +// * Delete cache based on key
  136 +// * @param {string} key
  137 +// * @memberof Cache
  138 +// */
  139 +// remove(key) {
  140 +// this.storage.removeItem(this.getKey(key));
  141 +// }
  142 +//
  143 +// /**
  144 +// * Delete all caches of this instance
  145 +// */
  146 +// clear() {
  147 +// this.storage.clear();
  148 +// }
  149 +// };
  150 +// return new WebStorage();
  151 +// }
2 152
3   -const GLOBAL_WS_URL = (() => {
4   - const { host, href } = location
5   - const reg = /^https/
6   - return `${ reg.test(href) ? 'wss' : 'ws' }://${ host }/api/ws/plugins/telemetry?token=${GLOBAL_TOKEN}`
  153 +const GLOBAL_STORAGE_KEY = (() => {
  154 + const isDev = location.href.includes('dev=1')
  155 + const DEVELOPMENT = 'DEVELOPMENT'
  156 + const PRODUCTION = 'PRODUCTION'
  157 + return `UNDEFINED__${ isDev ? DEVELOPMENT : PRODUCTION }__2.7.1__COMMON__LOCAL__KEY__`
  158 +})()
  159 +
  160 +const GLOBAL_TOKEN = (() => {
  161 + return JSON.parse(localStorage.getItem(GLOBAL_STORAGE_KEY)).value.JWT_TOKEN.value
7 162 })()
8 163
9   -// const GLOBAL_WS_URL = `ws://47.99.141.212:8080/api/ws/plugins/telemetry?token=${ GLOBAL_TOKEN }`
\ No newline at end of file
  164 +const GLOBAL_WS_URL = (() => {
  165 + const { host, href } = location
  166 + const reg = /^https/
  167 + return `${ reg.test(href) ? 'wss' : 'ws' }://${ host }/api/ws/plugins/telemetry?token=${ GLOBAL_TOKEN }`
  168 +})()
... ...
No preview for this file type
... ... @@ -11170,7 +11170,6 @@ class DispatchCenter {
11170 11170 * @description 建立socket连接
11171 11171 */
11172 11172 connectSocket() {
11173   - const GLOBAL_TOKEN = JSON.parse(localStorage.getItem("UNDEFINED__DEVELOPMENT__2.7.1__COMMON__LOCAL__KEY__")).value.JWT_TOKEN.value
11174 11173 this.socket = Ws.getInstance({ url: GLOBAL_WS_URL, onmessageCallback: this.socketOnmessage })
11175 11174 }
11176 11175
... ...
No preview for this file type
No preview for this file type