diff --git a/plugins/omi-router/dist/omi-router.js b/plugins/omi-router/dist/omi-router.js index 151a4d92d..2d6cf8bad 100644 --- a/plugins/omi-router/dist/omi-router.js +++ b/plugins/omi-router/dist/omi-router.js @@ -1,5 +1,5 @@ /*! - * OmiRouter v0.1.0 By dntzhang + * OmiRouter v0.1.1 By dntzhang * Github: https://github.com/AlloyTeam/omi * MIT Licensed. */ @@ -95,6 +95,12 @@ return /******/ (function(modules) { // webpackBootstrap hashMapping(dom.getAttribute('to')) }, false) }) + + var hash = window.location.hash.replace('#', '') + hashMapping(hash ? hash : routerOption.defaultRoute, renderTo) + if(hash) { + render() + } } function getParams(toArr, pathArr) { @@ -129,6 +135,10 @@ return /******/ (function(modules) { // webpackBootstrap window.addEventListener('hashchange', function() { hashMapping(window.location.hash.replace('#',''), renderTo) + render() + }, false) + + function render(){ if(store){ store.$route = { } store.$route.params = params @@ -151,7 +161,7 @@ return /******/ (function(modules) { // webpackBootstrap }) preInstance = instance preRenderTo = renderTo - }, false) + } function deleteInstance(instance){ for(var key in Omi.instances){ diff --git a/plugins/omi-router/dist/omi-router.min.js b/plugins/omi-router/dist/omi-router.min.js index a5714dd4f..fa7ed99cf 100644 --- a/plugins/omi-router/dist/omi-router.min.js +++ b/plugins/omi-router/dist/omi-router.min.js @@ -1,6 +1,6 @@ /*! - * OmiRouter v0.1.0 By dntzhang + * OmiRouter v0.1.1 By dntzhang * Github: https://github.com/AlloyTeam/omi * MIT Licensed. */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("omi")):"function"==typeof define&&define.amd?define(["omi"],t):"object"==typeof exports?exports.OmiRouter=t(require("omi")):e.OmiRouter=t(e.omi)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){!function(){function t(e,t){var r={};return e.forEach(function(e,n){n>0&&(r[t[n].replace(":","")]=e)}),r}function n(e){d.routes.every(function(r){var n=e.match(r.reg);if(n){var i=r.path.match(r.reg);return f=t(n,i),p=r.renderTo||d.renderTo,l=r.store||d.store,s=r.component,o(e),!1}return!0})}function o(e){window.location.hash=e}function i(e){for(var t in u.instances)if(u.instances.hasOwnProperty(t)){u.instances[t].id=e.id,delete u.instances[t],e=null;break}}var a={},u=r(1),c=r(2),p=null,f={},s=null,l=null,d={},h=null,g=null;a.init=function(e){d=e,e.routes.forEach(function(e){e.reg=c(e.path)}),u.extendPlugin("omi-router",function(e,t){e.setAttribute("href","javascript:void(0)"),e.addEventListener("click",function(){n(e.getAttribute("to"))},!1)})},window.addEventListener("hashchange",function(){n(window.location.hash.replace("#",""),p),l?(l.$route={},l.$route.params=f):l={methods:{install:function(){this.$route={},this.$route.params=f}}},h===p&&g&&i(g);var e=new s;u.render(e,p,{store:l}),g=e,h=p},!1),a.destroy=function(){delete u.plugins["omi-router"]},e.exports=a}()},function(t,r){t.exports=e},function(e,t,r){function n(e,t){for(var r,n=[],o=0,i=0,a="",u=t&&t.delimiter||"/";null!=(r=v.exec(e));){var f=r[0],s=r[1],l=r.index;if(a+=e.slice(i,l),i=l+f.length,s)a+=s[1];else{var d=e[i],h=r[2],g=r[3],m=r[4],x=r[5],y=r[6],w=r[7];a&&(n.push(a),a="");var E=null!=h&&null!=d&&d!==h,b="+"===y||"*"===y,$="?"===y||"*"===y,R=r[2]||u,j=m||x;n.push({name:g||o++,prefix:h||"",delimiter:R,optional:$,repeat:b,partial:E,asterisk:!!w,pattern:j?p(j):w?".*":"[^"+c(R)+"]+?"})}}return i0&&(r[t[n].replace(":","")]=e)}),r}function n(e){h.routes.every(function(r){var n=e.match(r.reg);if(n){var i=r.path.match(r.reg);return l=t(n,i),f=r.renderTo||h.renderTo,d=r.store||h.store,s=r.component,o(e),!1}return!0})}function o(e){window.location.hash=e}function i(){d?(d.$route={},d.$route.params=l):d={methods:{install:function(){this.$route={},this.$route.params=l}}},g===f&&m&&a(m);var e=new s;c.render(e,f,{store:d}),m=e,g=f}function a(e){for(var t in c.instances)if(c.instances.hasOwnProperty(t)){c.instances[t].id=e.id,delete c.instances[t],e=null;break}}var u={},c=r(1),p=r(2),f=null,l={},s=null,d=null,h={},g=null,m=null;u.init=function(e){h=e,e.routes.forEach(function(e){e.reg=p(e.path)}),c.extendPlugin("omi-router",function(e,t){e.setAttribute("href","javascript:void(0)"),e.addEventListener("click",function(){n(e.getAttribute("to"))},!1)});var t=window.location.hash.replace("#","");n(t?t:h.defaultRoute,f),t&&i()},window.addEventListener("hashchange",function(){n(window.location.hash.replace("#",""),f),i()},!1),u.destroy=function(){delete c.plugins["omi-router"]},e.exports=u}()},function(t,r){t.exports=e},function(e,t,r){function n(e,t){for(var r,n=[],o=0,i=0,a="",u=t&&t.delimiter||"/";null!=(r=x.exec(e));){var f=r[0],l=r[1],s=r.index;if(a+=e.slice(i,s),i=s+f.length,l)a+=l[1];else{var d=e[i],h=r[2],g=r[3],m=r[4],v=r[5],w=r[6],y=r[7];a&&(n.push(a),a="");var E=null!=h&&null!=d&&d!==h,b="+"===w||"*"===w,R="?"===w||"*"===w,$=r[2]||u,j=m||v;n.push({name:g||o++,prefix:h||"",delimiter:$,optional:R,repeat:b,partial:E,asterisk:!!y,pattern:j?p(j):y?".*":"[^"+c($)+"]+?"})}}return i