新增 inverted_index.json 和 record.json 文件,并更新 init_plugin.py 中的字段更新逻辑,移除 menu_type 字段的更新,确保只更新必要的插件元数据字段。

This commit is contained in:
mio 2025-04-16 14:09:01 +08:00
parent 4e85a7a434
commit 04b9df04c9
3 changed files with 14 additions and 10 deletions

1
inverted_index.json Normal file
View File

@ -0,0 +1 @@
{}

1
record.json Normal file
View File

@ -0,0 +1 @@
{}

View File

@ -139,26 +139,28 @@ async def _():
create_list.append(plugin) create_list.append(plugin)
else: else:
plugin.id = module2id[plugin.module_path] plugin.id = module2id[plugin.module_path]
# 确保menu_type字段包含在更新列表中 # 确保只更新应该来自插件元数据的字段
await plugin.save( await plugin.save(
update_fields=[ update_fields=[
"name", "name",
"author", "author",
"version", "version",
"admin_level",
"plugin_type", "plugin_type",
"admin_level",
"is_show", "is_show",
"menu_type", # 添加menu_type到更新列表 "ignore_prompt",
# 移除了 menu_type
# 确保 level, default_status, limit_superuser, cost_gold, impression, status, block_type 等用户配置不在此列表
] ]
) )
# 验证更新是否成功 # # 验证更新是否成功
updated_plugin = await PluginInfo.get(id=plugin.id) # updated_plugin = await PluginInfo.get(id=plugin.id)
if updated_plugin.menu_type != plugin.menu_type: # if updated_plugin.menu_type != plugin.menu_type:
logger.warning(f"插件 {plugin.name} 的menu_type更新失败: 期望值 '{plugin.menu_type}', 实际值 '{updated_plugin.menu_type}'") # logger.warning(f"插件 {plugin.name} 的menu_type更新失败: 期望值 '{plugin.menu_type}', 实际值 '{updated_plugin.menu_type}'")
# 尝试单独更新menu_type # # 尝试单独更新menu_type
updated_plugin.menu_type = plugin.menu_type # updated_plugin.menu_type = plugin.menu_type
await updated_plugin.save(update_fields=["menu_type"]) # await updated_plugin.save(update_fields=["menu_type"])
update_list.append(plugin) update_list.append(plugin)