@ppdocs/mcp 3.2.10 → 3.2.11

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.
Files changed (2) hide show
  1. package/dist/web/ui.js +18 -33
  2. package/package.json +1 -1
package/dist/web/ui.js CHANGED
@@ -74,9 +74,6 @@ label{font-size:12px;color:#64748b;font-weight:500;display:block;margin-bottom:4
74
74
  .tab.active{color:#60a5fa;border-color:#60a5fa}
75
75
  @keyframes pulse{0%,100%{opacity:1}50%{opacity:.4}}
76
76
  </style>
77
- <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
78
- <meta http-equiv="Pragma" content="no-cache">
79
- <meta http-equiv="Expires" content="0">
80
77
  </head>
81
78
  <body>
82
79
  <div class="app" id="app"></div>
@@ -92,7 +89,7 @@ function go(page,data){Object.assign(S,data||{});S.page=page;_lastDetailRid=null
92
89
  function toast(m,t){t=t||'ok';var e=document.getElementById('toast');e.textContent=m;e.className='toast '+t+' show';setTimeout(function(){e.className='toast'},3000)}
93
90
 
94
91
  // ============ API ============
95
- function api(path,opts){return fetch(path,opts).then(function(r){return r.json()}).then(function(d){console.log('[api]',path,d);return d})}
92
+ function api(path,opts){return fetch(path,opts).then(function(r){return r.json()})}
96
93
 
97
94
  // ============ Init ============
98
95
  function init(){
@@ -111,7 +108,7 @@ function init(){
111
108
  var entry=items[i].webkitGetAsEntry&&items[i].webkitGetAsEntry();
112
109
  if(entry&&entry.isDirectory){
113
110
  go('add',{addStep:1,addDir:entry.name});
114
- toast('📂 检测到 '+entry.name+',请补全绝对路径后发送授权');
111
+ toast('📂 请补全绝对路径,例如 D:/projects/'+entry.name);
115
112
  setTimeout(function(){var inp=document.getElementById('iDir');if(inp){inp.focus();inp.setSelectionRange(0,0)}},150);
116
113
  return;
117
114
  }
@@ -191,19 +188,22 @@ function renderAdd(){
191
188
  }
192
189
 
193
190
  function renderAddStep1(){
191
+ var dirName=S.addDir?S.addDir.replace(/\\\\/g,'/').split('/').filter(Boolean).pop():'';
192
+ var namePreview=dirName?'<div style="font-size:12px;color:#60a5fa;margin:-8px 0 12px">📂 项目名: <strong>'+dirName+'</strong></div>':'';
194
193
  return '<span class="back" onclick="cancelAuth();go(\\x27list\\x27)">← 返回项目列表</span>'+
195
- '<div class="card no-hover"><div class="section"><h2>➕ 添加项目</h2>'+
196
- '<p style="font-size:13px;color:#64748b;margin-bottom:12px">点击发送授权,在主机端 PPDocs 应用中选择项目并批准</p>'+
197
- '<div class="fg"><label>本地项目目录 (可选,MCP安装时需要)</label><input id="iDir" value="'+S.addDir+'" placeholder="Win: D:\\\\projects\\\\app Mac: /Users/xxx/app" oninput="S.addDir=this.value"></div>'+
194
+ '<div class="card no-hover"><div class="section"><h2>➕ 添加项目 — Step 1/2</h2>'+
195
+ '<p style="font-size:13px;color:#64748b;margin-bottom:12px">指定本地项目目录,以目录名作为项目名称</p>'+
196
+ '<div class="fg"><label>本地项目目录 (绝对路径)</label><input id="iDir" value="'+S.addDir+'" placeholder="例: D:/projects/my-app" oninput="S.addDir=this.value;_render()"></div>'+
197
+ namePreview+
198
198
  '<div class="btn-row"><button class="btn btn-p" onclick="doAuthStart()">📡 发送授权请求</button></div>'+
199
199
  '</div></div>';
200
200
  }
201
201
 
202
202
  function doAuthStart(){
203
- var dir=(document.getElementById('iDir')?document.getElementById('iDir').value:'').trim();
204
- if(dir&&!/^[A-Za-z]:[\\\\\\/]|^\\/|^~\//.test(dir)){toast('路径需为绝对路径(D:\\xxx 或 /Users/xxx)或留空','err');return}
203
+ var dir=document.getElementById('iDir').value.trim();
204
+ if(dir&&!/^[A-Za-z]:[\\\\\\/]|^\\//.test(dir)){toast('路径需为绝对路径(D:\\xxx 或 /Users/xxx)或留空','err');return}
205
205
  S.addDir=dir;
206
- api('/api/auth/start',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({localDir:dir||''})}).then(function(r){
206
+ api('/api/auth/start',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({localDir:dir})}).then(function(r){
207
207
  if(!r.ok){toast(r.error||'授权请求失败','err');return}
208
208
  S.authRequestId=r.requestId;S.authStartTime=Date.now();S.authStatus='pending';S.addStep=2;
209
209
  render();startAuthPoll();
@@ -304,7 +304,7 @@ function renderOverview(p){
304
304
  '<div class="stat"><span>同步: '+(p.connected?'🟢 运行中':'🔴 '+p.syncStatus)+' '+(p.lastSync?'('+p.lastSync+')':'')+'</span></div>'+
305
305
  '</div></div>'+
306
306
  '<div class="card no-hover"><div class="section"><h2>📚 知识图谱</h2>'+
307
- '<div class="tree-box" id="treeBox">加载中 ...</div></div></div>';
307
+ '<div class="tree-box" id="treeBox">加载中...</div></div></div>';
308
308
  }
309
309
 
310
310
  function renderMcpTab(p){
@@ -361,22 +361,11 @@ function renderPromptsTab(p){
361
361
 
362
362
  // ============ Data Loading ============
363
363
  function loadTree(rid){
364
- var box=document.getElementById('treeBox');
365
- if(!box) return;
366
- var xhr=new XMLHttpRequest();
367
- xhr.open('GET','/api/bind/'+rid+'/tree?_='+Date.now(),true);
368
- xhr.onload=function(){
369
- try{
370
- var r=JSON.parse(xhr.responseText);
371
- var txt=r.tree||'知识库为空';
372
- var NL=String.fromCharCode(10);
373
- if(r.docCount>0) txt='共 '+r.docCount+' 文档, '+r.dirCount+' 目录'+NL+NL+txt;
374
- if(r.readOnly) txt='🔒 只读模式'+NL+NL+txt;
375
- box.textContent=txt;
376
- }catch(e){box.textContent='解析失败: '+e}
377
- };
378
- xhr.onerror=function(){box.textContent='请求失败'};
379
- xhr.send();
364
+ var box=document.getElementById('treeBox');if(!box)return Promise.resolve();
365
+ return api('/api/bind/'+rid+'/tree').then(function(r){
366
+ var prefix=r.readOnly?'🔒 只读模式\\n\\n':'';
367
+ box.textContent=r.tree?(prefix+(r.docCount>0?''+r.docCount+' 文档, '+r.dirCount+' 目录\\n\\n':'')+r.tree):'知识库为空';
368
+ }).catch(function(e){box.textContent='加载失败: '+e});
380
369
  }
381
370
  function loadMcpStatus(rid){return api('/api/bind/'+rid+'/mcp').then(function(r){S.mcpStatus=r.platforms||{}}).catch(function(){S.mcpStatus={}})}
382
371
  function loadMcpAll(rid){return api('/api/bind/'+rid+'/mcp/all').then(function(r){S.mcpAll=r.servers||[]}).catch(function(){S.mcpAll=[]})}
@@ -469,11 +458,7 @@ render=function(){
469
458
  var _rid=S.projects[S.detailIdx]?S.projects[S.detailIdx].remoteId:null;
470
459
  if(S.page==='detail'&&_rid&&!_detailLoading&&_lastDetailRid!==_rid){
471
460
  _detailLoading=true;_lastDetailRid=_rid;
472
- loadMcpStatus(_rid);loadMcpAll(_rid);loadPrompts(_rid);
473
- setTimeout(function(){
474
- _detailLoading=false;
475
- loadTree(_rid);
476
- },100);
461
+ Promise.all([loadTree(_rid),loadMcpStatus(_rid),loadMcpAll(_rid),loadPrompts(_rid)]).then(function(){_detailLoading=false;_render()}).catch(function(){_detailLoading=false});
477
462
  }
478
463
  };
479
464
  setInterval(function(){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ppdocs/mcp",
3
- "version": "3.2.10",
3
+ "version": "3.2.11",
4
4
  "description": "ppdocs MCP Server - Knowledge Graph for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",