Flex Btn Bug Fix
This commit is contained in:
@@ -466,37 +466,20 @@ def PDF翻译中文并重新编译PDF(txt, llm_kwargs, plugin_kwargs, chatbot, h
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
repeat, project_folder = check_repeat_upload(file_manifest[0], hash_tag)
|
||||
|
||||
except_flag = False
|
||||
|
||||
if repeat:
|
||||
yield from update_ui_lastest_msg(f"发现重复上传,请查收结果(压缩包)...", chatbot=chatbot, history=history)
|
||||
|
||||
try:
|
||||
trans_html_file = [f for f in glob.glob(f'{project_folder}/**/*.trans.html', recursive=True)][0]
|
||||
promote_file_to_downloadzone(trans_html_file, rename_file=None, chatbot=chatbot)
|
||||
|
||||
translate_pdf = [f for f in glob.glob(f'{project_folder}/**/merge_translate_zh.pdf', recursive=True)][0]
|
||||
promote_file_to_downloadzone(translate_pdf, rename_file=None, chatbot=chatbot)
|
||||
|
||||
comparison_pdf = [f for f in glob.glob(f'{project_folder}/**/comparison.pdf', recursive=True)][0]
|
||||
promote_file_to_downloadzone(comparison_pdf, rename_file=None, chatbot=chatbot)
|
||||
|
||||
zip_res = zip_result(project_folder)
|
||||
promote_file_to_downloadzone(file=zip_res, chatbot=chatbot)
|
||||
|
||||
return True
|
||||
|
||||
return
|
||||
except:
|
||||
report_exception(chatbot, history, a=f"解析项目: {txt}", b=f"发现重复上传,但是无法找到相关文件")
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
|
||||
chatbot.append([f"没有相关文件", '尝试重新翻译PDF...'])
|
||||
yield from update_ui(chatbot=chatbot, history=history)
|
||||
|
||||
except_flag = True
|
||||
|
||||
|
||||
elif not repeat or except_flag:
|
||||
else:
|
||||
yield from update_ui_lastest_msg(f"未发现重复上传", chatbot=chatbot, history=history)
|
||||
|
||||
# <-------------- convert pdf into tex ------------->
|
||||
|
||||
18
main.py
18
main.py
@@ -260,18 +260,19 @@ def main():
|
||||
None,
|
||||
_js=js_code_for_css_changing
|
||||
)
|
||||
|
||||
|
||||
switchy_bt.click(None, [switchy_bt], None, _js="(switchy_bt)=>on_flex_button_click(switchy_bt)")
|
||||
# 随变按钮的回调函数注册
|
||||
def route(request: gr.Request, k, *args, **kwargs):
|
||||
if k in [r"点击这里搜索插件列表", r"请先从插件列表中选择"]: return
|
||||
if k not in [r"点击这里搜索插件列表", r"请先从插件列表中选择"]:
|
||||
if plugins[k].get("Function", None):
|
||||
yield from ArgsGeneralWrapper(plugins[k]["Function"])(request, *args, **kwargs)
|
||||
|
||||
click_handle = switchy_bt.click(route, [switchy_bt, *input_combo], output_combo)
|
||||
switchy_bt.click(None, [switchy_bt], None, _js="(switchy_bt)=>on_flex_button_click(switchy_bt)")
|
||||
|
||||
click_handle.then(on_report_generated, [cookies, file_upload, chatbot], [cookies, file_upload, chatbot]).then(None, [switchy_bt], None, _js=r"(fn)=>on_plugin_exe_complete(fn)")
|
||||
cancel_handles.append(click_handle)
|
||||
|
||||
# 旧插件的高级参数区确认按钮(隐藏)
|
||||
old_plugin_callback = gr.Button(r"未选定任何插件", variant="secondary", visible=False, elem_id="old_callback_btn_for_plugin_exe")
|
||||
click_handle_ng = old_plugin_callback.click(route, [switchy_bt, *input_combo], output_combo)
|
||||
click_handle_ng.then(on_report_generated, [cookies, file_upload, chatbot], [cookies, file_upload, chatbot]).then(None, [switchy_bt], None, _js=r"(fn)=>on_plugin_exe_complete(fn)")
|
||||
cancel_handles.append(click_handle_ng)
|
||||
# 新一代插件的高级参数区确认按钮(隐藏)
|
||||
click_handle_ng = new_plugin_callback.click(route_switchy_bt_with_arg, [
|
||||
gr.State(["new_plugin_callback", "usr_confirmed_arg"] + input_combo_order),
|
||||
@@ -279,7 +280,6 @@ def main():
|
||||
], output_combo)
|
||||
click_handle_ng.then(on_report_generated, [cookies, file_upload, chatbot], [cookies, file_upload, chatbot]).then(None, [switchy_bt], None, _js=r"(fn)=>on_plugin_exe_complete(fn)")
|
||||
cancel_handles.append(click_handle_ng)
|
||||
|
||||
# 终止按钮的回调函数注册
|
||||
stopBtn.click(fn=None, inputs=None, outputs=None, cancels=cancel_handles)
|
||||
stopBtn2.click(fn=None, inputs=None, outputs=None, cancels=cancel_handles)
|
||||
|
||||
@@ -1695,7 +1695,11 @@ function run_advanced_plugin_launch_code(key){
|
||||
generate_menu(advanced_plugin_init_code_lib[key], key);
|
||||
}
|
||||
function on_flex_button_click(key){
|
||||
if (advanced_plugin_init_code_lib.hasOwnProperty(key)){
|
||||
run_advanced_plugin_launch_code(key);
|
||||
}else{
|
||||
document.getElementById("old_callback_btn_for_plugin_exe").click();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user