-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ♻️ 使用Uninfo重构PlatformUtils基础方法 * 🩹 优化插件加载与模块格式转换逻辑 * 🚑 修复商店道具无法使用 * 🚑 修复道具无法正常使用 * 🔧 增加Bot状态管理及模块禁用功能 * 🎨 优化Web UI代码结构,修改target方法 * 🚨 auto fix by pre-commit hooks * 🎨 添加菜单API及优化异常处理 * 🐛 优化菜单API及模型结构,修复WebUi插件列表Api * 📝 更新仓库readme * 🚨 add mdlint file * 📝 Add help chapter. * 🐛 修复优化AuthChecker逻辑 * 🐛 优化数据库API,移除冗余导入及修正SQL_DICT引用 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: BalconyJH <balconyjh@gmail.com>
- Loading branch information
1 parent
ebf05fd
commit 35014e4
Showing
32 changed files
with
1,950 additions
and
1,765 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
MD013: false | ||
MD024: # 重复标题 | ||
siblings_only: true | ||
MD033: false # 允许 html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ body { | |
} | ||
|
||
.main { | ||
height: 448px; | ||
height: 444px; | ||
width: 335px; | ||
padding: 0 30px; | ||
position: relative; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .tabs import * # noqa: F403 | ||
from .menu import * # noqa: F403f | ||
from .tabs import * # noqa: F403f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from fastapi import APIRouter | ||
from fastapi.responses import JSONResponse | ||
|
||
from zhenxun.services.log import logger | ||
|
||
from ...base_model import Result | ||
from ...utils import authentication | ||
from .data_source import menu_manage | ||
from .model import MenuData | ||
|
||
router = APIRouter(prefix="/menu") | ||
|
||
|
||
@router.get( | ||
"/get_menus", | ||
dependencies=[authentication()], | ||
response_model=Result[list[MenuData]], | ||
response_class=JSONResponse, | ||
deprecated="获取菜单列表", # type: ignore | ||
) | ||
async def _() -> Result[list[MenuData]]: | ||
try: | ||
return Result.ok(menu_manage.get_menus(), "拿到菜单了哦!") | ||
except Exception as e: | ||
logger.error(f"{router.prefix}/get_menus 调用错误", "WebUi", e=e) | ||
return Result.fail(f"发生了一点错误捏 {type(e)}: {e}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import ujson as json | ||
|
||
from zhenxun.configs.path_config import DATA_PATH | ||
from zhenxun.services.log import logger | ||
|
||
from .model import MenuData, MenuItem | ||
|
||
|
||
class MenuManage: | ||
def __init__(self) -> None: | ||
self.file = DATA_PATH / "web_ui" / "menu.json" | ||
self.menu = [] | ||
if self.file.exists(): | ||
try: | ||
self.menu = json.load(self.file.open(encoding="utf8")) | ||
except Exception as e: | ||
logger.warning("菜单文件损坏,已重新生成...", "WebUi", e=e) | ||
if not self.menu: | ||
self.menu = [ | ||
MenuItem( | ||
name="仪表盘", | ||
module="dashboard", | ||
router="/dashboard", | ||
icon="dashboard", | ||
default=True, | ||
), | ||
MenuItem( | ||
name="真寻控制台", | ||
module="command", | ||
router="/command", | ||
icon="command", | ||
), | ||
MenuItem( | ||
name="插件列表", module="plugin", router="/plugin", icon="plugin" | ||
), | ||
MenuItem( | ||
name="插件商店", module="store", router="/store", icon="store" | ||
), | ||
MenuItem( | ||
name="好友/群组", module="manage", router="/manage", icon="user" | ||
), | ||
MenuItem( | ||
name="数据库管理", | ||
module="database", | ||
router="/database", | ||
icon="database", | ||
), | ||
MenuItem( | ||
name="系统信息", module="system", router="/system", icon="system" | ||
), | ||
] | ||
self.save() | ||
|
||
def get_menus(self): | ||
return MenuData(menus=self.menu) | ||
|
||
def save(self): | ||
self.file.parent.mkdir(parents=True, exist_ok=True) | ||
temp = [menu.dict() for menu in self.menu] | ||
with self.file.open("w", encoding="utf8") as f: | ||
json.dump(temp, f, ensure_ascii=False, indent=4) | ||
|
||
|
||
menu_manage = MenuManage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from pydantic import BaseModel | ||
|
||
|
||
class MenuItem(BaseModel): | ||
module: str | ||
"""模块名称""" | ||
name: str | ||
"""菜单名称""" | ||
router: str | ||
"""路由""" | ||
icon: str | ||
"""图标""" | ||
default: bool = False | ||
"""默认选中""" | ||
|
||
|
||
class MenuData(BaseModel): | ||
bot_type: str = "zhenxun" | ||
"""bot类型""" | ||
menus: list[MenuItem] | ||
"""菜单列表""" |
Oops, something went wrong.