参考这两篇即可: https://gist.github.com/guoc/a7a00e6d4d1adc0b26c2aaf01b6f1fab https://gist.github.com/schultyy/5673939