queryConfig.js 5.9 KB
Newer Older
徐立's avatar
徐立 committed
1 2 3 4 5 6 7 8 9
/**
 * @param key 配置文件中 key
 * @author yyq
 * @version 0.0.1
 * @return 配置信息
 * @description
 * 当未传入key时返回config对象
 * 当key存在是且存在对应key值时返回key值 否则返回config对象
 * */
钟是志's avatar
钟是志 committed
10

11
//请求地址前缀
钟是志's avatar
钟是志 committed
12

13 14
if (typeof globalThis === 'undefined') { // globalThis 在qq浏览器存在兼容性问题 https://caniuse.com/?search=globalThis
  var globalThis = window;
15 16
}

17 18 19
if (!globalThis.CONFIG) {
  var SERVER_PATH = 'https://xg.gzjszy.net/produce/v1/api/onestop';
  var ACTION_PATH = SERVER_PATH + '';
钟是志's avatar
钟是志 committed
20
  globalThis.CONFIG = {
21 22 23 24 25 26 27 28 29 30 31 32 33
    SYSCODE: 'code',
    OAUTH_ACTION_PATH: ACTION_PATH + '',                                    //服务请求地址
    PERM_ACTION_PATH: ACTION_PATH + '',                                        //服务请求地址
    API_ACTION_PATH: ACTION_PATH + '',                                     //服务请求地址
    FILE_UPLOAD_ACTION_PATH: ACTION_PATH + '/folder/uploadFileApi/upload',          //文件上传地址
    LAYOUT_HEADER_LOGO: 'default_layoutHeader_logo.png',                            //layout 系统logo
    LOGIN_HEADER_LOGO: 'default_layoutHeader_logo2.png',                                                          //登录页面头部logo
    SYSTEM_NAME: '一站式事物管理系统',                                                        //系统名称
    LAYOUT_HEADER_SYSTEM_WELCOME: '欢迎进入装备及资产管理系统',               //layout头部系统欢迎语
    LAYOUT_TYPE: 'ZY',                                                              //使用Layout内省       ANT | ZY  分别为ant-pro自带layout和知用layout
    LAYOUT_HEADER_CENTER_BACKGROUND: 'lsz.png',                                     //layout头部中间背景图片
    LAYOUT_SIDER_FOOTER_BACKGROUND: 'lsz2.png',                                     //layout菜单底部背景图片
    LOGIN_BACKGROUND: 'logoPic_gyys.png',                                                 //layout菜单底部背景图片
钟是志's avatar
钟是志 committed
34
    CHECK_PATH: true,                                                              //layout菜单底部背景图片
35 36
    LOGIN_REDIRECT: '/portal/home',                                                          //登录后重定向地址
    WS_PATH: null,
钟是志's avatar
钟是志 committed
37 38 39 40
    DYNAMIC_ACTION_PATH: ACTION_PATH,
  };
}

徐立's avatar
徐立 committed
41
const queryConfig = (key) => {
42 43 44 45
  const dynamicConfig = typeof globalThis !== 'undefined' ? globalThis.CONFIG : window.CONFIG;
  // console.log(dynamicConfig);
  if (typeof key === 'undefined') return dynamicConfig;
  return dynamicConfig[key];
徐立's avatar
徐立 committed
46 47 48 49 50
};

/**
 * @description 获取系统编码
 * */
51
export const querySysCode = () => queryConfig('SYSCODE');
徐立's avatar
徐立 committed
52

53
export const queryWsPath = () => queryConfig('WS_PATH');
徐立's avatar
徐立 committed
54

xuli's avatar
xuli committed
55 56 57
/**
 * @description 获取场景设计器定制后台地址
 * */
58
export const queryDynamicActionPath = () => queryConfig('DYNAMIC_ACTION_PATH');
xuli's avatar
xuli committed
59

徐立's avatar
徐立 committed
60 61 62
/**
 * @description 获取服务端请求路径前戳
 * */
63
export const queryOauthActionPath = () => queryConfig('OAUTH_ACTION_PATH');
徐立's avatar
徐立 committed
64 65 66 67

/**
 * @description 获取服务端请求路径前戳
 * */
68
export const queryPermActionPath = () => queryConfig('PERM_ACTION_PATH');
徐立's avatar
徐立 committed
69 70 71 72

