From b244b09396e4a796dc39ff3d90a9bcd1a58bdccb Mon Sep 17 00:00:00 2001 From: unknown <1371033826@qq.com> Date: Tue, 24 Jun 2025 23:24:18 +0800 Subject: [PATCH] 0624 --- js/projects.js | 13 ++++++++----- mixio.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/js/projects.js b/js/projects.js index c2b64ab..e146507 100644 --- a/js/projects.js +++ b/js/projects.js @@ -1318,6 +1318,7 @@ function view_project(projectName, projectType) { clearAllButton.click(function() { isChanged = true + if (globalTableProjectInfo.currentTp != "$") { if (globalTableProjectInfo.currentTp.split(",,").length == 1) delete globalTableProjectInfo.received[globalTableProjectInfo.currentTp] @@ -4278,7 +4279,8 @@ function prepare_storDia(){ function downloadFile(filename) { let url = "store/" + globalUserName + "/" + globalProjectName + "/" + filename; - console.log(url) + if(isMixly) + url = "store/MixIO/" + globalUserName.substr(1) + "/" + globalProjectName + "/" + filename; let a = document.createElement('a'); a.href = url; a.download = filename; @@ -4319,7 +4321,8 @@ function prepare_storDia(){ let deletePromises = selectedFiles.map(filename => { return $.getJSON('deleteImgStore', { 'projectName': globalProjectName, - 'filename': filename + 'filename': filename, + 'isMixly': isMixly }); }); @@ -4380,9 +4383,9 @@ function prepare_storDia(){ if(/^\d+$/.test(timePart)) { return parseInt(timePart); } - + console.log("timePart:", timePart); // 尝试解析 YYYY-MM-DD HH:MM:SS 格式 - const datePattern = /^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/; + const datePattern = /^(\d{4})-(\d{2})-(\d{2})-(\d{2})-(\d{2})-(\d{2})$/; const match = timePart.match(datePattern); if(match) { @@ -4549,7 +4552,7 @@ function prepare_storDia(){ let infoDiv = $('
'); // Filename (truncated) - let shortName = filename.length > 20 ? filename.substring(0, 17) + '...' : filename; + let shortName = filename.split("_")[0] infoDiv.append('
' + shortName + '
'); // File type and date diff --git a/mixio.js b/mixio.js index d0d0f39..be63d0c 100644 --- a/mixio.js +++ b/mixio.js @@ -1424,6 +1424,40 @@ var mixioServer = async function() { res.redirect('/') }) + app.get('/clearImgStore', function(req, res) { + if (req.session.userName && req.query.projectName && req.query.topicName){ + var projectName = req.query.projectName + var isMixly = req.query.isMixly + // store/username/projectName + var imgStorePath = 'store/' + req.session.userName + "/" + projectName + if (isMixly == "true") + { + imgStorePath = path.join('store/MixIO/' + req.session.userName.substr(1) + "/" + projectName) + } + // 删除所有开头为$topicName_的文件 + fs.readdir(imgStorePath, function(err, files) { + if (err) { + console.log(err) + } else { + files.forEach(function(file) { + if (file.startsWith(req.query.topicName + "_")) { + fs.unlink(path.join(imgStorePath, file), function(err) { + if (err) { + console.log(err) + } + }) + } + }) + } + }) + res.send({ + "status": "success" + } + ) + } else + res.redirect('/') + }) + app.get('/projects', function(req, res) { if (req.session.userName) { ejs.renderFile(__dirname + '/ejs/projects.ejs', {