config.default.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. '/sys/upload/uploadImageXy', // 上传图片到Xy
  31. '/visit/pcVisitCommit', // 视频巡访提交
  32. '/index',
  33. '/sys/login/in',
  34. '/sys/login/connection',
  35. '/wx/wxMessage',
  36. '/wx/getSign',
  37. '/wx/getOpenId',
  38. '/wx/getAppId',
  39. '/wxinfo/isExist',
  40. '/wxinfo/bing',
  41. '/wxinfo/visitIsExist',
  42. '/wxinfo/visitBing',
  43. '/wxinfo/visitUnbind',
  44. '/wxinfo/visitByFid',
  45. '/wxinfo/visitByNumber',
  46. '/visit/one',
  47. '/applet/isExist',
  48. '/applet/bing',
  49. '/applet/homeStatistics',
  50. '/welcomeMessage/list',
  51. '/banner/list',
  52. '/wx/getAppletOpenId',
  53. '/applet/appletVisitIsExist',
  54. '/applet/appletVisitBing',
  55. '/applet/appletVisitUnbind',
  56. '/oss/getALiOssToken',
  57. '/wxinfo/ownerAdd', // 未登录的用户也可以自主上报信息
  58. '/wxinfo/ownerUpdate', // 自主填报修改采集记录
  59. '/wxinfo/ownerStatistics', // 自主填报查询吉林省统计
  60. // '/info/createOldInfoOwnerUser', // 将以前的第五级地区自主上报员 生成一次(且只可执行一次)
  61. // '/info/createYlxtSelectUser', // 生成前三级 养老系统 信息查询管理员 生成一次(且只可执行一次) // CH 2022-11-15 16:17:03
  62. '/sys/user/selectOne', // 修改默认密码
  63. '/sys/user/updatePwdBeforeLogin', // 修改默认密码
  64. ];
  65. const url = ctx.request.url;
  66. for (const item of ignoreUrl) {
  67. if (url.indexOf(item) >= 0) {
  68. return true;
  69. }
  70. }
  71. return false;
  72. },
  73. };
  74. config.xml2js = {
  75. match(ctx) {
  76. const matchUrl = [ '/wx/wxMessage' ];
  77. const url = ctx.request.url;
  78. for (const item of matchUrl) {
  79. if (url.indexOf(item) >= 0) {
  80. return true;
  81. }
  82. }
  83. return false;
  84. },
  85. };
  86. config.common = {
  87. match() {
  88. return true;
  89. },
  90. };
  91. config.wechat_config = {
  92. // 这边使用的是故事机的appId 后期无解
  93. appId: 'wx22055631b887c2ab',
  94. appSecret: '328614e5d0d0b5f90c8480a6a9f81b00',
  95. getAccessToken: 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=APPID&secret=APPSECRET',
  96. createMenu: 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=ACCESS_TOKEN',
  97. getUserInfo: 'https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN',
  98. getJsApiTicket: 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi',
  99. // 公众号获取openid
  100. oauthAccessToken: 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code',
  101. // 小程序获取openid
  102. getAppletAccessToken: 'https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=CODE&grant_type=authorization_code',
  103. oauthUserinfo: 'https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID&lang=zh_CN',
  104. };
  105. // 加密
  106. config.dump = { ignore: new Set([
  107. 'pass', 'pwd', 'passd', 'passwd', 'password', 'keys', 'masterKey', 'accessKey',
  108. // ignore any key contains "secret" keyword
  109. /secret/i, 'wechat_config', 'userConfig',
  110. ]) };
  111. // add your user config here
  112. const userConfig = {
  113. // myAppName: 'egg',
  114. cors: {
  115. origin: '*', // 注释掉就是上面的white生效
  116. allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH',
  117. },
  118. sessionTimeOut: 86400, // 24H
  119. defaultPassword: '123456',
  120. defaultYlxtSelectPassword: 'sckj@2022',
  121. defaultPageSize: 10,
  122. defaultUploadPath: './app/public/',
  123. defaultWritePathPre: '/public/uploads/',
  124. defaultWriteAliOSSPath: 'public/uploads/',
  125. scanPathPre: '/public/uploads/scan/',
  126. scanAliOSSPath: 'public/uploads/scan/',
  127. defaultWriteFilePathPre: '/public/file/',
  128. uploadDir: './app/public/avatar/upload/',
  129. defaultAdminId: '5d0070438217f92210e6f972',
  130. defaultAdminRoleId: '5d030a91ebd90c299489c121',
  131. defaultManagerRoleId: '5d036441464ced1f1840204a',
  132. defaultUserRoleId: '5d0c41046a0a730a44fe06b5',
  133. defaultOwnerManagerRoleId: '617f4b42e134000015002d42', // 自主上报员ObjectId
  134. defaultYLXTSelectRoleId: '617f4b42e134000015002a11', // 养老系统信息查看角色ObjectId-2022-11-15-CH
  135. fileType: {
  136. AUTH: '/public/uploads/auth/', // 采集员认证文件照片
  137. INFO: '/public/uploads/info/', // 采集老人的照片
  138. VISIT: '/public/uploads/visit/', // 巡防照片
  139. SCAN: '/public/uploads/scan/', // 二维码生成路径
  140. CARD: '/public/uploads/card/', // 身份卡图片
  141. },
  142. roleArn: 'acs:ram::35026409:role/aliyunststokenverify', // 阿里云RAM受信账号
  143. tokenExpireTime: 3600, // OssToken 过期时间(900-3600秒)
  144. sessionName: 'SCKJALiOssToken', // 用户自定义参数。此参数用来区分不同的令牌,可用于用户级别的访问审计。
  145. logger: {
  146. consoleLevel: 'DEBUG', // NONE
  147. allowDebugAtProd: true,
  148. level: 'DEBUG', // NONE
  149. },
  150. };
  151. return {
  152. ...config,
  153. ...userConfig,
  154. };
  155. };