-
{{ item.label + " " }}
@@ -11,7 +11,7 @@
:disable-transitions="true"
:key="item.value + ''"
:index="index"
- :type="item.elTagType === 'primary' ? '' : item.elTagType"
+ :type="(item.elTagType === 'primary' || item.elTagType === 'default')? '' : item.elTagType"
:class="item.elTagClass"
>
{{ item.label + " " }}
diff --git a/src/components/IconSelect/index.vue b/src/components/IconSelect/index.vue
index a275954e942eb9b70d614f6f74918704c8f07bc2..1cd0023cd4a76c05636922c525c89b2f87b3be09 100644
--- a/src/components/IconSelect/index.vue
+++ b/src/components/IconSelect/index.vue
@@ -2,7 +2,7 @@
-
+
diff --git a/src/layout/components/Sidebar/SidebarItem.vue b/src/layout/components/Sidebar/SidebarItem.vue
index 204b19bcc00af61e86214e65dd30d9aaa6a424c5..4459cdfa43b57df65236ce93f4257d9b995222cd 100644
--- a/src/layout/components/Sidebar/SidebarItem.vue
+++ b/src/layout/components/Sidebar/SidebarItem.vue
@@ -18,8 +18,8 @@
{
if (to.path === '/login') {
next({ path: '/' });
NProgress.done();
+ } else if (whiteList.indexOf(to.path) !== -1) {
+ next()
} else {
if (useUserStore().roles.length === 0) {
isRelogin.show = true;
diff --git a/src/router/index.ts b/src/router/index.ts
index 6c56cd3f99f64b0d9a532f3bf0b6330aa0eab357..271385c6d8761aedc1009c6c387db26ce8cb7f6a 100644
--- a/src/router/index.ts
+++ b/src/router/index.ts
@@ -139,7 +139,7 @@ export const dynamicRoutes: RouteOption[] = [
path: '/system/oss-config',
component: Layout,
hidden: true,
- permissions: ['system:oss:list'],
+ permissions: ['system:ossConfig:list'],
children: [
{
path: 'index',
diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts
index 2593d1ab45dadd72120fb047d44e07e35cd1974b..7c02de0a0f0d73d8aae290ef946a7027ba3ad3ae 100644
--- a/src/store/modules/user.ts
+++ b/src/store/modules/user.ts
@@ -63,6 +63,10 @@ export const useUserStore = defineStore('user', () => {
removeToken();
};
+ const setAvatar = (value: string) => {
+ avatar.value = value;
+ };
+
return {
userId,
token,
@@ -72,7 +76,8 @@ export const useUserStore = defineStore('user', () => {
permissions,
login,
getInfo,
- logout
+ logout,
+ setAvatar
};
});
diff --git a/src/types/element.d.ts b/src/types/element.d.ts
index e8d1f620bda02f905b080e3d01b96fdef50bc499..ba7598d6d59b001393b664b46c4cf499156ceb38 100644
--- a/src/types/element.d.ts
+++ b/src/types/element.d.ts
@@ -24,7 +24,6 @@ declare global {
declare type ElColorPickerInstance = InstanceType;
declare type ElRateInstance = InstanceType;
declare type ElSliderInstance = InstanceType;
- declare type ElUploadInstance = InstanceType;
declare type ElScrollbarInstance = InstanceType;
declare type TransferKey = ep.TransferKey;
diff --git a/src/types/env.d.ts b/src/types/env.d.ts
index 15fa03a685064fe17a89f48501bef6f06065c592..9560307a774be254e93b94e1d55e2e2ded0c487b 100644
--- a/src/types/env.d.ts
+++ b/src/types/env.d.ts
@@ -68,6 +68,7 @@ interface ImportMetaEnv {
VITE_APP_POWERJOB_ADMIN: string;
VITE_APP_ENV: string;
VITE_APP_RSA_PUBLIC_KEY: string;
+ VITE_APP_RSA_PRIVATE_KEY: string;
VITE_APP_CLIENT_ID: string;
VITE_APP_WEBSOCKET: string;
}
diff --git a/src/utils/crypto.ts b/src/utils/crypto.ts
index 133893eac4a5d9e83ef9c4a1b332e81a7e52ae3a..8217146b6b61680416f24f907df1b0b0e8eb5716 100644
--- a/src/utils/crypto.ts
+++ b/src/utils/crypto.ts
@@ -30,6 +30,13 @@ export const encryptBase64 = (str: CryptoJS.lib.WordArray) => {
return CryptoJS.enc.Base64.stringify(str);
};
+/**
+ * 解密base64
+ */
+export const decryptBase64 = (str: string) => {
+ return CryptoJS.enc.Base64.parse(str);
+};
+
/**
* 使用密钥对数据进行加密
* @param message
@@ -43,3 +50,17 @@ export const encryptWithAes = (message: string, aesKey: CryptoJS.lib.WordArray)
});
return encrypted.toString();
};
+
+/**
+ * 使用密钥对数据进行解密
+ * @param message
+ * @param aesKey
+ * @returns {string}
+ */
+export const decryptWithAes = (message: string, aesKey: CryptoJS.lib.WordArray) => {
+ const decrypted = CryptoJS.AES.decrypt(message, aesKey, {
+ mode: CryptoJS.mode.ECB,
+ padding: CryptoJS.pad.Pkcs7
+ });
+ return decrypted.toString(CryptoJS.enc.Utf8);
+};
diff --git a/src/utils/jsencrypt.ts b/src/utils/jsencrypt.ts
index 98114b43720a11099f5ba1a1d4f12642d82e3e5b..42de5a01c20fea222fb781cacc5d2713af28bbac 100644
--- a/src/utils/jsencrypt.ts
+++ b/src/utils/jsencrypt.ts
@@ -4,7 +4,7 @@ import JSEncrypt from 'jsencrypt';
const publicKey = import.meta.env.VITE_APP_RSA_PUBLIC_KEY;
// 前端不建议存放私钥 不建议解密数据 因为都是透明的意义不大
-const privateKey = '**********';
+const privateKey = import.meta.env.VITE_APP_RSA_PRIVATE_KEY;
// 加密
export const encrypt = (txt: string) => {
diff --git a/src/utils/request.ts b/src/utils/request.ts
index ed6771399bacda10fff02d0f2eb1bc5893ca4dc9..a183ca63a8d1100e28f91fc81b6175832ed3d180 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -8,9 +8,10 @@ import { errorCode } from '@/utils/errorCode';
import { LoadingInstance } from 'element-plus/es/components/loading/src/loading';
import FileSaver from 'file-saver';
import { getLanguage } from '@/lang';
-import { encryptBase64, encryptWithAes, generateAesKey } from '@/utils/crypto';
-import { encrypt } from '@/utils/jsencrypt';
+import { encryptBase64, encryptWithAes, generateAesKey, decryptWithAes, decryptBase64 } from '@/utils/crypto';
+import { encrypt, decrypt } from '@/utils/jsencrypt';
+const encryptHeader = 'encrypt-key';
let downloadLoadingInstance: LoadingInstance;
// 是否显示重新登录
export const isRelogin = { show: false };
@@ -78,7 +79,7 @@ service.interceptors.request.use(
if (isEncrypt && (config.method === 'post' || config.method === 'put')) {
// 生成一个 AES 密钥
const aesKey = generateAesKey();
- config.headers['encrypt-key'] = encrypt(encryptBase64(aesKey));
+ config.headers[encryptHeader] = encrypt(encryptBase64(aesKey));
config.data = typeof config.data === 'object' ? encryptWithAes(JSON.stringify(config.data), aesKey) : encryptWithAes(config.data, aesKey);
}
// FormData数据去请求头Content-Type
@@ -96,6 +97,20 @@ service.interceptors.request.use(
// 响应拦截器
service.interceptors.response.use(
(res: AxiosResponse) => {
+ // 加密后的 AES 秘钥
+ const keyStr = res.headers[encryptHeader];
+ // 加密
+ if (keyStr != null && keyStr != '') {
+ const data = res.data;
+ // 请求体 AES 解密
+ const base64Str = decrypt(keyStr);
+ // base64 解码 得到请求头的 AES 秘钥
+ const aesKey = decryptBase64(base64Str.toString());
+ // aesKey 解码 data
+ const decryptData = decryptWithAes(data, aesKey);
+ // 将结果 (得到的是 JSON 字符串) 转为 JSON
+ res.data = JSON.parse(decryptData);
+ }
// 未设置状态码则默认成功状态
const code = res.data.code || HttpStatus.SUCCESS;
// 获取错误信息
diff --git a/src/views/monitor/online/index.vue b/src/views/monitor/online/index.vue
index 1a25dc55e9800a30ce0fb47ab4217b65ebbf5898..d105cd7737119bc1bb86cff014c419b8f9dd62c1 100644
--- a/src/views/monitor/online/index.vue
+++ b/src/views/monitor/online/index.vue
@@ -63,6 +63,8 @@