nonebot-plugin-shiro-web-console 0.1.12__py3-none-any.whl → 0.1.13__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.

@@ -35,7 +35,7 @@ __plugin_meta__ = PluginMetadata(
35
35
  supported_adapters={"~onebot.v11"},
36
36
  extra={
37
37
  "author": "luojisama",
38
- "version": "0.1.12",
38
+ "version": "0.1.13",
39
39
  "pypi_test": "nonebot-plugin-shiro-web-console",
40
40
  },
41
41
  )
@@ -611,6 +611,7 @@ if app:
611
611
  @app.get("/web_console/api/plugins", dependencies=[Depends(check_auth)])
612
612
  async def get_plugins():
613
613
  from nonebot import get_loaded_plugins
614
+ from importlib.metadata import version, PackageNotFoundError
614
615
  import os
615
616
  plugins = []
616
617
  for p in get_loaded_plugins():
@@ -627,11 +628,26 @@ if app:
627
628
  elif module_name.startswith("nonebot_plugin_"):
628
629
  plugin_type = "store"
629
630
 
631
+ # 获取版本号
632
+ ver = "0.0.0"
633
+ # 优先尝试从 importlib 获取真实安装版本
634
+ try:
635
+ # 尝试将包名中的下划线替换为连字符(常见 PyPI 命名规范)
636
+ pkg_name = module_name.replace("_", "-")
637
+ ver = version(pkg_name)
638
+ except PackageNotFoundError:
639
+ try:
640
+ ver = version(module_name)
641
+ except PackageNotFoundError:
642
+ # 如果获取失败,回退到元数据中的版本
643
+ if metadata and metadata.extra and "version" in metadata.extra:
644
+ ver = metadata.extra.get("version", "0.0.0")
645
+
630
646
  plugins.append({
631
647
  "id": p.name,
632
648
  "name": metadata.name if metadata else p.name,
633
649
  "description": metadata.description if metadata else "暂无描述",
634
- "version": metadata.extra.get("version", "1.0.0") if metadata and metadata.extra else "1.0.0",
650
+ "version": ver,
635
651
  "type": plugin_type,
636
652
  "module": module_name,
637
653
  "homepage": metadata.homepage if metadata else None
@@ -1092,6 +1092,19 @@
1092
1092
  }
1093
1093
  }
1094
1094
 
1095
+ function compareVersions(v1, v2) {
1096
+ const parts1 = v1.split('.').map(p => parseInt(p, 10) || 0);
1097
+ const parts2 = v2.split('.').map(p => parseInt(p, 10) || 0);
1098
+
1099
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
1100
+ const n1 = parts1[i] || 0;
1101
+ const n2 = parts2[i] || 0;
1102
+ if (n1 > n2) return 1;
1103
+ if (n1 < n2) return -1;
1104
+ }
1105
+ return 0;
1106
+ }
1107
+
1095
1108
  async function openUpdates() {
1096
1109
  const listEl = document.getElementById('updates-list');
1097
1110
  const countEl = document.getElementById('updates-count');
@@ -1122,12 +1135,12 @@
1122
1135
  const storePlugin = storeData.find(s => s.module_name === local.module || s.project_link === local.id);
1123
1136
 
1124
1137
  if (storePlugin) {
1125
- // 简单版本比较: 如果字符串不相等,且 store 版本通常较新
1126
1138
  // 移除 'v' 前缀进行比较
1127
1139
  const v1 = (local.version || '0.0.0').replace(/^v/, '');
1128
1140
  const v2 = (storePlugin.version || '0.0.0').replace(/^v/, '');
1129
1141
 
1130
- if (v1 !== v2) {
1142
+ // 只显示商店版本大于本地版本的情况
1143
+ if (compareVersions(v2, v1) > 0) {
1131
1144
  updates.push({
1132
1145
  local: local,
1133
1146
  store: storePlugin
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-shiro-web-console
3
- Version: 0.1.12
3
+ Version: 0.1.13
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=xuNGFmfhF3VD7424se72ZJCwEb7tJSJkCZ3gsQy4y5Q,41931
2
+ nonebot_plugin_shiro_web_console/config.py,sha256=LqHht8N5CuSMyBbEjzyJgfZtg05cvBlpGn_2MgTjt-g,202
3
+ nonebot_plugin_shiro_web_console/static/index.html,sha256=a_gFy8nFLZ2mS41Ny-n7_2KQ-row_iflYa8Nq4u9j2w,88596
4
+ nonebot_plugin_shiro_web_console-0.1.13.dist-info/METADATA,sha256=Q-xgGCqWPYCc_BK-3q-RdP-k5zpLcvxBeqg5-ps0H3E,1980
5
+ nonebot_plugin_shiro_web_console-0.1.13.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
+ nonebot_plugin_shiro_web_console-0.1.13.dist-info/licenses/LICENSE,sha256=WedEfsrQQfoZsmbJHIAPn4UY_IcpavYULMV5in_ZPbg,1066
7
+ nonebot_plugin_shiro_web_console-0.1.13.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- nonebot_plugin_shiro_web_console/__init__.py,sha256=hAkxmqi7wSe8xDOlmWKgHNBmbjwfCu5iTNVl52x3hMQ,41226
2
- nonebot_plugin_shiro_web_console/config.py,sha256=LqHht8N5CuSMyBbEjzyJgfZtg05cvBlpGn_2MgTjt-g,202
3
- nonebot_plugin_shiro_web_console/static/index.html,sha256=rpCJlGm4f0PWvBB4uVn-t_g2r8DWiywd02fG6qNvXl0,88112
4
- nonebot_plugin_shiro_web_console-0.1.12.dist-info/METADATA,sha256=6t1xGleTrByc2AIFV6JbR3L8g_QeHSMWXWzMAjmTMis,1980
5
- nonebot_plugin_shiro_web_console-0.1.12.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
6
- nonebot_plugin_shiro_web_console-0.1.12.dist-info/licenses/LICENSE,sha256=WedEfsrQQfoZsmbJHIAPn4UY_IcpavYULMV5in_ZPbg,1066
7
- nonebot_plugin_shiro_web_console-0.1.12.dist-info/RECORD,,