/**
 * @description 获取服务端请求路径前戳
 * */
73
export const queryApiActionPath = () => queryConfig('API_ACTION_PATH');
徐立's avatar
徐立 committed
74 75 76 77

/**
 * @description 获取文件上传地址
 * */
78
export const queryFileUploadActionPath = () => queryConfig('FILE_UPLOAD_ACTION_PATH');
徐立's avatar
徐立 committed
79 80 81 82

/**
 * @description 获取layout头部logo名称
 * */
83
export const queryLayoutHeaderLogo = () => queryConfig('LAYOUT_HEADER_LOGO');
徐立's avatar
徐立 committed
84 85 86 87

/**
 * @description 获取登录页面头部logo名称
 * */
88
export const queryLoginHeaderLogo = () => queryConfig('LOGIN_HEADER_LOGO');
徐立's avatar
徐立 committed
89 90 91 92

/**
 * @description 获取系统名称
 * */
93
export const querySystemName = () => queryConfig('SYSTEM_NAME');
徐立's avatar
徐立 committed
94 95 96 97

/**
 * @description 获取layout头部系统欢迎语
 * */
98
export const queryLayoutHeaderSystemWelcome = () => queryConfig('LAYOUT_HEADER_SYSTEM_WELCOME');
徐立's avatar
徐立 committed
99 100 101 102

/**
 * @description 获取layout类型
 * */
103
export const queryLayoutType = () => queryConfig('LAYOUT_TYPE');
徐立's avatar
徐立 committed
104 105 106 107

/**
 * @description 获取layout头部中间背景图片
 * */
108
export const queryLayoutHeaderCenterBackground = () =>
109
  queryConfig('LAYOUT_HEADER_CENTER_BACKGROUND');
徐立's avatar
徐立 committed
110 111 112 113

/**
 * @description 获取layout菜单底部背景图片
 * */
114
export const queryLayoutSiderFooterBackground = () => queryConfig('LAYOUT_SIDER_FOOTER_BACKGROUND');
徐立's avatar
徐立 committed
115 116 117 118

/**
 * @description 获取登录页面登录框旁背景图片
 * */
119
export const queryLoginBackground = () => queryConfig('LOGIN_BACKGROUND');
徐立's avatar
徐立 committed
120 121 122 123 124 125 126 127 128

/**
 * @description 获取动态图片前缀
 * */
export const queryDynamicImagePrefix = () => `${window.publicPath}images/dynamic/`;

/**
 * @description 获取配置项路由是否需要权限控制
 * */
129
export const queryCheckPath = () => queryConfig('CHECK_PATH');
徐立's avatar
徐立 committed
130 131 132 133

/**
 * @description 获取配置项路由是否需要权限控制
 * */
134
export const queryLoginRedirect = () => queryConfig('LOGIN_REDIRECT');
135
export const queryApiVersion = () => queryConfig('apiVersion');
136
export const queryUiaApi = () => queryConfig('oauthServer');
137
export const queryIsSafe = () => queryConfig('IS_SAFE'); // 是否开启文件上传加密 2022年5月24日 钟是志 解决北电科安全防火墙bug
钟是志's avatar
钟是志 committed
138
export const queryIsBinary = () => queryConfig('IS_BINARY'); // 是否开启接口加密二进制上传 2022年6月9日 钟是志 解决北电科安全测评 27448
139
export const resetLoginUrl = () => queryConfig('resetLoginUrl'); // 是否退出登录注销token 解决北电科安全测评
钟是志's avatar
钟是志 committed
140
export const hiddenExitButton = () => queryConfig('hiddenExitButton');
徐立's avatar
徐立 committed
141

142
export const queryFileUrl = (url = '', defaultFile = '') => {
143
  if (url && typeof url === 'string' && url.length > 10) {
144
    if (url.indexOf('http') > -1) {
145 146 147 148 149
      return url;
    }
    const prefix = window.CONFIG['FILE_PATH'] || window.CONFIG['API_ACTION_PATH'];
    return prefix + url;
  } else {
150 151 152
    if (defaultFile) {
      return defaultFile;
    }
153 154 155 156
    return '';
  }
};

徐立's avatar
徐立 committed
157
export default queryConfig;