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