提交 67325e68 编写于 作者: tony001's avatar tony001

update:统一环境参数入口

上级 b0095911
import { SyncSeriesHook } from "qx-util"; import { SyncSeriesHook } from "qx-util";
import { Environment } from "@/environments/environment";
import router from "@/router"; import router from "@/router";
import { AppBase, IParam, ViewDetail, IApp, IOpenViewService, deepCopy, Http, IAppAuthService, IAppNotificationService, IAppFuncService, IAppActionService, IAppCodeListService } from "@core"; import { AppBase, IParam, ViewDetail, IApp, IOpenViewService, deepCopy, Http, IAppAuthService, IAppNotificationService, IAppFuncService, IAppActionService, IAppCodeListService } from "@core";
import { AppFuncConfig, AppViewConfig, AppEntityConfig } from './config'; import { AppFuncConfig, AppViewConfig, AppEntityConfig } from './config';
import { DataServiceRegister, UIServiceRegister } from "./register"; import { DataServiceRegister, UIServiceRegister } from "./register";
import { Environment } from "@/environments/environment";
import { AppActionService, AppAuthService, AppCodeListService, AppFuncService, AppNotificationService, OpenViewService } from "@/service"; import { AppActionService, AppAuthService, AppCodeListService, AppFuncService, AppNotificationService, OpenViewService } from "@/service";
export class App extends AppBase implements IApp { export class App extends AppBase implements IApp {
...@@ -174,6 +174,16 @@ export class App extends AppBase implements IApp { ...@@ -174,6 +174,16 @@ export class App extends AppBase implements IApp {
return AppEntityConfig[codeName] ? deepCopy(AppEntityConfig[codeName]) : undefined; return AppEntityConfig[codeName] ? deepCopy(AppEntityConfig[codeName]) : undefined;
} }
/**
* 获取环境参数
*
* @return {*} {IParam}
* @memberof App
*/
public getEnvironmentParam(): IParam {
return Environment;
}
/** /**
* @description 跳转登录页 * @description 跳转登录页
* *
...@@ -181,8 +191,8 @@ export class App extends AppBase implements IApp { ...@@ -181,8 +191,8 @@ export class App extends AppBase implements IApp {
*/ */
gotoLoginPage(): void { gotoLoginPage(): void {
const currentRoute = unref(router.currentRoute); const currentRoute = unref(router.currentRoute);
if (Environment.loginUrl) { if (this.getEnvironmentParam().loginUrl) {
window.location.href = `${Environment.loginUrl}?redirect=${window.location.href}`; window.location.href = `${this.getEnvironmentParam().loginUrl}?redirect=${window.location.href}`;
} else { } else {
if (Object.is(currentRoute.name, 'login')) { if (Object.is(currentRoute.name, 'login')) {
return; return;
......
...@@ -104,6 +104,13 @@ export interface IApp { ...@@ -104,6 +104,13 @@ export interface IApp {
*/ */
getViewInfo(codeName: string): ViewDetail | undefined; getViewInfo(codeName: string): ViewDetail | undefined;
/**
* 获取环境参数
*
* @return {*} {IParam}
* @memberof IApp
*/
getEnvironmentParam(): IParam;
/** /**
* 获取实体信息 * 获取实体信息
......
...@@ -142,6 +142,17 @@ export abstract class AppBase implements IApp { ...@@ -142,6 +142,17 @@ export abstract class AppBase implements IApp {
return undefined; return undefined;
} }
/**
* 获取环境参数
*
* @return {*} {IParam}
* @memberof AppBase
*/
public getEnvironmentParam(): IParam {
throw new Error("Method not implemented.");
}
/** /**
* @description 获取实体信息 * @description 获取实体信息
* *
......
import qs from "qs"; import qs from "qs";
import { clearCookie, getCookie, setCookie } from "qx-util"; import { clearCookie, getCookie, setCookie } from "qx-util";
import { deepCopy, getSessionStorage, Http, IAppAuthService, IParam, removeSessionStorage, setSessionStorage } from "@core"; import { deepCopy, getSessionStorage, Http, IAppAuthService, IParam, removeSessionStorage, setSessionStorage } from "@core";
import { Environment } from "@/environments/environment";
/** /**
* 应用权限服务基类 * 应用权限服务基类
...@@ -65,7 +64,7 @@ export abstract class AppAuthServiceBase implements IAppAuthService { ...@@ -65,7 +64,7 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
* @memberof AppAuthServiceBase * @memberof AppAuthServiceBase
*/ */
public getEnablePermission(): boolean { public getEnablePermission(): boolean {
return this.appData.enablepermissionvalid && Environment.enablePermissionValid; return this.appData.enablepermissionvalid && App.getEnvironmentParam().enablePermissionValid;
} }
/** /**
...@@ -77,7 +76,7 @@ export abstract class AppAuthServiceBase implements IAppAuthService { ...@@ -77,7 +76,7 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
*/ */
public async initAppAuth(params: IParam, hooks: IParam): Promise<any> { public async initAppAuth(params: IParam, hooks: IParam): Promise<any> {
let result = true; let result = true;
if (Environment && Environment.SaaSMode) { if (App.getEnvironmentParam() && App.getEnvironmentParam().SaaSMode) {
if (getSessionStorage('activeOrgData')) { if (getSessionStorage('activeOrgData')) {
result = await this.getAppInitData(hooks, params); result = await this.getAppInitData(hooks, params);
} else { } else {
...@@ -251,8 +250,8 @@ export abstract class AppAuthServiceBase implements IAppAuthService { ...@@ -251,8 +250,8 @@ export abstract class AppAuthServiceBase implements IAppAuthService {
tempViewParam = this.hanldeViewParam(tempViewParam.redirect); tempViewParam = this.hanldeViewParam(tempViewParam.redirect);
} }
} }
if (!tempViewParam.srfdcsystem && Environment.mockDcSystemId) { if (!tempViewParam.srfdcsystem && App.getEnvironmentParam().mockDcSystemId) {
Object.assign(tempViewParam, { srfdcsystem: Environment.mockDcSystemId }); Object.assign(tempViewParam, { srfdcsystem: App.getEnvironmentParam().mockDcSystemId });
} }
if (tempViewParam.srfdcsystem) { if (tempViewParam.srfdcsystem) {
hooks.dcSystemBefore.callSync({ dcsystem: tempViewParam.srfdcsystem }); hooks.dcSystemBefore.callSync({ dcsystem: tempViewParam.srfdcsystem });
......
import { ControlServiceBase, ControlVOBase, deepCopy, IContext, IParam, isEmpty, TreeNodeRSVO, TreeNodeVO } from "@core"; import { ControlServiceBase, ControlVOBase, deepCopy, IContext, IParam, isEmpty, TreeNodeRSVO, TreeNodeVO } from "@core";
import { Environment } from "@/environments/environment";
/** /**
* @description 树部件服务 * @description 树部件服务
...@@ -416,7 +415,7 @@ export class TreeService<T extends ControlVOBase> extends ControlServiceBase<T> ...@@ -416,7 +415,7 @@ export class TreeService<T extends ControlVOBase> extends ControlServiceBase<T>
} }
if (context && context.srfparentkey) { if (context && context.srfparentkey) {
Object.assign(searchFilter, { srfparentkey: deepCopy(context).srfparentkey }); Object.assign(searchFilter, { srfparentkey: deepCopy(context).srfparentkey });
if (Environment && Environment.enableIssue) { if (App.getEnvironmentParam() && App.getEnvironmentParam().enableIssue) {
Object.assign(searchFilter, { nodeid: deepCopy(context).srfparentkey }); Object.assign(searchFilter, { nodeid: deepCopy(context).srfparentkey });
} }
} }
......
import { IParam } from "@core"; import { IParam } from "@core";
import { Environment } from "@/environments/environment";
/** /**
* 界面服务基类 * 界面服务基类
...@@ -74,7 +73,7 @@ export class UIServiceBase { ...@@ -74,7 +73,7 @@ export class UIServiceBase {
* @memberof UIServiceBase * @memberof UIServiceBase
*/ */
protected getAllOPPrivs(data: any, dataAccAction: string) { protected getAllOPPrivs(data: any, dataAccAction: string) {
if (!Environment.enablePermissionValid) { if (!App.getEnvironmentParam().enablePermissionValid) {
return 1; return 1;
} }
if (data && (Object.keys(data).length > 0)) { if (data && (Object.keys(data).length > 0)) {
......
import { Environment } from '@/environments/environment'; import { getCookie, SyncSeriesHook } from 'qx-util';
import { IParam } from '@core';
import { clearCookie, getCookie, SyncSeriesHook } from 'qx-util';
import { getSessionStorage } from '../util'; import { getSessionStorage } from '../util';
import { Http } from './http'; import { Http } from './http';
...@@ -66,7 +64,7 @@ export class Interceptors { ...@@ -66,7 +64,7 @@ export class Interceptors {
private intercept(): void { private intercept(): void {
Http.getHttp().interceptors.request.use((config: any) => { Http.getHttp().interceptors.request.use((config: any) => {
Interceptors.hooks.request.callSync({ config: config }); Interceptors.hooks.request.callSync({ config: config });
if (Environment.SaaSMode && (!config.url.startsWith("/uaa/getbydcsystem/"))) { if (App.getEnvironmentParam().SaaSMode && (!config.url.startsWith("/uaa/getbydcsystem/"))) {
let activeOrgData = getSessionStorage('activeOrgData'); let activeOrgData = getSessionStorage('activeOrgData');
config.headers['srforgid'] = activeOrgData?.orgid; config.headers['srforgid'] = activeOrgData?.orgid;
config.headers['srfsystemid'] = activeOrgData?.systemid; config.headers['srfsystemid'] = activeOrgData?.systemid;
...@@ -74,8 +72,8 @@ export class Interceptors { ...@@ -74,8 +72,8 @@ export class Interceptors {
if (getCookie('ibzuaa-token')) { if (getCookie('ibzuaa-token')) {
config.headers['Authorization'] = `Bearer ${getCookie('ibzuaa-token')}`; config.headers['Authorization'] = `Bearer ${getCookie('ibzuaa-token')}`;
} }
if (!Object.is(Environment.BaseUrl, "") && !config.url.startsWith('https://') && !config.url.startsWith('http://') && !config.url.startsWith('./assets')) { if (!Object.is(App.getEnvironmentParam().BaseUrl, "") && !config.url.startsWith('https://') && !config.url.startsWith('http://') && !config.url.startsWith('./assets')) {
config.url = Environment.BaseUrl + config.url; config.url = App.getEnvironmentParam().BaseUrl + config.url;
} }
return config; return config;
}, (error: any) => { }, (error: any) => {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册