diff --git a/static/web_panel/home.html b/static/web_panel/home.html index 0e0bcc8..9b89b90 100644 --- a/static/web_panel/home.html +++ b/static/web_panel/home.html @@ -72,6 +72,6 @@ - + diff --git a/static/web_panel/js/app.js b/static/web_panel/js/app.js index 6ea01ec..4af5209 100644 --- a/static/web_panel/js/app.js +++ b/static/web_panel/js/app.js @@ -172,6 +172,26 @@ async function loadPluginPage(pluginName) { } +// ═══ Global file/dir picker (reusable by any page) ═══ +// Usage: pickPath('dir', function(path) { document.getElementById('my-input').value = path; }) +window.pickPath = function(mode, callback) { + var id = 'picker_' + Date.now(); + window['_pickCallback_' + id] = callback; + var url = './static/pages/files.html?picker=1&mode=' + (mode || 'dir') + '&cb=' + id; + var w = window.open(url, 'fm-picker', 'width=680,height=520'); + if (!w) { alert('请允许弹窗以使用文件选择器'); return; } + // Listen for pick result + window.addEventListener('message', function handler(e) { + try { + var d = JSON.parse(e.data); + if (d.action === 'fm-picked' && d.callback_id === id) { + window.removeEventListener('message', handler); + if (d.path && callback) callback(d.path); + } + } catch(ex) {} + }); +}; + // ═══ Sidebar toggle ═══ function toggleSidebar() { document.getElementById('app').classList.toggle('collapsed'); diff --git a/static/web_panel/pages/files.js b/static/web_panel/pages/files.js index 0f038f7..c07544c 100644 --- a/static/web_panel/pages/files.js +++ b/static/web_panel/pages/files.js @@ -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 { diff --git a/static/web_panel/pages/projects.html b/static/web_panel/pages/projects.html index 4585d4f..5d40538 100644 --- a/static/web_panel/pages/projects.html +++ b/static/web_panel/pages/projects.html @@ -17,7 +17,7 @@

添加新项目

项目名称
启动命令
-
工作目录
+
工作目录
端口 (可选)
代理路径 (可选)
@@ -29,6 +29,7 @@

从 Git 部署

Git URL
分支
+
目标目录
@@ -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()}