fix webui update plugin_shop

This commit is contained in:
HibiKier 2022-06-03 00:59:00 +08:00
parent 24d9ec2b75
commit 252d45c79b
4 changed files with 13 additions and 7 deletions

View File

@ -243,6 +243,11 @@ __Docker 最新版本由 [Sakuracio](https://github.com/Sakuracio) 提供__
## 更新 ## 更新
### 2022/6/3
* 修复了webUI插件相关API问题
* 插件仓库在已安装插件边上会提示\[已安装]
### 2022/5/31 ### 2022/5/31
* 修复开启/关闭全部功能时帮助图片未重绘 [@pull/721](https://github.com/HibiKier/zhenxun_bot/pull/721) * 修复开启/关闭全部功能时帮助图片未重绘 [@pull/721](https://github.com/HibiKier/zhenxun_bot/pull/721)

View File

@ -16,7 +16,7 @@ usage
指令 指令
查看插件仓库 查看插件仓库
更新插件仓库 更新插件仓库
安装插件 [name/id] 安装插件 [name/id] 重新安装等同于更新
卸载插件 [name/id] 卸载插件 [name/id]
""".strip() """.strip()
__plugin_des__ = "从真寻适配仓库中下载插件" __plugin_des__ = "从真寻适配仓库中下载插件"

View File

@ -3,6 +3,7 @@ import shutil
import zipfile import zipfile
from pathlib import Path from pathlib import Path
from typing import Union, Tuple from typing import Union, Tuple
from utils.manager import plugins_manager
import ujson as json import ujson as json
@ -76,7 +77,7 @@ async def install_plugin(name: str) -> str:
os.system( os.system(
f"poetry run pip install -r {(extensive_plugin_path / f'{name}' / 'requirements.txt').absolute()}" f"poetry run pip install -r {(extensive_plugin_path / f'{name}' / 'requirements.txt').absolute()}"
) )
with open(extensive_plugin_path / f'{name}' / "plugin_info.json", 'w') as f: with open(extensive_plugin_path / f"{name}" / "plugin_info.json", "w") as f:
json.dump(data[name], f, ensure_ascii=False, indent=4) json.dump(data[name], f, ensure_ascii=False, indent=4)
logger.debug("移动插件文件夹完成...") logger.debug("移动插件文件夹完成...")
logger.info(f"成功安装插件 {name} 成功!\n{tmp}") logger.info(f"成功安装插件 {name} 成功!\n{tmp}")
@ -115,6 +116,7 @@ async def show_plugin_repo() -> Union[int, str]:
if code != 200: if code != 200:
return code return code
plugin_info = json.load(open(plugin_json, "r", encoding="utf8")) plugin_info = json.load(open(plugin_json, "r", encoding="utf8"))
load_plugin_list = plugins_manager.get_data().keys()
image_list = [] image_list = []
w, h = 0, 0 w, h = 0, 0
line_height = 10 line_height = 10
@ -129,8 +131,9 @@ async def show_plugin_repo() -> Union[int, str]:
"github_url": plugin_info[key]["github_url"], "github_url": plugin_info[key]["github_url"],
} }
s = ( s = (
f'id{i+1}\n名称:{plugin_info[key]["plugin_name"]}\n' f'id{i+1}\n名称:{plugin_info[key]["plugin_name"]}'
f'模块:{key}\n' f' \t\t{"<f font_color=#1a7e30>[已安装]</f>" if key in load_plugin_list else ""}\n'
f"模块:{key}\n"
f'作者:{plugin_info[key]["author"]}\n' f'作者:{plugin_info[key]["author"]}\n'
f'版本:{plugin_info[key]["version"]}\n' f'版本:{plugin_info[key]["version"]}\n'
f'简介:{plugin_info[key]["introduction"]}\n' f'简介:{plugin_info[key]["introduction"]}\n'

View File

@ -108,7 +108,7 @@ def _(plugin: Plugin, user: User = Depends(token_to_user)) -> Result:
if str(c.value).lower() in ["true", "false"] and ( if str(c.value).lower() in ["true", "false"] and (
c.default_value is None or isinstance(c.default_value, bool) c.default_value is None or isinstance(c.default_value, bool)
): ):
c.value = True if str(c.value).lower() == "true" else False c.value = str(c.value).lower() == "true"
elif isinstance( elif isinstance(
Config.get_config(plugin.model, c.key, c.value), int Config.get_config(plugin.model, c.key, c.value), int
) or isinstance(c.default_value, int): ) or isinstance(c.default_value, int):
@ -127,8 +127,6 @@ def _(plugin: Plugin, user: User = Depends(token_to_user)) -> Result:
else: else:
if plugin.plugin_settings: if plugin.plugin_settings:
for key, value in plugin.plugin_settings: for key, value in plugin.plugin_settings:
if plugin.plugin_settings.cmd:
plugin.plugin_settings.cmd = plugin.plugin_settings.cmd.split(',')
plugins2settings_manager.set_module_data(plugin.model, key, value) plugins2settings_manager.set_module_data(plugin.model, key, value)
if plugin.plugin_manager: if plugin.plugin_manager:
for key, value in plugin.plugin_manager: for key, value in plugin.plugin_manager: