feat: 全局文件选择器 + 项目管理路径选择按钮

- app.js新增window.pickPath(mode,callback)全局复用
- 项目管理「工作目录」+Git部署「目标目录」添加📁选择按钮
- Git部署不再硬编码data/projects,改用用户选择的目标目录
- files.js picker模式读取URL cb参数实现callback_id回传
- app.js版本号更新至v=0701

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
qinglong
2026-06-11 21:11:50 +08:00
parent 99c3e3e853
commit dc0bb79a7e
4 changed files with 25 additions and 3 deletions
+1
View File
@@ -12,6 +12,7 @@ window.FilesModule = {
if (params.get('picker') === '1') {
self.pickerMode = true;
self.pickerMode = params.get('mode') || 'dir';
self.pickerCallback = params.get('cb') || null;
}
window.addEventListener('message', function(e) {
try {
+3 -2
View File
@@ -17,7 +17,7 @@
<h3 style="margin-bottom:12px">添加新项目</h3>
<div class="input-group"><span class="label">项目名称</span><input class="input" id="proj-name" placeholder="如: my-app"></div>
<div class="input-group"><span class="label">启动命令</span><input class="input" id="proj-cmd" placeholder="如: python3 main.py"></div>
<div class="input-group"><span class="label">工作目录</span><input class="input" id="proj-cwd" value="."></div>
<div class="input-group"><span class="label">工作目录</span><div style="display:flex;gap:6px"><input class="input" id="proj-cwd" value="." style="flex:1"><button class="btn btn-sm btn-outlined" onclick="pickPath('dir',function(p){document.getElementById('proj-cwd').value=p})" title="选择目录" style="flex-shrink:0"><svg width="14" height="14" viewBox="0 0 24 24"><path fill="currentColor" d="M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l2 2H20v10z"/></svg></button></div></div>
<div class="input-group"><span class="label">端口 (可选)</span><input class="input" id="proj-port" type="number" placeholder="5000" style="width:120px"></div>
<div class="input-group"><span class="label">代理路径 (可选)</span><input class="input" id="proj-proxy" placeholder="如: /myapp" style="width:200px"></div>
<button class="btn btn-filled" onclick="addProject()" style="margin-top:8px">启动项目</button>
@@ -29,6 +29,7 @@
<h3 style="margin-bottom:12px">从 Git 部署</h3>
<div class="input-group"><span class="label">Git URL</span><input class="input" id="git-url" placeholder="https://git.yeij.top/user/repo.git"></div>
<div class="input-group"><span class="label">分支</span><input class="input" id="git-branch" value="main" style="width:160px"></div>
<div class="input-group"><span class="label">目标目录</span><div style="display:flex;gap:6px"><input class="input" id="git-cwd" value="data/projects" style="flex:1"><button class="btn btn-sm btn-outlined" onclick="pickPath("dir",function(p){document.getElementById("git-cwd").value=p})" title="选择目录" style="flex-shrink:0"><svg width="14" height="14" viewBox="0 0 24 24"><path fill="currentColor" d="M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V6h5.17l2 2H20v10z"/></svg></button></div></div>
<button class="btn btn-filled" onclick="deployGit()" style="margin-top:8px">克隆并部署</button>
</div>
</div>
@@ -50,7 +51,7 @@ async function deployGit(){
var u=document.getElementById("git-url").value,b=document.getElementById("git-branch").value;
if(!u){alert("请填写 Git URL");return}
var n=u.split("/").pop().replace(".git","");
await fetch("./api/projects/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,cmd:["git","clone","-b",b,u,n],cwd:"data/projects"})});
await fetch("./api/projects/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,cmd:["git","clone","-b",b,u,n],cwd:document.getElementById("git-cwd").value})});
refresh()
}
async function stopP(el,n){await fetch("./api/projects/"+n+"/stop",{method:"POST"});refresh()}