Files
yshop-pro-uniapp/unpackage/dist/build/h5/assets/useRouter.2bdb47a0.js
2023-11-14 17:21:03 +08:00

2 lines
1.6 KiB
JavaScript

import{am as e,an as a,ao as t,ap as s,aq as n,ar as r,as as o,at as u,au as i,av as c,aw as l,ax as g,U as m,ay as f,az as p,aA as d,aB as h}from"./index-d76b1e7a.js";function P(a,t){return e(a)?t:a}const w=e=>(s,n=t())=>{!c&&a(e,s,n)},T=w(s),y=w(n),x=w(r),b=w(o),C=w(u),j=w(i),v=()=>{function e(e,a=0){return L(e),new Promise(((t,s)=>{const n=()=>m({...e,success:()=>{t(!0)},fail:e=>{s(e)}});0!==a?setTimeout((()=>{n()}),a):n()}))}function a(){return g()}return{push:function(e={},a={}){a={type:"navigateTo",data:{},timeout:0,...a},L(e),O(e,a.data);const t={navigateTo:p,redirectTo:d,reLaunch:h};return new Promise(((s,n)=>{const r=()=>t[a.type]({...e,success:()=>{s(!0)},fail:e=>{n(e)}});0!==a.timeout?setTimeout((()=>{r()}),a.timeout):r()}))},pushToTab:e,goBack:function(t,s=0){return new Promise(((n,r)=>{const o=()=>{1!==a().length?f({...t,success:()=>{n(!0)},fail:e=>{r(e)}}):e({url:"/pages/index/index"})};0!==s?setTimeout((()=>{o()}),s):o()}))},getParams:function(e){return"object"!=typeof e?{}:e.details?JSON.parse(decodeURIComponent(e.details)):{}},preLoad:function(e){return new Promise(((a,t)=>{l({url:e,success:()=>{a(!0)},fail:a=>{t({message:`${e}预加载失败,请检查路径`,error:a})}})}))},getCurrentPage:function(){const e=g();return{currentPages:e,prePage:e.length-2>=0?e[e.length-2]:null,nowPage:e.length-1>=0?e[e.length-1]:null}},getCurrentPageList:a}},L=e=>{if(!e.url)throw new Error("options 必须携带url参数")},O=(e,a)=>(Object.keys(a).length>0&&(e.url=`${e.url}?details=${encodeURIComponent(JSON.stringify(a))}`),e);export{C as a,j as b,T as c,y as d,b as e,x as o,P as r,v as u};