nonebot-plugin-shiro-web-console 0.1.6__py3-none-any.whl → 0.1.7__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.
- nonebot_plugin_shiro_web_console/__init__.py +582 -477
- nonebot_plugin_shiro_web_console/static/index.html +55 -17
- {nonebot_plugin_shiro_web_console-0.1.6.dist-info → nonebot_plugin_shiro_web_console-0.1.7.dist-info}/METADATA +1 -2
- nonebot_plugin_shiro_web_console-0.1.7.dist-info/RECORD +7 -0
- nonebot_plugin_shiro_web_console-0.1.6.dist-info/RECORD +0 -7
- {nonebot_plugin_shiro_web_console-0.1.6.dist-info → nonebot_plugin_shiro_web_console-0.1.7.dist-info}/WHEEL +0 -0
- {nonebot_plugin_shiro_web_console-0.1.6.dist-info → nonebot_plugin_shiro_web_console-0.1.7.dist-info}/licenses/LICENSE +0 -0
|
@@ -317,17 +317,18 @@
|
|
|
317
317
|
|
|
318
318
|
#nav-bar {
|
|
319
319
|
width: 100%;
|
|
320
|
-
height:
|
|
320
|
+
height: auto;
|
|
321
|
+
min-height: 60px;
|
|
321
322
|
flex-direction: row;
|
|
322
323
|
order: 2; /* 放到下面 */
|
|
323
324
|
padding: 0;
|
|
324
|
-
padding-bottom: env(safe-area-inset-bottom);
|
|
325
|
+
padding-bottom: max(10px, env(safe-area-inset-bottom));
|
|
325
326
|
justify-content: space-around;
|
|
326
327
|
border-top: 1px solid var(--border-color);
|
|
327
328
|
background: var(--bg-view);
|
|
328
329
|
}
|
|
329
330
|
|
|
330
|
-
.nav-item { flex: 1; height:
|
|
331
|
+
.nav-item { flex: 1; height: auto; padding: 10px 0; border-radius: 0; font-size: 28px; }
|
|
331
332
|
|
|
332
333
|
#content-wrapper { order: 1; height: calc(100vh - var(--nav-height)); }
|
|
333
334
|
|
|
@@ -744,26 +745,61 @@
|
|
|
744
745
|
try {
|
|
745
746
|
const res = await authorizedFetch('/web_console/api/logs');
|
|
746
747
|
const logs = await res.json();
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
<span style="color: ${color}; font-weight: bold; margin: 0 5px;">${log.level.padEnd(7)}</span>
|
|
757
|
-
<span style="color: #569cd6;">${log.module}</span>
|
|
758
|
-
<span style="color: #ce9178;"> - ${log.message}</span>
|
|
759
|
-
</div>`;
|
|
760
|
-
}).join('');
|
|
748
|
+
// 如果是手动刷新,或者初次加载,清空当前视图
|
|
749
|
+
if (!viewer.querySelector('.log-entry') || viewer.innerText.includes('正在加载') || viewer.innerText.includes('失败')) {
|
|
750
|
+
viewer.innerHTML = '';
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
// 这里简单处理:全量刷新时清空重绘,或者我们可以优化为合并。
|
|
754
|
+
// 为了简单起见,fetchLogs 我们还是全量替换吧,但是使用 appendLog 的逻辑来生成 HTML
|
|
755
|
+
viewer.innerHTML = '';
|
|
756
|
+
logs.forEach(log => appendLog(log, false)); // false 表示不自动滚动,最后统一滚动
|
|
761
757
|
viewer.scrollTop = viewer.scrollHeight;
|
|
762
758
|
} catch (e) {
|
|
763
759
|
viewer.innerHTML = '<div style="color: #f44747;">获取日志失败</div>';
|
|
764
760
|
}
|
|
765
761
|
}
|
|
766
762
|
|
|
763
|
+
function appendLog(log, autoScroll = true) {
|
|
764
|
+
const viewer = document.getElementById('log-viewer');
|
|
765
|
+
|
|
766
|
+
// 清理非日志内容的提示信息
|
|
767
|
+
if (viewer.firstElementChild && !viewer.firstElementChild.classList.contains('log-entry')) {
|
|
768
|
+
viewer.innerHTML = '';
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
let color = '#d4d4d4';
|
|
772
|
+
if (log.level === 'ERROR') color = '#f44747';
|
|
773
|
+
else if (log.level === 'WARNING') color = '#cca700';
|
|
774
|
+
else if (log.level === 'SUCCESS') color = '#6a9955';
|
|
775
|
+
else if (log.level === 'DEBUG') color = '#b5cea8';
|
|
776
|
+
else if (log.level === 'INFO') color = '#d4d4d4';
|
|
777
|
+
|
|
778
|
+
const div = document.createElement('div');
|
|
779
|
+
div.className = 'log-entry';
|
|
780
|
+
div.style.marginBottom = '4px';
|
|
781
|
+
div.innerHTML = `
|
|
782
|
+
<span style="color: #888;">[${log.time}]</span>
|
|
783
|
+
<span style="color: ${color}; font-weight: bold; margin: 0 5px;">${log.level.padEnd(7)}</span>
|
|
784
|
+
<span style="color: #569cd6;">${log.module}</span>
|
|
785
|
+
<span style="color: #ce9178;"> - ${log.message}</span>
|
|
786
|
+
`;
|
|
787
|
+
|
|
788
|
+
// 检查是否滚动到底部
|
|
789
|
+
const isScrolledToBottom = viewer.scrollHeight - viewer.clientHeight <= viewer.scrollTop + 50;
|
|
790
|
+
|
|
791
|
+
viewer.appendChild(div);
|
|
792
|
+
|
|
793
|
+
// 限制日志条数,防止页面卡顿
|
|
794
|
+
if (viewer.children.length > 1000) {
|
|
795
|
+
viewer.removeChild(viewer.firstElementChild);
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
if (autoScroll && isScrolledToBottom) {
|
|
799
|
+
viewer.scrollTop = viewer.scrollHeight;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
767
803
|
// 主题切换
|
|
768
804
|
function toggleTheme(isDark) {
|
|
769
805
|
const icon = document.getElementById('theme-icon');
|
|
@@ -1337,6 +1373,8 @@
|
|
|
1337
1373
|
// 发现新会话,刷新列表
|
|
1338
1374
|
fetchChats();
|
|
1339
1375
|
}
|
|
1376
|
+
} else if (data.type === 'new_log') {
|
|
1377
|
+
appendLog(data.data);
|
|
1340
1378
|
}
|
|
1341
1379
|
};
|
|
1342
1380
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nonebot-plugin-shiro-web-console
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
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
|
|
@@ -27,7 +27,6 @@ Requires-Dist: nonebot-adapter-onebot>=2.4.0
|
|
|
27
27
|
Requires-Dist: nonebot-plugin-localstore>=0.6.0
|
|
28
28
|
Requires-Dist: nonebot2>=2.2.0
|
|
29
29
|
Requires-Dist: pydantic
|
|
30
|
-
Requires-Dist: uvicorn>=0.20.0
|
|
31
30
|
Description-Content-Type: text/markdown
|
|
32
31
|
|
|
33
32
|
# nonebot-plugin-shiro-web-console
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
nonebot_plugin_shiro_web_console/__init__.py,sha256=cl3lnf0tqc5DqJxFOH6kBelGZNP9vMq72Cn9TdQ8YIU,36860
|
|
2
|
+
nonebot_plugin_shiro_web_console/config.py,sha256=LqHht8N5CuSMyBbEjzyJgfZtg05cvBlpGn_2MgTjt-g,202
|
|
3
|
+
nonebot_plugin_shiro_web_console/static/index.html,sha256=z_WZGULFlmNpDVzmax9ux1qIBaUNfCScaeXw2QOsI8w,80129
|
|
4
|
+
nonebot_plugin_shiro_web_console-0.1.7.dist-info/METADATA,sha256=wZ8AiV1SRm2mjQbTuvdznPzRQS9lZzfextSaQ7NwiYE,1979
|
|
5
|
+
nonebot_plugin_shiro_web_console-0.1.7.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
+
nonebot_plugin_shiro_web_console-0.1.7.dist-info/licenses/LICENSE,sha256=WedEfsrQQfoZsmbJHIAPn4UY_IcpavYULMV5in_ZPbg,1066
|
|
7
|
+
nonebot_plugin_shiro_web_console-0.1.7.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
nonebot_plugin_shiro_web_console/__init__.py,sha256=YPO-XtylSdnOF3vqEmflOhEbsnZr1xg7Ul46PziSd7o,31567
|
|
2
|
-
nonebot_plugin_shiro_web_console/config.py,sha256=LqHht8N5CuSMyBbEjzyJgfZtg05cvBlpGn_2MgTjt-g,202
|
|
3
|
-
nonebot_plugin_shiro_web_console/static/index.html,sha256=YFQ4e0WsfWYHQ01pD0Xify-CFCcnKE9mXDG6vQimU4s,78428
|
|
4
|
-
nonebot_plugin_shiro_web_console-0.1.6.dist-info/METADATA,sha256=W8H1BPkptruRzqt7FyPZJZlrAjC129F0xh7AiGM7vJE,2010
|
|
5
|
-
nonebot_plugin_shiro_web_console-0.1.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
-
nonebot_plugin_shiro_web_console-0.1.6.dist-info/licenses/LICENSE,sha256=WedEfsrQQfoZsmbJHIAPn4UY_IcpavYULMV5in_ZPbg,1066
|
|
7
|
-
nonebot_plugin_shiro_web_console-0.1.6.dist-info/RECORD,,
|
|
File without changes
|