Skip to content

Commit 5243196

Browse files
committed
fix: 当前工作空间不应该显示 打开移除
fix #12018
1 parent 2863eec commit 5243196

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

app/src/menus/workspace.ts

+31-12
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
208208
}
209209
}];
210210
workspaceSubMenu.push({id: "separator_1", type: "separator"});
211+
const workspaceDir = window.siyuan.config.system.workspaceDir;
211212
response.data.forEach((item: IWorkspace) => {
212-
workspaceSubMenu.push(workspaceItem(item) as IMenu);
213+
workspaceSubMenu.push(workspaceItem(item, workspaceDir) as IMenu);
213214
});
214215
/// #else
215216
workspaceSubMenu = [{
@@ -532,16 +533,27 @@ const openWorkspace = (workspace: string) => {
532533
/// #endif
533534
};
534535

535-
const workspaceItem = (item: IWorkspace) => {
536-
/// #if !BROWSER
537-
return {
538-
label: `<div aria-label="${item.path}" class="fn__ellipsis ariaLabel" style="max-width: 256px">
539-
${originalPath().basename(item.path)}
540-
</div>`,
541-
current: !item.closed,
542-
iconHTML: "",
543-
type: "submenu",
544-
submenu: [{
536+
const workspaceItem = (item: IWorkspace, workspaceDir: string) => {
537+
let submenu: any[];
538+
if (item.path === workspaceDir) {
539+
submenu = [{
540+
id: "showInFolder",
541+
icon: "iconFolder",
542+
label: window.siyuan.languages.showInFolder,
543+
click() {
544+
showFileInFolder(item.path);
545+
}
546+
}, {
547+
id: "copyPath",
548+
icon: "iconCopy",
549+
label: window.siyuan.languages.copyPath,
550+
click() {
551+
writeText(item.path);
552+
showMessage(window.siyuan.languages.copied);
553+
}
554+
}];
555+
} else {
556+
submenu = [{
545557
id: "openBy",
546558
icon: "iconOpenWindow",
547559
label: window.siyuan.languages.openBy,
@@ -570,7 +582,14 @@ const workspaceItem = (item: IWorkspace) => {
570582
click() {
571583
fetchPost("/api/system/removeWorkspaceDir", {path: item.path});
572584
}
573-
}],
585+
}];
586+
}
587+
return {
588+
label: `<div aria-label="${item.path}" class="fn__ellipsis ariaLabel" style="max-width: 256px">${originalPath().basename(item.path)}</div>`,
589+
current: !item.closed,
590+
iconHTML: "",
591+
type: "submenu",
592+
submenu,
574593
click() {
575594
openWorkspace(item.path);
576595
},

0 commit comments

Comments
 (0)