dsh-apis-plugin 0.1.7 → 0.1.8
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 -3
- package/client.js +13 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ apis=
|
|
|
44
44
|
|
|
45
45
|
- `baseUrl`:请求时拼接在接口路径前(改文件即生效,无需重启)
|
|
46
46
|
- `apis`:接口白名单,支持 `{param}` 模板段(如 `/users/{id}`),agent 请求时填实际值
|
|
47
|
-
-
|
|
47
|
+
- **增删接口只改这个文件**,改完点插件配置页的「扫描」(或重启)生效
|
|
48
48
|
|
|
49
49
|
### 2. api_doc.md(接口文档,建议提供)
|
|
50
50
|
|
|
@@ -88,7 +88,7 @@ agent 调用 `{prefix}_api_doc` 时按路径命中对应小节返回。
|
|
|
88
88
|
| 操作 | 说明 |
|
|
89
89
|
|---|---|
|
|
90
90
|
| API 配置 | 填 api.cfg / api_doc.md 所在目录,**失焦或回车自动保存** |
|
|
91
|
-
|
|
|
91
|
+
| 扫描 | 重扫目录:接口列表严格等于当前 api.cfg 内容;**目录留空点击则清空列表** |
|
|
92
92
|
| 接口列表 | 只读展示,增删请在 api.cfg 中操作 |
|
|
93
93
|
|
|
94
94
|
### Agent 工具
|
|
@@ -111,7 +111,7 @@ dsh 控制台日志:
|
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
- `endpoints=0`:检查 API 目录路径是否正确、api.cfg 是否与目录同级
|
|
114
|
-
- 加载后列表与 api.cfg
|
|
114
|
+
- 加载后列表与 api.cfg 不一致:确认已在配置页点过「扫描」
|
|
115
115
|
- 提示未配置 baseUrl:在 api.cfg 写入 `baseUrl=http://...`
|
|
116
116
|
|
|
117
117
|
## License
|
package/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// 浏览器半侧:在「插件配置」标签页为 dsh-apis-plugin 命名空间注册一张展示卡片
|
|
2
|
-
// 接口的增删以 api.cfg 为唯一来源:这里只读展示列表,编辑请改 api.cfg
|
|
3
|
-
// API
|
|
2
|
+
// 接口的增删以 api.cfg 为唯一来源:这里只读展示列表,编辑请改 api.cfg 后点「扫描」重扫
|
|
3
|
+
// API 目录失焦或点「扫描」时自动保存,无页脚按钮
|
|
4
4
|
// 样式与 DOM 结构对齐原生 PluginCard(li 卡片 + SVG 箭头)
|
|
5
5
|
window.__ModuleLoader__.load({
|
|
6
6
|
id: "dsh-apis-plugin",
|
|
@@ -81,8 +81,8 @@ window.__ModuleLoader__.load({
|
|
|
81
81
|
function ApisCard(props) {
|
|
82
82
|
const state = props.useApisCard((s) => s);
|
|
83
83
|
const [dirDraft, setDirDraft] = react.useState(null); // 文档目录,null 表示未编辑
|
|
84
|
-
const [loading, setLoading] = react.useState(false); //
|
|
85
|
-
const [loaded, setLoaded] = react.useState(false); //
|
|
84
|
+
const [loading, setLoading] = react.useState(false); // 扫描进行中
|
|
85
|
+
const [loaded, setLoaded] = react.useState(false); // 扫描完成后短暂提示
|
|
86
86
|
const [open, setOpen] = react.useState(false); // 折叠态只显示标题行
|
|
87
87
|
const ready = state.status === "ready" && state.writable;
|
|
88
88
|
|
|
@@ -93,15 +93,15 @@ window.__ModuleLoader__.load({
|
|
|
93
93
|
const shownDir = dirDraft ?? savedDir;
|
|
94
94
|
const dirDirty = dirDraft !== null && dirDraft !== savedDir;
|
|
95
95
|
|
|
96
|
-
/**
|
|
96
|
+
/** 目录失焦时自动保存(点「扫描」也会先写入目录) */
|
|
97
97
|
function commitDir() {
|
|
98
98
|
if (dirDirty && ready) scope.set("apiDir", dirDraft);
|
|
99
99
|
setDirDraft(null);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
/**
|
|
102
|
+
/** 扫描:把目录写入配置并翻转 scanToken,服务端重扫 api.cfg 后回写接口列表;目录为空则清空列表 */
|
|
103
103
|
async function loadApis() {
|
|
104
|
-
if (loading || !ready
|
|
104
|
+
if (loading || !ready) return;
|
|
105
105
|
setLoading(true);
|
|
106
106
|
try {
|
|
107
107
|
if (dirDirty) await scope.set("apiDir", shownDir.trim());
|
|
@@ -143,7 +143,7 @@ window.__ModuleLoader__.load({
|
|
|
143
143
|
}),
|
|
144
144
|
// 展开体:API配置目录行 + 分隔线 + 接口行列表(只读)
|
|
145
145
|
open && react_jsx_runtime.jsxs("div", { className: "apis-body", children: [
|
|
146
|
-
// API配置:文档目录(api.cfg / api_doc.md 所在目录,失焦自动保存)+
|
|
146
|
+
// API配置:文档目录(api.cfg / api_doc.md 所在目录,失焦自动保存)+ 扫描按钮(目录为空则清空列表)
|
|
147
147
|
react_jsx_runtime.jsxs("div", { className: "apis-row", children: [
|
|
148
148
|
react_jsx_runtime.jsx("div", { className: "apis-rowLabel apis-rowLabelWide", children: "API配置" }),
|
|
149
149
|
react_jsx_runtime.jsx("input", {
|
|
@@ -151,19 +151,19 @@ window.__ModuleLoader__.load({
|
|
|
151
151
|
onChange: (e) => setDirDraft(e.target.value),
|
|
152
152
|
onBlur: commitDir,
|
|
153
153
|
onKeyDown: (e) => { if (e.key === "Enter") e.currentTarget.blur(); },
|
|
154
|
-
placeholder: "api.cfg / api_doc.md
|
|
154
|
+
placeholder: "api.cfg / api_doc.md 所在目录,留空扫描即清空列表",
|
|
155
155
|
className: "apis-input",
|
|
156
156
|
}),
|
|
157
157
|
react_jsx_runtime.jsx("button", {
|
|
158
|
-
type: "button", disabled: !ready || loading
|
|
158
|
+
type: "button", disabled: !ready || loading,
|
|
159
159
|
onClick: loadApis,
|
|
160
|
-
className: "apis-btn apis-discard", children: loading ? "扫描中…" : "
|
|
160
|
+
className: "apis-btn apis-discard", children: loading ? "扫描中…" : "扫描",
|
|
161
161
|
}),
|
|
162
|
-
loaded && react_jsx_runtime.jsx("span", { className: "apis-saved", children: "
|
|
162
|
+
loaded && react_jsx_runtime.jsx("span", { className: "apis-saved", children: "已扫描" }),
|
|
163
163
|
] }),
|
|
164
164
|
react_jsx_runtime.jsx("hr", { className: "apis-hr" }),
|
|
165
165
|
!state.writable && react_jsx_runtime.jsx("span", { className: "apis-description", children: "只读" }),
|
|
166
|
-
list.length ? list.map(row) : react_jsx_runtime.jsx("span", { className: "apis-empty", children: "暂无接口:请在 API 目录下的 api.cfg 中配置 apis
|
|
166
|
+
list.length ? list.map(row) : react_jsx_runtime.jsx("span", { className: "apis-empty", children: "暂无接口:请在 API 目录下的 api.cfg 中配置 apis,然后点击「扫描」" }),
|
|
167
167
|
] }),
|
|
168
168
|
],
|
|
169
169
|
});
|