|
|
|
@ -58,27 +58,29 @@ 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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 创建快捷方式
|
|
|
|
|
const shortcutFolderPath = path.join(folderPath, shortcutName);
|
|
|
|
|
const shortcutFileContent = `[InternetShortcut]\nURL=${shortcutURL}`;
|
|
|
|
|
|
|
|
|
|
console.log('shortcutURL', shortcutURL);
|
|
|
|
|
console.log('shortcutLinkPath', shortcutLinkPath);
|
|
|
|
|
fs.symlink(shortcutURL, shortcutLinkPath, 'file', (err) => {
|
|
|
|
|
fs.writeFile(shortcutFolderPath, shortcutFileContent, (err) => {
|
|
|
|
|
if (err) {
|
|
|
|
|
console.error(err);
|
|
|
|
|
res.status(500).send('安装失败');
|
|
|
|
|
return;
|
|
|
|
|
res.status(500).send('安装失败!');
|
|
|
|
|
} else {
|
|
|
|
|
res.status(200).send('安装成功!');
|
|
|
|
|
}
|
|
|
|
|
res.send('安装成功');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// // 快捷方式的配置
|
|
|
|
|