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

update:统一环境参数入口

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