nonebot-plugin-shiro-web-console 0.1.11__tar.gz → 0.1.12__tar.gz

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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-shiro-web-console
3
- Version: 0.1.11
3
+ Version: 0.1.12
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
@@ -35,7 +35,7 @@ __plugin_meta__ = PluginMetadata(
35
35
  supported_adapters={"~onebot.v11"},
36
36
  extra={
37
37
  "author": "luojisama",
38
- "version": "0.1.11",
38
+ "version": "0.1.12",
39
39
  "pypi_test": "nonebot-plugin-shiro-web-console",
40
40
  },
41
41
  )
@@ -514,6 +514,7 @@
514
514
  <div class="sub-nav">
515
515
  <div class="sub-nav-item active" id="tab-local" onclick="switchPluginTab('local')">已安装</div>
516
516
  <div class="sub-nav-item" id="tab-store" onclick="switchPluginTab('store')">插件商店</div>
517
+ <div class="sub-nav-item" id="tab-updates" onclick="switchPluginTab('updates')">检查更新</div>
517
518
  </div>
518
519
  </div>
519
520
  <div class="page-content" id="plugin-content" style="padding: 20px; background: var(--bg-main);">
@@ -533,6 +534,15 @@
533
534
  <span id="action-status" style="font-weight: bold; color: var(--primary-color);"></span>
534
535
  </div>
535
536
  </div>
537
+ <!-- 更新视图 -->
538
+ <div id="updates-view" style="display: none;">
539
+ <div id="updates-list" style="display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 15px;">
540
+ <!-- 更新卡片 -->
541
+ </div>
542
+ <div id="updates-status-bar" style="margin-top: 20px; padding: 10px 0; font-size: 0.85em; color: var(--text-secondary); border-top: 1px solid var(--border-color);">
543
+ <span id="updates-count">正在检查更新...</span>
544
+ </div>
545
+ </div>
536
546
  </div>
537
547
  </div>
538
548
  </div>
@@ -1051,6 +1061,120 @@
1051
1061
  }
1052
1062
  }
1053
1063
 
