@wendongfly/zihi 1.1.9 → 1.1.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.
package/dist/index.html CHANGED
@@ -468,11 +468,12 @@
468
468
  </div>
469
469
  <input id="inp-cmd" type="hidden">
470
470
  <div class="field">
471
- <label>工作目录 <span style="font-weight:400;text-transform:none">(可选)</span></label>
471
+ <label>工作目录</label>
472
472
  <div style="display:flex;gap:0.5rem">
473
473
  <input id="inp-cwd" type="text" placeholder="留空使用默认目录" autocomplete="off" spellcheck="false" style="flex:1">
474
474
  <button onclick="openDirPicker()" style="flex-shrink:0;background:var(--bg);border:1px solid var(--border);border-radius:8px;padding:0 0.75rem;color:var(--text);font-size:1.1rem;cursor:pointer">📁</button>
475
475
  </div>
476
+ <div id="cwd-hint" style="font-size:0.72rem;color:var(--muted);margin-top:0.3rem;display:none"></div>
476
477
  <div id="recent-dirs" style="display:flex;flex-wrap:wrap;gap:0.35rem;margin-top:0.4rem"></div>
477
478
  </div>
478
479
  <button id="btn-create" onclick="createSession()">创建</button>
@@ -489,6 +490,7 @@
489
490
  <div id="dir-list"></div>
490
491
  <div id="dir-actions">
491
492
  <button class="dir-btn cancel" onclick="closeDirPicker()">取消</button>
493
+ <button class="dir-btn" onclick="createSubDir()" style="background:#21262d;border-color:#30363d">新建文件夹</button>
492
494
  <button class="dir-btn primary" onclick="selectDir()">选择此目录</button>
493
495
  </div>
494
496
  </div>
@@ -541,9 +543,15 @@
541
543
  if (data.name) document.getElementById('user-name').textContent = data.name;
542
544
  if (data.dir) {
543
545
  _userDir = data.dir;
544
- // 默认填入绑定目录,隐藏盘符栏,保留最近目录
545
- document.getElementById('inp-cwd').value = data.dir;
546
+ // 锁定输入框为只读,隐藏盘符栏
547
+ var cwdInput = document.getElementById('inp-cwd');
548
+ cwdInput.value = data.dir;
549
+ cwdInput.readOnly = true;
550
+ cwdInput.style.opacity = '0.7';
551
+ cwdInput.placeholder = '点击右侧 📁 选择子目录';
546
552
  document.getElementById('drive-bar').style.display = 'none';
553
+ document.getElementById('cwd-hint').style.display = 'block';
554
+ document.getElementById('cwd-hint').textContent = '请在 ' + data.dir + ' 下选择或新建项目文件夹';
547
555
  renderRecentDirs();
548
556
  }
549
557
  }).catch(() => {});
@@ -754,12 +762,17 @@
754
762
  const title = document.getElementById('inp-title').value.trim() || '新任务';
755
763
  const initCmd = document.getElementById('inp-cmd').value.trim() || undefined;
756
764
  const cwd = document.getElementById('inp-cwd').value.trim() || undefined;
765
+ // 有绑定目录时,必须选择子目录,不能直接在根目录创建会话
766
+ if (_userDir && (!cwd || cwd.replace(/[\\/]+$/, '') === _userDir.replace(/[\\/]+$/, ''))) {
767
+ alert('请在 ' + _userDir + ' 下选择或新建一个项目文件夹');
768
+ return;
769
+ }
757
770
  if (cwd) recordDir(cwd);
758
771
  const preset = selectedPreset != null ? PRESETS[selectedPreset] : null;
759
772
  closeSheet();
760
773
  document.getElementById('inp-title').value = '';
761
774
  document.getElementById('inp-cmd').value = '';
762
- document.getElementById('inp-cwd').value = '';
775
+ document.getElementById('inp-cwd').value = _userDir || '';
763
776
 
764
777
  if (preset?.type === 'agent') {
765
778
  // Agent 模式:使用 Claude SDK
@@ -830,6 +843,10 @@
830
843
  document.getElementById('dir-picker').classList.remove('open');
831
844
  }
832
845
  function selectDir() {
846
+ if (_userDir && _dirCurrent.replace(/[\\/]+$/, '') === _userDir.replace(/[\\/]+$/, '')) {
847
+ alert('不能选择根目录,请选择或新建一个子文件夹');
848
+ return;
849
+ }
833
850
  document.getElementById('inp-cwd').value = _dirCurrent;
834
851
  recordDir(_dirCurrent);
835
852
  closeDirPicker();
@@ -881,7 +898,9 @@
881
898
  });
882
899
  const dirList = document.getElementById('dir-list');
883
900
  dirList.innerHTML = '';
884
- if (data.parent) {
901
+ // 有绑定目录时,不允许向上跳出绑定目录
902
+ var atRoot = _userDir && _dirCurrent.replace(/[\\/]+$/, '') === _userDir.replace(/[\\/]+$/, '');
903
+ if (data.parent && !atRoot) {
885
904
  const el = document.createElement('div');
886
905
  el.className = 'dir-item';
887
906
  el.dataset.path = data.parent;
@@ -904,6 +923,24 @@
904
923
  const item = e.target.closest('.dir-item');
905
924
  if (item?.dataset.path) loadDirs(item.dataset.path);
906
925
  });
926
+
927
+ function createSubDir() {
928
+ var name = prompt('新建文件夹名称:');
929
+ if (!name || !name.trim()) return;
930
+ // 在当前目录下创建子文件夹
931
+ var newPath = _dirCurrent.replace(/[\\/]+$/, '') + '/' + name.trim();
932
+ fetch('/api/files/mkdir', {
933
+ method: 'POST',
934
+ headers: { 'Content-Type': 'application/json' },
935
+ body: JSON.stringify({ path: newPath }),
936
+ }).then(function(r) { return r.json(); }).then(function(data) {
937
+ if (data.ok || data.error?.includes('已存在')) {
938
+ loadDirs(_dirCurrent); // 刷新列表
939
+ } else {
940
+ alert('创建失败: ' + (data.error || '未知错误'));
941
+ }
942
+ }).catch(function(e) { alert('创建失败: ' + e.message); });
943
+ }
907
944
  function escH(s) { return s.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); }
908
945
 
909
946
  // ── 导入已有 Claude 会话 ───────────────────────────────────
package/dist/login.html CHANGED
@@ -138,7 +138,7 @@
138
138
  <button type="submit" id="btn">进入</button>
139
139
  </form>
140
140
 
141
- <div class="hint">密码见服务器启动日志<br>或编辑 ~/.zihi/password</div>
141
+ <div class="hint">请输入管理员分配的密码</div>
142
142
  </div>
143
143
 
144
144
  <script>
package/dist/package.json CHANGED
@@ -1 +1 @@
1
- {"type":"module","version":"1.1.8"}
1
+ {"type":"module","version":"1.1.10"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wendongfly/zihi",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "AI Agent terminal sharing with interactive permission approval via Claude Agent SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",