From dc0bb79a7ee066e01202a77355e2e9d03d644fe1 Mon Sep 17 00:00:00 2001 From: qinglong Date: Thu, 11 Jun 2026 21:11:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=A8=E5=B1=80=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=99=A8=20+=20=E9=A1=B9=E7=9B=AE=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E8=B7=AF=E5=BE=84=E9=80=89=E6=8B=A9=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- static/web_panel/home.html | 2 +- static/web_panel/js/app.js | 20 ++++++++++++++++++++ static/web_panel/pages/files.js | 1 + static/web_panel/pages/projects.html | 5 +++-- 4 files changed, 25 insertions(+), 3 deletions(-) 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()}