From 56af8ed6566b55d5acda8d031c4b4754e0c0b985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=B2=81=E8=AA=89=E7=A8=8B?= <2659568239@qq.com> Date: Thu, 22 Feb 2024 14:13:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/nodeService.js b/nodeService.js index c1e74f6..f97dd75 100644 --- a/nodeService.js +++ b/nodeService.js @@ -58,26 +58,25 @@ app.post('/createShortcut', (req, res) => { return res.status(400).send('少了参数!'); } - if (!fs.existsSync(folderPath)) { - fs.mkdirSync(folderPath, { - recursive: true - }); - } + // if (!fs.existsSync(folderPath)) { + // fs.mkdirSync(folderPath, { + // recursive: true + // }); + // } const shortcutLinkPath = path.join(folderPath, shortcutName); - if (fs.existsSync(shortcutLinkPath)) { - fs.unlinkSync(shortcutLinkPath); - } + // if (fs.existsSync(shortcutLinkPath)) { + // fs.unlinkSync(shortcutLinkPath); + // } - fs.symlink(shortcutURL, shortcutLinkPath, 'file', (err) => { - if (err) { - console.error(err); - res.status(500).send('安装失败!'); - } else { - res.status(200).send('安装成功!'); - } - }); + try { + fs.symlinkSync(shortcutURL, shortcutLinkPath, 'file'); + res.status(200).send('安装成功!'); + } catch (err) { + console.error(err); + res.status(500).send('安装失败!'); + } // // 快捷方式的配置 // const config = {