@liguoshuai/pi-web-chat 1.7.1 → 1.7.2
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/public/app.js +5 -0
- package/public/index.html +4 -1
- package/public/style.css +11 -0
- package/server.js +8 -1
package/package.json
CHANGED
package/public/app.js
CHANGED
|
@@ -87,6 +87,11 @@ async function loadServerConfig() {
|
|
|
87
87
|
const data = await res.json();
|
|
88
88
|
if (data.home) state.homeDir = data.home;
|
|
89
89
|
if (data.serverCwd) state.serverCwd = data.serverCwd;
|
|
90
|
+
if (data.version) {
|
|
91
|
+
state.version = data.version;
|
|
92
|
+
const verEl = $("#appVersion");
|
|
93
|
+
if (verEl) verEl.textContent = `v${data.version}`;
|
|
94
|
+
}
|
|
90
95
|
} catch {}
|
|
91
96
|
if (!state.cwd) {
|
|
92
97
|
state.cwd = localStorage.getItem("pi_cwd") || state.serverCwd || state.homeDir || "";
|
package/public/index.html
CHANGED
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
<div class="session-list" id="sessionList"></div>
|
|
24
24
|
<div class="sidebar-bottom">
|
|
25
25
|
<div id="connStatus" class="conn-status" title="点击可重新连接"><span id="connDot" style="color: var(--danger);">●</span> <span id="connLabel">连接中…</span></div>
|
|
26
|
-
<div
|
|
26
|
+
<div class="sidebar-bottom-meta">
|
|
27
|
+
<a href="https://pi.dev" target="_blank" rel="noopener">pi.dev</a>
|
|
28
|
+
<span id="appVersion" class="app-version" title="pi-web-chat 版本"></span>
|
|
29
|
+
</div>
|
|
27
30
|
</div>
|
|
28
31
|
</aside>
|
|
29
32
|
|
package/public/style.css
CHANGED
|
@@ -141,6 +141,17 @@ body {
|
|
|
141
141
|
}
|
|
142
142
|
.sidebar-bottom a { color: var(--text-muted); text-decoration: none; }
|
|
143
143
|
.sidebar-bottom a:hover { color: var(--text); }
|
|
144
|
+
.sidebar-bottom-meta {
|
|
145
|
+
margin-top: 6px;
|
|
146
|
+
display: flex;
|
|
147
|
+
align-items: center;
|
|
148
|
+
justify-content: space-between;
|
|
149
|
+
}
|
|
150
|
+
.app-version {
|
|
151
|
+
font-size: 11px;
|
|
152
|
+
color: var(--text-dim);
|
|
153
|
+
user-select: none;
|
|
154
|
+
}
|
|
144
155
|
.conn-status {
|
|
145
156
|
display: inline-flex;
|
|
146
157
|
align-items: center;
|
package/server.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { spawn } from "child_process";
|
|
5
5
|
import { randomUUID } from "crypto";
|
|
6
6
|
import { readFile, readdir, stat } from "fs/promises";
|
|
7
|
-
import { existsSync } from "fs";
|
|
7
|
+
import { readFileSync, existsSync } from "fs";
|
|
8
8
|
import { StringDecoder } from "string_decoder";
|
|
9
9
|
import express from "express";
|
|
10
10
|
import { WebSocketServer } from "ws";
|
|
@@ -15,6 +15,12 @@ import { dirname } from "path";
|
|
|
15
15
|
|
|
16
16
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
17
17
|
|
|
18
|
+
let PKG_VERSION = "1.0.0";
|
|
19
|
+
try {
|
|
20
|
+
const pkg = JSON.parse(readFileSync(path.join(__dirname, "package.json"), "utf8"));
|
|
21
|
+
if (pkg.version) PKG_VERSION = pkg.version;
|
|
22
|
+
} catch {}
|
|
23
|
+
|
|
18
24
|
// Resolve pi binary: prefer PI_BIN env, else search PATH, else fall back to ~/.npm-global/bin/pi
|
|
19
25
|
function resolvePiBin() {
|
|
20
26
|
if (process.env.PI_BIN && existsSync(process.env.PI_BIN)) return process.env.PI_BIN;
|
|
@@ -456,6 +462,7 @@ app.get("/api/config", (req, res) => {
|
|
|
456
462
|
res.json({
|
|
457
463
|
home: home(),
|
|
458
464
|
serverCwd: process.cwd(),
|
|
465
|
+
version: PKG_VERSION,
|
|
459
466
|
});
|
|
460
467
|
});
|
|
461
468
|
|