提交 af8b7217 编写于 作者: Z zhuzhiyong

feat: fix ui

上级 f44af289
"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(){},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 0},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(){})},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(){})},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 u=e[c];if(n._id==u._id){if(n.hidden=u.hidden,n.checked=u.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 d=!1,p=0,l=n.sceneList.length;p<l;p++){for(var h=n.sceneList[p],f=0,g=u.sceneList.length;f<g;f++){var m=u.sceneList[f];if(h._id==m._id&&m.checked){h.checked=m.checked,d=!0;break}}if(d)break}!d&&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 u=e[c];if(n._id==u._id){n.hidden=u.hidden,n.checked=u.checked,n.templateData=u.templateData?u.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});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)),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 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(){},attached:function(){this.pageInit()},detached:function(){wx.setStorageSync("dokit-mocklist",this.data.mockList),wx.setStorageSync("dokit-tpllist",this.data.tplList)}},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 0},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(){})},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(){})},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});var i=this.matchUrlRequest.bind(this),n=this.matchUrlTpl.bind(this);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)),t.success=function(t){a(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 e;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);return wx.setStorageSync("dokit-tpllist",r.data.tplList),e},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
......@@ -5,7 +5,7 @@
</view>
<view class="list-wrap">
<scroll-view class='list-scroll' scroll-y style="height: 100%">
<view wx:if="{{ curNav == 'mock'}}" class="mock-list">
<view hidden="{{curNav !== 'mock'}}" class="mock-list">
<view wx:for="{{ mockList }}" wx:key="index">
<view class="item-wrap">
<view class="list-item" data-index="{{ index }}" data-type="mock" catchtap="onExpand">
......@@ -40,7 +40,7 @@
</view>
</view>
</view>
<view wx:if="{{ curNav == 'tpl'}}" class="tpl-list">
<view hidden="{{curNav !== 'tpl'}}" class="tpl-list">
<view wx:for="{{ tplList }}" wx:key="index">
<view class="item-wrap">
<view class="list-item" data-index="{{ index }}" data-type="tpl" catchtap="onExpand">
......
"use strict";var img=require("../../utils/imgbase64");Component({data:{storage:[],limitSize:0,currentSize:0,isShowManage:!1,addPopupClass:"",isShowMask:!1,isDeleteMode:!1,checkedStorage:[],addInfo:{key:"",value:"",title:"添加",disabled:!1},img:img},lifetimes:{created:function(){},attached:function(){this.setData({addInfo:{key:"",value:"",title:"添加",disabled:!1}}),this.getStorageInfo()},detached:function(){}},methods:{openDeleteMode:function(){this.setData({isDeleteMode:!0}),this.closeAll()},cancelDelete:function(){this.setData({isDeleteMode:!1})},showAddPopup:function(){this.setData({isShowManage:!1,addPopupClass:"add-dialog-active",addInfo:{key:"",value:"",title:"添加",disabled:!1}})},getStorageInfo:function(){var a=[],e=wx.getStorageInfoSync();this.setData({limitSize:e.limitSize}),this.setData({currentSize:e.currentSize}),e.keys.forEach(function(e){var t={key:e,value:wx.getStorageSync(e),isModify:!1,ischecked:!1};a.push(t)}),this.setData({storage:a})},closeAddPopup:function(){this.closeAll()},closeAll:function(){this.setData({isShowManage:!1,isShowMask:!1,addPopupClass:""})},openManageMeau:function(){this.setData({isShowManage:!0,isShowMask:!0})},clearStorage:function(){var t=this;this.data.checkedStorage.length&&wx.showModal({title:"提示",content:"确定删除选中内容?",success:function(e){e.confirm&&(t.data.checkedStorage.forEach(function(e){wx.removeStorageSync(e)}),t.onLoad())}})},clearAll:function(){var t=this;this.setData({isShowManage:!1}),wx.showModal({title:"提示",content:"确定要清除所有吗?",success:function(e){e.confirm&&(wx.clearStorageSync(),t.onLoad()),t.closeAll()}})},checkboxChange:function(e){this.setData({checkedStorage:e.detail.value})},modifyItemValue:function(e){this.setData({isShowMask:!0,addPopupClass:"add-dialog-active",addInfo:{key:e.currentTarget.dataset.key,value:e.currentTarget.dataset.value,title:"修改",disabled:!0}})},bingAddInfoKey:function(e){this.setData({"addInfo.key":e.detail.value})},bingAddInfoValue:function(e){this.setData({"addInfo.value":e.detail.value})},addStorage:function(){this.data.addInfo.key&&this.data.addInfo.value&&(wx.setStorageSync(this.data.addInfo.key,this.data.addInfo.value),this.onLoad()),this.closeAll()},onGoBack:function(){this.triggerEvent("toggle",{componentType:"dokit"})}}});
\ No newline at end of file
"use strict";var img=require("../../utils/imgbase64");Component({data:{storage:[],limitSize:0,currentSize:0,isShowManage:!1,addPopupClass:"",isShowMask:!1,isDeleteMode:!1,checkedStorage:[],addInfo:{key:"",value:"",title:"添加",disabled:!1},img:img},lifetimes:{created:function(){},attached:function(){this.componentInit()},detached:function(){}},methods:{componentInit:function(){this.setData({addInfo:{key:"",value:"",title:"添加",disabled:!1}}),this.getStorageInfo()},openDeleteMode:function(){this.setData({isDeleteMode:!0}),this.closeAll()},cancelDelete:function(){this.setData({isDeleteMode:!1})},showAddPopup:function(){this.setData({isShowManage:!1,addPopupClass:"add-dialog-active",addInfo:{key:"",value:"",title:"添加",disabled:!1}})},getStorageInfo:function(){var a=[],t=wx.getStorageInfoSync();this.setData({limitSize:t.limitSize}),this.setData({currentSize:t.currentSize}),t.keys.forEach(function(t){var e={key:t,value:wx.getStorageSync(t),isModify:!1,ischecked:!1};a.push(e)}),a=a.filter(function(t){return-1==["dokit-mocklist","dokit-tpllist"].indexOf(t.key)}),this.setData({storage:a})},closeAddPopup:function(){this.closeAll()},closeAll:function(){this.setData({isShowManage:!1,isShowMask:!1,addPopupClass:""})},openManageMeau:function(){this.setData({isShowManage:!0,isShowMask:!0})},clearStorage:function(){var e=this;this.data.checkedStorage.length&&wx.showModal({title:"提示",content:"确定删除选中内容?",success:function(t){t.confirm&&(e.data.checkedStorage.forEach(function(t){wx.removeStorageSync(t)}),e.componentInit())}})},clearAll:function(){var e=this;this.setData({isShowManage:!1}),wx.showModal({title:"提示",content:"确定要清除所有吗?",success:function(t){t.confirm&&(wx.getStorageInfoSync().keys.forEach(function(t){-1==["dokit-mocklist","dokit-tpllist"].indexOf(t)&&wx.removeStorageSync(t)}),e.componentInit());e.closeAll()}})},checkboxChange:function(t){this.setData({checkedStorage:t.detail.value})},modifyItemValue:function(t){this.setData({isShowMask:!0,addPopupClass:"add-dialog-active",addInfo:{key:t.currentTarget.dataset.key,value:t.currentTarget.dataset.value,title:"修改",disabled:!0}})},bingAddInfoKey:function(t){this.setData({"addInfo.key":t.detail.value})},bingAddInfoValue:function(t){this.setData({"addInfo.value":t.detail.value})},addStorage:function(){this.data.addInfo.key&&this.data.addInfo.value&&(wx.setStorageSync(this.data.addInfo.key,this.data.addInfo.value),this.componentInit()),this.closeAll()},onGoBack:function(){this.triggerEvent("toggle",{componentType:"dokit"})}}});
\ No newline at end of file
......@@ -17,7 +17,7 @@
<view class="table-title"><view class="key-title">Key</view><view class="value-title">Value</view></view>
<checkbox-group bindchange="checkboxChange" class="storage-content-box">
<view class="storage-item" wx:for="{{storage}}" wx:key="key">
<checkbox wx:if="{{isDeleteMode}}" class="storage-check" value="{{item.key}}" checked="{{item.checked}}" color="#fff"/>
<checkbox wx:if="{{isDeleteMode}}" class="storage-check" value="{{item.key}}" checked="{{item.checked}}" color="#337cc4"/>
<text class="storage-key {{isDeleteMode?'':'add-some-flex'}}">{{item.key}}</text>
<text class="storage-value" title="{{item.value}}">{{item.value}}</text>
<view class="clear-single-btn" type="primary" data-key="{{item.key}}" data-value="{{item.value}}" bindtap="modifyItemValue">
......
<!-- <view hidden="{{ curCom == 'dokit' }}">
<debug hidden="{{ curCom !== 'debug' }}" bindtoggle="tooggleComponent"></debug>
<appinformation hidden="{{ curCom !== 'appinformation' }}" bindtoggle="tooggleComponent"></appinformation>
<positionsimulation hidden="{{ curCom !== 'positionsimulation' }}" bindtoggle="tooggleComponent"></positionsimulation>
<storage hidden="{{ curCom !== 'storage' }}" bindtoggle="tooggleComponent"></storage>
<h5door hidden="{{ curCom !== 'h5door' }}" bindtoggle="tooggleComponent"></h5door>
<httpinjector hidden="{{ curCom !== 'httpinjector' }}" bindtoggle="tooggleComponent"></httpinjector>
<apimock hidden="{{ curCom !== 'apimock' }}" bindtoggle="tooggleComponent" projectId="{{ projectId }}"></apimock>
</view>
<view hidden="{{ curCom !== 'dokit' }}">
<cover-image
bindtap="tooggleComponent"
data-type="debug"
class="dokit-entrance"
src="//pt-starimg.didistatic.com/static/starimg/img/W8OeOO6Pue1561556055823.png"
></cover-image>
</view> -->
<block wx:if="{{ curCom!= 'dokit' }}">
<debug wx:if="{{ curCom === 'debug' }}" bindtoggle="tooggleComponent"></debug>
<appinformation wx:if="{{ curCom === 'appinformation' }}" bindtoggle="tooggleComponent"></appinformation>
......
......@@ -31,6 +31,7 @@ Component({
},
detached () {
wx.setStorageSync('dokit-mocklist', this.data.mockList)
wx.setStorageSync('dokit-tpllist', this.data.tplList)
}
},
methods: {
......@@ -194,8 +195,8 @@ Component({
addRequestHooks () {
Object.defineProperty(wx, "request" , { writable: true });
console.group('addRequestHooks success')
const matchUrlRequest = this.matchUrlRequest
const matchUrlTpl = this.matchUrlTpl
const matchUrlRequest = this.matchUrlRequest.bind(this)
const matchUrlTpl = this.matchUrlTpl.bind(this)
wx.request = function (options) {
const opt = util.deepClone(options)
const originSuccessFn = options.success
......@@ -206,8 +207,7 @@ Component({
console.warn('被拦截了~')
}
options.success = function (res) {
originSuccessFn(res)
matchUrlTpl(opt, res)
originSuccessFn(matchUrlTpl(opt, res))
}
app.originRequest(options)
}
......@@ -245,7 +245,7 @@ Component({
},
matchUrlTpl (options, res) {
let curTplItem,that = this
if (!that.data.tplList.length) { return false }
if (!that.data.tplList.length) { return res }
for (let i=0,len=that.data.tplList.length;i<len;i++) {
curTplItem = that.data.tplList[i]
if (that.requestIsmatch(options, curTplItem) && curTplItem.checked && res.statusCode == 200) {
......@@ -253,6 +253,7 @@ Component({
}
}
wx.setStorageSync('dokit-tpllist', that.data.tplList)
return res
},
uploadTplData () {
......
......@@ -5,7 +5,7 @@
</view>
<view class="list-wrap">
<scroll-view class='list-scroll' scroll-y style="height: 100%">
<view wx:if="{{ curNav == 'mock'}}" class="mock-list">
<view hidden="{{curNav !== 'mock'}}" class="mock-list">
<view wx:for="{{ mockList }}" wx:key="index">
<view class="item-wrap">
<view class="list-item" data-index="{{ index }}" data-type="mock" catchtap="onExpand">
......@@ -40,7 +40,7 @@
</view>
</view>
</view>
<view wx:if="{{ curNav == 'tpl'}}" class="tpl-list">
<view hidden="{{curNav !== 'tpl'}}" class="tpl-list">
<view wx:for="{{ tplList }}" wx:key="index">
<view class="item-wrap">
<view class="list-item" data-index="{{ index }}" data-type="tpl" catchtap="onExpand">
......
......@@ -4,7 +4,7 @@
right: 0;
left: 0;
width: 100%;
min-height: 100%;
height: 100vh;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
......
......@@ -5,7 +5,7 @@
top: 0;
background: #f5f6f7;
width: 100%;
height: 100%;
height: 100vh;
z-index: 9998
}
.debug-container {
......
......@@ -4,7 +4,7 @@
right: 0;
top: 0;
width: 100%;
height: 100%;
height: 100vh;
background-color: #fff;
z-index: 9998
}
......
.injector-container {
position: absolute;
width: 100%;
height: 100%;
height: 100vh;
box-sizing: border-box;
left: 0;
right: 0;
......
......@@ -3,7 +3,7 @@
}
.position-tools {
width: 100%;
height: 100%;
height: 100vh;
box-sizing: border-box;
position: absolute;
left: 0;
......
......@@ -20,21 +20,24 @@ Component({
lifetimes: {
created () { },
attached () {
this.setData({
addInfo:{
key:'',
value:'',
title:'添加',
disabled:false
}
})
this.getStorageInfo()
this.componentInit()
},
detached () {
console.log('detached')
}
},
methods: {
componentInit () {
this.setData({
addInfo:{
key:'',
value:'',
title:'添加',
disabled:false
}
})
this.getStorageInfo()
},
openDeleteMode(){
this.setData({
isDeleteMode:true
......@@ -73,6 +76,7 @@ Component({
}
storageArr.push(info)
});
storageArr = storageArr.filter(item => ["dokit-mocklist", "dokit-tpllist"].indexOf(item.key) == -1)
this.setData({storage:storageArr})
},
closeAddPopup(){
......@@ -103,7 +107,7 @@ Component({
this.data.checkedStorage.forEach((item)=>{
wx.removeStorageSync(item)
})
this.onLoad()
this.componentInit()
}
}
})
......@@ -117,8 +121,13 @@ Component({
content: '确定要清除所有吗?',
success:res => {
if (res.confirm) {
wx.clearStorageSync()
this.onLoad()
let storageInfo = wx.getStorageInfoSync()
storageInfo.keys.forEach(key => {
if (["dokit-mocklist", "dokit-tpllist"].indexOf(key) == -1) {
wx.removeStorageSync(key)
}
});
this.componentInit()
}
this.closeAll()
}
......@@ -148,7 +157,7 @@ Component({
addStorage(){
if(this.data.addInfo.key&&this.data.addInfo.value){
wx.setStorageSync(this.data.addInfo.key, this.data.addInfo.value)
this.onLoad()
this.componentInit()
}
this.closeAll()
},
......
......@@ -17,7 +17,7 @@
<view class="table-title"><view class="key-title">Key</view><view class="value-title">Value</view></view>
<checkbox-group bindchange="checkboxChange" class="storage-content-box">
<view class="storage-item" wx:for="{{storage}}" wx:key="key">
<checkbox wx:if="{{isDeleteMode}}" class="storage-check" value="{{item.key}}" checked="{{item.checked}}" color="#fff"/>
<checkbox wx:if="{{isDeleteMode}}" class="storage-check" value="{{item.key}}" checked="{{item.checked}}" color="#337cc4"/>
<text class="storage-key {{isDeleteMode?'':'add-some-flex'}}">{{item.key}}</text>
<text class="storage-value" title="{{item.value}}">{{item.value}}</text>
<view class="clear-single-btn" type="primary" data-key="{{item.key}}" data-value="{{item.value}}" bindtap="modifyItemValue">
......
......@@ -2,7 +2,7 @@
background-color: #fff;
position: absolute;
width: 100%;
height: 100%;
height: 100vh;
box-sizing: border-box;
padding: 32rpx;
left: 0;
......
<!-- <view hidden="{{ curCom == 'dokit' }}">
<debug hidden="{{ curCom !== 'debug' }}" bindtoggle="tooggleComponent"></debug>
<appinformation hidden="{{ curCom !== 'appinformation' }}" bindtoggle="tooggleComponent"></appinformation>
<positionsimulation hidden="{{ curCom !== 'positionsimulation' }}" bindtoggle="tooggleComponent"></positionsimulation>
<storage hidden="{{ curCom !== 'storage' }}" bindtoggle="tooggleComponent"></storage>
<h5door hidden="{{ curCom !== 'h5door' }}" bindtoggle="tooggleComponent"></h5door>
<httpinjector hidden="{{ curCom !== 'httpinjector' }}" bindtoggle="tooggleComponent"></httpinjector>
<apimock hidden="{{ curCom !== 'apimock' }}" bindtoggle="tooggleComponent" projectId="{{ projectId }}"></apimock>
</view>
<view hidden="{{ curCom !== 'dokit' }}">
<cover-image
bindtap="tooggleComponent"
data-type="debug"
class="dokit-entrance"
src="//pt-starimg.didistatic.com/static/starimg/img/W8OeOO6Pue1561556055823.png"
></cover-image>
</view> -->
<block wx:if="{{ curCom!= 'dokit' }}">
<debug wx:if="{{ curCom === 'debug' }}" bindtoggle="tooggleComponent"></debug>
<appinformation wx:if="{{ curCom === 'appinformation' }}" bindtoggle="tooggleComponent"></appinformation>
......
{
"name": "dokit-miniapp",
"version": "0.0.2-alpha6",
"version": "0.0.2-alpha7",
"description": "",
"main": "dist/index/index.js",
"miniprogram": "dokit",
......
......@@ -31,6 +31,7 @@ Component({
},
detached () {
wx.setStorageSync('dokit-mocklist', this.data.mockList)
wx.setStorageSync('dokit-tpllist', this.data.tplList)
}
},
methods: {
......@@ -194,8 +195,8 @@ Component({
addRequestHooks () {
Object.defineProperty(wx, "request" , { writable: true });
console.group('addRequestHooks success')
const matchUrlRequest = this.matchUrlRequest
const matchUrlTpl = this.matchUrlTpl
const matchUrlRequest = this.matchUrlRequest.bind(this)
const matchUrlTpl = this.matchUrlTpl.bind(this)
wx.request = function (options) {
const opt = util.deepClone(options)
const originSuccessFn = options.success
......@@ -206,8 +207,7 @@ Component({
console.warn('被拦截了~')
}
options.success = function (res) {
originSuccessFn(res)
matchUrlTpl(opt, res)
originSuccessFn(matchUrlTpl(opt, res))
}
app.originRequest(options)
}
......@@ -245,7 +245,7 @@ Component({
},
matchUrlTpl (options, res) {
let curTplItem,that = this
if (!that.data.tplList.length) { return false }
if (!that.data.tplList.length) { return res }
for (let i=0,len=that.data.tplList.length;i<len;i++) {
curTplItem = that.data.tplList[i]
if (that.requestIsmatch(options, curTplItem) && curTplItem.checked && res.statusCode == 200) {
......@@ -253,6 +253,7 @@ Component({
}
}
wx.setStorageSync('dokit-tpllist', that.data.tplList)
return res
},
uploadTplData () {
......
......@@ -5,7 +5,7 @@
</view>
<view class="list-wrap">
<scroll-view class='list-scroll' scroll-y style="height: 100%">
<view wx:if="{{ curNav == 'mock'}}" class="mock-list">
<view hidden="{{curNav !== 'mock'}}" class="mock-list">
<view wx:for="{{ mockList }}" wx:key="index">
<view class="item-wrap">
<view class="list-item" data-index="{{ index }}" data-type="mock" catchtap="onExpand">
......@@ -40,7 +40,7 @@
</view>
</view>
</view>
<view wx:if="{{ curNav == 'tpl'}}" class="tpl-list">
<view hidden="{{curNav !== 'tpl'}}" class="tpl-list">
<view wx:for="{{ tplList }}" wx:key="index">
<view class="item-wrap">
<view class="list-item" data-index="{{ index }}" data-type="tpl" catchtap="onExpand">
......
......@@ -20,21 +20,24 @@ Component({
lifetimes: {
created () { },
attached () {
this.setData({
addInfo:{
key:'',
value:'',
title:'添加',
disabled:false
}
})
this.getStorageInfo()
this.componentInit()
},
detached () {
console.log('detached')
}
},
methods: {
componentInit () {
this.setData({
addInfo:{
key:'',
value:'',
title:'添加',
disabled:false
}
})
this.getStorageInfo()
},
openDeleteMode(){
this.setData({
isDeleteMode:true
......@@ -73,6 +76,7 @@ Component({
}
storageArr.push(info)
});
storageArr = storageArr.filter(item => ["dokit-mocklist", "dokit-tpllist"].indexOf(item.key) == -1)
this.setData({storage:storageArr})
},
closeAddPopup(){
......@@ -103,7 +107,7 @@ Component({
this.data.checkedStorage.forEach((item)=>{
wx.removeStorageSync(item)
})
this.onLoad()
this.componentInit()
}
}
})
......@@ -117,8 +121,13 @@ Component({
content: '确定要清除所有吗?',
success:res => {
if (res.confirm) {
wx.clearStorageSync()
this.onLoad()
let storageInfo = wx.getStorageInfoSync()
storageInfo.keys.forEach(key => {
if (["dokit-mocklist", "dokit-tpllist"].indexOf(key) == -1) {
wx.removeStorageSync(key)
}
});
this.componentInit()
}
this.closeAll()
}
......@@ -148,7 +157,7 @@ Component({
addStorage(){
if(this.data.addInfo.key&&this.data.addInfo.value){
wx.setStorageSync(this.data.addInfo.key, this.data.addInfo.value)
this.onLoad()
this.componentInit()
}
this.closeAll()
},
......
......@@ -17,7 +17,7 @@
<view class="table-title"><view class="key-title">Key</view><view class="value-title">Value</view></view>
<checkbox-group bindchange="checkboxChange" class="storage-content-box">
<view class="storage-item" wx:for="{{storage}}" wx:key="key">
<checkbox wx:if="{{isDeleteMode}}" class="storage-check" value="{{item.key}}" checked="{{item.checked}}" color="#fff"/>
<checkbox wx:if="{{isDeleteMode}}" class="storage-check" value="{{item.key}}" checked="{{item.checked}}" color="#337cc4"/>
<text class="storage-key {{isDeleteMode?'':'add-some-flex'}}">{{item.key}}</text>
<text class="storage-value" title="{{item.value}}">{{item.value}}</text>
<view class="clear-single-btn" type="primary" data-key="{{item.key}}" data-value="{{item.value}}" bindtap="modifyItemValue">
......
<!-- <view hidden="{{ curCom == 'dokit' }}">
<debug hidden="{{ curCom !== 'debug' }}" bindtoggle="tooggleComponent"></debug>
<appinformation hidden="{{ curCom !== 'appinformation' }}" bindtoggle="tooggleComponent"></appinformation>
<positionsimulation hidden="{{ curCom !== 'positionsimulation' }}" bindtoggle="tooggleComponent"></positionsimulation>
<storage hidden="{{ curCom !== 'storage' }}" bindtoggle="tooggleComponent"></storage>
<h5door hidden="{{ curCom !== 'h5door' }}" bindtoggle="tooggleComponent"></h5door>
<httpinjector hidden="{{ curCom !== 'httpinjector' }}" bindtoggle="tooggleComponent"></httpinjector>
<apimock hidden="{{ curCom !== 'apimock' }}" bindtoggle="tooggleComponent" projectId="{{ projectId }}"></apimock>
</view>
<view hidden="{{ curCom !== 'dokit' }}">
<cover-image
bindtap="tooggleComponent"
data-type="debug"
class="dokit-entrance"
src="//pt-starimg.didistatic.com/static/starimg/img/W8OeOO6Pue1561556055823.png"
></cover-image>
</view> -->
<block wx:if="{{ curCom!= 'dokit' }}">
<debug wx:if="{{ curCom === 'debug' }}" bindtoggle="tooggleComponent"></debug>
<appinformation wx:if="{{ curCom === 'appinformation' }}" bindtoggle="tooggleComponent"></appinformation>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册