dsh-plugin-codegraph-panel 0.5.2 → 0.6.0
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/lib/client.js +26 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -231,16 +231,41 @@ window.__ModuleLoader__.load({
|
|
|
231
231
|
|
|
232
232
|
const trimmed = root.trim();
|
|
233
233
|
|
|
234
|
+
// 打开就自动读一次。路径为空时请求不带 root,宿主用当前会话的工作区回答。
|
|
235
|
+
React.useEffect(function () {
|
|
236
|
+
loadStatus();
|
|
237
|
+
// 只在挂载时跑:之后的读取都由「刷新」「重建」按钮驱动
|
|
238
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
239
|
+
}, []);
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 服务端解析出的工作区回填到输入框。
|
|
243
|
+
*
|
|
244
|
+
* 用户打开设置页时通常只用关心「我现在这个会话」的索引状态,让他把会话自己的路径再抄一遍
|
|
245
|
+
* 是没有意义的摩擦。请求不带 root 时宿主会回答当前会话的工作区,这里把它显示出来,之后
|
|
246
|
+
* 的刷新/重建就用这个值。
|
|
247
|
+
*/
|
|
248
|
+
function adoptResolvedRoot(asked, data) {
|
|
249
|
+
const resolved = data && typeof data.root === "string" ? data.root : "";
|
|
250
|
+
if (asked !== "" || resolved === "") return;
|
|
251
|
+
setRoot(resolved);
|
|
252
|
+
writeStoredRoot(resolved);
|
|
253
|
+
}
|
|
254
|
+
|
|
234
255
|
/** 所有错误都走 state,不 throw —— 一个 tab 不该把设置页打白 */
|
|
235
256
|
async function loadStatus() {
|
|
236
|
-
const
|
|
257
|
+
const asked = root.trim();
|
|
258
|
+
const result = await call(asked === "" ? API + "/state" : stateUrl(asked));
|
|
237
259
|
if (!result.ok) {
|
|
260
|
+
// 即便这次失败(例如还没有索引),服务端也已经解析出了工作区,回填免得用户再填一次
|
|
261
|
+
adoptResolvedRoot(asked, result.data);
|
|
238
262
|
setError(result.message);
|
|
239
263
|
return;
|
|
240
264
|
}
|
|
241
265
|
setError(null);
|
|
242
266
|
setStatus(result.data && result.data.status ? result.data.status : null);
|
|
243
267
|
setLoaded(true);
|
|
268
|
+
adoptResolvedRoot(asked, result.data);
|
|
244
269
|
}
|
|
245
270
|
|
|
246
271
|
async function onRefresh() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-codegraph-panel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Settings-page panel for dsh-plugin-codegraph: a 代码图谱 tab that shows one workspace's index status and can rebuild it. Browser half only — every number comes from the host's /dsh-plugin-codegraph/api/* routes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|