fix(admin): fix hash route error
This commit is contained in:
parent
c0a46ce4c3
commit
42ac2e72a7
|
@ -10,7 +10,7 @@
|
|||
|
||||
* 基于 omi web components
|
||||
* 开箱即用,大量内置模板和组件
|
||||
* vite + ts + twind + lazy load
|
||||
* vite + twind + lazy load
|
||||
* 主题实时切换
|
||||
* 仪表盘
|
||||
* 移动优先,响应式设计
|
||||
|
|
|
@ -10,7 +10,7 @@ English | [简体中文](./README.CN.md)
|
|||
|
||||
* Web components base
|
||||
* Out of the box, a large number of built-in templates, components and icons
|
||||
* Vite + ts + twind + lazy load
|
||||
* Vite + twind + lazy load
|
||||
* Theme real-time switching
|
||||
* Mobile first, responsive design
|
||||
* Routing animation
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
"masonry-layout": "^4.2.2",
|
||||
"mockjs": "^1.1.0",
|
||||
"omi": "^6.21.3",
|
||||
"omi-router": "^3.0.0",
|
||||
"omi-router": "^3.0.1",
|
||||
"omi-twind": "^0.0.1",
|
||||
"prismjs": "^1.24.0",
|
||||
"xlsx": "^0.17.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { WeElement, render, h, tag } from 'omi'
|
||||
|
||||
import { route } from 'omi-router'
|
||||
import { route, hashChange } from 'omi-router'
|
||||
|
||||
//提前使用最新版本注册组件
|
||||
import '@omiu/popover'
|
||||
|
@ -295,6 +295,9 @@ export default class extends WeElement {
|
|||
node.md.then((e) => {
|
||||
this.store.markdown = e.default
|
||||
})
|
||||
|
||||
// 重新读取 hash 值
|
||||
hashChange()
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "omi-router",
|
||||
"version": "3.0.0",
|
||||
"version": "3.0.1",
|
||||
"description": "Router for Omi",
|
||||
"main": "src/index.js",
|
||||
"module": "src/index.esm.js",
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
/*!
|
||||
* omi-router v2.1.0 by dntzhang
|
||||
* omi-router v3.0.1 by dntzhang
|
||||
* Router for Omi.
|
||||
* Github: https://github.com/Tencent/omi
|
||||
* MIT Licensed.
|
||||
*/
|
||||
export declare function hashChange(evt: any): void;
|
||||
export declare function route(path: any, callback: any): void;
|
||||
declare const router: {
|
||||
route: typeof route;
|
||||
hashChange: typeof hashChange;
|
||||
};
|
||||
export default router;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* omi-router v3.0.0 http://omijs.org
|
||||
* omi-router v3.0.1 http://omijs.org
|
||||
* Front End Cross-Frameworks Framework.
|
||||
* By dntzhang https://github.com/dntzhang
|
||||
* Github: https://github.com/Tencent/omi
|
||||
|
@ -9,7 +9,7 @@
|
|||
/**
|
||||
* Expose `pathToRegexp`.
|
||||
*/
|
||||
var pathToRegexp_1 = pathToRegexp;
|
||||
var _pathToRegexp_3_2_0_pathToRegexp = pathToRegexp;
|
||||
var match_1 = match;
|
||||
var regexpToFunction_1 = regexpToFunction;
|
||||
var parse_1 = parse;
|
||||
|
@ -416,15 +416,15 @@ function pathToRegexp (path, keys, options) {
|
|||
|
||||
return stringToRegexp(/** @type {string} */ (path), keys, options)
|
||||
}
|
||||
pathToRegexp_1.match = match_1;
|
||||
pathToRegexp_1.regexpToFunction = regexpToFunction_1;
|
||||
pathToRegexp_1.parse = parse_1;
|
||||
pathToRegexp_1.compile = compile_1;
|
||||
pathToRegexp_1.tokensToFunction = tokensToFunction_1;
|
||||
pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
|
||||
_pathToRegexp_3_2_0_pathToRegexp.match = match_1;
|
||||
_pathToRegexp_3_2_0_pathToRegexp.regexpToFunction = regexpToFunction_1;
|
||||
_pathToRegexp_3_2_0_pathToRegexp.parse = parse_1;
|
||||
_pathToRegexp_3_2_0_pathToRegexp.compile = compile_1;
|
||||
_pathToRegexp_3_2_0_pathToRegexp.tokensToFunction = tokensToFunction_1;
|
||||
_pathToRegexp_3_2_0_pathToRegexp.tokensToRegExp = tokensToRegExp_1;
|
||||
|
||||
/*!
|
||||
* omi-router v2.1.0 by dntzhang
|
||||
* omi-router v3.0.1 by dntzhang
|
||||
* Router for Omi.
|
||||
* Github: https://github.com/Tencent/omi
|
||||
* MIT Licensed.
|
||||
|
@ -444,8 +444,8 @@ root.route.to = function (path, data) {
|
|||
location.hash = '#' + path;
|
||||
}
|
||||
};
|
||||
window.addEventListener('hashchange', change);
|
||||
function change(evt) {
|
||||
window.addEventListener('hashchange', hashChange);
|
||||
function hashChange(evt) {
|
||||
var byNative = false;
|
||||
//need to fix a line by omi-link
|
||||
if (window.history.length === root.historyLength && !root.route._routeByTo) {
|
||||
|
@ -455,7 +455,7 @@ function change(evt) {
|
|||
root.route._routeByTo = false;
|
||||
root.historyLength = window.history.length;
|
||||
var prevent = false;
|
||||
if (evt.type === 'hashchange' && root.route.before) {
|
||||
if (evt && evt.type === 'hashchange' && root.route.before) {
|
||||
prevent = root.route.before(evt) === false;
|
||||
}
|
||||
if (prevent)
|
||||
|
@ -485,11 +485,11 @@ function change(evt) {
|
|||
if (notFound) {
|
||||
mapping['*'] && mapping['*'].callback({ byNative: byNative });
|
||||
}
|
||||
if (evt.type === 'hashchange' && root.route.after) {
|
||||
if (evt && evt.type === 'hashchange' && root.route.after) {
|
||||
root.route.after(evt);
|
||||
}
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', change);
|
||||
document.addEventListener('DOMContentLoaded', hashChange);
|
||||
function getParams(toArr, pathArr) {
|
||||
var params = {};
|
||||
toArr.forEach(function (item, index) {
|
||||
|
@ -502,10 +502,10 @@ function getParams(toArr, pathArr) {
|
|||
function route(path, callback) {
|
||||
mapping[path] = {
|
||||
callback: callback,
|
||||
reg: pathToRegexp_1(path)
|
||||
reg: _pathToRegexp_3_2_0_pathToRegexp(path)
|
||||
};
|
||||
}
|
||||
var router = { route: route };
|
||||
var router = { route: route, hashChange: hashChange };
|
||||
function getGlobal() {
|
||||
if (typeof global !== 'object' ||
|
||||
!global ||
|
||||
|
@ -533,6 +533,5 @@ function getUrlParams(url) {
|
|||
return args;
|
||||
}
|
||||
|
||||
export default router;
|
||||
export { route };
|
||||
export { router as default, hashChange, route };
|
||||
//# sourceMappingURL=index.esm.js.map
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -96,10 +96,10 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
/************************************************************************/
|
||||
/******/ ({
|
||||
|
||||
/***/ "./node_modules/path-to-regexp/index.js":
|
||||
/*!**********************************************!*\
|
||||
!*** ./node_modules/path-to-regexp/index.js ***!
|
||||
\**********************************************/
|
||||
/***/ "./node_modules/_path-to-regexp@3.2.0@path-to-regexp/index.js":
|
||||
/*!********************************************************************!*\
|
||||
!*** ./node_modules/_path-to-regexp@3.2.0@path-to-regexp/index.js ***!
|
||||
\********************************************************************/
|
||||
/*! no static exports found */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
|
@ -517,7 +517,7 @@ function pathToRegexp (path, keys, options) {
|
|||
|
||||
/***/ }),
|
||||
|
||||
/***/ "./node_modules/webpack/buildin/global.js":
|
||||
/***/ "./node_modules/_webpack@4.46.0@webpack/buildin/global.js":
|
||||
/*!***********************************!*\
|
||||
!*** (webpack)/buildin/global.js ***!
|
||||
\***********************************/
|
||||
|
@ -558,14 +558,14 @@ module.exports = g;
|
|||
"use strict";
|
||||
/* WEBPACK VAR INJECTION */(function(global) {
|
||||
/*!
|
||||
* omi-router v2.1.0 by dntzhang
|
||||
* omi-router v3.0.1 by dntzhang
|
||||
* Router for Omi.
|
||||
* Github: https://github.com/Tencent/omi
|
||||
* MIT Licensed.
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.route = void 0;
|
||||
var path_to_regexp_1 = __webpack_require__(/*! path-to-regexp */ "./node_modules/path-to-regexp/index.js");
|
||||
exports.route = exports.hashChange = void 0;
|
||||
var path_to_regexp_1 = __webpack_require__(/*! path-to-regexp */ "./node_modules/_path-to-regexp@3.2.0@path-to-regexp/index.js");
|
||||
var mapping = {};
|
||||
var root = getGlobal();
|
||||
root.route = route;
|
||||
|
@ -581,8 +581,8 @@ root.route.to = function (path, data) {
|
|||
location.hash = '#' + path;
|
||||
}
|
||||
};
|
||||
window.addEventListener('hashchange', change);
|
||||
function change(evt) {
|
||||
window.addEventListener('hashchange', hashChange);
|
||||
function hashChange(evt) {
|
||||
var byNative = false;
|
||||
//need to fix a line by omi-link
|
||||
if (window.history.length === root.historyLength && !root.route._routeByTo) {
|
||||
|
@ -592,7 +592,7 @@ function change(evt) {
|
|||
root.route._routeByTo = false;
|
||||
root.historyLength = window.history.length;
|
||||
var prevent = false;
|
||||
if (evt.type === 'hashchange' && root.route.before) {
|
||||
if (evt && evt.type === 'hashchange' && root.route.before) {
|
||||
prevent = root.route.before(evt) === false;
|
||||
}
|
||||
if (prevent)
|
||||
|
@ -622,11 +622,12 @@ function change(evt) {
|
|||
if (notFound) {
|
||||
mapping['*'] && mapping['*'].callback({ byNative: byNative });
|
||||
}
|
||||
if (evt.type === 'hashchange' && root.route.after) {
|
||||
if (evt && evt.type === 'hashchange' && root.route.after) {
|
||||
root.route.after(evt);
|
||||
}
|
||||
}
|
||||
document.addEventListener('DOMContentLoaded', change);
|
||||
exports.hashChange = hashChange;
|
||||
document.addEventListener('DOMContentLoaded', hashChange);
|
||||
function getParams(toArr, pathArr) {
|
||||
var params = {};
|
||||
toArr.forEach(function (item, index) {
|
||||
|
@ -643,7 +644,7 @@ function route(path, callback) {
|
|||
};
|
||||
}
|
||||
exports.route = route;
|
||||
var router = { route: route };
|
||||
var router = { route: route, hashChange: hashChange };
|
||||
exports.default = router;
|
||||
function getGlobal() {
|
||||
if (typeof global !== 'object' ||
|
||||
|
@ -672,7 +673,7 @@ function getUrlParams(url) {
|
|||
return args;
|
||||
}
|
||||
|
||||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
|
||||
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/_webpack@4.46.0@webpack/buildin/global.js */ "./node_modules/_webpack@4.46.0@webpack/buildin/global.js")))
|
||||
|
||||
/***/ })
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* omi-router v2.1.0 by dntzhang
|
||||
* omi-router v3.0.1 by dntzhang
|
||||
* Router for Omi.
|
||||
* Github: https://github.com/Tencent/omi
|
||||
* MIT Licensed.
|
||||
|
@ -23,9 +23,9 @@ root.route.to = function (path, data) {
|
|||
}
|
||||
}
|
||||
|
||||
window.addEventListener('hashchange', change)
|
||||
window.addEventListener('hashchange', hashChange)
|
||||
|
||||
function change(evt) {
|
||||
export function hashChange(evt) {
|
||||
let byNative = false
|
||||
//need to fix a line by omi-link
|
||||
if (window.history.length === root.historyLength && !root.route._routeByTo) {
|
||||
|
@ -35,7 +35,7 @@ function change(evt) {
|
|||
root.route._routeByTo = false
|
||||
root.historyLength = window.history.length
|
||||
let prevent = false
|
||||
if (evt.type === 'hashchange' && root.route.before) {
|
||||
if (evt && evt.type === 'hashchange' && root.route.before) {
|
||||
prevent = root.route.before(evt) === false
|
||||
}
|
||||
if (prevent) return
|
||||
|
@ -65,12 +65,12 @@ function change(evt) {
|
|||
mapping['*'] && mapping['*'].callback({ byNative: byNative })
|
||||
}
|
||||
|
||||
if (evt.type === 'hashchange' && root.route.after) {
|
||||
if (evt && evt.type === 'hashchange' && root.route.after) {
|
||||
root.route.after(evt)
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', change)
|
||||
document.addEventListener('DOMContentLoaded', hashChange)
|
||||
|
||||
function getParams(toArr, pathArr) {
|
||||
const params = {}
|
||||
|
@ -91,8 +91,7 @@ export function route(path, callback) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
const router = { route }
|
||||
const router = { route, hashChange }
|
||||
export default router
|
||||
|
||||
function getGlobal() {
|
||||
|
|
Loading…
Reference in New Issue