dsh-workspace-nest 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/client.js +35 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,7 @@ dsh plugin --profile web add dsh-workspace-nest
|
|
|
15
15
|
## 它做什么
|
|
16
16
|
|
|
17
17
|
- **多级子工作区**:任意工作区行的悬停菜单里点「新增子工作区」,会在该工作区目录下创建一个子文件夹并把它注册成普通工作区。层级由目录的祖先关系推导,所以想看几层就看几层。
|
|
18
|
+
- **子工作区也能选已有目录**:子工作区对话框里的「系统选择器」直接挑一个**已经存在**的文件夹注册成子工作区,不新建目录;挑到父工作区目录之外的位置会被拦下并提示,因为那样的目录注册后是根工作区,不是子工作区。
|
|
18
19
|
- **每一级都能开会话**:父工作区既能放会话,也能放下级文件夹;行菜单里的「新建会话」把会话建在当前这一级。
|
|
19
20
|
- **会话置顶**:会话行菜单里的「置顶」把它排到**所属最近一级文件夹**的会话列表最前面,行尾带图钉标记;置顶集合由 Host 持久化,刷新、重启都不丢。
|
|
20
21
|
- **常用行操作**:重命名、删除、归档、分叉、会话搜索都走真实服务,和自带浏览器一致。
|
|
@@ -25,6 +26,8 @@ dsh plugin --profile web add dsh-workspace-nest
|
|
|
25
26
|
|
|
26
27
|
本插件的 Host 半边用真实文件系统能力补上这一步:一条本地 JSON POST 路由,名字必须是单个路径段,落点必须仍在父工作区目录内;创建的目录里留一个空的 `.dsh-workspace-nest` 标记文件。路由不可达时,客户端会退回浏览器侧的 `createDirectory`。
|
|
27
28
|
|
|
29
|
+
「系统选择器」那条路不需要这条路由:挑中的目录已经存在,注册即可,父子关系由路径祖先关系推导出来。
|
|
30
|
+
|
|
28
31
|
## 兼容性
|
|
29
32
|
|
|
30
33
|
- 目标:DSH **0.2.x**(Web / 桌面端),声明在 `package.json` 的 `engines.dsh`;
|
package/client.js
CHANGED
|
@@ -100,8 +100,10 @@ window.__ModuleLoader__.load({
|
|
|
100
100
|
addCommit: "\u6DFB\u52A0",
|
|
101
101
|
addBusy: "\u5904\u7406\u4E2D\u2026",
|
|
102
102
|
subTitle: "\u65B0\u589E\u5B50\u5DE5\u4F5C\u533A",
|
|
103
|
-
subHint: "\
|
|
103
|
+
subHint: "\u5728\u8BE5\u5DE5\u4F5C\u533A\u76EE\u5F55\u4E0B\u521B\u5EFA\u6587\u4EF6\u5939\uFF0C\u6216\u9009\u4E00\u4E2A\u5DF2\u5B58\u5728\u7684\u6587\u4EF6\u5939\uFF0C\u5E76\u628A\u5B83\u6CE8\u518C\u4E3A\u5B50\u5DE5\u4F5C\u533A\uFF1A",
|
|
104
104
|
subNameLabel: "\u5B50\u5DE5\u4F5C\u533A\u6587\u4EF6\u5939\u540D",
|
|
105
|
+
subPick: "\u7CFB\u7EDF\u9009\u62E9\u5668",
|
|
106
|
+
subPickOutside: "\u8BF7\u5728\u300C{name}\u300D\u76EE\u5F55\u4E0B\u9009\u62E9\u6587\u4EF6\u5939\uFF1B\u76EE\u5F55\u4E4B\u5916\u7684\u4F4D\u7F6E\u6CE8\u518C\u540E\u4F1A\u53D8\u6210\u6839\u5DE5\u4F5C\u533A\uFF0C\u4E0D\u4F1A\u6210\u4E3A\u5B50\u5DE5\u4F5C\u533A\u3002",
|
|
105
107
|
subCommit: "\u521B\u5EFA",
|
|
106
108
|
subBusy: "\u521B\u5EFA\u4E2D\u2026",
|
|
107
109
|
subBadName: "\u8BF7\u8F93\u5165\u4E00\u4E2A\u4E0D\u542B\u8DEF\u5F84\u5206\u9694\u7B26\u7684\u6587\u4EF6\u5939\u540D\u3002",
|
|
@@ -846,6 +848,15 @@ window.__ModuleLoader__.load({
|
|
|
846
848
|
setAddBusy(false);
|
|
847
849
|
});
|
|
848
850
|
};
|
|
851
|
+
const settleSub = (parent, workspaceId) => {
|
|
852
|
+
setSubTarget(null);
|
|
853
|
+
actions.setExpanded(parent.workspaceId, true);
|
|
854
|
+
try {
|
|
855
|
+
startSession(workspaceId);
|
|
856
|
+
} catch (reason) {
|
|
857
|
+
setNotice(fmt(TEXT.noticeFailed, { action: TEXT.newSession, reason: reasonText(reason) }));
|
|
858
|
+
}
|
|
859
|
+
};
|
|
849
860
|
const submitSub = () => {
|
|
850
861
|
if (subTarget === null || subBusy) return;
|
|
851
862
|
const name = subName.trim();
|
|
@@ -857,19 +868,34 @@ window.__ModuleLoader__.load({
|
|
|
857
868
|
setSubError(null);
|
|
858
869
|
const parent = subTarget;
|
|
859
870
|
createChildWorkspace(parent, name).then((created) => {
|
|
860
|
-
|
|
861
|
-
actions.setExpanded(parent.workspaceId, true);
|
|
862
|
-
try {
|
|
863
|
-
startSession(created.workspaceId);
|
|
864
|
-
} catch (reason) {
|
|
865
|
-
setNotice(fmt(TEXT.noticeFailed, { action: TEXT.newSession, reason: reasonText(reason) }));
|
|
866
|
-
}
|
|
871
|
+
settleSub(parent, created.workspaceId);
|
|
867
872
|
}).catch((reason) => {
|
|
868
873
|
setSubError(reason instanceof Error ? reason.message : String(reason));
|
|
869
874
|
}).finally(() => {
|
|
870
875
|
setSubBusy(false);
|
|
871
876
|
});
|
|
872
877
|
};
|
|
878
|
+
const chooseSubDirectory = () => {
|
|
879
|
+
if (subTarget === null || subBusy) return;
|
|
880
|
+
const parent = subTarget;
|
|
881
|
+
setSubBusy(true);
|
|
882
|
+
setSubError(null);
|
|
883
|
+
Promise.resolve().then(() => pickDirectory()).then((path) => {
|
|
884
|
+
if (path === null || path === void 0) return void 0;
|
|
885
|
+
const picked = path.length > 1 ? path.replace(/[/\\]+$/, "") : path;
|
|
886
|
+
if (!isUnder(parent.path, picked)) {
|
|
887
|
+
setSubError(fmt(TEXT.subPickOutside, { name: parent.title }));
|
|
888
|
+
return void 0;
|
|
889
|
+
}
|
|
890
|
+
return createWorkspace({ path: picked }).then((created) => {
|
|
891
|
+
settleSub(parent, created.workspaceId);
|
|
892
|
+
});
|
|
893
|
+
}).catch((reason) => {
|
|
894
|
+
setSubError(reasonText(reason));
|
|
895
|
+
}).finally(() => {
|
|
896
|
+
setSubBusy(false);
|
|
897
|
+
});
|
|
898
|
+
};
|
|
873
899
|
const submitRename = () => {
|
|
874
900
|
if (renameTarget === null || renaming) return;
|
|
875
901
|
const title = renameDraft.trim();
|
|
@@ -1051,6 +1077,7 @@ window.__ModuleLoader__.load({
|
|
|
1051
1077
|
/* @__PURE__ */ jsx(Button, { variant: "outline", disabled: subBusy, onClick: () => {
|
|
1052
1078
|
setSubTarget(null);
|
|
1053
1079
|
}, children: TEXT.cancel }),
|
|
1080
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", disabled: subBusy, onClick: chooseSubDirectory, children: TEXT.subPick }),
|
|
1054
1081
|
/* @__PURE__ */ jsx(Button, { variant: "primary", disabled: subBusy || subName.trim() === "", onClick: submitSub, children: subBusy ? TEXT.subBusy : TEXT.subCommit })
|
|
1055
1082
|
] }),
|
|
1056
1083
|
children: /* @__PURE__ */ jsxs("div", { className: css.dialogBody, children: [
|