1064
+ function switchPluginTab(tab) {
1065
+ // Update tabs
1066
+ document.querySelectorAll('.sub-nav-item').forEach(el => el.classList.remove('active'));
1067
+ document.getElementById(`tab-${tab}`).classList.add('active');
1068
+
1069
+ // Update views
1070
+ document.getElementById('local-plugins-view').style.display = 'none';
1071
+ document.getElementById('store-plugins-view').style.display = 'none';
1072
+ document.getElementById('updates-view').style.display = 'none';
1073
+
1074
+ // Show search bar only for local/store
1075
+ const searchContainer = document.getElementById('plugin-search-container');
1076
+ const localSearch = document.getElementById('local-plugin-search');
1077
+ const storeSearch = document.getElementById('store-search');
1078
+
1079
+ searchContainer.style.visibility = tab === 'updates' ? 'hidden' : 'visible';
1080
+ localSearch.style.display = tab === 'local' ? 'block' : 'none';
1081
+ storeSearch.style.display = tab === 'store' ? 'block' : 'none';
1082
+
1083
+ if (tab === 'local') {
1084
+ document.getElementById('local-plugins-view').style.display = 'block';
1085
+ fetchPlugins();
1086
+ } else if (tab === 'store') {
1087
+ document.getElementById('store-plugins-view').style.display = 'block';
1088
+ openStore();
1089
+ } else if (tab === 'updates') {
1090
+ document.getElementById('updates-view').style.display = 'block';
1091
+ openUpdates();
1092
+ }
1093
+ }
1094
+
1095
+ async function openUpdates() {
1096
+ const listEl = document.getElementById('updates-list');
1097
+ const countEl = document.getElementById('updates-count');
1098
+
1099
+ listEl.innerHTML = '<div style="grid-column: 1/-1; text-align: center; color: #999;">正在检查更新...</div>';
1100
+ countEl.textContent = '正在获取数据...';
1101
+
1102
+ try {
1103
+ // 并行获取已安装插件和商店数据
1104
+ const [pluginsRes, storeRes] = await Promise.all([
1105
+ authorizedFetch('/web_console/api/plugins'),
1106
+ authorizedFetch('/web_console/api/store')
1107
+ ]);
1108
+
1109
+ const installedPlugins = await pluginsRes.json();
1110
+ const storeData = await storeRes.json();
1111
+
1112
+ if (storeData.error) {
1113
+ listEl.innerHTML = `<div style="grid-column: 1/-1; text-align: center; color: #dc3545;">${storeData.error}</div>`;
1114
+ return;
1115
+ }
1116
+
1117
+ // 筛选有更新的插件
1118
+ const updates = [];
1119
+
1120
+ installedPlugins.forEach(local => {
1121
+ // 通过 module_name 匹配
1122
+ const storePlugin = storeData.find(s => s.module_name === local.module || s.project_link === local.id);
1123
+
1124
+ if (storePlugin) {
1125
+ // 简单版本比较: 如果字符串不相等,且 store 版本通常较新
1126
+ // 移除 'v' 前缀进行比较
1127
+ const v1 = (local.version || '0.0.0').replace(/^v/, '');
1128
+ const v2 = (storePlugin.version || '0.0.0').replace(/^v/, '');
1129
+
1130
+ if (v1 !== v2) {
1131
+ updates.push({
1132
+ local: local,
1133
+ store: storePlugin
1134
+ });
1135
+ }
1136
+ }
1137
+ });
1138
+
1139
+ if (updates.length === 0) {
1140
+ listEl.innerHTML = '<div style="grid-column: 1/-1; text-align: center; color: #999; padding: 40px;">所有插件已是最新版本 🎉</div>';
1141
+ countEl.textContent = '暂无更新';
1142
+ } else {
1143
+ renderUpdates(updates);
1144
+ countEl.textContent = `发现 ${updates.length} 个可更新插件`;
1145
+ }
1146
+
1147
+ } catch (e) {
1148
+ listEl.innerHTML = `<div style="grid-column: 1/-1; text-align: center; color: #dc3545;">检查更新失败: ${e.message}</div>`;
1149
+ }
1150
+ }
1151
+
1152
+ function renderUpdates(updates) {
1153
+ const listEl = document.getElementById('updates-list');
1154
+ listEl.innerHTML = updates.map(item => {
1155
+ const p = item.store;
1156
+ const local = item.local;
1157
+ return `
1158
+ <div class="store-card" style="border-left: 4px solid var(--primary-color);">
1159
+ <div style="display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0;">
1160
+ <a href="${p.homepage || '#'}" target="_blank" class="store-name" title="${p.name}">${p.name}</a>
1161
+ <span class="plugin-tag tag-store" style="font-size: 0.6em;">更新</span>
1162
+ </div>
1163
+ <div class="store-desc" title="${p.desc}">${p.desc}</div>
1164
+ <div class="store-meta" style="margin-top: 10px; display: grid; grid-template-columns: auto 1fr; gap: 5px 15px; font-size: 0.85em;">
1165
+ <span style="color: #999;">当前版本:</span>
1166
+ <span style="font-family: monospace;">${local.version}</span>
1167
+ <span style="color: var(--primary-color); font-weight: bold;">最新版本:</span>
1168
+ <span style="font-family: monospace; color: var(--primary-color); font-weight: bold;">${p.version}</span>
1169
+ </div>
1170
+ <div class="store-footer">
1171
+ <button onclick="handleStoreAction('update', '${p.project_link}')" class="store-btn store-btn-update" style="width: 100%;">立即更新</button>
1172
+ </div>
1173
+ </div>
1174
+ `;
1175
+ }).join('');
1176
+ }
1177
+
1054
1178
  function filterLocalPlugins() {
1055
1179
  const kw = document.getElementById('local-plugin-search').value.toLowerCase();
1056
1180
  const cards = document.querySelectorAll('#plugin-list .plugin-card');
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "nonebot-plugin-shiro-web-console"
3
- version = "0.1.11"
3
+ version = "0.1.12"
4
4
  description = "一个用于 NoneBot2 的网页控制台插件,支持通过浏览器查看日志和发送消息"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.9"