iflow-run 1.0.2 → 1.0.4
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 +1 -1
- package/server.js +5 -1
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":
|
|
1
|
+
{"name":"iflow-run","version":"1.0.4","description":"查看 iflow-cli 会话轨迹和历史会话的 Web 应用","type":"commonjs","main":"server.js","bin":{"iflow-run":"./bin/iflow-run.js"},"scripts":{"start":"node server.js","dev":"node server.js"},"keywords":["iflow","session","history","cli","viewer","dashboard"],"author":"dukewen <dukewen666@gmail.com>","license":"MIT","files":["bin/","public/","server.js","package.json","README.md"],"dependencies":{"express":"^4.18.2","cors":"^2.8.5"},"engines":{"node":">=14.0.0"}}
|
package/server.js
CHANGED
|
@@ -7,6 +7,10 @@ const os = require('os');
|
|
|
7
7
|
|
|
8
8
|
const app = express();
|
|
9
9
|
|
|
10
|
+
// 获取当前文件所在目录(用于 npm 全局安装后正确找到静态文件)
|
|
11
|
+
// 在 CommonJS 中 __dirname 是内置变量,但为了兼容 npm 全局安装,我们使用计算后的路径
|
|
12
|
+
const currentDir = path.dirname(require.main.filename || process.mainModule.filename);
|
|
13
|
+
|
|
10
14
|
// 支持通过环境变量或命令行参数配置
|
|
11
15
|
const args = process.argv.slice(2);
|
|
12
16
|
const PORT = process.env.PORT || process.env.IFLOW_RUN_PORT || args.find(arg => arg.startsWith('--port='))?.split('=')[1] || 3000;
|
|
@@ -26,7 +30,7 @@ let projectsCacheTime = 0;
|
|
|
26
30
|
|
|
27
31
|
app.use(cors());
|
|
28
32
|
app.use(express.json());
|
|
29
|
-
app.use(express.static('public'));
|
|
33
|
+
app.use(express.static(path.join(currentDir, 'public')));
|
|
30
34
|
|
|
31
35
|
// 读取所有项目
|
|
32
36
|
app.get('/api/projects', async (req, res) => {
|