From 07eab9378ad88d1038b714160041b438cf4c16f7 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Fri, 17 Jan 2025 15:54:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A5=E5=8F=A3=E5=8A=A0=E5=AF=86?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=8E=A7=E5=88=B6=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.ts | 6 ++++-- src/api/ne/neInfo.ts | 6 ++++-- src/constants/cache-keys-constants.ts | 3 +++ src/store/modules/app.ts | 10 ++++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/api/login.ts b/src/api/login.ts index e7ff947d..ca521231 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -1,3 +1,5 @@ +import { CACHE_SESSION_CRYPTO_API } from '@/constants/cache-keys-constants'; +import { sessionGet } from '@/utils/cache-session-utils'; import { request } from '@/plugins/http-fetch'; // 登录方法 @@ -7,7 +9,7 @@ export function login(data: Record) { method: 'post', data: data, whithToken: false, - crypto: true, + crypto: sessionGet(CACHE_SESSION_CRYPTO_API) !== 'false', }); } @@ -22,7 +24,7 @@ export function register(data: Record) { method: 'post', data: data, whithToken: false, - crypto: true, + crypto: sessionGet(CACHE_SESSION_CRYPTO_API) !== 'false', }); } diff --git a/src/api/ne/neInfo.ts b/src/api/ne/neInfo.ts index 2d66d90b..013443c3 100644 --- a/src/api/ne/neInfo.ts +++ b/src/api/ne/neInfo.ts @@ -1,3 +1,5 @@ +import { CACHE_SESSION_CRYPTO_API } from '@/constants/cache-keys-constants'; +import { sessionGet } from '@/utils/cache-session-utils'; import { request } from '@/plugins/http-fetch'; /** @@ -36,7 +38,7 @@ export function addNeInfo(data: Record) { url: `/ne/info`, method: 'post', data: data, - crypto: true, + crypto: sessionGet(CACHE_SESSION_CRYPTO_API) !== 'false', timeout: 30_000, }); } @@ -51,7 +53,7 @@ export function updateNeInfo(data: Record) { url: `/ne/info`, method: 'put', data: data, - crypto: true, + crypto: sessionGet(CACHE_SESSION_CRYPTO_API) !== 'false', timeout: 30_000, }); } diff --git a/src/constants/cache-keys-constants.ts b/src/constants/cache-keys-constants.ts index 94e02304..b09b2ffb 100644 --- a/src/constants/cache-keys-constants.ts +++ b/src/constants/cache-keys-constants.ts @@ -1,3 +1,6 @@ +/**会话缓存-接口加密 */ +export const CACHE_SESSION_CRYPTO_API = 'cache:session:cryptoApi'; + /**会话缓存-网络请求 */ export const CACHE_SESSION_FATCH = 'cache:session:fatch'; diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 81405212..b10f77d6 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -1,9 +1,10 @@ import { getSysConf } from '@/api'; -import { CACHE_LOCAL_I18N } from '@/constants/cache-keys-constants'; +import { CACHE_LOCAL_I18N, CACHE_SESSION_CRYPTO_API } from '@/constants/cache-keys-constants'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { removeToken } from '@/plugins/auth-token'; import { parseUrlPath } from '@/plugins/file-static-url'; import { localGet, localSet } from '@/utils/cache-local-utils'; +import { sessionSet } from '@/utils/cache-session-utils'; import { defineStore } from 'pinia'; /**应用参数类型 */ @@ -22,6 +23,8 @@ type AppStore = { bootloader: boolean; // 用户登录认证 loginAuth: boolean; + // 用户接口加密 + cryptoApi: boolean; // 序列号 serialNum: string; /**应用版权声明 */ @@ -55,6 +58,7 @@ const useAppStore = defineStore('app', { buildTime: `-`, bootloader: false, loginAuth: true, + cryptoApi: true, serialNum: `-`, copyright: `Copyright ©2023 For ${import.meta.env.VITE_APP_NAME}`, logoType: 'icon', @@ -88,7 +92,9 @@ const useAppStore = defineStore('app', { if (this.bootloader) { removeToken(); } - this.loginAuth = res.data.loginAuth !== 'false' ; + this.loginAuth = res.data.loginAuth !== 'false'; + this.cryptoApi = res.data.cryptoApi !== 'false'; + sessionSet(CACHE_SESSION_CRYPTO_API, res.data.cryptoApi); this.serialNum = res.data.serialNum; this.appName = res.data.title; this.copyright = res.data.copyright;