Vanessa 2024-11-23 00:11:18 +08:00
parent 83b932478e
commit 8a6ba2b2d0
2 changed files with 20 additions and 20 deletions

View file

@ -462,10 +462,10 @@ export class Backlink extends Model {
}
public refresh() {
if (!this.blockId) {
const element = this.element.querySelector('.block__icon[data-type="refresh"] svg');
if (!this.blockId || element.classList.contains("fn__rotate")) {
return;
}
const element = this.element.querySelector('.block__icon[data-type="refresh"] svg');
element.classList.add("fn__rotate");
fetchPost("/api/ref/refreshBacklink", {
id: this.blockId,

View file

@ -126,24 +126,24 @@ export class Protyle {
}
break;
case "transactions":
if (options.backlinkData) {
getAllModels().backlink.find(item => {
if (item.element.contains(this.protyle.element)) {
item.refresh();
return true;
}
});
} else {
data.data[0].doOperations.forEach((item: IOperation) => {
if (!this.protyle.preview.element.classList.contains("fn__none") &&
item.action !== "updateAttrs" // 预览模式下点击只读
) {
this.protyle.preview.render(this.protyle);
} else {
onTransaction(this.protyle, item, false);
}
});
}
data.data[0].doOperations.find((item: IOperation) => {
if (!this.protyle.preview.element.classList.contains("fn__none") &&
item.action !== "updateAttrs" // 预览模式下点击只读
) {
this.protyle.preview.render(this.protyle);
} else if (options.backlinkData && ["delete", "move"].includes(item.action)) {
// 只对特定情况刷新,否则展开、编辑等操作刷新会频繁
getAllModels().backlink.find(backlinkItem => {
if (backlinkItem.element.contains(this.protyle.element)) {
backlinkItem.refresh();
return true;
}
});
return true;
} else {
onTransaction(this.protyle, item, false);
}
});
break;
case "readonly":
window.siyuan.config.editor.readOnly = data.data;