Spaces:
Running
Running
Update breed_recommendation.py
Browse files- breed_recommendation.py +15 -16
breed_recommendation.py
CHANGED
@@ -23,24 +23,22 @@ def create_custom_button_style():
|
|
23 |
cursor: pointer;
|
24 |
transition: all 0.3s ease;
|
25 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
26 |
-
width: 100%;
|
27 |
-
margin: 20px 0;
|
28 |
-
font-size: 1.1em;
|
29 |
}
|
30 |
#find-match-btn:hover {
|
31 |
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
|
32 |
opacity: 0.95;
|
33 |
-
transform: translateY(-1px); /* 輕微上升效果 */
|
34 |
-
}
|
35 |
-
#find-match-btn:active {
|
36 |
-
transform: translateY(1px); /* 點擊時下壓效果 */
|
37 |
}
|
38 |
#search-status {
|
39 |
text-align: center;
|
40 |
-
padding:
|
41 |
font-size: 1.1em;
|
42 |
color: #666;
|
43 |
-
|
|
|
|
|
44 |
}
|
45 |
</style>
|
46 |
"""
|
@@ -215,6 +213,9 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
215 |
elem_id="recommendation-output"
|
216 |
)
|
217 |
|
|
|
|
|
|
|
218 |
def on_find_match_click(*args):
|
219 |
try:
|
220 |
print("Starting breed matching process...")
|
@@ -278,6 +279,10 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
278 |
return ["Error getting recommendations", gr.HTML.update(visible=False)]
|
279 |
|
280 |
get_recommendations_btn.click(
|
|
|
|
|
|
|
|
|
281 |
fn=on_find_match_click,
|
282 |
inputs=[
|
283 |
living_space,
|
@@ -292,13 +297,7 @@ def create_recommendation_tab(UserPreferences, get_breed_recommendations, format
|
|
292 |
children_age,
|
293 |
noise_tolerance
|
294 |
],
|
295 |
-
outputs=[recommendation_output, search_status]
|
296 |
-
_js="""
|
297 |
-
() => {
|
298 |
-
document.getElementById('search-status').style.display = 'block';
|
299 |
-
return [];
|
300 |
-
}
|
301 |
-
""" # 立即顯示搜尋狀態
|
302 |
)
|
303 |
|
304 |
return {
|
|
|
23 |
cursor: pointer;
|
24 |
transition: all 0.3s ease;
|
25 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
26 |
+
width: 100%;
|
27 |
+
margin: 20px 0;
|
28 |
+
font-size: 1.1em;
|
29 |
}
|
30 |
#find-match-btn:hover {
|
31 |
box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
|
32 |
opacity: 0.95;
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
#search-status {
|
35 |
text-align: center;
|
36 |
+
padding: 15px;
|
37 |
font-size: 1.1em;
|
38 |
color: #666;
|
39 |
+
margin: 10px 0;
|
40 |
+
border-radius: 8px;
|
41 |
+
background: rgba(255, 95, 109, 0.1);
|
42 |
}
|
43 |
</style>
|
44 |
"""
|
|
|
213 |
elem_id="recommendation-output"
|
214 |
)
|
215 |
|
216 |
+
def show_loading_status():
|
217 |
+
return gr.HTML.update(visible=True)
|
218 |
+
|
219 |
def on_find_match_click(*args):
|
220 |
try:
|
221 |
print("Starting breed matching process...")
|
|
|
279 |
return ["Error getting recommendations", gr.HTML.update(visible=False)]
|
280 |
|
281 |
get_recommendations_btn.click(
|
282 |
+
fn=show_loading_status,
|
283 |
+
outputs=search_status,
|
284 |
+
queue=False
|
285 |
+
).then(
|
286 |
fn=on_find_match_click,
|
287 |
inputs=[
|
288 |
living_space,
|
|
|
297 |
children_age,
|
298 |
noise_tolerance
|
299 |
],
|
300 |
+
outputs=[recommendation_output, search_status]
|
|
|
|
|
|
|
|
|
|
|
|
|
301 |
)
|
302 |
|
303 |
return {
|