This commit is contained in:
Vanessa 2023-03-25 16:56:56 +08:00
parent b4395bfca4
commit e936a2d5d7
5 changed files with 77 additions and 17 deletions

View file

@ -29,7 +29,8 @@ export const initFramework = () => {
let bookmark: MobileBookmarks;
let tag: MobileTags;
// 不能使用 getEventName否则点击返回会展开右侧栏
sidebarElement.querySelector(".toolbar--border").addEventListener("click", (event: Event & {
const firstToolbarElement = sidebarElement.querySelector(".toolbar--border")
firstToolbarElement.addEventListener("click", (event: Event & {
target: Element
}) => {
const svgElement = hasTopClosestByTag(event.target, "svg");
@ -41,8 +42,11 @@ export const initFramework = () => {
closePanel();
return;
}
sidebarElement.querySelectorAll(".toolbar--border svg").forEach(item => {
firstToolbarElement.querySelectorAll(".toolbar__icon").forEach(item => {
const itemType = item.getAttribute("data-type");
if (!itemType) {
return;
}
if (itemType === type) {
if (type === "sidebar-outline-tab") {
if (!outline) {
@ -57,13 +61,13 @@ export const initFramework = () => {
backlink.update();
}
} else if (type === "sidebar-bookmark-tab") {
if (!backlink) {
if (!bookmark) {
bookmark = new MobileBookmarks();
} else {
backlink.update();
}
} else if (type === "sidebar-tag-tab") {
if (!backlink) {
if (!tag) {
tag = new MobileTags();
} else {
tag.update();