|
3 | 3 | const langs = { |
4 | 4 | "zh_cn": { |
5 | 5 | "dashboard": "数据统计", |
| 6 | + "version": "版本信息", |
6 | 7 | "measure": "宽带测试", |
7 | 8 | "authentication.fetching": "获取账户信息中", |
8 | 9 | "authentication.login": "登陆", |
|
238 | 239 | ".root .left .copyright": [ |
239 | 240 | "position: fixed;", |
240 | 241 | "bottom: 2px", |
| 242 | + "width: 184px", |
| 243 | + "box-sizing: border-sizing", |
| 244 | + "display: flex", |
| 245 | + "justify-content: center", |
| 246 | + "flex-direction: column", |
| 247 | + "align-items: center" |
| 248 | + ], |
| 249 | + ".root .left .box": [ |
| 250 | + "box-sizing: border-sizing", |
| 251 | + "border-radius: 8px", |
| 252 | + "padding-left: 8px", |
| 253 | + "padding-right: 8px", |
| 254 | + "background: white", |
| 255 | + "margin-bottom: 4px", |
| 256 | + "margin-top: 4px" |
241 | 257 | ], |
242 | 258 | ".qps .icon": [ |
243 | 259 | "width: 14px", |
|
471 | 487 | display_left() |
472 | 488 | update_left() |
473 | 489 | } |
474 | | - header.append(ttb.createElement("h3").append(ttb.createElement("a").setText(document.title).setAttribute("href", (() => { |
| 490 | + const github = (() => { |
475 | 491 | for (child of document.head.children) { |
476 | 492 | if (child.getAttribute("github")) return "//github.com/" + child.getAttribute("github") |
477 | 493 | } |
478 | 494 | return "" |
479 | | - })()))) |
| 495 | + })(); |
| 496 | + header.append(ttb.createElement("h3").append(ttb.createElement("a").setText(document.title).setAttribute("href", github))) |
480 | 497 | left_copyright.append( |
481 | | - ttb.createElement("p").append(ttb.createElement("a").setAttribute("href", "//github.com/TTB-Network").setText("TTB Network"), " - ", ttb.VERSION) |
| 498 | + ttb.createElement("a").class("box").setAttribute("href", "//github.com/TTB-Network").setText("TTB Network") |
482 | 499 | ) |
483 | 500 | left_arrow.event("click", () => { |
484 | 501 | left.toggle("hide") |
|
841 | 858 | onopen() { |
842 | 859 | if (this._isws) ttb.createNotication("info", "", ttb.createElement("h4").setText("实时隧道已开启")) |
843 | 860 | this.send("uptime") |
844 | | - this.send("storage") |
| 861 | + this.send("version") |
845 | 862 | this.send("status") |
846 | 863 | this._timer_qps?.block(); |
847 | 864 | this._timer?.block() |
|
1099 | 1116 | }) |
1100 | 1117 |
|
1101 | 1118 | } |
| 1119 | + if (type == "version") { |
| 1120 | + if (data.cur != data.latest) { |
| 1121 | + ttb.createNotication("info", "", ttb.createElement("h4").setText("有新的版本更新"), ttb.createElement("p").setText(data.latest)) |
| 1122 | + } |
| 1123 | + version.version = data |
| 1124 | + version._update() |
| 1125 | + } |
1102 | 1126 | root_handler("_ws_message", type, data) |
1103 | 1127 | } |
1104 | 1128 | _deserializeData(input) { |
|
1362 | 1386 | page.push(...this._page) |
1363 | 1387 | } |
1364 | 1388 | } |
| 1389 | + class Version { |
| 1390 | + constructor() { |
| 1391 | + this.version = { |
| 1392 | + "cur": "Unknown", |
| 1393 | + "latest": "Unknown" |
| 1394 | + } |
| 1395 | + this._page = [ |
| 1396 | + ttb.createElement("div").class("panel").append( |
| 1397 | + ttb.createElement("p").class("title").setText("当前节点版本"), |
| 1398 | + ttb.createElement("p").class("value").setText("-"), |
| 1399 | + ttb.createElement("p").class("title").setText("最新版本"), |
| 1400 | + ttb.createElement("p").class("value").setText("-"), |
| 1401 | + ttb.createElement("button").class("button").setText("查看详情").setAttribute("href").event('click', () => { |
| 1402 | + if (this.version.cur == this.version.latest) return |
| 1403 | + window.location.href = github + "/releases/" + this.version.latest |
| 1404 | + }) |
| 1405 | + ) |
| 1406 | + ] |
| 1407 | + this._update() |
| 1408 | + } |
| 1409 | + _update() { |
| 1410 | + this._page[0].getChildrens()[1].setText(this.version.cur) |
| 1411 | + this._page[0].getChildrens()[3].setText(this.version.latest) |
| 1412 | + this._page[0].getChildrens()[4].valueOf().style.display = (this.version.cur != this.version.latest ? "" : "none") |
| 1413 | + } |
| 1414 | + connect(page) { |
| 1415 | + page.push(...this._page) |
| 1416 | + } |
| 1417 | + } |
1365 | 1418 | class Storage { |
1366 | 1419 | constructor() { |
1367 | 1420 | this._storages = [] |
1368 | 1421 | } |
1369 | | - connect() { |
| 1422 | + connect(page) { |
1370 | 1423 | //ws.send("storage") |
1371 | 1424 | } |
1372 | 1425 | } |
1373 | 1426 | const ws = new MainWebSocket() |
1374 | 1427 | const dashboard = new Dashboard() |
1375 | 1428 | const measure = new Measure() |
1376 | 1429 | const storage = new Storage() |
| 1430 | + const version = new Version() |
1377 | 1431 | menu("dashboard", "", dashboard) |
| 1432 | + menu("version", "", version) |
1378 | 1433 | ws.menu("measure", "", measure) |
1379 | 1434 | ws.setAuthInfo() |
1380 | 1435 | })(); |
|
0 commit comments