Vanessa 2023-04-21 21:58:57 +08:00
parent bec5fbc9cb
commit bb36ff79b5
12 changed files with 62 additions and 15 deletions

View file

@ -145,6 +145,7 @@
flex: 1; flex: 1;
font-size: 17px; font-size: 17px;
min-height: 30px; min-height: 30px;
line-height: 30px;
} }
} }

View file

@ -35,6 +35,7 @@
<svg data-type="sidebar-bookmark-tab" class="toolbar__icon"><use xlink:href="#iconBookmark"></use></svg> <svg data-type="sidebar-bookmark-tab" class="toolbar__icon"><use xlink:href="#iconBookmark"></use></svg>
<svg data-type="sidebar-tag-tab" class="toolbar__icon"><use xlink:href="#iconTags"></use></svg> <svg data-type="sidebar-tag-tab" class="toolbar__icon"><use xlink:href="#iconTags"></use></svg>
<svg data-type="sidebar-backlink-tab" class="toolbar__icon"><use xlink:href="#iconLink"></use></svg> <svg data-type="sidebar-backlink-tab" class="toolbar__icon"><use xlink:href="#iconLink"></use></svg>
<svg data-type="sidebar-inbox-tab" class="toolbar__icon"><use xlink:href="#iconInbox"></use></svg>
<span class="fn__flex-1"></span> <span class="fn__flex-1"></span>
<svg class="toolbar__icon"><use xlink:href="#iconRight"></use></svg> <svg class="toolbar__icon"><use xlink:href="#iconRight"></use></svg>
</div> </div>
@ -44,6 +45,7 @@
<div class="fn__flex-column fn__none" data-type="sidebar-bookmark"></div> <div class="fn__flex-column fn__none" data-type="sidebar-bookmark"></div>
<div class="fn__flex-column fn__none" data-type="sidebar-tag"></div> <div class="fn__flex-column fn__none" data-type="sidebar-tag"></div>
<div class="fn__flex-column fn__none" data-type="sidebar-backlink"></div> <div class="fn__flex-column fn__none" data-type="sidebar-backlink"></div>
<div class="fn__flex-column fn__none" data-type="sidebar-inbox"></div>
</div> </div>
</div> </div>
<div id="menu" class="b3-menu b3-menu--fullscreen"></div> <div id="menu" class="b3-menu b3-menu--fullscreen"></div>

View file

