🎨 从工作空间列表中移除
This commit is contained in:
parent
c50400428b
commit
de8949d88d
8 changed files with 52 additions and 30 deletions
|
@ -2,7 +2,7 @@
|
|||
"workspaceList": "Workspaces",
|
||||
"openWorkspace": "Open Workspace",
|
||||
"openedWorkspace": "Opened Workspaces",
|
||||
"removeWorkspaceTip": "The workspace cannot be recovered after being deleted, are you sure to delete it?",
|
||||
"removeWorkspaceTip": "Remove from Workspaces",
|
||||
"new": "New",
|
||||
"share2LiandiConfirmTip": "Are you sure to share this document to Liandi?",
|
||||
"share2Liandi": "Share to Liandi",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"workspaceList": "Áreas de trabajo",
|
||||
"openWorkspace": "Abrir espacio de trabajo",
|
||||
"openedWorkspace": "Espacio de trabajo abierto",
|
||||
"removeWorkspaceTip": "El espacio de trabajo no se puede recuperar después de eliminarlo, ¿está seguro de eliminarlo?",
|
||||
"removeWorkspaceTip": "Quitar de los espacios de trabajo",
|
||||
"new": "Nuevo",
|
||||
"share2LiandiConfirmTip": "¿Estás seguro de compartir este documento con Liandi?",
|
||||
"share2Liandi": "Compartir con Liandi",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"workspaceList": "Espaces de travail",
|
||||
"openWorkspace": "Ouvrir l'espace de travail",
|
||||
"openedWorkspace": "Espace de travail ouvert",
|
||||
"removeWorkspaceTip": "L'espace de travail ne peut pas être récupéré après avoir été supprimé, êtes-vous sûr de le supprimer ?",
|
||||
"removeWorkspaceTip": "Supprimer des espaces de travail",
|
||||
"new": "Nouveau",
|
||||
"share2LiandiConfirmTip": "Êtes-vous sûr de partager ce document avec Liandi ?",
|
||||
"share2Liandi": "Partager avec Liandi",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"workspaceList": "工作空間列表",
|
||||
"openWorkspace": "打開工作空間",
|
||||
"openedWorkspace": "已打開的工作空間",
|
||||
"removeWorkspaceTip": "刪除工作空間後無法恢復,確定刪除嗎?",
|
||||
"removeWorkspaceTip": "從工作空間列表中移除",
|
||||
"new": "新建",
|
||||
"share2LiandiConfirmTip": "確定將該文檔分享到鏈滴嗎?",
|
||||
"share2Liandi": "分享到鏈滴",
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"workspaceList": "工作空间列表",
|
||||
"openWorkspace": "打开工作空间",
|
||||
"openedWorkspace": "已打开的工作空间",
|
||||
"removeWorkspaceTip": "删除工作空间后无法恢复,确定删除吗?",
|
||||
"removeWorkspaceTip": "从工作空间列表中移除",
|
||||
"new": "新建",
|
||||
"share2LiandiConfirmTip": "确定将该文档分享到链滴吗?",
|
||||
"share2Liandi": "分享到链滴",
|
||||
|
|
|
@ -256,6 +256,8 @@ progressLoading: 400
|
|||
max-width: 96px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
user-select: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import {MenuItem} from "./Menu";
|
||||
/// #if !BROWSER
|
||||
import {dialog} from "@electron/remote";
|
||||
import {ipcRenderer} from "electron";
|
||||
import {ipcRenderer, shell} from "electron";
|
||||
/// #endif
|
||||
import {openHistory} from "../history/history";
|
||||
import {getOpenNotebookCount, originalPath} from "../util/pathName";
|
||||
import {mountHelp, newDailyNote} from "../util/mount";
|
||||
import {fetchPost} from "../util/fetch";
|
||||
import {Constants} from "../constants";
|
||||
import {setStorageVal} from "../protyle/util/compatibility";
|
||||
import {setStorageVal, writeText} from "../protyle/util/compatibility";
|
||||
import {openCard} from "../card/openCard";
|
||||
import {showMessage} from "../dialog/message";
|
||||
|
||||
export const workspaceMenu = (rect: DOMRect) => {
|
||||
window.siyuan.menus.menu.remove();
|
||||
|
@ -90,37 +91,23 @@ export const workspaceMenu = (rect: DOMRect) => {
|
|||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
iconHTML: window.siyuan.languages.openedWorkspace,
|
||||
label:"",
|
||||
label: "",
|
||||
type: "readonly"
|
||||
}).element);
|
||||
response.data.forEach((item: IWorkspace) => {
|
||||
if (item.closed) {
|
||||
return;
|
||||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: `<div class="b3-tooltips b3-tooltips__e" aria-label="${item.path}">
|
||||
<div class="fn__ellipsis" style="max-width: 256px">${originalPath().basename(item.path)}</div>
|
||||
</div>`,
|
||||
click: () => {
|
||||
openWorkspace(item.path);
|
||||
}
|
||||
}).element);
|
||||
workspaceItem(item)
|
||||
});
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
iconHTML: window.siyuan.languages.workspaceList,
|
||||
label:"",
|
||||
label: "",
|
||||
type: "readonly"
|
||||
}).element);
|
||||
response.data.forEach((item: IWorkspace) => {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: `<div class="b3-tooltips b3-tooltips__e" aria-label="${item.path}">
|
||||
<div class="fn__ellipsis" style="max-width: 256px">${originalPath().basename(item.path)}</div>
|
||||
</div>`,
|
||||
click: () => {
|
||||
openWorkspace(item.path);
|
||||
}
|
||||
}).element);
|
||||
workspaceItem(item)
|
||||
});
|
||||
/// #endif
|
||||
window.siyuan.menus.menu.popup({x: rect.left, y: rect.bottom});
|
||||
|
@ -139,3 +126,38 @@ const openWorkspace = (workspace: string) => {
|
|||
});
|
||||
/// #endif
|
||||
};
|
||||
|
||||
const workspaceItem = (item: IWorkspace) => {
|
||||
/// #if !BROWSER
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: `<div class="b3-tooltips b3-tooltips__ne" aria-label="${item.path}">
|
||||
<div class="fn__ellipsis" style="max-width: 256px">${originalPath().basename(item.path)}</div>
|
||||
</div>`,
|
||||
click() {
|
||||
openWorkspace(item.path);
|
||||
},
|
||||
submenu: [{
|
||||
label: window.siyuan.languages.openBy,
|
||||
click() {
|
||||
openWorkspace(item.path);
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.showInFolder,
|
||||
click() {
|
||||
shell.showItemInFolder(item.path);
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.copy,
|
||||
click() {
|
||||
writeText(item.path);
|
||||
showMessage(window.siyuan.languages.copied);
|
||||
}
|
||||
}, {
|
||||
label: window.siyuan.languages.removeWorkspaceTip,
|
||||
click() {
|
||||
fetchPost("/api/system/removeWorkspaceDir", {path: item.path});
|
||||
}
|
||||
}]
|
||||
}).element);
|
||||
/// #endif
|
||||
}
|
||||
|
|
|
@ -476,16 +476,14 @@ ${accountHTML}
|
|||
break;
|
||||
} else if (target.getAttribute("data-type") === "remove") {
|
||||
const p = target.parentElement.getAttribute("data-path");
|
||||
confirmDialog("⚠️ " + window.siyuan.languages.remove + " " + pathPosix().basename(p), window.siyuan.languages.removeWorkspaceTip, () => {
|
||||
fetchPost("/api/system/removeWorkspaceDir", {path: p}, () => {
|
||||
genWorkspace(workspaceDirElement);
|
||||
});
|
||||
fetchPost("/api/system/removeWorkspaceDir", {path: p}, () => {
|
||||
genWorkspace(workspaceDirElement);
|
||||
});
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
break;
|
||||
} else if (target.classList.contains("b3-list-item") && !target.classList.contains("b3-list-item--focus")) {
|
||||
confirmDialog(window.siyuan.languages.confirm,`${pathPosix().basename(window.siyuan.config.system.workspaceDir)} -> ${pathPosix().basename(target.getAttribute("data-path"))}?`, () => {
|
||||
confirmDialog(window.siyuan.languages.confirm, `${pathPosix().basename(window.siyuan.config.system.workspaceDir)} -> ${pathPosix().basename(target.getAttribute("data-path"))}?`, () => {
|
||||
fetchPost("/api/system/setWorkspaceDir", {
|
||||
path: target.getAttribute("data-path")
|
||||
}, () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue