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:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user