@ -30,6 +30,9 @@ export const lockScreen = () => {
}; };
export const kernelError = () => { export const kernelError = () => {
if (document.querySelector("#errorLog")){
return;
}
let iosReStart = ""; let iosReStart = "";
if (window.siyuan.config.system.container === "ios" && window.webkit?.messageHandlers) { if (window.siyuan.config.system.container === "ios" && window.webkit?.messageHandlers) {
iosReStart = `<div class="fn__hr"></div><div class="fn__flex"><div class="fn__flex-1"></div><button class="b3-button">${window.siyuan.languages.retry}</button></div>`; iosReStart = `<div class="fn__hr"></div><div class="fn__flex"><div class="fn__flex-1"></div><button class="b3-button">${window.siyuan.languages.retry}</button></div>`;

View file

@ -63,8 +63,7 @@ export class Model {
} }
}; };
ws.onerror = (err: Event & { target: { url: string, readyState: number } }) => { ws.onerror = (err: Event & { target: { url: string, readyState: number } }) => {
const logElement = document.getElementById("errorLog"); if (err.target.url.endsWith("&type=main") && err.target.readyState === 3) {
if (err.target.url.endsWith("&type=main") && err.target.readyState === 3 && !logElement) {
kernelError(); kernelError();
} }
}; };

View file

@ -1,5 +1,7 @@
/// #if !MOBILE
import {Tab} from "../Tab"; import {Tab} from "../Tab";
import {getDockByType, setPanelFocus} from "../util"; import {getDockByType, setPanelFocus} from "../util";
/// #endif
import {fetchPost} from "../../util/fetch"; import {fetchPost} from "../../util/fetch";
import {updateHotkeyTip} from "../../protyle/util/compatibility"; import {updateHotkeyTip} from "../../protyle/util/compatibility";
import {Model} from "../Model"; import {Model} from "../Model";
@ -11,6 +13,7 @@ import {replaceFileName} from "../../editor/rename";
import {escapeHtml} from "../../util/escape"; import {escapeHtml} from "../../util/escape";
import {unicode2Emoji} from "../../emoji"; import {unicode2Emoji} from "../../emoji";
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import {isMobile} from "../../util/functions";
export class Inbox extends Model { export class Inbox extends Model {
private element: Element; private element: Element;
@ -19,11 +22,41 @@ export class Inbox extends Model {
private pageCount = 1; private pageCount = 1;
private data: { [key: string]: IInbox } = {}; private data: { [key: string]: IInbox } = {};
constructor(tab: Tab) { constructor(tab: Tab | Element) {
super({id: tab.id}); super({id: tab.id});
this.element = tab.panelElement; if (tab instanceof Element) {
this.element = tab;
} else {
this.element = tab.panelElement;
}
/// #if MOBILE
this.element.innerHTML = `<div class="toolbar toolbar--border toolbar--dark">
<div class="fn__space"></div>
<div class="toolbar__text">
${window.siyuan.languages.inbox}
<span class="fn__space"></span>
<span class="inboxSelectCount ft__smaller ft__on-surface"></span>
</div>
<span class="fn__flex-1"></span>
<span class="fn__space"></span>
<div class="fn__flex">
<input class="fn__flex-center toolbar__icon" data-type="selectall" type="checkbox">
<svg class="toolbar__icon" data-type="refresh"><use xlink:href='#iconRefresh'></use></svg>
<svg data-type="more" class="toolbar__icon fn__none"><use xlink:href='#iconMore'></use></svg>
<svg data-type="previous" disabled="disabled" class="toolbar__icon"><use xlink:href='#iconLeft'></use></svg>
<svg data-type="next" disabled="disabled" class="toolbar__icon"><use xlink:href='#iconRight'></use></svg>
</div>
<div class="fn__flex fn__none">
<svg data-type="back" class="toolbar__icon"><use xlink:href='#iconLeft'></use></svg>
<svg data-type="refreshDetails" class="toolbar__icon"><use xlink:href='#iconRefresh'></use></svg>
<svg data-type="move" class="toolbar__icon"><use xlink:href='#iconMove'></use></svg>
<svg data-type="delete" class="toolbar__icon"><use xlink:href='#iconTrashcan'></use></svg>
</div>
</div>
<div class="inbox__details fn__none"></div>
<div class="fn__flex-1 inbox__list"></div>`;
/// #else
this.element.classList.add("fn__flex-column", "file-tree", "sy__inbox"); this.element.classList.add("fn__flex-column", "file-tree", "sy__inbox");
this.element.innerHTML = `<div class="block__icons"> this.element.innerHTML = `<div class="block__icons">
<div class="block__logo"> <div class="block__logo">
<svg><use xlink:href="#iconInbox"></use></svg> <svg><use xlink:href="#iconInbox"></use></svg>
@ -56,11 +89,14 @@ export class Inbox extends Model {
</div> </div>
<div class="inbox__details fn__none"></div> <div class="inbox__details fn__none"></div>
<div class="fn__flex-1 inbox__list"></div>`; <div class="fn__flex-1 inbox__list"></div>`;
/// #endif
const countElement = this.element.querySelector(".inboxSelectCount"); const countElement = this.element.querySelector(".inboxSelectCount");
const detailsElement = this.element.querySelector(".inbox__details"); const detailsElement = this.element.querySelector(".inbox__details");
const selectAllElement = this.element.querySelector(".block__icons input") as HTMLInputElement; const selectAllElement = this.element.querySelector(".block__icons input") as HTMLInputElement;
this.element.addEventListener("click", (event: MouseEvent) => { this.element.addEventListener("click", (event: MouseEvent) => {
/// #if !MOBILE
setPanelFocus(this.element); setPanelFocus(this.element);
/// #endif
let target = event.target as HTMLElement; let target = event.target as HTMLElement;
while (target && !target.isEqualNode(this.element)) { while (target && !target.isEqualNode(this.element)) {
const typeElement = hasClosestByAttribute(target, "data-type", null); const typeElement = hasClosestByAttribute(target, "data-type", null);
@ -181,7 +217,9 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
} }
); );
this.update(); this.update();
/// #if !MOBILE
setPanelFocus(this.element); setPanelFocus(this.element);
/// #endif
} }
private updateAction() { private updateAction() {
@ -296,7 +334,7 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
</ul>`; </ul>`;
return; return;
} }
const refreshElement = this.element.querySelector('[data-type="refresh"] svg'); const refreshElement = this.element.querySelector(`[data-type="refresh"]${isMobile() ? "" : " svg"}`);
if (refreshElement.classList.contains("fn__rotate")) { if (refreshElement.classList.contains("fn__rotate")) {
return; return;
} }
@ -327,8 +365,8 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
this.pageCount = response.data.data.pagination.paginationRecordCount; this.pageCount = response.data.data.pagination.paginationRecordCount;
this.element.querySelector(".inboxSelectCount").innerHTML = `${this.selectIds.length}/${this.pageCount}`; this.element.querySelector(".inboxSelectCount").innerHTML = `${this.selectIds.length}/${this.pageCount}`;
const previousElement = this.element.querySelector('span[data-type="previous"]'); const previousElement = this.element.querySelector('[data-type="previous"]');
const nextElement = this.element.querySelector('span[data-type="next"]'); const nextElement = this.element.querySelector('[data-type="next"]');
if (response.data.data.pagination.paginationPageCount > this.currentPage) { if (response.data.data.pagination.paginationPageCount > this.currentPage) {
nextElement.removeAttribute("disabled"); nextElement.removeAttribute("disabled");
} else { } else {
@ -340,7 +378,7 @@ ${(Lute.New()).MarkdownStr("", data.shorthandContent)}
previousElement.removeAttribute("disabled"); previousElement.removeAttribute("disabled");
} }
const selectCount = this.element.lastElementChild.querySelectorAll(".b3-list-item").length; const selectCount = this.element.lastElementChild.querySelectorAll(".b3-list-item").length;
(this.element.querySelector(".block__icons input") as HTMLInputElement).checked = this.element.lastElementChild.querySelectorAll("input:checked").length === selectCount && selectCount !== 0; this.element.firstElementChild.querySelector("input").checked = this.element.lastElementChild.querySelectorAll("input:checked").length === selectCount && selectCount !== 0;
}); });
} }
} }

