let defaultConfig = require('@/utils/config/defaultConfig').default;

const isInstalled = () => {
  try {
    require('@/SystemConfig.json')
    return true;
  } catch (err) {
    return false;
  }
};

if (isInstalled()) {
  const customSystemConfig = require('@/SystemConfig.json');
  defaultConfig = Object.assign(defaultConfig, customSystemConfig);
}

/**
 * 导出自定义的配置信息
 * @param systemConfig
 * @returns {{adminAccess: string, secretKey: string, adminUser: string, secretValue: string, systemConfig: string, loginTitle: string, language: string, loginPage: string, indexTitle: string, token: string, defaultLang: string}}
 */
export function initSystemConfig(systemConfig) {
  return Object.assign({}, defaultConfig, systemConfig || {});
}

/**
 * 导入默认的配置
 */
export default defaultConfig;