mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
reset and modify.
This commit is contained in:
parent
2623b94dd3
commit
b108c86d38
@ -1,5 +1,6 @@
|
||||
import { isMobile } from '../util/env';
|
||||
import * as dom from '../util/dom';
|
||||
import { removeParams } from '../router/util';
|
||||
import config from '../config';
|
||||
import Tweezer from 'tweezer.js';
|
||||
|
||||
@ -59,8 +60,7 @@ function highlight(path) {
|
||||
return;
|
||||
}
|
||||
|
||||
const li =
|
||||
nav[getNavKey(decodeURIComponent(path), last.getAttribute('data-id'))];
|
||||
const li = nav[getNavKey(path, last.getAttribute('data-id'))];
|
||||
|
||||
if (!li || li === active) {
|
||||
return;
|
||||
@ -86,7 +86,7 @@ function highlight(path) {
|
||||
}
|
||||
|
||||
function getNavKey(path, id) {
|
||||
return `${path}?id=${id}`;
|
||||
return `${decodeURIComponent(path)}?id=${decodeURIComponent(id)}`;
|
||||
}
|
||||
|
||||
export function scrollActiveSidebar(router) {
|
||||
@ -127,7 +127,7 @@ export function scrollActiveSidebar(router) {
|
||||
return;
|
||||
}
|
||||
|
||||
const path = router.getCurrentPath();
|
||||
const path = removeParams(router.getCurrentPath());
|
||||
dom.off('scroll', () => highlight(path));
|
||||
dom.on('scroll', () => highlight(path));
|
||||
dom.on(sidebar, 'mouseover', () => {
|
||||
|
||||
@ -44,6 +44,10 @@ export const isAbsolutePath = cached(path => {
|
||||
return /(:|(\/{2}))/g.test(path);
|
||||
});
|
||||
|
||||
export const removeParams = cached(path => {
|
||||
return path.split(/[?#]/)[0];
|
||||
});
|
||||
|
||||
export const getParentPath = cached(path => {
|
||||
if (/\/$/g.test(path)) {
|
||||
return path;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user