From 7b89dc412fef3988f249ebd5bfed40d64abcdaed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=91=9E=E5=AE=81?= <3134191406@qq.com> Date: Thu, 22 Feb 2024 13:27:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=92=A4=E5=9B=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 62 +++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/nodeService.js b/nodeService.js index c79a2a6..c1e74f6 100644 --- a/nodeService.js +++ b/nodeService.js @@ -70,36 +70,7 @@ app.post('/createShortcut', (req, res) => { fs.unlinkSync(shortcutLinkPath); } - // 快捷方式的配置 - const config = { - name: shortcutName, - exec: 'x-www-browser', - // icon: '/path/to/favicon.png', // 图标路径,可选 - icon: '', - url: shortcutURL, - terminal: false, - type: 'Application', - categories: 'Network;WebBrowser;' - }; - - // 快捷方式文件内容 - let desktopFileContent = `[Desktop Entry] - Name=${config.name} - Exec=${config.exec} ${config.url} - Type=${config.type} - Icon=${config.icon || ''} - Terminal=${config.terminal} - Categories=${config.categories} - Comment=Open ${config.name} in your web browser`; - - // 如果有图标路径,确保图标文件存在 - // if (config.icon && !fs.existsSync(config.icon)) { - // console.error('Icon file does not exist.'); - // process.exit(1); - // } - - // 创建快捷方式文件 - fs.writeFile(shortcutLinkPath, desktopFileContent, 'utf8', function (err) { + fs.symlink(shortcutURL, shortcutLinkPath, 'file', (err) => { if (err) { console.error(err); res.status(500).send('安装失败!'); @@ -108,7 +79,36 @@ app.post('/createShortcut', (req, res) => { } }); - // fs.symlink(shortcutURL, shortcutLinkPath, 'file', (err) => { + // // 快捷方式的配置 + // const config = { + // name: shortcutName, + // exec: 'x-www-browser', + // // icon: '/path/to/favicon.png', // 图标路径,可选 + // icon: '', + // url: shortcutURL, + // terminal: false, + // type: 'Application', + // categories: 'Network;WebBrowser;' + // }; + + // // 快捷方式文件内容 + // let desktopFileContent = `[Desktop Entry] + // Name=${config.name} + // Exec=${config.exec} ${config.url} + // Type=${config.type} + // Icon=${config.icon || ''} + // Terminal=${config.terminal} + // Categories=${config.categories} + // Comment=Open ${config.name} in your web browser`; + + // // 如果有图标路径,确保图标文件存在 + // // if (config.icon && !fs.existsSync(config.icon)) { + // // console.error('Icon file does not exist.'); + // // process.exit(1); + // // } + + // // 创建快捷方式文件 + // fs.writeFile(shortcutLinkPath, desktopFileContent, 'utf8', function (err) { // if (err) { // console.error(err); // res.status(500).send('安装失败!');