mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🐛 优化菜单API及模型结构,修复WebUi插件列表Api
This commit is contained in:
parent
12916e79bb
commit
fa31efaf2d
@ -44,7 +44,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.main {
|
.main {
|
||||||
height: 448px;
|
height: 444px;
|
||||||
width: 335px;
|
width: 335px;
|
||||||
padding: 0 30px;
|
padding: 0 30px;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|||||||
@ -6,7 +6,7 @@ from zhenxun.services.log import logger
|
|||||||
from ...base_model import Result
|
from ...base_model import Result
|
||||||
from ...utils import authentication
|
from ...utils import authentication
|
||||||
from .data_source import menu_manage
|
from .data_source import menu_manage
|
||||||
from .model import MenuItem
|
from .model import MenuData
|
||||||
|
|
||||||
router = APIRouter(prefix="/menu")
|
router = APIRouter(prefix="/menu")
|
||||||
|
|
||||||
@ -14,11 +14,11 @@ router = APIRouter(prefix="/menu")
|
|||||||
@router.get(
|
@router.get(
|
||||||
"/get_menus",
|
"/get_menus",
|
||||||
dependencies=[authentication()],
|
dependencies=[authentication()],
|
||||||
response_model=Result[list[MenuItem]],
|
response_model=Result[list[MenuData]],
|
||||||
response_class=JSONResponse,
|
response_class=JSONResponse,
|
||||||
deprecated="获取菜单列表", # type: ignore
|
deprecated="获取菜单列表", # type: ignore
|
||||||
)
|
)
|
||||||
async def _() -> Result[list[MenuItem]]:
|
async def _() -> Result[list[MenuData]]:
|
||||||
try:
|
try:
|
||||||
return Result.ok(menu_manage.get_menus(), "拿到菜单了哦!")
|
return Result.ok(menu_manage.get_menus(), "拿到菜单了哦!")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import ujson as json
|
|||||||
from zhenxun.configs.path_config import DATA_PATH
|
from zhenxun.configs.path_config import DATA_PATH
|
||||||
from zhenxun.services.log import logger
|
from zhenxun.services.log import logger
|
||||||
|
|
||||||
from .model import MenuItem
|
from .model import MenuData, MenuItem
|
||||||
|
|
||||||
|
|
||||||
class MenuManage:
|
class MenuManage:
|
||||||
@ -52,7 +52,7 @@ class MenuManage:
|
|||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
def get_menus(self):
|
def get_menus(self):
|
||||||
return self.menu
|
return MenuData(menus=self.menu)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
self.file.parent.mkdir(parents=True, exist_ok=True)
|
self.file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|||||||
@ -12,3 +12,10 @@ class MenuItem(BaseModel):
|
|||||||
"""图标"""
|
"""图标"""
|
||||||
default: bool = False
|
default: bool = False
|
||||||
"""默认选中"""
|
"""默认选中"""
|
||||||
|
|
||||||
|
|
||||||
|
class MenuData(BaseModel):
|
||||||
|
bot_type: str = "zhenxun"
|
||||||
|
"""bot类型"""
|
||||||
|
menus: list[MenuItem]
|
||||||
|
"""菜单列表"""
|
||||||
|
|||||||
@ -5,11 +5,10 @@ from fastapi import Query
|
|||||||
|
|
||||||
from zhenxun.configs.config import Config
|
from zhenxun.configs.config import Config
|
||||||
from zhenxun.configs.utils import ConfigGroup
|
from zhenxun.configs.utils import ConfigGroup
|
||||||
from zhenxun.models.plugin_info import PluginInfo
|
|
||||||
from zhenxun.models.plugin_info import PluginInfo as DbPluginInfo
|
from zhenxun.models.plugin_info import PluginInfo as DbPluginInfo
|
||||||
from zhenxun.utils.enum import BlockType, PluginType
|
from zhenxun.utils.enum import BlockType, PluginType
|
||||||
|
|
||||||
from .model import PluginConfig, PluginDetail, UpdatePlugin
|
from .model import PluginConfig, PluginDetail, PluginInfo, UpdatePlugin
|
||||||
|
|
||||||
|
|
||||||
class ApiDataSource:
|
class ApiDataSource:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user