chore: sse配置文件关闭
This commit is contained in:
parent
6183d22b20
commit
d304e8a2a3
@ -21,5 +21,5 @@ VITE_GLOB_RSA_PRIVATE_KEY=MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmc3CuP
|
||||
# 客户端id
|
||||
VITE_GLOB_APP_CLIENT_ID=e5cd7e4891bf95d1d19206ce24a7b32e
|
||||
|
||||
# 开启WEBSOCKET
|
||||
VITE_GLOB_WEBSOCKET_ENABLE=false
|
||||
# 开启SSE
|
||||
VITE_GLOB_SSE_ENABLE=true
|
||||
|
@ -27,6 +27,6 @@ VITE_GLOB_RSA_PRIVATE_KEY=MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmc3CuP
|
||||
# 客户端id
|
||||
VITE_GLOB_APP_CLIENT_ID=e5cd7e4891bf95d1d19206ce24a7b32e
|
||||
|
||||
# 开启WEBSOCKET
|
||||
VITE_GLOB_WEBSOCKET_ENABLE=false
|
||||
# 开启SSE
|
||||
VITE_GLOB_SSE_ENABLE=true
|
||||
|
||||
|
@ -4,7 +4,10 @@ import { useAppConfig } from '@vben/hooks';
|
||||
|
||||
import { requestClient } from '#/api/request';
|
||||
|
||||
const { clientId } = useAppConfig(import.meta.env, import.meta.env.PROD);
|
||||
const { clientId, sseEnable } = useAppConfig(
|
||||
import.meta.env,
|
||||
import.meta.env.PROD,
|
||||
);
|
||||
|
||||
export namespace AuthApi {
|
||||
/**
|
||||
@ -96,6 +99,12 @@ export function doLogout() {
|
||||
* @returns void
|
||||
*/
|
||||
export function seeConnectionClose() {
|
||||
/**
|
||||
* 未开启sse 不需要处理
|
||||
*/
|
||||
if (!sseEnable) {
|
||||
return;
|
||||
}
|
||||
return requestClient.get<void>('/resource/sse/close');
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ import { notification } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
const { apiURL, clientId } = useAppConfig(
|
||||
const { apiURL, clientId, sseEnable } = useAppConfig(
|
||||
import.meta.env,
|
||||
import.meta.env.PROD,
|
||||
);
|
||||
@ -40,6 +40,12 @@ export const useNotifyStore = defineStore(
|
||||
* 开始监听sse消息
|
||||
*/
|
||||
function startListeningMessage() {
|
||||
/**
|
||||
* 未开启 不监听
|
||||
*/
|
||||
if (!sseEnable) {
|
||||
return;
|
||||
}
|
||||
const accessStore = useAccessStore();
|
||||
const token = accessStore.accessToken;
|
||||
|
||||
|
@ -21,7 +21,7 @@ export function useAppConfig(
|
||||
VITE_GLOB_ENABLE_ENCRYPT,
|
||||
VITE_GLOB_RSA_PRIVATE_KEY,
|
||||
VITE_GLOB_RSA_PUBLIC_KEY,
|
||||
VITE_GLOB_WEBSOCKET_ENABLE,
|
||||
VITE_GLOB_SSE_ENABLE,
|
||||
} = config;
|
||||
|
||||
return {
|
||||
@ -34,7 +34,7 @@ export function useAppConfig(
|
||||
rsaPrivateKey: VITE_GLOB_RSA_PRIVATE_KEY,
|
||||
// RSA公钥
|
||||
rsaPublicKey: VITE_GLOB_RSA_PUBLIC_KEY,
|
||||
// 是否开启websocket
|
||||
websocketEnable: VITE_GLOB_WEBSOCKET_ENABLE === 'true',
|
||||
// 是否开启sse
|
||||
sseEnable: VITE_GLOB_SSE_ENABLE === 'true',
|
||||
};
|
||||
}
|
||||
|
8
packages/types/global.d.ts
vendored
8
packages/types/global.d.ts
vendored
@ -18,8 +18,8 @@ export interface VbenAdminProAppConfigRaw {
|
||||
VITE_GLOB_RSA_PRIVATE_KEY: string;
|
||||
// RSA请求加密公钥
|
||||
VITE_GLOB_RSA_PUBLIC_KEY: string;
|
||||
// 是否开启websocket 注意从配置文件获取的类型为string
|
||||
VITE_GLOB_WEBSOCKET_ENABLE: string;
|
||||
// 是否开启sse 注意从配置文件获取的类型为string
|
||||
VITE_GLOB_SSE_ENABLE: string;
|
||||
}
|
||||
|
||||
export interface ApplicationConfig {
|
||||
@ -33,8 +33,8 @@ export interface ApplicationConfig {
|
||||
rsaPrivateKey: string;
|
||||
// RSA请求加密公钥
|
||||
rsaPublicKey: string;
|
||||
// 是否开启websocket
|
||||
websocketEnable: boolean;
|
||||
// 是否开启sse
|
||||
sseEnable: boolean;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
Loading…
Reference in New Issue
Block a user