-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhangi
committed
Jul 27, 2023
1 parent
61a75af
commit 782c107
Showing
16 changed files
with
330 additions
and
323 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ pnpm-debug.log* | |
# Editor directories and files | ||
.idea | ||
.vscode | ||
.history | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
function t(t,e){var o=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.push.apply(o,n)}return o}function e(e){for(var o=1;o<arguments.length;o++){var n=null!=arguments[o]?arguments[o]:{};o%2?t(Object(n),!0).forEach((function(t){c(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var o=0;o<e.length;o++){var n=e[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function i(t,e,o){return e&&r(t.prototype,e),o&&r(t,o),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t,e,o){return(e=l(e))in t?Object.defineProperty(t,e,{value:o,enumerable:!0,configurable:!0,writable:!0}):t[e]=o,t}function a(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var n,r,i,c,a=[],u=!0,s=!1;try{if(i=(o=o.call(t)).next,0===e){if(Object(o)!==o)return;u=!1}else for(;!(u=(n=i.call(o)).done)&&(a.push(n.value),a.length!==e);u=!0);}catch(t){s=!0,r=t}finally{try{if(!u&&null!=o.return&&(c=o.return(),Object(c)!==c))return}finally{if(s)throw r}}return a}}(t,e)||s(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(t){return function(t){if(Array.isArray(t))return h(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||s(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(t,e){if(t){if("string"==typeof t)return h(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?h(t,e):void 0}}function h(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,n=new Array(e);o<e;o++)n[o]=t[o];return n}function l(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var n=o.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var f,y=function(t,e,o){try{if(e){for(var n=e.split("."),r=o?n.length-1:n.length,i=0;i<r;i++)t=t[n[i]];return o?{key:n[r],obj:t}:t}return t}catch(t){return}},p=function(t){return f&&f.state?f:t&&t.$store||{}},m=function(){function t(e){var o=e.customhook,r=e.name,i=e.destroy,c=e.hit,a=void 0!==c&&c,u=e.watchKey,s=e.onUpdate;n(this,t),this.name=r,this.destroy=i,this.hit=a,this.need=!1,this.initFlag=!1,u&&(this.watchKey=u.replace("$store.state.","")),this.onUpdate=s,this.__customhook=o}return i(t,[{key:"init",value:function(){var t=this;this.initFlag||(this.watchKey&&this.watchAttr((function(e){t[e?"cycleStart":"cycleEnd"]()})),this.initFlag=!0)}},{key:"cycleStart",value:function(){this.hit||(this.hit=!0,this.__customhook&&this.__customhook.triggerHook(this.name))}},{key:"cycleEnd",value:function(){this.hit&&(this.hit=!1,this.__customhook&&this.__customhook.resetExecute(this.name))}},{key:"watchAttr",value:function(t){try{var e=this;p(this.__customhook.pageInstance).watch((function(t){return y(t,e.watchKey)}),(function(o,n){t(e.onUpdate?e.onUpdate(o,n):o)}),{watchKey:e.watchKey})}catch(t){}}}]),t}(),k={},d=["onLaunch","created","beforeMount","mounted","activated","deactivated","beforeDestroy","destroyed","onLoad","attached","detached","onShow","onHide","onReady","onUnload"],b=function(t){return e({Launch:new m({customhook:t,name:"onLaunch",destroy:"onUnload",hit:!0}),Created:new m({customhook:t,name:"created",destroy:"destroyed",hit:"created"==j.initHook}),Load:new m({customhook:t,name:"onLoad",destroy:"onUnload",hit:"onLoad"==j.initHook}),Attached:new m({customhook:t,name:"attached",destroy:"detached"}),Show:new m({customhook:t,name:"onShow",destroy:"onHide"}),Mounted:new m({customhook:t,name:"mounted",destroy:"destroyed"}),Ready:new m({customhook:t,name:"onReady",destroy:"onUnload"})},Object.keys(k).reduce((function(e,o){var n=k[o];return n.customhook=t,(e[o]=new m(n))&&e}),{}))},v=function(){return Object.keys(k)},g=d.map((function(t){return H(t)})),w=function(){function t(e,o,r){n(this,t),this.pageInstance=e,this.customHooks={},this.customHookArr=[],this.hook={},this.options=o||{},this.pageHooks=r,this.init()}return i(t,[{key:"init",value:function(){var t=this,e=b(this);this.hook=e;var o=this.pageHooks,n=o.hasOwnProperty("beforeCreate")||o.hasOwnProperty("onReady"),r=this.filterHooks(n?o:o.__proto__),i=r.customHookArr,c=r.hookInscape;this.customHookArr=i,i.forEach((function(n){t.customHooks[n]={callback:o[n].bind(t.pageInstance),inscape:c[n],execute:!1},c[n].forEach((function(t){return e[t].need=!0}))})),i.length&&Object.keys(e).forEach((function(t){return e[t].need&&e[t].init()}))}},{key:"filterHooks",value:function(t){var e=this,o={};return{customHookArr:Object.keys(t).filter((function(t){var n=e.getHookArr(t);return!!n.length&&(o[t]=n.filter((function(o){return!!e.hook[o]||(console.warn('[custom-hook 错误声明警告] "'.concat(o,'"钩子未注册,意味着"').concat(t,'"可能永远不会执行,请先注册此钩子再使用,文档:https://github.com/1977474741/spa-custom-hooks#-diyhooks对象说明')),!1)})),t=="on"+n.join("")&&o[t].length==n.length)})),hookInscape:o}}},{key:"triggerHook",value:function(t){var e=this;this.customHookArr.forEach((function(t){var o=e.customHooks[t];o.inscape.every((function(t){return e.hook[t].need&&e.checkHookHit(e.hook[t])}))&&!o.execute&&(o.execute=!0,e.customHooks[t].callback(e.options))}))}},{key:"resetExecute",value:function(t){var e=this;t=H(t),this.customHookArr.forEach((function(o){var n=e.customHooks[o];-1!=n.inscape.indexOf(t)&&(n.execute=!1)}))}},{key:"splitHook",value:function(t){t=t.replace("on","").split(/(?=[A-Z])/);for(var e=u(new Set(g.concat(v()))).sort((function(t,e){return e.length-t.length})),o=[],n="",r=0;r<t.length;r++){n+=t[r],-1!=e.indexOf(n)&&(o.push(n),n="")}return o}},{key:"checkHookHit",value:function(t){if(t.watchKey){var e=y(p(t.__customhook.pageInstance).state,t.watchKey);return t.onUpdate?t.onUpdate(e):e}return t.hit}},{key:"getHookArr",value:function(t){if(-1==t.indexOf("on"))return[];var e=this.splitHook(t),o=v();return e.length>1||-1!=o.indexOf(e[0])?e:[]}}]),t}();function H(t){return t=(t=t.replace("on","")).substring(0,1).toUpperCase()+t.substring(1)}var O={"vue-h5":{hooksKey:"$options",initHook:"beforeCreate",supportComponent:!0,isPage:function(t){return t._compiled&&this.supportComponent}},"vue-miniprogram":{hooksKey:"$options",initHook:"beforeCreate",supportComponent:!0,isPage:function(){return this.supportComponent}},miniprogram:{hooksKey:"",initHook:"onLoad",initHookApp:"onLaunch",supportComponent:!0,isPage:function(){return this.supportComponent}}},j=O["vue-miniprogram"],A=function(t,n,r,i){var a;function u(t){var e=y(this,j.hooksKey);j.isPage(e)&&(null!=r&&r.state||!i||(r.state=this[i]||i),this.customHook=new w(this,t,e))}t.mpvueVersion?j.initHook="onLoad":t.userAgentKey&&(j=O[t.userAgentKey]),f=r,k=n,t.mixin(e(e({},d.reduce((function(t,e){return(t[e]=function(t){if(("object"==o(this.customHook)||null==o(this.customHook))&&this.customHook.customHookArr.length){t&&Object.keys(t).length>0&&(this.customHook.options=t);var n=this.customHook.hook;for(var r in n){var i=n[r];i.name==e?i.cycleStart():i.destroy==e&&i.cycleEnd()}}})&&t}),{})),{},(c(a={},j.initHook,(function(t){u.call(this,t)})),c(a,j.initHookApp,(function(t){u.call(this,t)})),a)))},S=Object.freeze({__proto__:null,get BASE(){return j},install:A}),P={mixin:function(t){var e=this,o=Page,n=App;Page=function(n){e.mergeHook(t,n),o(n)},App=function(o){e.mergeHook(t,o),n(o)}},mergeHook:function(t,e){for(var o=function(){var t=a(r[n],2),o=t[0],i=t[1],c=e[o];e[o]=function(){for(var t=arguments.length,e=new Array(t),o=0;o<t;o++)e[o]=arguments[o];return i.call.apply(i,[this].concat(e)),c&&c.call.apply(c,[this].concat(e))}},n=0,r=Object.entries(t);n<r.length;n++)o()},userAgentKey:"miniprogram"},_={},E={watch:function(t,e,n){var r=p().state,i=n.watchKey,c=y(r,i,!0);_[i]?_[i].push(e):_[i]=[e],function t(n,r){var u=n[r];Object.defineProperty(n,r,{configurable:!0,enumerable:!0,set:function(t){u=t,_[i].map((function(t){return t(c.obj[c.key])}))},get:function(){return u}}),Array.isArray(n[r])&&(s=n[r],h=function(){e(c.obj[c.key])},l=Object.create(s),["push","pop","shift","unshift","splice","sort","reverse"].forEach((function(t){var e=l[t];!function(t,e,o,n){Object.defineProperty(t,e,{value:o,enumerable:!!n,writable:!0,configurable:!0})}(s,t,(function(){return e.apply(this,arguments),h.apply(this,arguments)}))})));var s,h,l;if("object"===o(n[r])&&null!=n[r])for(var f=0,y=Object.entries(n[r]);f<y.length;f++){var p=a(y[f],2),m=p[0];p[1],t(n[r],m)}}(c.obj,c.key)}};var K={install:function(){arguments.length<3?A(P,arguments[0],E,arguments[1]||"globalData"):A.apply(S,arguments)},setHit:function(t,e){b()[t][e?"cycleStart":"cycleEnd"]()}};export{K as default}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.