Skip to content

Commit

Permalink
Merge pull request #764 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
webui 页面配置新增 配置模板;更新投资人;删减违禁词
  • Loading branch information
Ikaros-521 committed Apr 16, 2024
2 parents 8fcb079 + b3c3314 commit bb8c33b
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 17 deletions.
2 changes: 0 additions & 2 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1571,8 +1571,6 @@
"read_username": true,
"filter": true,
"thanks": true,
"so_vits_svc": true,
"ddsp_svc": true,
"local_qa": true,
"choose_song": true,
"sd": true,
Expand Down
2 changes: 0 additions & 2 deletions config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -1571,8 +1571,6 @@
"read_username": true,
"filter": true,
"thanks": true,
"so_vits_svc": true,
"ddsp_svc": true,
"local_qa": true,
"choose_song": true,
"sd": true,
Expand Down
2 changes: 0 additions & 2 deletions data/badwords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2709,8 +2709,6 @@ bili_
看棋器
楊震
孔雀王
帐号
学历证
易丹轩
美骚妇
黎阳评
Expand Down
12 changes: 6 additions & 6 deletions docs/投资人/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,18 @@
{
name: "天然呆",
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_240303081807_QQ%E5%9B%BE%E7%89%8720240303161650.jpg",
amount: "¥188"
amount: "¥200"
},
{
name: "J丶异乡人",
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_230920161039_111.jpg",
amount: "¥188"
},
{
name: "海哥哥",
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_240327133453_%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240327213240.jpg",
amount: "¥188"
},
{
name: "花开一季",
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_230817152316_QQ%E5%9B%BE%E7%89%8720230817232145.jpg",
Expand Down Expand Up @@ -301,11 +306,6 @@
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_240322134625_QQ%E5%9B%BE%E7%89%8720240322214605.jpg",
amount: "¥100"
},
{
name: "海哥哥",
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_240327133453_%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20240327213240.jpg",
amount: "¥100"
},
{
name: "张帆",
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_240409155719_QQ%E5%9B%BE%E7%89%8720240409235702.jpg",
Expand Down
Binary file modified docs/投资人/invest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1802,7 +1802,7 @@ def on_message(ws, message):
pass

def on_error(ws, error):
logging.error("Error:", error)
logging.error(f"Error:{error}")


def on_close(ws):
Expand Down
57 changes: 53 additions & 4 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,48 @@ def webui_local_dir_to_endpoint_del(index):
logging.error(traceback.format_exc())


# 配置模板保存
def config_template_save(file_path: str):
try:
with open(config_path, 'r', encoding="utf-8") as config_file:
config_data = json.load(config_file)

# 将JSON数据保存到文件中
with open(file_path, "w", encoding="utf-8") as file:
json.dump(config_data, file, indent=2, ensure_ascii=False)
file.flush() # 刷新缓冲区,确保写入立即生效

logging.info("配置模板保存成功!")
ui.notify(position="top", type="positive", message=f"配置模板保存成功!")

return True
except Exception as e:
logging.error(f"配置模板保存失败!\n{e}")
ui.notify(position="top", type="negative", message=f"配置模板保存失败!{e}")
return False


# 配置模板加载
def config_template_load(file_path: str):
try:
with open(file_path, 'r', encoding="utf-8") as config_file:
config_data = json.load(config_file)

# 将JSON数据保存到文件中
with open(config_path, "w", encoding="utf-8") as file:
json.dump(config_data, file, indent=2, ensure_ascii=False)
file.flush() # 刷新缓冲区,确保写入立即生效

logging.info("配置模板加载成功!重启后读取!想反悔就直接保存下当前配置,然后再重启!!!")
ui.notify(position="top", type="positive", message=f"配置模板加载成功!重启后读取!想反悔就直接保存下当前配置,然后再重启!!!")

return True
except Exception as e:
logging.error(f"配置模板读取失败!\n{e}")
ui.notify(position="top", type="negative", message=f"配置模板读取失败!{e}")
return False


"""
配置操作
"""
Expand Down Expand Up @@ -2367,8 +2409,6 @@ def common_textarea_handle(content):
config_data["webui"]["show_card"]["common_config"]["read_username"] = switch_webui_show_card_common_config_read_username.value
config_data["webui"]["show_card"]["common_config"]["filter"] = switch_webui_show_card_common_config_filter.value
config_data["webui"]["show_card"]["common_config"]["thanks"] = switch_webui_show_card_common_config_thanks.value
config_data["webui"]["show_card"]["common_config"]["so_vits_svc"] = switch_webui_show_card_common_config_so_vits_svc.value
config_data["webui"]["show_card"]["common_config"]["ddsp_svc"] = switch_webui_show_card_common_config_ddsp_svc.value
config_data["webui"]["show_card"]["common_config"]["local_qa"] = switch_webui_show_card_common_config_local_qa.value
config_data["webui"]["show_card"]["common_config"]["choose_song"] = switch_webui_show_card_common_config_choose_song.value
config_data["webui"]["show_card"]["common_config"]["sd"] = switch_webui_show_card_common_config_sd.value
Expand Down Expand Up @@ -5314,17 +5354,26 @@ def update_echart_gift():
value=config.get("webui", "theme", "choose")
)

with ui.card().style(card_css):
ui.label("配置模板")
with ui.row():
input_config_template_path = ui.input(label='配置模板路径', value="", placeholder='输入你需要加载或保存的配置文件路径,例如:直播带货.json')

button_config_template_save = ui.button('保存配置到文件', on_click=lambda: config_template_save(input_config_template_path.value), color=button_internal_color).style(button_internal_css)
button_config_template_load = ui.button('读取模板到本地(慎点)', on_click=lambda: config_template_load(input_config_template_path.value), color=button_internal_color).style(button_internal_css)



with ui.card().style(card_css):
ui.label("板块显示/隐藏")

with ui.card().style(card_css):
ui.label("通用配置")
with ui.row():
switch_webui_show_card_common_config_read_comment = ui.switch('念弹幕', value=config.get("webui", "show_card", "common_config", "read_comment")).style(switch_internal_css)
switch_webui_show_card_common_config_read_username = ui.switch('回复时念用户名', value=config.get("webui", "show_card", "common_config", "read_username")).style(switch_internal_css)
switch_webui_show_card_common_config_filter = ui.switch('过滤', value=config.get("webui", "show_card", "common_config", "filter")).style(switch_internal_css)
switch_webui_show_card_common_config_thanks = ui.switch('答谢', value=config.get("webui", "show_card", "common_config", "thanks")).style(switch_internal_css)
switch_webui_show_card_common_config_so_vits_svc = ui.switch('SO-VITS-SVC', value=config.get("webui", "show_card", "common_config", "so_vits_svc")).style(switch_internal_css)
switch_webui_show_card_common_config_ddsp_svc = ui.switch('DDSP-SVC', value=config.get("webui", "show_card", "common_config", "ddsp_svc")).style(switch_internal_css)
switch_webui_show_card_common_config_local_qa = ui.switch('本地问答', value=config.get("webui", "show_card", "common_config", "local_qa")).style(switch_internal_css)
switch_webui_show_card_common_config_choose_song = ui.switch('点歌', value=config.get("webui", "show_card", "common_config", "choose_song")).style(switch_internal_css)
switch_webui_show_card_common_config_sd = ui.switch('Stable Diffusion', value=config.get("webui", "show_card", "common_config", "sd")).style(switch_internal_css)
Expand Down

0 comments on commit bb8c33b

Please sign in to comment.