nonebot-plugin-shiro-web-console 0.1.8__py3-none-any.whl → 0.1.10__py3-none-any.whl

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.

Potentially problematic release.


This version of nonebot-plugin-shiro-web-console might be problematic. Click here for more details.

@@ -16,7 +16,7 @@ from collections import deque
16
16
  from fastapi import FastAPI, WebSocket, WebSocketDisconnect, Request, Response, Depends, HTTPException
17
17
  from fastapi.staticfiles import StaticFiles
18
18
  from fastapi.responses import HTMLResponse, JSONResponse, FileResponse
19
- from nonebot import get_app, get_bot, get_bots, get_driver, logger, on_message, on_command, require, on_bot_connect
19
+ from nonebot import get_app, get_bot, get_bots, get_driver, logger, on_message, on_command, require
20
20
  import nonebot_plugin_localstore
21
21
  from .config import Config, config
22
22
  from nonebot.permission import SUPERUSER
@@ -35,7 +35,7 @@ __plugin_meta__ = PluginMetadata(
35
35
  supported_adapters={"~onebot.v11"},
36
36
  extra={
37
37
  "author": "luojisama",
38
- "version": "0.1.8",
38
+ "version": "0.1.10",
39
39
  "pypi_test": "nonebot-plugin-shiro-web-console",
40
40
  },
41
41
  )
@@ -447,7 +447,7 @@ async def on_api_called(bot: Bot, exception: Optional[Exception], api: str, data
447
447
  except Exception as e:
448
448
  logger.error(f"处理 Bot 发送消息 Hook 失败: {e}")
449
449
 
450
- @on_bot_connect
450
+ @driver.on_bot_connect
451
451
  async def _(bot: Bot):
452
452
  if hasattr(bot, "on_called_api"):
453
453
  bot.on_called_api(on_api_called)
@@ -1307,6 +1307,8 @@
1307
1307
  }
1308
1308
  };
1309
1309
 
1310
+ let appInterval = null;
1311
+
1310
1312
  async function initApp() {
1311
1313
  initWS();
1312
1314
  await fetchChats();
@@ -1317,9 +1319,11 @@
1317
1319
 
1318
1320
  showPage('home');
1319
1321
  // 定时刷新状态
1320
- setInterval(() => {
1322
+ if (appInterval) clearInterval(appInterval);
1323
+ appInterval = setInterval(() => {
1321
1324
  if (document.getElementById('page-home').classList.contains('active')) fetchStatus();
1322
- if (document.getElementById('page-logs').classList.contains('active')) fetchLogs();
1325
+ // 日志已通过 WebSocket 推送,不再轮询,避免刷屏
1326
+ // if (document.getElementById('page-logs').classList.contains('active')) fetchLogs();
1323
1327
  }, 5000);
1324
1328
  }
1325
1329
 
@@ -1343,6 +1347,11 @@
1343
1347
 
1344
1348
  // 初始化 WebSocket
1345
1349
  function initWS() {
1350
+ if (ws) {
1351
+ ws.onclose = null; // 防止触发重连
1352
+ ws.close();
1353
+ }
1354
+
1346
1355
  const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
1347
1356
  // 添加 token 参数防止连接被服务端拒绝 (code 1008)
1348
1357
  const wsUrl = `${protocol}//${window.location.host}/web_console/ws?token=${authToken}`;
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-shiro-web-console
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: 一个用于 NoneBot2 的网页控制台插件,支持通过浏览器查看日志和发送消息
5
5
  Project-URL: Homepage, https://github.com/luojisama/nonebot-plugin-shiro-web-console
6
6
  Project-URL: Bug Tracker, https://github.com/luojisama/nonebot-plugin-shiro-web-console/issues
@@ -0,0 +1,7 @@
1
+ nonebot_plugin_shiro_web_console/__init__.py,sha256=Ea03KJC-C2VF1GibNg6JlNujtabq6-5iQ0etzldngEo,41226
2
+ nonebot_plugin_shiro_web_console/config.py,sha256=LqHht8N5CuSMyBbEjzyJgfZtg05cvBlpGn_2MgTjt-g,202
3
+ nonebot_plugin_shiro_web_console/static/index.html,sha256=X4ii96HJ5mefyUk3OnitcMYsgCdjlbpOvsp6Co7LpiA,80569
4
+ nonebot_plugin_shiro_web_console-0.1.10.dist-info/METADATA,sha256=TJ8kOAPygKe9idmz43LoFS5MpgHd4lV4JO305nqW2x4,1980
5
+ nonebot_plugin_shiro_web_console-0.1.10.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ nonebot_plugin_shiro_web_console-0.1.10.dist-info/licenses/LICENSE,sha256=WedEfsrQQfoZsmbJHIAPn4UY_IcpavYULMV5in_ZPbg,1066
7
+ nonebot_plugin_shiro_web_console-0.1.10.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- nonebot_plugin_shiro_web_console/__init__.py,sha256=m9Qx-OSgUvy21BgOfG5sTH-vaqjOPZI3nmo6gPsoXts,41234
2
- nonebot_plugin_shiro_web_console/config.py,sha256=LqHht8N5CuSMyBbEjzyJgfZtg05cvBlpGn_2MgTjt-g,202
3
- nonebot_plugin_shiro_web_console/static/index.html,sha256=47BThvsWr9LSgz61f6jSMD6tBj83nPQqltl2_6vahgM,80258
4
- nonebot_plugin_shiro_web_console-0.1.8.dist-info/METADATA,sha256=jbxZZave9tJAUdTqcwJ4d0CaW43PqsDpPRNWy_NC0C8,1979
5
- nonebot_plugin_shiro_web_console-0.1.8.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
- nonebot_plugin_shiro_web_console-0.1.8.dist-info/licenses/LICENSE,sha256=WedEfsrQQfoZsmbJHIAPn4UY_IcpavYULMV5in_ZPbg,1066
7
- nonebot_plugin_shiro_web_console-0.1.8.dist-info/RECORD,,