mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
e0e40dbad2
commit
34e833d0c1
7 changed files with 72 additions and 5 deletions
|
|
@ -15,6 +15,53 @@ import {escapeHtml} from "../util/escape";
|
|||
import {getWorkspaceName} from "../util/noRelyPCFunction";
|
||||
import {needSubscribe} from "../util/needSubscribe";
|
||||
import {redirectToCheckAuth} from "../util/pathName";
|
||||
import {getAllModels} from "../layout/getAll";
|
||||
import {reloadProtyle} from "../protyle/util/reload";
|
||||
|
||||
export const reloadSync = (data:{upsertRootIDs: string[], removeRootIDs: string[]}) => {
|
||||
const allModels = getAllModels()
|
||||
allModels.editor.forEach(item => {
|
||||
if (data.upsertRootIDs.includes(item.editor.protyle.block.rootID)) {
|
||||
reloadProtyle(item.editor.protyle)
|
||||
} else if (data.removeRootIDs.includes(item.editor.protyle.block.rootID)) {
|
||||
item.parent.parent.removeTab(item.parent.id, false, false, false);
|
||||
}
|
||||
})
|
||||
allModels.graph.forEach(item => {
|
||||
item.searchGraph(false);
|
||||
})
|
||||
allModels.outline.forEach(item => {
|
||||
if (item.type === "local" && data.removeRootIDs.includes(item.blockId)) {
|
||||
item.parent.parent.removeTab(item.parent.id, false, false, false);
|
||||
} else if (item.type !== "local" || data.upsertRootIDs.includes(item.blockId)){
|
||||
fetchPost("/api/outline/getDocOutline", {
|
||||
id: item.blockId,
|
||||
}, response => {
|
||||
item.update(response);
|
||||
});
|
||||
}
|
||||
})
|
||||
allModels.backlink.forEach(item => {
|
||||
if (item.type === "local" && data.removeRootIDs.includes(item.rootId)) {
|
||||
item.parent.parent.removeTab(item.parent.id, false, false, false);
|
||||
} else {
|
||||
item.refresh();
|
||||
}
|
||||
})
|
||||
allModels.files.forEach(item => {
|
||||
item.init(false);
|
||||
})
|
||||
allModels.bookmark.forEach(item => {
|
||||
item.update();
|
||||
})
|
||||
allModels.tag.forEach(item => {
|
||||
item.update();
|
||||
})
|
||||
// NOTE asset 无法获取推送地址,先不处理
|
||||
allModels.search.forEach(item => {
|
||||
item.parent.panelElement.querySelector("#searchRefresh").dispatchEvent(new CustomEvent("input"));
|
||||
})
|
||||
}
|
||||
|
||||
export const lockScreen = () => {
|
||||
if (window.siyuan.config.readonly) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import {
|
|||
processSync,
|
||||
progressBackgroundTask,
|
||||
progressLoading,
|
||||
progressStatus,
|
||||
progressStatus, reloadSync,
|
||||
setTitle,
|
||||
transactionError
|
||||
} from "./dialog/processSystem";
|
||||
|
|
@ -53,6 +53,9 @@ class App {
|
|||
msgCallback: (data) => {
|
||||
if (data) {
|
||||
switch (data.cmd) {
|
||||
case "syncMergeResult":
|
||||
reloadSync(data.data);
|
||||
break;
|
||||
case "readonly":
|
||||
window.siyuan.config.editor.readOnly = data.data;
|
||||
updateEditModeElement();
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ export class Backlink extends Model {
|
|||
}
|
||||
}
|
||||
|
||||
private refresh() {
|
||||
public refresh() {
|
||||
const element = this.element.querySelector('.block__icon[data-type="refresh"] svg');
|
||||
element.classList.add("fn__rotate");
|
||||
fetchPost("/api/ref/refreshBacklink", {
|
||||
|
|
|
|||
|
|
@ -636,7 +636,7 @@ export class Files extends Model {
|
|||
}
|
||||
}
|
||||
|
||||
private init(init = true) {
|
||||
public init(init = true) {
|
||||
let html = "";
|
||||
let closeHtml = "";
|
||||
window.siyuan.notebooks.forEach((item) => {
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ export class Tag extends Model {
|
|||
setPanelFocus(this.element);
|
||||
}
|
||||
|
||||
private update() {
|
||||
public update() {
|
||||
const element = this.element.querySelector('.block__icon[data-type="refresh"] svg');
|
||||
if (element.classList.contains("fn__rotate")) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import {Outline} from "./dock/Outline";
|
|||
import {Backlink} from "./dock/Backlink";
|
||||
import {Asset} from "../asset";
|
||||
import {Search} from "../search";
|
||||
import {Files} from "./dock/Files";
|
||||
import {Bookmark} from "./dock/Bookmark";
|
||||
import {Tag} from "./dock/Tag";
|
||||
|
||||
export const getAllModels = () => {
|
||||
const models: IModels = {
|
||||
|
|
@ -14,7 +17,11 @@ export const getAllModels = () => {
|
|||
asset: [],
|
||||
outline: [],
|
||||
backlink: [],
|
||||
search: []
|
||||
search: [],
|
||||
inbox: [],
|
||||
files: [],
|
||||
bookmark: [],
|
||||
tag: []
|
||||
};
|
||||
const getTabs = (layout: Layout) => {
|
||||
for (let i = 0; i < layout.children.length; i++) {
|
||||
|
|
@ -33,6 +40,12 @@ export const getAllModels = () => {
|
|||
models.asset.push(model);
|
||||
} else if (model instanceof Search) {
|
||||
models.search.push(model);
|
||||
} else if (model instanceof Files) {
|
||||
models.files.push(model);
|
||||
} else if (model instanceof Bookmark) {
|
||||
models.bookmark.push(model);
|
||||
} else if (model instanceof Tag) {
|
||||
models.tag.push(model);
|
||||
}
|
||||
} else {
|
||||
getTabs(item as Layout);
|
||||
|
|
|
|||
4
app/src/types/index.d.ts
vendored
4
app/src/types/index.d.ts
vendored
|
|
@ -651,6 +651,10 @@ declare interface IModels {
|
|||
graph: import("../layout/dock/Graph").Graph[],
|
||||
outline: import("../layout/dock/Outline").Outline[]
|
||||
backlink: import("../layout/dock/Backlink").Backlink[]
|
||||
inbox: import("../layout/dock/Inbox").Inbox[]
|
||||
files: import("../layout/dock/Files").Files[]
|
||||
bookmark: import("../layout/dock/Bookmark").Bookmark[]
|
||||
tag: import("../layout/dock/Tag").Tag[]
|
||||
asset: import("../asset").Asset[]
|
||||
search: import("../search").Search[]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue