Skip to content

Commit 8148c2c

Browse files
committed
feat: 增强插件页面功能,添加返回按钮逻辑并更新测试用例
1 parent d33df15 commit 8148c2c

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

astrbot/core/star/context.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
if TYPE_CHECKING:
5050
from astrbot.core.cron.manager import CronJobManager
5151

52+
WebApiHandler = Callable[..., Awaitable[Any]]
53+
RegisteredWebApi = tuple[str, WebApiHandler, list[str], str]
54+
5255

5356
class PlatformManagerProtocol(Protocol):
5457
platform_insts: list[Platform]
@@ -57,7 +60,7 @@ class PlatformManagerProtocol(Protocol):
5760
class Context:
5861
"""暴露给插件的接口上下文。"""
5962

60-
registered_web_apis: list = []
63+
registered_web_apis: list[RegisteredWebApi] = []
6164

6265
# 向后兼容的变量
6366
_register_tasks: list[Awaitable] = []
@@ -512,8 +515,8 @@ def add_llm_tools(self, *tools: FunctionTool) -> None:
512515
def register_web_api(
513516
self,
514517
route: str,
515-
view_handler: Awaitable,
516-
methods: list,
518+
view_handler: WebApiHandler,
519+
methods: list[str],
517520
desc: str,
518521
) -> None:
519522
"""注册 Web API。

dashboard/src/views/PluginPagePage.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ const pluginName = computed(() => String(route.params.pluginName || ""));
2424
const pageName = computed(() => String(route.params.pageName || ""));
2525
const getIframeWindow = () => iframeRef.value?.contentWindow || null;
2626
27+
const goBack = () => {
28+
if (window.history.length > 1) {
29+
router.back();
30+
return;
31+
}
32+
router.push("/extension#installed");
33+
};
34+
2735
const cleanupSSEConnections = () => {
2836
for (const eventSource of sseConnections.values()) {
2937
eventSource.close();
@@ -401,7 +409,7 @@ watch([pluginName, pageName], loadPluginPage, { immediate: true });
401409
variant="tonal"
402410
color="primary"
403411
prepend-icon="mdi-arrow-left"
404-
@click="router.push('/extension#installed')"
412+
@click="goBack"
405413
>
406414
{{ tm("buttons.back") }}
407415
</v-btn>
@@ -410,9 +418,6 @@ watch([pluginName, pageName], loadPluginPage, { immediate: true });
410418
<div class="text-h2 mb-1">
411419
{{ page?.title || pageName || tm("buttons.openPages") }}
412420
</div>
413-
<div class="text-body-2 text-medium-emphasis">
414-
{{ plugin?.display_name || plugin?.name || pluginName }}
415-
</div>
416421
</div>
417422
</div>
418423

tests/test_dashboard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def append(message, *args):
600600
"cert_file or key_file is missing" in message
601601
for message in warning_messages
602602
)
603-
assert any("Starting Page at http://" in message for message in info_messages)
603+
assert any("Starting WebUI at http://" in message for message in info_messages)
604604
finally:
605605
core_lifecycle_td.astrbot_config["dashboard"] = original_dashboard_config
606606

0 commit comments

Comments
 (0)