vue2server7 7.0.81 → 7.0.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2server7",
3
- "version": "7.0.81",
3
+ "version": "7.0.83",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src --ext ts --exec \"ts-node src/app.ts\"",
Binary file
Binary file
package/test/1 DELETED
@@ -1,39 +0,0 @@
1
- const express = require('express');
2
- const path = require('path');
3
- const fs = require('fs').promises;
4
- const app = express();
5
-
6
- // 静态资源目录(例如 'public')
7
- const staticDir = path.join(__dirname, 'public');
8
-
9
- // 1. 使用 express.static 提供静态文件下载能力
10
- app.use(express.static(staticDir));
11
-
12
- // 2. 自定义首页路由:列出目录中的文件
13
- app.get('/', async (req, res) => {
14
- try {
15
- const files = await fs.readdir(staticDir);
16
- const fileLinks = files
17
- .map(file => `<li><a href="/${encodeURIComponent(file)}" download>${file}</a></li>`)
18
- .join('');
19
-
20
- res.send(`
21
- <html>
22
- <head><title>文件列表</title></head>
23
- <body>
24
- <h2>静态资源目录中的文件:</h2>
25
- <ul>${fileLinks}</ul>
26
- </body>
27
- </html>
28
- `);
29
- } catch (err) {
30
- console.error(err);
31
- res.status(500).send('无法读取目录');
32
- }
33
- });
34
-
35
- // 启动服务器
36
- const PORT = process.env.PORT || 3000;
37
- app.listen(PORT, () => {
38
- console.log(`服务器运行在 http://localhost:${PORT}`);
39
- });