Skip to content

Commit aa920bd

Browse files
committed
fix(core): 统一交互接口修复Bangumi映射闪退问题
问题:
1 parent 4d85425 commit aa920bd

File tree

3 files changed

+18
-33
lines changed

3 files changed

+18
-33
lines changed

core/interaction.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,7 @@ class InteractionProvider(ABC):
2424
"""Abstract base class for providing user interaction."""
2525

2626
@abstractmethod
27-
async def handle_new_bangumi_key(
28-
self,
29-
bangumi_key: str,
30-
bangumi_value: Any,
31-
bangumi_url: str,
32-
db_name: str,
33-
mappable_props: List[str],
34-
recommended_props: List[str] = None,
35-
) -> Dict[str, Any]:
27+
async def handle_new_bangumi_key(self, request_data: Dict[str, Any]) -> Dict[str, Any]:
3628
"""
3729
Handle a new, unmapped key from Bangumi.
3830
Returns a dictionary with 'action' and 'data'.
@@ -54,15 +46,13 @@ async def confirm_brand_merge(self, new_brand_name: str, suggested_brand: str) -
5446
class ConsoleInteractionProvider(InteractionProvider):
5547
"""Console implementation for user interaction using input()."""
5648

57-
async def handle_new_bangumi_key(
58-
self,
59-
bangumi_key: str,
60-
bangumi_value: Any,
61-
bangumi_url: str,
62-
db_name: str,
63-
mappable_props: List[str],
64-
recommended_props: List[str] = None,
65-
) -> Dict[str, Any]:
49+
async def handle_new_bangumi_key(self, request_data: Dict[str, Any]) -> Dict[str, Any]:
50+
bangumi_key = request_data["bangumi_key"]
51+
bangumi_value = request_data["bangumi_value"]
52+
bangumi_url = request_data["bangumi_url"]
53+
db_name = request_data["db_name"]
54+
mappable_props = request_data["mappable_props"]
55+
recommended_props = request_data.get("recommended_props", [])
6656

6757
def _get_action_input():
6858
prompt_header = (

core/mapping_manager.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,15 @@ async def handle_new_key(
238238
bangumi_key, mappable_props, limit=3, threshold=0.6
239239
)
240240

241-
result = await self.interaction_provider.handle_new_bangumi_key(
242-
bangumi_key=bangumi_key,
243-
bangumi_value=bangumi_value,
244-
bangumi_url=bangumi_url,
245-
db_name=db_name,
246-
mappable_props=mappable_props,
247-
recommended_props=recommended_props,
248-
)
241+
request_data = {
242+
"bangumi_key": bangumi_key,
243+
"bangumi_value": bangumi_value,
244+
"bangumi_url": bangumi_url,
245+
"db_name": db_name,
246+
"mappable_props": mappable_props,
247+
"recommended_props": recommended_props,
248+
}
249+
result = await self.interaction_provider.handle_new_bangumi_key(request_data)
249250

250251
action = result.get("action")
251252
data = result.get("data")

utils/gui_bridge.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,7 @@ async def ask_for_new_property_type(self, prop_name: str) -> str | None:
107107
self.ask_for_new_property_type_requested.emit({"prop_name": prop_name})
108108
return await self.future
109109

110-
async def handle_new_bangumi_key(self, db_type: str, prop_name: str, prop_value: str, page_id: str) -> dict:
111-
request_data = {
112-
"db_type": db_type,
113-
"prop_name": prop_name,
114-
"prop_value": prop_value,
115-
"page_id": page_id,
116-
}
110+
async def handle_new_bangumi_key(self, request_data: dict) -> dict:
117111
self.future = self.loop.create_future()
118112
self.handle_new_bangumi_key_requested.emit(request_data)
119113
return await self.future

0 commit comments

Comments
 (0)