Переглянути джерело

Merge branch 'V0.0.4' of http://10.87.21.221:8000/jzyd_yyds/soc_web into V0.0.4

jiawuxian 1 рік тому
батько
коміт
76a1f5bf25

+ 3 - 1
package.json

@@ -40,6 +40,7 @@
     "@riophae/vue-treeselect": "0.4.0",
     "axios": "0.24.0",
     "clipboard": "2.0.8",
+    "core-js": "^3.34.0",
     "core.js": "^0.4.2",
     "dayjs": "^1.11.9",
     "echarts": "5.4.0",
@@ -50,12 +51,13 @@
     "js-beautify": "1.13.0",
     "js-cookie": "3.0.1",
     "jsencrypt": "3.0.0-rc.1",
-    "node-polyfill-webpack-plugin": "^2.0.1",
+    "node-polyfill-webpack-plugin": "^3.0.0",
     "nprogress": "0.2.0",
     "quill": "1.3.7",
     "screenfull": "5.0.2",
     "sortablejs": "1.10.2",
     "vue": "2.6.12",
+    "gm-crypt": "0.0.2",
     "vue-count-to": "1.0.13",
     "vue-cropper": "0.5.5",
     "vue-meta": "2.4.0",

+ 2 - 2
src/store/modules/user.js

@@ -1,7 +1,7 @@
 import { login, logout, getInfo, refreshToken ,tokenLogin} from '@/api/login'
 import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
 import {deptTreeSelect,handsheDeptTreeSelect,businessTreeSelect,wholeTreeSelect} from "@/api/system/public";
-
+import { SM4Encrypt, SM4Decrypt } from '@/utils/sm4.js'
 const user = {
   state: {
     token: getToken(),
@@ -77,7 +77,7 @@ const user = {
     // 登录
     Login({ commit }, userInfo) {
       const username = userInfo.username.trim()
-      const password = userInfo.password
+      const password = SM4Encrypt(userInfo.password)
       const code = userInfo.code
       const uuid = userInfo.uuid
       return new Promise((resolve, reject) => {

+ 34 - 0
src/utils/sm4.js

@@ -0,0 +1,34 @@
+const SM4 = require('gm-crypt').sm4;
+const pwdKey = 'rDWBHusbFTlOURS4'; // 密钥 前后端一致即可,后端提供
+let sm4Config = {
+  key: pwdKey, // key值要与后端的一致,后端解密是根据这个key
+  mode: 'ecb', // 加密的方式有两种,ecb和cbc两种,也是看后端如何定义的,cbc的话下面还要加一个iv的参数,ecb不用
+//   iv: pwdKey, // iv是cbc模式的第二个参数,也需要跟后端配置的一致 iv是initialization vector的意思,就是加密的初始化矢量,初始化加密函数的变量,也叫初始向量
+  cipherType: 'base64',
+};
+
+/*
+ * 加密工具函数
+ * @param {String} text 待加密文本
+ * @param key string 加密key(16位)
+ * @param iv string 偏移向量(16位)
+ */
+export function SM4Encrypt(text, key = pwdKey, iv = pwdKey) {
+  sm4Config.key = key;
+//   sm4Config.iv = iv;
+  const sm4Util = new SM4(sm4Config); // new一个sm4函数,将sm4Config作为参数传递进去
+  return sm4Util.encrypt(text, key);
+}
+
+/*
+ * 解密工具函数
+ * @param {String} text 待解密密文
+ * @param key string 加密key(16位)
+ * @param iv string 偏移向量(16位)
+ */
+export function SM4Decrypt(text, key = pwdKey, iv = pwdKey) {
+  sm4Config.key = key;
+//   sm4Config.iv = iv;
+  const sm4Util = new SM4(sm4Config); // new一个sm4函数,将sm4Config作为参数传递进去
+  return sm4Util.decrypt(text, key);
+}

+ 1 - 1
src/views/core/drill/drillDictionary/index.vue

@@ -154,7 +154,7 @@
                             />
                           </template>
                         </el-table-column>-->
-            <el-table-column label="演练场景" scoped-slot="drillProjects" align="center" width="180"
+            <el-table-column label="演练场景" scoped-slot="drillProjects" header-align="center" align="left" width="180"
                              prop="drillProjects">
               <template slot-scope="scope">
                 <div class="ellipsis" :title="scope.row.drillProjects">{{ scope.row.drillProjects }}</div>