mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
🐛 删除已打开页签报错
This commit is contained in:
parent
c358f8f8ee
commit
5acdc1f3c7
4 changed files with 9 additions and 9 deletions
|
|
@ -34,7 +34,7 @@ export const lockFile = (id: string) => {
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
getAllModels().editor.find((item) => {
|
getAllModels().editor.find((item) => {
|
||||||
if (item.editor.protyle.block.rootID === id) {
|
if (item.editor.protyle.block.rootID === id) {
|
||||||
item.parent.parent.removeTab(item.parent.id);
|
item.parent.parent.removeTab(item.parent.id, false, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -482,10 +482,10 @@ export class Wnd {
|
||||||
model.send("closews", {});
|
model.send("closews", {});
|
||||||
}
|
}
|
||||||
|
|
||||||
private removeTabAction = (id: string, closeAll = false) => {
|
private removeTabAction = (id: string, closeAll = false, hasSaveScroll = true) => {
|
||||||
this.children.find((item, index) => {
|
this.children.find((item, index) => {
|
||||||
if (item.id === id) {
|
if (item.id === id) {
|
||||||
if (item.model instanceof Editor) {
|
if (item.model instanceof Editor && hasSaveScroll) {
|
||||||
saveScroll(item.model.editor.protyle);
|
saveScroll(item.model.editor.protyle);
|
||||||
}
|
}
|
||||||
if (this.children.length === 1) {
|
if (this.children.length === 1) {
|
||||||
|
|
@ -545,7 +545,7 @@ export class Wnd {
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
public removeTab(id: string, closeAll = false) {
|
public removeTab(id: string, closeAll = false, needSaveScroll = true) {
|
||||||
for (let index = 0; index < this.children.length; index++) {
|
for (let index = 0; index < this.children.length; index++) {
|
||||||
const item = this.children[index];
|
const item = this.children[index];
|
||||||
if (item.id === id) {
|
if (item.id === id) {
|
||||||
|
|
@ -554,9 +554,9 @@ export class Wnd {
|
||||||
showMessage(window.siyuan.languages.uploading);
|
showMessage(window.siyuan.languages.uploading);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.removeTabAction(id, closeAll);
|
this.removeTabAction(id, closeAll, needSaveScroll);
|
||||||
} else {
|
} else {
|
||||||
this.removeTabAction(id, closeAll);
|
this.removeTabAction(id, closeAll, needSaveScroll);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -140,13 +140,13 @@ class Protyle {
|
||||||
break;
|
break;
|
||||||
case "unmount":
|
case "unmount":
|
||||||
if (this.protyle.model && this.protyle.notebookId === data.data.box) {
|
if (this.protyle.model && this.protyle.notebookId === data.data.box) {
|
||||||
this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id);
|
this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "remove":
|
case "remove":
|
||||||
if (this.protyle.model && (this.protyle.notebookId === data.data.box &&
|
if (this.protyle.model && (this.protyle.notebookId === data.data.box &&
|
||||||
(!data.data.path || this.protyle.path.indexOf(getDisplayName(data.data.path, false, true)) === 0))) {
|
(!data.data.path || this.protyle.path.indexOf(getDisplayName(data.data.path, false, true)) === 0))) {
|
||||||
this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id);
|
this.protyle.model.parent.parent.removeTab(this.protyle.model.parent.id, false, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[]
|
||||||
if (data.code === 1) {
|
if (data.code === 1) {
|
||||||
// 其他报错
|
// 其他报错
|
||||||
if (protyle.model) {
|
if (protyle.model) {
|
||||||
protyle.model.parent.parent.removeTab(protyle.model.parent.id);
|
protyle.model.parent.parent.removeTab(protyle.model.parent.id, false, false);
|
||||||
} else {
|
} else {
|
||||||
protyle.element.innerHTML = `<div class="ft__smaller ft__secondary b3-form__space--small" contenteditable="false">${window.siyuan.languages.refExpired}</div>`;
|
protyle.element.innerHTML = `<div class="ft__smaller ft__secondary b3-form__space--small" contenteditable="false">${window.siyuan.languages.refExpired}</div>`;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue