提交 5b131860 编写于 作者: Z zhuzhiyong

feat: update package.json

上级 d2d18956
"use strict";function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach(function(t){_defineProperty(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function _defineProperty(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}var util=require("../../utils/util.js"),img=require("../../utils/imgbase64"),app=getApp();Object.prototype.hasOwnProperty.call(app,"originRequest")||"[object Function]"===Object.prototype.toString.apply(getApp().originRequest)||(app.originRequest=wx.request);var mockBaseUrl="https://mock.dokit.cn";Component({properties:{projectId:{type:String,value:""}},data:{mockList:[],tplList:[],curScene:"",curNav:"mock",templateData:"",urlId:"",isShow:!1,img:img},lifetimes:{created:function(){console.log("app",app)},attached:function(){this.pageInit()},detached:function(){wx.setStorageSync("dokit-mocklist",this.data.mockList)}},methods:{onGoBack:function(){this.triggerEvent("toggle",{componentType:"dokit"})},request:function(t){return new Promise(function(e,a){app.originRequest(_objectSpread({},t,{success:function(t){return e(t)},fail:function(t){return a(t)}}))})},pageInit:function(){this.initList(),this.addRequestHooks()},getProjectId:function(){return this.data.projectId?this.data.projectId:void console.warn("您还没有设置 projectId,去快平台端体验吧:https://www.dokit.cn")},initList:function(){var a=this,t={url:"".concat(mockBaseUrl,"/api/app/interface"),method:"GET",data:{projectId:this.getProjectId(),isfull:1}};a.request(t).then(function(t){var e=t.data.data;e&&e.datalist&&e.datalist.length&&(a.updateMockList(e.datalist),a.updateTplList(e.datalist))}).catch()},updateMockList:function(t){var e=[],a=this,r=wx.getStorageSync("dokit-mocklist");e=r&&r.length?a.mergeMockList(t,r):t.map(function(t){return a.processMockItem(t)}),a.setData({mockList:e},function(){console.log("dokit-mocklist",a.data.mockList)})},updateTplList:function(t){var e=[],a=this,r=wx.getStorageSync("dokit-tpllist");e=r&&r.length?a.mergeTplList(t,r):t.map(function(t){return a.processTplItem(t)}),a.setData({tplList:e},function(){console.log("dokit-tpllist",a.data.tplList)})},mergeMockList:function(t,e){for(var a=[],r=0,i=t.length;r<i;r++){for(var n=t[r],s=!1,c=0,o=e.length;c<o;c++){var d=e[c];if(n._id==d._id){if(n.hidden=d.hidden,n.checked=d.checked,n.query=n.query?JSON.stringify(n.query):"{}",n.body=n.body?JSON.stringify(n.body):"{}",util.isArray(n.sceneList)&&n.sceneList.length){for(var u=!1,p=0,l=n.sceneList.length;p<l;p++){for(var h=n.sceneList[p],f=0,g=d.sceneList.length;f<g;f++){var m=d.sceneList[f];if(h._id==m._id&&m.checked){h.checked=m.checked,u=!0;break}}if(u)break}!u&&n.sceneList[0]&&(n.sceneList[0].checked=!0)}else n.sceneList=[];s=!0;break}}s||(n=this.processMockItem(n)),a.push(n)}return a},mergeTplList:function(t,e){for(var a=[],r=0,i=t.length;r<i;r++){for(var n=t[r],s=!1,c=0,o=e.length;c<o;c++){var d=e[c];if(n._id==d._id){n.hidden=d.hidden,n.checked=d.checked,n.templateData=d.templateData?d.templateData:"",s=!0;break}}s||(n=this.processTplItem(n)),a.push(n)}return a},processMockItem:function(t){return _objectSpread({},t,{hidden:!0,checked:!1,query:t.query?JSON.stringify(t.query):"{}",body:t.body?JSON.stringify(t.body):"{}",sceneList:util.isArray(t.sceneList)?t.sceneList.map(function(t,e){return _objectSpread({},t,{checked:0===e})}):[]})},processTplItem:function(t){return _objectSpread({},t,{hidden:!0,checked:!1,query:t.query?JSON.stringify(t.query):"{}",body:t.body?JSON.stringify(t.body):"{}"})},addRequestHooks:function(){Object.defineProperty(wx,"request",{writable:!0}),console.group("addRequestHooks success");var i=this.matchUrlRequest,n=this.matchUrlTpl;wx.request=function(t){var e=util.deepClone(t),a=t.success,r=i(t);r&&(t.url="".concat(mockBaseUrl,"/api/app/scene/").concat(r),console.group("request options",t),console.warn("被拦截了~")),t.success=function(t){a(t),n(e,t)},app.originRequest(t)}},onTabbar:function(t){t.currentTarget.dataset.type},onNavChange:function(t){var e=t.currentTarget.dataset.type;this.setData({curNav:e})},onExpand:function(t){var e=t.currentTarget.dataset,a=e.index,r=e.type,i="".concat(r,"List[").concat(a,"].hidden");this.setData(_defineProperty({},i,!this.data["".concat(r,"List")][a].hidden))},onToggleChecked:function(t){var e=t.currentTarget.dataset,a=e.index,r=e.type,i="".concat(r,"List[").concat(a,"].checked");this.setData(_defineProperty({},i,!this.data["".concat(r,"List")][a].checked))},onRadioChange:function(t){var a=this,e=t.currentTarget.dataset,r=e.index,i=e.idx;this.data.mockList[r].sceneList.map(function(t,e){a.data.mockList[r].sceneList[e].checked=e==i})},matchUrlTpl:function(t,e){var a,r=this;if(!r.data.tplList.length)return!1;for(var i=0,n=r.data.tplList.length;i<n;i++)a=r.data.tplList[i],r.requestIsmatch(t,a)&&a.checked&&200==e.statusCode&&(r.data.tplList[i].templateData=e.data);wx.setStorageSync("dokit-tpllist",r.data.tplList)},uploadTplData:function(){},matchUrlRequest:function(t){var e,a,r=!1;if(!this.data.mockList.length)return!1;for(var i=0,n=this.data.mockList.length;i<n;i++)if(e=this.data.mockList[i],this.requestIsmatch(t,e)){r=!0;break}if(e.sceneList&&e.sceneList.length)for(var s=0,c=e.sceneList.length;s<c;s++){var o=e.sceneList[s];if(o.checked){a=o._id;break}}else a=!1;return r&&e.checked&&a},requestIsmatch:function(t,e){var a=util.getPartUrlByParam(t.url,"path"),r=util.getPartUrlByParam(t.url,"query");return this.urlMethodIsEqual(a,t.method,e.path,e.method)&&this.requestParamsIsEqual(r,t.data,e.query,e.body)},urlMethodIsEqual:function(t,e,a,r){return e=e||"GET",(t=t?"/".concat(t):"")==a&&e.toUpperCase()==r.toUpperCase()},requestParamsIsEqual:function(t,e,a,r){t=util.search2Json(t),e=e||{};try{return JSON.stringify(t)==a&&JSON.stringify(e)==r}catch(t){return!1}},onPreview:function(t){var e=t.currentTarget.dataset.index,a=this.data.tplList[e],r=a.templateData,i=a._id;if(r){var n;try{n=JSON.stringify(r,null,4)}catch(t){}this.setData({urlId:i,templateData:n,isShow:!this.data.isShow})}else wx.showToast({title:"没有模板数据哦~",image:"../assets/img/error.png",duration:1e3})},onCancel:function(){this.setData({isShow:!1})},onUpload:function(t){var e=this,a=t.currentTarget.dataset.index,r={};if(null!=a){var i=e.data.tplList[a];r={id:i._id,tempData:i.templateData,projectId:e.getProjectId()}}else r={id:e.data.urlId,tempData:e.data.templateData,projectId:e.getProjectId()};var n={url:"".concat(mockBaseUrl,"/api/app/interface"),method:"POST",data:r};e.request(n).then(function(t){wx.showToast({title:"上传成功!",icon:"success",duration:1e3}),e.data.isShow&&e.onCancel()}).catch()}}});
\ No newline at end of file
"use strict";function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach(function(t){_defineProperty(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function _defineProperty(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}var img=require("../../assets/imgs/imgbase64"),util=require("../../utils/util.js"),app=getApp();Object.prototype.hasOwnProperty.call(app,"originRequest")||"[object Function]"===Object.prototype.toString.apply(getApp().originRequest)||(app.originRequest=wx.request);var mockBaseUrl="https://mock.dokit.cn";Component({properties:{projectId:{type:String,value:""}},data:{mockList:[],tplList:[],curScene:"",curNav:"mock",templateData:"",urlId:"",isShow:!1,img:img},lifetimes:{created:function(){console.log("app",app)},attached:function(){this.pageInit()},detached:function(){wx.setStorageSync("dokit-mocklist",this.data.mockList)}},methods:{onGoBack:function(){this.triggerEvent("toggle",{componentType:"dokit"})},request:function(t){return new Promise(function(e,a){app.originRequest(_objectSpread({},t,{success:function(t){return e(t)},fail:function(t){return a(t)}}))})},pageInit:function(){this.initList(),this.addRequestHooks()},getProjectId:function(){return this.data.projectId?this.data.projectId:void console.warn("您还没有设置 projectId,去快平台端体验吧:https://www.dokit.cn")},initList:function(){var a=this,t={url:"".concat(mockBaseUrl,"/api/app/interface"),method:"GET",data:{projectId:this.getProjectId(),isfull:1}};a.request(t).then(function(t){var e=t.data.data;e&&e.datalist&&e.datalist.length&&(a.updateMockList(e.datalist),a.updateTplList(e.datalist))}).catch()},updateMockList:function(t){var e=[],a=this,r=wx.getStorageSync("dokit-mocklist");e=r&&r.length?a.mergeMockList(t,r):t.map(function(t){return a.processMockItem(t)}),a.setData({mockList:e},function(){console.log("dokit-mocklist",a.data.mockList)})},updateTplList:function(t){var e=[],a=this,r=wx.getStorageSync("dokit-tpllist");e=r&&r.length?a.mergeTplList(t,r):t.map(function(t){return a.processTplItem(t)}),a.setData({tplList:e},function(){console.log("dokit-tpllist",a.data.tplList)})},mergeMockList:function(t,e){for(var a=[],r=0,i=t.length;r<i;r++){for(var n=t[r],s=!1,c=0,o=e.length;c<o;c++){var d=e[c];if(n._id==d._id){if(n.hidden=d.hidden,n.checked=d.checked,n.query=n.query?JSON.stringify(n.query):"{}",n.body=n.body?JSON.stringify(n.body):"{}",util.isArray(n.sceneList)&&n.sceneList.length){for(var u=!1,p=0,l=n.sceneList.length;p<l;p++){for(var h=n.sceneList[p],f=0,g=d.sceneList.length;f<g;f++){var m=d.sceneList[f];if(h._id==m._id&&m.checked){h.checked=m.checked,u=!0;break}}if(u)break}!u&&n.sceneList[0]&&(n.sceneList[0].checked=!0)}else n.sceneList=[];s=!0;break}}s||(n=this.processMockItem(n)),a.push(n)}return a},mergeTplList:function(t,e){for(var a=[],r=0,i=t.length;r<i;r++){for(var n=t[r],s=!1,c=0,o=e.length;c<o;c++){var d=e[c];if(n._id==d._id){n.hidden=d.hidden,n.checked=d.checked,n.templateData=d.templateData?d.templateData:"",s=!0;break}}s||(n=this.processTplItem(n)),a.push(n)}return a},processMockItem:function(t){return _objectSpread({},t,{hidden:!0,checked:!1,query:t.query?JSON.stringify(t.query):"{}",body:t.body?JSON.stringify(t.body):"{}",sceneList:util.isArray(t.sceneList)?t.sceneList.map(function(t,e){return _objectSpread({},t,{checked:0===e})}):[]})},processTplItem:function(t){return _objectSpread({},t,{hidden:!0,checked:!1,query:t.query?JSON.stringify(t.query):"{}",body:t.body?JSON.stringify(t.body):"{}"})},addRequestHooks:function(){Object.defineProperty(wx,"request",{writable:!0}),console.group("addRequestHooks success");var i=this.matchUrlRequest,n=this.matchUrlTpl;wx.request=function(t){var e=util.deepClone(t),a=t.success,r=i(t);r&&(t.url="".concat(mockBaseUrl,"/api/app/scene/").concat(r),console.group("request options",t),console.warn("被拦截了~")),t.success=function(t){a(t),n(e,t)},app.originRequest(t)}},onTabbar:function(t){t.currentTarget.dataset.type},onNavChange:function(t){var e=t.currentTarget.dataset.type;this.setData({curNav:e})},onExpand:function(t){var e=t.currentTarget.dataset,a=e.index,r=e.type,i="".concat(r,"List[").concat(a,"].hidden");this.setData(_defineProperty({},i,!this.data["".concat(r,"List")][a].hidden))},onToggleChecked:function(t){var e=t.currentTarget.dataset,a=e.index,r=e.type,i="".concat(r,"List[").concat(a,"].checked");this.setData(_defineProperty({},i,!this.data["".concat(r,"List")][a].checked))},onRadioChange:function(t){var a=this,e=t.currentTarget.dataset,r=e.index,i=e.idx;this.data.mockList[r].sceneList.map(function(t,e){a.data.mockList[r].sceneList[e].checked=e==i})},matchUrlTpl:function(t,e){var a,r=this;if(!r.data.tplList.length)return!1;for(var i=0,n=r.data.tplList.length;i<n;i++)a=r.data.tplList[i],r.requestIsmatch(t,a)&&a.checked&&200==e.statusCode&&(r.data.tplList[i].templateData=e.data);wx.setStorageSync("dokit-tpllist",r.data.tplList)},uploadTplData:function(){},matchUrlRequest:function(t){var e,a,r=!1;if(!this.data.mockList.length)return!1;for(var i=0,n=this.data.mockList.length;i<n;i++)if(e=this.data.mockList[i],this.requestIsmatch(t,e)){r=!0;break}if(e.sceneList&&e.sceneList.length)for(var s=0,c=e.sceneList.length;s<c;s++){var o=e.sceneList[s];if(o.checked){a=o._id;break}}else a=!1;return r&&e.checked&&a},requestIsmatch:function(t,e){var a=util.getPartUrlByParam(t.url,"path"),r=util.getPartUrlByParam(t.url,"query");return this.urlMethodIsEqual(a,t.method,e.path,e.method)&&this.requestParamsIsEqual(r,t.data,e.query,e.body)},urlMethodIsEqual:function(t,e,a,r){return e=e||"GET",(t=t?"/".concat(t):"")==a&&e.toUpperCase()==r.toUpperCase()},requestParamsIsEqual:function(t,e,a,r){t=util.search2Json(t),e=e||{};try{return JSON.stringify(t)==a&&JSON.stringify(e)==r}catch(t){return!1}},onPreview:function(t){var e=t.currentTarget.dataset.index,a=this.data.tplList[e],r=a.templateData,i=a._id;if(r){var n;try{n=JSON.stringify(r,null,4)}catch(t){}this.setData({urlId:i,templateData:n,isShow:!this.data.isShow})}else wx.showToast({title:"没有模板数据哦~",image:"../assets/img/error.png",duration:1e3})},onCancel:function(){this.setData({isShow:!1})},onUpload:function(t){var e=this,a=t.currentTarget.dataset.index,r={};if(null!=a){var i=e.data.tplList[a];r={id:i._id,tempData:i.templateData,projectId:e.getProjectId()}}else r={id:e.data.urlId,tempData:e.data.templateData,projectId:e.getProjectId()};var n={url:"".concat(mockBaseUrl,"/api/app/interface"),method:"POST",data:r};e.request(n).then(function(t){wx.showToast({title:"上传成功!",icon:"success",duration:1e3}),e.data.isShow&&e.onCancel()}).catch()}}});
\ No newline at end of file
const img = require('../../assets/imgs/imgbase64')
const util = require('../../utils/util.js');
const img = require('../../utils/imgbase64')
const app = getApp()
if (!Object.prototype.hasOwnProperty.call(app, 'originRequest') && Object.prototype.toString.apply(getApp().originRequest) !== "[object Function]") {
app.originRequest = wx.request
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册