|
|
@@ -17,7 +17,7 @@
|
|
|
|
<h3 style="margin-bottom:12px">添加新项目</h3>
|
|
|
|
<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-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-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-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>
|
|
|
|
<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>
|
|
|
|
<button class="btn btn-filled" onclick="addProject()" style="margin-top:8px">启动项目</button>
|
|
|
@@ -29,6 +29,7 @@
|
|
|
|
<h3 style="margin-bottom:12px">从 Git 部署</h3>
|
|
|
|
<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">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><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>
|
|
|
|
<button class="btn btn-filled" onclick="deployGit()" style="margin-top:8px">克隆并部署</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@@ -50,7 +51,7 @@ async function deployGit(){
|
|
|
|
var u=document.getElementById("git-url").value,b=document.getElementById("git-branch").value;
|
|
|
|
var u=document.getElementById("git-url").value,b=document.getElementById("git-branch").value;
|
|
|
|
if(!u){alert("请填写 Git URL");return}
|
|
|
|
if(!u){alert("请填写 Git URL");return}
|
|
|
|
var n=u.split("/").pop().replace(".git","");
|
|
|
|
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()
|
|
|
|
refresh()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
async function stopP(el,n){await fetch("./api/projects/"+n+"/stop",{method:"POST"});refresh()}
|
|
|
|
async function stopP(el,n){await fetch("./api/projects/"+n+"/stop",{method:"POST"});refresh()}
|
|
|
|