Skip to content

Commit

Permalink
Merge pull request #234 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
弹幕、入场、礼物的数据库日志记录GUI适配
  • Loading branch information
Ikaros-521 authored Aug 15, 2023
2 parents f56ce1b + 0525edc commit 8c19c91
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 12 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,9 @@ cmd输入命令即可:`doctoc /path/to/file`
### 2023-08-14
- 新增Claude2的接入

### 2023-08-15
- 弹幕、入场、礼物的数据库日志记录GUI适配

</details>


Expand Down
13 changes: 11 additions & 2 deletions UI_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def setupUi(self, MainWindow):
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -2882, 980, 9184))
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -8518, 980, 9260))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.verticalLayout = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents)
self.verticalLayout.setContentsMargins(35, 20, 35, 20)
Expand Down Expand Up @@ -1381,6 +1381,14 @@ def setupUi(self, MainWindow):
self.gridLayout_19.addWidget(self.lineEdit_header_useragent, 0, 1, 1, 1)
self.gridLayout_18.addLayout(self.gridLayout_19, 0, 1, 1, 1)
self.verticalLayout.addWidget(self.groupBox_header)
self.groupBox_database = QtWidgets.QGroupBox(self.scrollAreaWidgetContents)
self.groupBox_database.setObjectName("groupBox_database")
self.gridLayout_67 = QtWidgets.QGridLayout(self.groupBox_database)
self.gridLayout_67.setObjectName("gridLayout_67")
self.gridLayout_database = QtWidgets.QGridLayout()
self.gridLayout_database.setObjectName("gridLayout_database")
self.gridLayout_67.addLayout(self.gridLayout_database, 0, 0, 1, 1)
self.verticalLayout.addWidget(self.groupBox_database)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout_21.addWidget(self.scrollArea, 0, 0, 1, 1)
self.stackedWidget.addWidget(self.page)
Expand Down Expand Up @@ -1506,7 +1514,7 @@ def setupUi(self, MainWindow):
self.scrollArea_copywriting_config.setWidgetResizable(True)
self.scrollArea_copywriting_config.setObjectName("scrollArea_copywriting_config")
self.scrollAreaWidgetContents_4 = QtWidgets.QWidget()
self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 644, 498))
self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 355, 102))
self.scrollAreaWidgetContents_4.setObjectName("scrollAreaWidgetContents_4")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.scrollAreaWidgetContents_4)
self.verticalLayout_4.setObjectName("verticalLayout_4")
Expand Down Expand Up @@ -2022,6 +2030,7 @@ def retranslateUi(self, MainWindow):
self.groupBox_header.setTitle(_translate("MainWindow", "请求头"))
self.label_header_useragent.setText(_translate("MainWindow", "userAgent"))
self.lineEdit_header_useragent.setText(_translate("MainWindow", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42"))
self.groupBox_database.setTitle(_translate("MainWindow", "数据库"))
self.textBrowser.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
Expand Down
9 changes: 5 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"choose_song": true,
"sd": true,
"log": true,
"schedule": true
"schedule": true,
"database": true
},
"read_user_name": {
"enable": true,
Expand Down Expand Up @@ -330,8 +331,8 @@
],
"database": {
"path": "data/data.db",
"comment_enable": false,
"entrance_enable": false,
"gift_enable": false
"comment_enable": true,
"entrance_enable": true,
"gift_enable": true
}
}
3 changes: 2 additions & 1 deletion config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"choose_song": true,
"sd": true,
"log": true,
"schedule": true
"schedule": true,
"database": true
},
"read_user_name": {
"enable": true,
Expand Down
81 changes: 80 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,8 @@ def get_box_name_by_key(key):
"choose_song": "点歌模式",
"sd": "Stable Diffusion",
"log": "日志",
"schedule": "定时任务"
"schedule": "定时任务",
"database": "数据库"
# 可以继续添加其他键和值
}

Expand Down Expand Up @@ -1376,6 +1377,65 @@ def vits_gui_create():

vits_gui_create()

# 数据库
def database_gui_create():
data_json = []

database_config = config.get("database")
tmp_json = {
"label_text": "数据库路径",
"label_tip": "数据库文件存储路径",
"data": database_config["path"],
"main_obj_name": "database",
"index": 0
}
data_json.append(tmp_json)

tmp_json = {
"label_text": "弹幕日志",
"label_tip": "存储记录原始的用户弹幕数据,用于后期排查问题、分析用户画像等",
"data": database_config["comment_enable"],
"widget_text": "",
"click_func": "",
"main_obj_name": "database",
"index": 1
}
data_json.append(tmp_json)

tmp_json = {
"label_text": "入场日志",
"label_tip": "存储记录原始的用户入场数据,用于后期排查问题、分析流量等",
"data": database_config["entrance_enable"],
"widget_text": "",
"click_func": "",
"main_obj_name": "database",
"index": 1
}
data_json.append(tmp_json)

tmp_json = {
"label_text": "礼物日志",
"label_tip": "存储记录原始的用户礼物数据,用于后期排查问题、分析富哥富婆等",
"data": database_config["gift_enable"],
"widget_text": "",
"click_func": "",
"main_obj_name": "database",
"index": 1
}
data_json.append(tmp_json)

widgets = self.create_widgets_from_json(data_json)

# 动态添加widget到对应的gridLayout
row = 0
# 分2列,左边就是label说明,右边就是输入框等
for i in range(0, len(widgets), 2):
self.ui.gridLayout_database.addWidget(widgets[i], row, 0)
self.ui.gridLayout_database.addWidget(widgets[i + 1], row, 1)
row += 1

database_gui_create()

# 显隐各板块
self.oncomboBox_chat_type_IndexChanged(chat_type_index)
self.oncomboBox_audio_synthesis_type_IndexChanged(audio_synthesis_type_index)
Expand Down Expand Up @@ -1953,6 +2013,25 @@ def reorganize_vits_data(vits_data):
# 写回json
config_data["vits"] = reorganize_vits_data(vits_data)

# 数据库
def reorganize_database_data(database_data):
keys = list(database_data.keys())

tmp_json = {
"path": database_data[keys[0]],
"comment_enable": database_data[keys[1]],
"entrance_enable": database_data[keys[2]],
"gift_enable": database_data[keys[3]]
}

logging.debug(f"tmp_json={tmp_json}")

return tmp_json

database_data = self.update_data_from_gridLayout(self.ui.gridLayout_database)
# 写回json
config_data["database"] = reorganize_database_data(database_data)

# 获取自定义板块显隐的数据
show_box_data = self.update_data_from_gridLayout(self.ui.gridLayout_show_box, "show_box")
show_box_json = {}
Expand Down
20 changes: 16 additions & 4 deletions ui/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ font: 75 12pt &quot;微软雅黑&quot;;</string>
<property name="geometry">
<rect>
<x>0</x>
<y>-2882</y>
<y>-8518</y>
<width>980</width>
<height>9184</height>
<height>9260</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -2543,6 +2543,18 @@ font: 75 12pt &quot;微软雅黑&quot;;</string>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_database">
<property name="title">
<string>数据库</string>
</property>
<layout class="QGridLayout" name="gridLayout_67">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_database"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</widget>
Expand Down Expand Up @@ -2824,8 +2836,8 @@ font: 80 10pt &quot;微软雅黑&quot;;</string>
<rect>
<x>0</x>
<y>0</y>
<width>644</width>
<height>498</height>
<width>355</width>
<height>102</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
Expand Down

0 comments on commit 8c19c91

Please sign in to comment.