diff --git a/src/utils/nodeService.js b/nodeService.js similarity index 79% rename from src/utils/nodeService.js rename to nodeService.js index d665aeb..04303f3 100644 --- a/src/utils/nodeService.js +++ b/nodeService.js @@ -5,11 +5,12 @@ const cors = require('cors'); const bodyParser = require('body-parser'); const app = express(); -const port = 3000; // 可以根据需要修改端口号 +const port = 8080; // 可以根据需要修改端口号 app.use(cors()); app.use(bodyParser.json()); +// 创建快捷方式接口 app.post('/createShortcut', (req, res) => { // folderPath:存放的路径 shortcutName: 快捷方式名称 shortcutURL: 快捷方式的访问地址 const { folderPath, shortcutName, shortcutURL } = req.body; @@ -45,8 +46,15 @@ app.post('/createShortcut', (req, res) => { }); }); -// 运行项目 需要进入到当前的文件夹目录打开终端 执行 node nodeService.js +// 静态文件服务,指定 dist 目录为静态文件目录 +app.use(express.static(path.join(__dirname, 'dist'))); + +// 所有请求都返回 index.html 文件,让前端路由处理页面跳转 +app.get('*', function(req, res) { + res.sendFile(path.join(__dirname, 'dist', 'index.html')); +}); +// 运行项目 需要进入到当前的文件夹目录打开终端 执行 node nodeService.js app.listen(port, () => { console.log(`Server is running on port ${port}`); }); \ No newline at end of file diff --git a/src/pages/InitialSystem/PowerOnAuth/index.tsx b/src/pages/InitialSystem/PowerOnAuth/index.tsx index 71d5d91..7152ce6 100644 --- a/src/pages/InitialSystem/PowerOnAuth/index.tsx +++ b/src/pages/InitialSystem/PowerOnAuth/index.tsx @@ -60,7 +60,7 @@ const PowerOnAuth: FC = ({ }) => { // 在指定的目录下安装快捷方式 const installSuccess = async () => { try { - const response = await fetch('http://localhost:3000/createShortcut', { + const response = await fetch('http://127.0.0.1:8080/createShortcut', { method: 'POST', headers: { 'Content-Type': 'application/json' }, mode: "cors", diff --git a/src/pages/InstallExe/exeDialog/CodeManage.tsx b/src/pages/InstallExe/exeDialog/CodeManage.tsx index 9160b36..5de13a1 100644 --- a/src/pages/InstallExe/exeDialog/CodeManage.tsx +++ b/src/pages/InstallExe/exeDialog/CodeManage.tsx @@ -59,7 +59,7 @@ const CodeManage: FC = ({ // 在指定的目录下安装快捷方式 const installSuccess = async () => { try { - const response = await fetch('http://localhost:3000/createShortcut', { + const response = await fetch('http://127.0.0.1:8080/createShortcut', { method: 'POST', headers: { 'Content-Type': 'application/json' }, mode: "cors", diff --git a/src/pages/InstallExe/exeDialog/CoreArea.tsx b/src/pages/InstallExe/exeDialog/CoreArea.tsx index e2cb199..269490b 100644 --- a/src/pages/InstallExe/exeDialog/CoreArea.tsx +++ b/src/pages/InstallExe/exeDialog/CoreArea.tsx @@ -69,7 +69,7 @@ const CoreArea: FC = ({ // 在指定的目录下安装快捷方式 const installSuccess = async () => { try { - const response = await fetch('http://localhost:3000/createShortcut', { + const response = await fetch('http://127.0.0.1:8080/createShortcut', { method: 'POST', headers: { 'Content-Type': 'application/json' }, mode: "cors", diff --git a/src/pages/InstallExe/exeDialog/DutyArea.tsx b/src/pages/InstallExe/exeDialog/DutyArea.tsx index 0ba8b5b..d0fa233 100644 --- a/src/pages/InstallExe/exeDialog/DutyArea.tsx +++ b/src/pages/InstallExe/exeDialog/DutyArea.tsx @@ -69,7 +69,7 @@ const DutyArea: FC = ({ // 在指定的目录下安装快捷方式 const installSuccess = async () => { try { - const response = await fetch('http://localhost:3000/createShortcut', { + const response = await fetch('http://127.0.0.1:8080/createShortcut', { method: 'POST', headers: { 'Content-Type': 'application/json' }, mode: "cors", diff --git a/src/pages/index.tsx b/src/pages/index.tsx index bdaef48..8a49879 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -18,7 +18,7 @@ export default function IndexPage() { const [tishiDialog, setTishiDialog] = useState(false); const list = [ - { name: '01MMD049安装.exe', img: '', url: '/installExe' }, + { name: '01MMD049安装.exe', img: '', url: '/installExe/offLine' }, { name: '初装系统', img: '', url: '/initialSystem' }, { name: '核心管理系统', img: '', url: '/coreSystemEntrance/hx1' }, { name: '需要导出的文件', img: '', url: null },