mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat: 整合登录
This commit is contained in:
@ -4,11 +4,11 @@
|
||||
* @param env The current env
|
||||
*/
|
||||
export function createServiceConfig(env: Env.ImportMeta) {
|
||||
const { VITE_SERVICE_BASE_URL, VITE_OTHER_SERVICE_BASE_URL } = env;
|
||||
const { VITE_SERVICE_BASE_URL, VITE_OTHER_SERVICE_BASE_URL, VITE_APP_BASE_API, VITE_APP_WEBSOCKET } = env;
|
||||
|
||||
let other = {} as Record<App.Service.OtherBaseURLKey, string>;
|
||||
try {
|
||||
other = JSON.parse(VITE_OTHER_SERVICE_BASE_URL);
|
||||
other = JSON.parse(VITE_OTHER_SERVICE_BASE_URL || '{}');
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('VITE_OTHER_SERVICE_BASE_URL is not a valid JSON string');
|
||||
@ -24,6 +24,7 @@ export function createServiceConfig(env: Env.ImportMeta) {
|
||||
const otherConfig: App.Service.OtherServiceConfigItem[] = otherHttpKeys.map(key => {
|
||||
return {
|
||||
key,
|
||||
ws: false,
|
||||
baseURL: httpConfig.other[key],
|
||||
proxyPattern: createProxyPattern(key)
|
||||
};
|
||||
@ -31,7 +32,8 @@ export function createServiceConfig(env: Env.ImportMeta) {
|
||||
|
||||
const config: App.Service.ServiceConfig = {
|
||||
baseURL: httpConfig.baseURL,
|
||||
proxyPattern: createProxyPattern(),
|
||||
ws: VITE_APP_WEBSOCKET === 'true',
|
||||
proxyPattern: VITE_APP_BASE_API,
|
||||
other: otherConfig
|
||||
};
|
||||
|
||||
@ -45,7 +47,7 @@ export function createServiceConfig(env: Env.ImportMeta) {
|
||||
* @param isProxy - if use proxy
|
||||
*/
|
||||
export function getServiceBaseURL(env: Env.ImportMeta, isProxy: boolean) {
|
||||
const { baseURL, other } = createServiceConfig(env);
|
||||
const { baseURL, other, proxyPattern } = createServiceConfig(env);
|
||||
|
||||
const otherBaseURL = {} as Record<App.Service.OtherBaseURLKey, string>;
|
||||
|
||||
@ -54,7 +56,7 @@ export function getServiceBaseURL(env: Env.ImportMeta, isProxy: boolean) {
|
||||
});
|
||||
|
||||
return {
|
||||
baseURL: isProxy ? createProxyPattern() : baseURL,
|
||||
baseURL: isProxy ? proxyPattern : baseURL,
|
||||
otherBaseURL
|
||||
};
|
||||
}
|
||||
@ -64,10 +66,6 @@ export function getServiceBaseURL(env: Env.ImportMeta, isProxy: boolean) {
|
||||
*
|
||||
* @param key If not set, will use the default key
|
||||
*/
|
||||
function createProxyPattern(key?: App.Service.OtherBaseURLKey) {
|
||||
if (!key) {
|
||||
return '/proxy-default';
|
||||
}
|
||||
|
||||
function createProxyPattern(key: App.Service.OtherBaseURLKey) {
|
||||
return `/proxy-${key}`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user