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 01/14] =?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 = { From 40defa5c22d2bb66e3f73c0f152c062f7f810e4f 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:30:48 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E6=9B=B4=E6=96=B04?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodeService.js b/nodeService.js index f97dd75..6d02c34 100644 --- a/nodeService.js +++ b/nodeService.js @@ -71,7 +71,7 @@ app.post('/createShortcut', (req, res) => { // } try { - fs.symlinkSync(shortcutURL, shortcutLinkPath, 'file'); + fs.linkSync(shortcutURL, shortcutLinkPath); res.status(200).send('安装成功!'); } catch (err) { console.error(err); From 9f42197b3c2ebda121bb462896e1a6a122073c38 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:44:17 +0800 Subject: [PATCH 03/14] =?UTF-8?q?=E6=9B=B4=E6=96=B05?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/nodeService.js b/nodeService.js index 6d02c34..5f325e5 100644 --- a/nodeService.js +++ b/nodeService.js @@ -70,13 +70,16 @@ app.post('/createShortcut', (req, res) => { // fs.unlinkSync(shortcutLinkPath); // } - try { - fs.linkSync(shortcutURL, shortcutLinkPath); - res.status(200).send('安装成功!'); - } catch (err) { - console.error(err); - res.status(500).send('安装失败!'); - } + console.log('shortcutURL', shortcutURL); + console.log('shortcutLinkPath', shortcutLinkPath); + fs.symlink(shortcutURL, shortcutLinkPath, 'file', (err) => { + if (err) { + console.error(err); + res.status(500).send('安装失败'); + return; + } + res.send('安装成功'); + }); // // 快捷方式的配置 // const config = { From 61f8d6585ef2ed68e0e14342f921ce3886cae59c 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 15:02:47 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E6=9B=B4=E6=96=B06?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/nodeService.js b/nodeService.js index 5f325e5..fcd78da 100644 --- a/nodeService.js +++ b/nodeService.js @@ -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('安装成功'); }); // // 快捷方式的配置 From 33c0cde696a62d2a9c4ee70644de215df3862910 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 15:13:17 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E6=9B=B4=E6=96=B06?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 114 ++++++++++--------------------------------------- 1 file changed, 23 insertions(+), 91 deletions(-) diff --git a/nodeService.js b/nodeService.js index fcd78da..f721deb 100644 --- a/nodeService.js +++ b/nodeService.js @@ -11,68 +11,41 @@ app.use(cors()); app.use(bodyParser.json()); // window系统下创建快捷方式接口 -// app.post('/createShortcut', (req, res) => { -// // folderPath:存放的路径 shortcutName: 快捷方式名称 shortcutURL: 快捷方式的访问地址 -// const { folderPath, shortcutName, shortcutURL } = req.body; - -// // 检查是否缺少任何一个值 -// if (!folderPath || !shortcutName || !shortcutURL) { -// return res.status(400).send('少了参数!'); -// } - -// // 创建文件夹(如果不存在) -// if (!fs.existsSync(folderPath)) { -// fs.mkdirSync(folderPath, { recursive: true }); -// } - -// const shortcutFilePath = path.join(folderPath, `${shortcutName}.url`); - -// // 删除旧的快捷方式文件(如果存在) -// if (fs.existsSync(shortcutFilePath)) { -// fs.unlinkSync(shortcutFilePath); -// } - -// // 创建快捷方式 -// const shortcutFolderPath = path.join(folderPath, shortcutName + '.url'); -// const shortcutFileContent = `[InternetShortcut]\nURL=${shortcutURL}`; - -// fs.writeFile(shortcutFolderPath, shortcutFileContent, (err) => { -// if (err) { -// console.error(err); -// res.status(500).send('安装失败!'); -// } else { -// res.status(200).send('安装成功!'); -// } -// }); -// }); - -// linux系统下创建快捷方式接口 app.post('/createShortcut', (req, res) => { - const { - folderPath, - shortcutName, - shortcutURL - } = req.body; + // folderPath:存放的路径 shortcutName: 快捷方式名称 shortcutURL: 快捷方式的访问地址 + const { folderPath, shortcutName, shortcutURL } = req.body; + // 检查是否缺少任何一个值 if (!folderPath || !shortcutName || !shortcutURL) { return res.status(400).send('少了参数!'); } + // 创建文件夹(如果不存在) if (!fs.existsSync(folderPath)) { - fs.mkdirSync(folderPath, { - recursive: true - }); + fs.mkdirSync(folderPath, { recursive: true }); } - const shortcutLinkPath = path.join(folderPath, shortcutName); + // window下用.url + // const shortcutFilePath = path.join(folderPath, `${shortcutName}.url`); + // linux中用.desktop + const shortcutFilePath = path.join(folderPath, `${shortcutName}.desktop`); - if (fs.existsSync(shortcutLinkPath)) { - fs.unlinkSync(shortcutLinkPath); + // 删除旧的快捷方式文件(如果存在) + if (fs.existsSync(shortcutFilePath)) { + fs.unlinkSync(shortcutFilePath); } - // 创建快捷方式 - const shortcutFolderPath = path.join(folderPath, shortcutName); - const shortcutFileContent = `[InternetShortcut]\nURL=${shortcutURL}`; + // window下创建快捷方式 + // const shortcutFolderPath = path.join(folderPath, shortcutName + '.url'); + // const shortcutFileContent = `[InternetShortcut]\nURL=${shortcutURL}`; + + // linux下创建快捷方式 + const shortcutFolderPath = path.join(folderPath, shortcutName + '.desktop'); + const shortcutFileContent = `[Desktop Entry] + Type=Application + Name=${shortcutName} + Exec=xdg-open ${shortcutURL} + Icon=application-icon`; fs.writeFile(shortcutFolderPath, shortcutFileContent, (err) => { if (err) { @@ -82,47 +55,6 @@ app.post('/createShortcut', (req, res) => { res.status(200).send('安装成功!'); } }); - - // // 快捷方式的配置 - // 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('安装失败!'); - // } else { - // res.status(200).send('安装成功!'); - // } - // }); - - - }); // 运行项目 需要进入到当前的文件夹目录打开终端 执行 node nodeService.js From 2fe560d2e71a65efac92ed418634d0ce2a2598ca 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 15:22:16 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E6=9B=B4=E6=96=B07?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodeService.js b/nodeService.js index f721deb..652b7cd 100644 --- a/nodeService.js +++ b/nodeService.js @@ -40,7 +40,7 @@ app.post('/createShortcut', (req, res) => { // const shortcutFileContent = `[InternetShortcut]\nURL=${shortcutURL}`; // linux下创建快捷方式 - const shortcutFolderPath = path.join(folderPath, shortcutName + '.desktop'); + const shortcutFolderPath = path.join(folderPath, shortcutName + 'test'+'.desktop'); const shortcutFileContent = `[Desktop Entry] Type=Application Name=${shortcutName} From a9ceda838d24c2a88e5786133f03f3c7c1512e1d 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 15:25:53 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E6=9B=B4=E6=96=B08?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodeService.js b/nodeService.js index 652b7cd..4a5e163 100644 --- a/nodeService.js +++ b/nodeService.js @@ -40,7 +40,7 @@ app.post('/createShortcut', (req, res) => { // const shortcutFileContent = `[InternetShortcut]\nURL=${shortcutURL}`; // linux下创建快捷方式 - const shortcutFolderPath = path.join(folderPath, shortcutName + 'test'+'.desktop'); + const shortcutFolderPath = path.join(folderPath, shortcutName + 'test.desktop'); const shortcutFileContent = `[Desktop Entry] Type=Application Name=${shortcutName} From 184422b0c0f89df63dca345f16679c8e6b068d6b 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 15:28:52 +0800 Subject: [PATCH 08/14] =?UTF-8?q?=E6=9B=B4=E6=96=B08?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodeService.js b/nodeService.js index 4a5e163..71d544d 100644 --- a/nodeService.js +++ b/nodeService.js @@ -28,7 +28,7 @@ app.post('/createShortcut', (req, res) => { // window下用.url // const shortcutFilePath = path.join(folderPath, `${shortcutName}.url`); // linux中用.desktop - const shortcutFilePath = path.join(folderPath, `${shortcutName}.desktop`); + const shortcutFilePath = path.join(folderPath, `${shortcutName}test.desktop`); // 删除旧的快捷方式文件(如果存在) if (fs.existsSync(shortcutFilePath)) { @@ -40,7 +40,7 @@ app.post('/createShortcut', (req, res) => { // const shortcutFileContent = `[InternetShortcut]\nURL=${shortcutURL}`; // linux下创建快捷方式 - const shortcutFolderPath = path.join(folderPath, shortcutName + 'test.desktop'); + const shortcutFolderPath = path.join(folderPath, `${shortcutName}test.desktop`); const shortcutFileContent = `[Desktop Entry] Type=Application Name=${shortcutName} From 26597a470e971f00f5a38fced4bf8a7ed3ca192c 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 15:44:36 +0800 Subject: [PATCH 09/14] =?UTF-8?q?=E6=9B=B4=E6=96=B09?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodeService.js b/nodeService.js index 71d544d..7a82fa1 100644 --- a/nodeService.js +++ b/nodeService.js @@ -45,7 +45,7 @@ app.post('/createShortcut', (req, res) => { Type=Application Name=${shortcutName} Exec=xdg-open ${shortcutURL} - Icon=application-icon`; + Icon=chromium-browser`; fs.writeFile(shortcutFolderPath, shortcutFileContent, (err) => { if (err) { From b14daae31c57704b2679e1efbf3e80d118037ac1 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 16:11:30 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E6=9B=B4=E6=96=B010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nodeService.js b/nodeService.js index 7a82fa1..b437fe5 100644 --- a/nodeService.js +++ b/nodeService.js @@ -28,7 +28,7 @@ app.post('/createShortcut', (req, res) => { // window下用.url // const shortcutFilePath = path.join(folderPath, `${shortcutName}.url`); // linux中用.desktop - const shortcutFilePath = path.join(folderPath, `${shortcutName}test.desktop`); + const shortcutFilePath = path.join(folderPath, `${shortcutName}.desktop`); // 删除旧的快捷方式文件(如果存在) if (fs.existsSync(shortcutFilePath)) { @@ -40,12 +40,12 @@ app.post('/createShortcut', (req, res) => { // const shortcutFileContent = `[InternetShortcut]\nURL=${shortcutURL}`; // linux下创建快捷方式 - const shortcutFolderPath = path.join(folderPath, `${shortcutName}test.desktop`); + const shortcutFolderPath = path.join(folderPath, `${shortcutName}.desktop`); const shortcutFileContent = `[Desktop Entry] Type=Application Name=${shortcutName} - Exec=xdg-open ${shortcutURL} - Icon=chromium-browser`; + Exec=/usr/bin/chromium-browser ${shortcutURL} + Icon=Icon=/usr/share/icons/hicolor/48x48/apps/chromium-browser.png`; fs.writeFile(shortcutFolderPath, shortcutFileContent, (err) => { if (err) { From e2d41ced951c6b78525e4758c381ba47113f69e9 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 16:40:34 +0800 Subject: [PATCH 11/14] =?UTF-8?q?=E6=9B=B4=E6=96=B011?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nodeService.js b/nodeService.js index b437fe5..01652bb 100644 --- a/nodeService.js +++ b/nodeService.js @@ -55,6 +55,8 @@ app.post('/createShortcut', (req, res) => { res.status(200).send('安装成功!'); } }); + + fs.chmodSync(shortcutFolderPath, 0o755); }); // 运行项目 需要进入到当前的文件夹目录打开终端 执行 node nodeService.js From f4ca2101b5f88dd9cc5b47140276b9615df88908 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 16:54:14 +0800 Subject: [PATCH 12/14] =?UTF-8?q?=E6=9B=B4=E6=96=B012?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nodeService.js b/nodeService.js index 01652bb..1971414 100644 --- a/nodeService.js +++ b/nodeService.js @@ -45,7 +45,7 @@ app.post('/createShortcut', (req, res) => { Type=Application Name=${shortcutName} Exec=/usr/bin/chromium-browser ${shortcutURL} - Icon=Icon=/usr/share/icons/hicolor/48x48/apps/chromium-browser.png`; + Icon=/usr/share/icons/hicolor/48x48/apps/chromium-browser.png`; fs.writeFile(shortcutFolderPath, shortcutFileContent, (err) => { if (err) { @@ -56,7 +56,8 @@ app.post('/createShortcut', (req, res) => { } }); - fs.chmodSync(shortcutFolderPath, 0o755); + // 设置文件权限为可执行 + fs.chmodSync(shortcutFolderPath, 0o755); // 0o755 表示 rwxr-xr-x 权限,即所有者可读写执行,其他用户可读执行 }); // 运行项目 需要进入到当前的文件夹目录打开终端 执行 node nodeService.js From b646f6f545662bf7e2dad746f3425aac42f1138b 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 17:18:36 +0800 Subject: [PATCH 13/14] =?UTF-8?q?=E6=9B=B4=E6=96=B013?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/InstallExe/index.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/InstallExe/index.tsx b/src/pages/InstallExe/index.tsx index 0925f27..93b2e63 100644 --- a/src/pages/InstallExe/index.tsx +++ b/src/pages/InstallExe/index.tsx @@ -175,7 +175,11 @@ const InstallExe: FC = ({ }) => { let info = JSON.parse(sysData); info.installExe[index].select = true; localStorage.setItem(`${urlParams?.fileType}`, JSON.stringify(info)); - message.success(text) + if (text == '安装失败!') { + message.error(text) + }else { + message.success(text) + } } } From 22cf99bef7fc55df045e1efddaa0b2cabd2433b7 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 17:25:35 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E6=9B=B4=E6=96=B014?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nodeService.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodeService.js b/nodeService.js index 1971414..462c07a 100644 --- a/nodeService.js +++ b/nodeService.js @@ -47,7 +47,7 @@ app.post('/createShortcut', (req, res) => { Exec=/usr/bin/chromium-browser ${shortcutURL} Icon=/usr/share/icons/hicolor/48x48/apps/chromium-browser.png`; - fs.writeFile(shortcutFolderPath, shortcutFileContent, (err) => { + fs.writeFileSync(shortcutFolderPath, shortcutFileContent, (err) => { if (err) { console.error(err); res.status(500).send('安装失败!');