一 whistle安裝(mac)
1 安裝node.js
whistle是基于node實(shí)現(xiàn)的,node.js官網(wǎng):http://nodejs.cn/

2 whistle安裝
1) 終端使用npm命令安裝whistle
$ npm install -g whistle
2) 終端啟動(dòng)whistle
aaadeMacBook-Pro:~ root# w2 start --init
[i] whistle@2.9.22 started
[i] 1. use your device to visit the following URL list, gets the IP of the URL you can access:
http://127.0.0.1:8899/
http://172.20.20.131:8899/
http://192.168.72.115:8899/
Note: If all the above URLs are unable to access, check the firewall settings
For help see https://github.com/avwo/whistle
[i] 2. set the HTTP proxy on your device with the above IP & PORT(8899)
[i] 3. use Chrome to visit http://local.whistlejs.com/ to get started
Setting global proxy (127.0.0.1:8899) successful.
security: SecKeychainCopyDefault: A default keychain could not be found.
添加「--init」會(huì)初始化mac的全局代理設(shè)置,關(guān)閉whislte后需要把下圖的兩個(gè)??去掉才能正常聯(lián)網(wǎng)
mac網(wǎng)絡(luò)偏好設(shè)置
3) whistle其他操作
關(guān)閉whistle
$ w2 stop
重啟whistle
$ w2 restart
whistle幫助
$ w2 help
3 打開(kāi)whistle后臺(tái)管理頁(yè)面
在瀏覽器輸入127.1:8899進(jìn)入whistle后臺(tái)管理頁(yè)面
二 https證書(shū)安裝
1 證書(shū)下載
點(diǎn)擊whistle頁(yè)面菜單中的HTTPS,點(diǎn)擊二維碼,即可下載證書(shū)。

2 證書(shū)安裝
https://jingyan.baidu.com/article/5225f26ba6dbfce6fb090856.html
三 修改接口返回值
需要先找到需要修改返回值的接口
1 獲取返回結(jié)果模板
打開(kāi)瀏覽器訪問(wèn)頁(yè)面,在控制臺(tái)中找到需要修改返回值的接口,copy該接口的返回值

2 設(shè)置返回結(jié)果
打開(kāi)whistle管理頁(yè)面,在value中新建一個(gè)json文件,將復(fù)制的內(nèi)容粘貼到文件中,修改參數(shù)為自己需要的返回結(jié)果

修改后,要點(diǎn)擊「save」才會(huì)保存生效
3 在rules中設(shè)置規(guī)則
進(jìn)入Rules-->default中設(shè)置規(guī)則,內(nèi)容格式:
#該接口請(qǐng)求的URL file://{values中存放該接口返回的文件名+文件后綴}
http://127.0.0.1:8080/test file://{list.json}
點(diǎn)擊「save」即可生效
4 重新載入頁(yè)面,查看接口返回結(jié)果
參考:
http://www.itdecent.cn/p/17c48959be44
https://www.cnblogs.com/lv-lxz/p/16030338.html
https://jingyan.baidu.com/article/5225f26ba6dbfce6fb090856.html
https://www.cnblogs.com/lv-lxz/p/16030338.html
