1. hash=$(git show -s -2 --format=%H)
  2. // 打印最近两次提交的hash
  3. diff=$(git diff --stat $hash)
  4. // 对比两次提交文件的差异
  5. // newAdmin/src/pages/finance/template/detail.vue | 3 +-
  6. // newAdmin/src/pages/finance/template/item.vue | 81 ++++---------------------
  7. // newAdmin/src/router/modules/finance/template.js | 12 ++--
  8. // 3 files changed, 19 insertions(+), 77 deletions(-)
  • 提取差异的文件的路径的根目录

socket.io

of 说明在 / 路径下,socket.emit(‘chat’, ‘hello world!’)的第一个参数chat 代表路由的route(‘chat’),当执行emit(‘chat’, xxxx)的时候,会触发app/io/ctronller/chat.js 中的 index 方法,但是在触发之前还要看一下有没有配置中间件,有中间件则先进入中间件。

前端在本地开发时用的是localhost或者ip的地址时,会有问题

  1. io(`${window.location.protocol}//${url}:8889/socket`, {
  2. reconnection: false,
  3. transports: ['websocket'] // 强制使用websocket,不使用兼容模式
  4. })

接口转发,共享session和cookie
下面是透传cookie的方式

  1. 'use strict'
  2. const { Service } = require('egg')
  3. class User extends Service {
  4. async checkLogin () {
  5. const { ctx } = this
  6. const result = await ctx.curl('http://test', {
  7. headers: {
  8. cookie: ctx.header.cookie
  9. },
  10. dataType: 'json',
  11. timeout: 3000
  12. })
  13. return result.data
  14. }
  15. }
  16. module.exports = User