From db95f3fa4b57b7457559da4ef5a841a10b4434e7 Mon Sep 17 00:00:00 2001 From: binbin_pan Date: Fri, 24 May 2024 09:12:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=97=E7=BD=91env=E7=8E=AF=E5=A2=83?= =?UTF-8?q?=E5=8F=98=E9=87=8F=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sgzb-ui/.env.production | 5 ++++- sgzb-ui/src/store/modules/user.js | 24 ++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/sgzb-ui/.env.production b/sgzb-ui/.env.production index bae011af..0f4b7e2d 100644 --- a/sgzb-ui/.env.production +++ b/sgzb-ui/.env.production @@ -5,4 +5,7 @@ VUE_APP_TITLE = 施工装备管理系统 ENV = 'production' # 若依管理系统/生产环境 -VUE_APP_BASE_API = '/gl/dev-api' # 南网需加上/gl +VUE_APP_BASE_API=dev-api + +# 南网需加上/gl +# VUE_APP_BASE_API = '/gl/dev-api' diff --git a/sgzb-ui/src/store/modules/user.js b/sgzb-ui/src/store/modules/user.js index 5cf92bb9..230569b0 100644 --- a/sgzb-ui/src/store/modules/user.js +++ b/sgzb-ui/src/store/modules/user.js @@ -5,27 +5,31 @@ import { Notification, MessageBox, Message, Loading } from 'element-ui' const secretKey = 'CCNWrpassWordKey' async function encryptData(data, keyStr) { - const keyUint8 = new TextEncoder().encode(keyStr); - const key = await crypto.subtle.importKey( + try { + const keyUint8 = new TextEncoder().encode(keyStr); + const key = await crypto.subtle.importKey( 'raw', keyUint8, { name: 'AES-CBC', length: 256 }, false, ['encrypt'] - ); + ); - const iv = crypto.getRandomValues(new Uint8Array(16)); - const cipherTextBuffer = await crypto.subtle.encrypt( + const iv = crypto.getRandomValues(new Uint8Array(16)); + const cipherTextBuffer = await crypto.subtle.encrypt( { name: 'AES-CBC', iv }, key, new TextEncoder().encode(data) - ); + ); - const combined = new Uint8Array(iv.length + cipherTextBuffer.byteLength); - combined.set(iv, 0); - combined.set(new Uint8Array(cipherTextBuffer), iv.length); + const combined = new Uint8Array(iv.length + cipherTextBuffer.byteLength); + combined.set(iv, 0); + combined.set(new Uint8Array(cipherTextBuffer), iv.length); - return btoa(String.fromCharCode.apply(null, combined)); + return btoa(String.fromCharCode.apply(null, combined)); + } catch (error) { + console.log('🚀 ~ encryptData ~ error:', error); + } } const user = {