View file

@ -532,7 +532,7 @@ export const popSearch = (config = window.siyuan.storage[Constants.LOCAL_SEARCHD
}); });
openModel({ openModel({
title: `<input id="toolbarSearch" placeholder="${window.siyuan.languages.showRecentUpdatedBlocks}" class="b3-text-field fn__block">`, title: `<input id="toolbarSearch" placeholder="${window.siyuan.languages.showRecentUpdatedBlocks}" class="toolbar__title fn__block">`,
icon: "iconSearch", icon: "iconSearch",
html: `<div class="fn__flex-column" style="height: 100%"> html: `<div class="fn__flex-column" style="height: 100%">
<div class="toolbar toolbar--border${config.hasReplace ? "" : " fn__none"}"> <div class="toolbar toolbar--border${config.hasReplace ? "" : " fn__none"}">

View file

@ -9,14 +9,15 @@ import {renderSnippet} from "../../config/util/snippets";
import {setEmpty} from "./setEmpty"; import {setEmpty} from "./setEmpty";
import {getIdZoomInByPath, getOpenNotebookCount} from "../../util/pathName"; import {getIdZoomInByPath, getOpenNotebookCount} from "../../util/pathName";
import {popMenu} from "../menu"; import {popMenu} from "../menu";
import {MobileFiles} from "./MobileFiles"; import {MobileFiles} from "../dock/MobileFiles";
import {MobileOutline} from "./MobileOutline"; import {MobileOutline} from "../dock/MobileOutline";
import {hasTopClosestByTag} from "../../protyle/util/hasClosest"; import {hasTopClosestByTag} from "../../protyle/util/hasClosest";
import {MobileBacklinks} from "./MobileBacklinks"; import {MobileBacklinks} from "../dock/MobileBacklinks";
import {MobileBookmarks} from "./MobileBookmarks"; import {MobileBookmarks} from "../dock/MobileBookmarks";
import {MobileTags} from "./MobileTags"; import {MobileTags} from "../dock/MobileTags";
import {activeBlur, hideKeyboardToolbar, initKeyboardToolbar} from "./keyboardToolbar"; import {activeBlur, hideKeyboardToolbar, initKeyboardToolbar} from "./keyboardToolbar";
import {syncGuide} from "../../sync/syncGuide"; import {syncGuide} from "../../sync/syncGuide";
import {Inbox} from "../../layout/dock/Inbox";
export const initFramework = () => { export const initFramework = () => {
setInlineStyle(); setInlineStyle();
@ -26,6 +27,7 @@ export const initFramework = () => {
let outline: MobileOutline; let outline: MobileOutline;
let backlink: MobileBacklinks; let backlink: MobileBacklinks;
let bookmark: MobileBookmarks; let bookmark: MobileBookmarks;
let inbox: Inbox;
let tag: MobileTags; let tag: MobileTags;
// 不能使用 getEventName否则点击返回会展开右侧栏 // 不能使用 getEventName否则点击返回会展开右侧栏
const firstToolbarElement = sidebarElement.querySelector(".toolbar--border"); const firstToolbarElement = sidebarElement.querySelector(".toolbar--border");
@ -71,6 +73,8 @@ export const initFramework = () => {
} else { } else {
tag.update(); tag.update();
} }
} else if (type === "sidebar-inbox-tab" && !inbox) {
inbox = new Inbox(document.querySelector('#sidebar [data-type="sidebar-inbox"]'));
} }
svgElement.classList.add("toolbar__icon--active"); svgElement.classList.add("toolbar__icon--active");
sidebarElement.lastElementChild.querySelector(`[data-type="${itemType.replace("-tab", "")}"]`).classList.remove("fn__none"); sidebarElement.lastElementChild.querySelector(`[data-type="${itemType.replace("-tab", "")}"]`).classList.remove("fn__none");