config.default.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* eslint valid-jsdoc: "off" */
  2. 'use strict';
  3. /**
  4. * @param {Egg.EggAppInfo} appInfo app info
  5. */
  6. module.exports = appInfo => {
  7. const config = exports = {};
  8. // use for cookie sign key, should change to your own and keep security
  9. config.keys = appInfo.name + '_1560223608734_7978';
  10. // post form请求 关闭csrf安全插件
  11. config.security = {
  12. csrf: {
  13. enable: false,
  14. ignoreJSON: true,
  15. },
  16. // domainWhiteList: [ 'http://www.baidu.com' ], // 配置白名单
  17. };
  18. // 配置上传
  19. config.multipart = {
  20. fileSize: '50mb',
  21. mode: 'stream',
  22. fileExtensions: [ '.jpg', '.img', '.png', '.docx' ], // 扩展几种上传的文件格式
  23. };
  24. // add your middleware config here
  25. config.middleware = [ 'common', 'interceptor', 'xml2js' ];
  26. config.interceptor = {
  27. ignore(ctx) {
  28. // 所有微信的接口 和 登录接口不需要带用户
  29. const ignoreUrl = [
  30. '/index',
  31. '/sys/login/in',
  32. '/sys/login/connection',
  33. '/wx/wxMessage',
  34. '/wx/getSign',
  35. '/wx/getOpenId',
  36. '/wx/getAppId',
  37. '/wxinfo/isExist',
  38. '/wxinfo/bing',
  39. '/wxinfo/visitIsExist',
  40. '/wxinfo/visitBing',
  41. '/wxinfo/visitUnbind',
  42. '/wxinfo/visitByFid',
  43. '/wxinfo/visitByNumber',
  44. '/visit/one',
  45. '/applet/isExist',
  46. '/applet/bing',
  47. '/applet/homeStatistics',
  48. '/welcomeMessage/list',
  49. '/banner/list',
  50. '/wx/getAppletOpenId',
  51. '/applet/appletVisitIsExist',
  52. '/applet/appletVisitBing',
  53. '/applet/appletVisitUnbind',
  54. '/oss/getALiOssToken',
  55. '/wxinfo/ownerAdd', // 未登录的用户也可以自主上报信息
  56. '/wxinfo/ownerUpdate', // 自主填报修改采集记录
  57. '/wxinfo/ownerStatistics', // 自主填报查询吉林省统计
  58. // '/info/createOldInfoOwnerUser', // 将以前的第五级地区自主上报员 生成一次(且只可执行一次)
  59. // '/sys/user/createYlxtSelectUser', // 生成前三级 养老系统 信息查询管理员 生成一次(且只可执行一次) // CH 2022-11-15 16:17:03
  60. ];
  61. const url = ctx.request.url;
  62. for (const item of ignoreUrl) {
  63. if (url.indexOf(item) >= 0) {
  64. return true;
  65. }
  66. }
  67. return false;
  68. },
  69. };
  70. config.xml2js = {
  71. match(ctx) {
  72. const matchUrl = [ '/wx/wxMessage' ];
  73. const url = ctx.request.url;
  74. for (const item of matchUrl) {
  75. if (url.indexOf(item) >= 0) {
  76. return true;
  77. }
  78. }
  79. return false;
  80. },
  81. };
  82. config.common = {
  83. match() {
  84. return true;
  85. },
  86. };
  87. config.wechat_config = {
  88. // 这边使用的是故事机的appId 后期无解
  89. appId: 'wx22055631b887c2ab',
  90. appSecret: '328614e5d0d0b5f90c8480a6a9f81b00',
  91. getAccessToken: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET',
  92. createMenu: 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN',
  93. getUserInfo: 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN',
  94. getJsApiTicket: 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi',
  95. // 公众号获取openid
  96. oauthAccessToken: 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code',
  97. // 小程序获取openid
  98. getAppletAccessToken: 'https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=CODE&grant_type=authorization_code',
  99. oauthUserinfo: 'https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN',
  100. };
  101. // 加密
  102. config.dump = { ignore: new Set([
  103. 'pass', 'pwd', 'passd', 'passwd', 'password', 'keys', 'masterKey', 'accessKey',
  104. // ignore any key contains "secret" keyword
  105. /secret/i, 'wechat_config', 'userConfig',
  106. ]) };
  107. // add your user config here
  108. const userConfig = {
  109. // myAppName: 'egg',
  110. cors: {
  111. origin: '*', // 注释掉就是上面的white生效
  112. allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  113. },
  114. sessionTimeOut: 86400, // 24H
  115. defaultPassword: '123456',
  116. defaultYlxtSelectPassword: 'sckj@2022',
  117. defaultPageSize: 10,
  118. defaultUploadPath: './app/public/',
  119. defaultWritePathPre: '/public/uploads/',
  120. defaultWriteAliOSSPath: 'public/uploads/',
  121. scanPathPre: '/public/uploads/scan/',
  122. scanAliOSSPath: 'public/uploads/scan/',
  123. defaultWriteFilePathPre: '/public/file/',
  124. defaultAdminId: '5d0070438217f92210e6f972',
  125. defaultAdminRoleId: '5d030a91ebd90c299489c121',
  126. defaultManagerRoleId: '5d036441464ced1f1840204a',
  127. defaultUserRoleId: '5d0c41046a0a730a44fe06b5',
  128. defaultOwnerManagerRoleId: '617f4b42e134000015002d42', // 自主上报员ObjectId
  129. defaultYLXTSelectRoleId: '617f4b42e134000015002a11', // 养老系统信息查看角色ObjectId-2022-11-15-CH
  130. roleArn: 'acs:ram::35026409:role/aliyunststokenverify', // 阿里云RAM受信账号
  131. tokenExpireTime: 3600, // OssToken 过期时间(900-3600秒)
  132. sessionName: 'SCKJALiOssToken', // 用户自定义参数。此参数用来区分不同的令牌,可用于用户级别的访问审计。
  133. logger: {
  134. consoleLevel: 'DEBUG', // NONE
  135. allowDebugAtProd: true,
  136. level: 'DEBUG', // NONE
  137. },
  138. };
  139. return {
  140. ...config,
  141. ...userConfig,
  142. };
  143. };