mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-12 20:21:21 +08:00
修改年度报告url
This commit is contained in:
parent
e817b868ba
commit
cb83c5bd81
@ -40,10 +40,3 @@ def excepthook(exc_type, exc_value, traceback_):
|
||||
|
||||
# 调用原始的 excepthook,以便程序正常退出
|
||||
sys.__excepthook__(exc_type, exc_value, traceback_)
|
||||
|
||||
|
||||
# 设置 excepthook
|
||||
sys.excepthook = excepthook
|
||||
result = None # 假设这里返回了一个 None
|
||||
for item in result: # 尝试迭代一个 None
|
||||
print(item)
|
@ -71,7 +71,7 @@ class ContactInfo(QWidget, Ui_Form):
|
||||
self.report_thread = ReportThread(self.contact)
|
||||
# self.report_thread.okSignal.connect(lambda x: QDesktopServices.openUrl(QUrl("http://127.0.0.1:21314")))
|
||||
self.report_thread.start()
|
||||
QDesktopServices.openUrl(QUrl("http://127.0.0.1:21314/charts"))
|
||||
QDesktopServices.openUrl(QUrl(f"http://127.0.0.1:21314/charts/{self.contact.wxid}"))
|
||||
|
||||
def annual_report(self):
|
||||
date_range = None
|
||||
@ -95,9 +95,8 @@ class ContactInfo(QWidget, Ui_Form):
|
||||
self.contact.save_avatar()
|
||||
Me().save_avatar()
|
||||
self.report_thread = ReportThread(self.contact, time_range)
|
||||
self.report_thread.okSignal.connect(lambda x: QDesktopServices.openUrl(QUrl("http://127.0.0.1:21314")))
|
||||
self.report_thread.start()
|
||||
QDesktopServices.openUrl(QUrl("http://127.0.0.1:21314/christmas"))
|
||||
QDesktopServices.openUrl(QUrl(f"http://127.0.0.1:21314/christmas/{self.contact.wxid}"))
|
||||
|
||||
def emotionale_Analysis(self):
|
||||
QDesktopServices.openUrl(QUrl("https://memotrace.lc044.love/"))
|
||||
|
@ -58,7 +58,19 @@ setInterval(getRTime, 1000);
|
||||
|
||||
</script>
|
||||
<script>
|
||||
fetch('/month_count')
|
||||
var wxid = '{{wxid}}';
|
||||
function month_count(time_range){
|
||||
const requestData = {
|
||||
wxid: wxid,
|
||||
time_range: time_range
|
||||
};
|
||||
fetch('/month_count',{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(chartOptions => {
|
||||
// 在这里使用 ECharts 渲染图表
|
||||
@ -66,9 +78,19 @@ setInterval(getRTime, 1000);
|
||||
var option = chartOptions.chart_data;
|
||||
myChart.setOption(JSON.parse(option));
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
fetch('/wordcloud')
|
||||
}
|
||||
function wordcloud(time_range){
|
||||
const requestData = {
|
||||
wxid: wxid,
|
||||
time_range: time_range
|
||||
};
|
||||
fetch('/wordcloud',{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(chartOptions => {
|
||||
// 在这里使用 ECharts 渲染图表
|
||||
@ -76,9 +98,19 @@ setInterval(getRTime, 1000);
|
||||
var option = chartOptions.chart_data;
|
||||
myChart.setOption(JSON.parse(option));
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
fetch('/calendar')
|
||||
}
|
||||
function calendar(time_range){
|
||||
const requestData = {
|
||||
wxid: wxid,
|
||||
time_range: time_range
|
||||
};
|
||||
fetch('/calendar',{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(chartOptions => {
|
||||
// 在这里使用 ECharts 渲染图表
|
||||
@ -86,9 +118,19 @@ setInterval(getRTime, 1000);
|
||||
var option = chartOptions.chart_data;
|
||||
myChart.setOption(JSON.parse(option));
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
fetch('/message_counter')
|
||||
}
|
||||
function message_counter(time_range){
|
||||
const requestData = {
|
||||
wxid: wxid,
|
||||
time_range: time_range
|
||||
};
|
||||
fetch('/message_counter',{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(requestData)
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(chartOptions => {
|
||||
// 在这里使用 ECharts 渲染图表
|
||||
@ -102,6 +144,12 @@ setInterval(getRTime, 1000);
|
||||
var option = chartOptions.chart_data_weekday;
|
||||
myChart2.setOption(JSON.parse(option));
|
||||
});
|
||||
}
|
||||
var time_range=['1997-01-01 00:00:00','2035-01-01 00:00:00']
|
||||
message_counter(time_range);
|
||||
month_count(time_range);
|
||||
calendar(time_range);
|
||||
wordcloud(time_range);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -8,9 +8,9 @@
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@latest/dist/echarts.min.js"></script>
|
||||
<script type="text/javascript" src="https://assets.pyecharts.org/assets/v5/echarts-wordcloud.min.js"></script>
|
||||
<link rel="stylesheet" href="https://memotrace.lc044.love/static/css/fullpage.min.css" />
|
||||
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
||||
<script src="https://memotrace.lc044.love/static/js/fullpage.min.js"></script>
|
||||
<script src="https://davidshimjs.github.io/qrcodejs/qrcode.min.js"></script>
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
||||
<script type="text/javascript" src="https://memotrace.lc044.love/static/js/fullpage.min.js"></script>
|
||||
<script type="text/javascript" src="https://davidshimjs.github.io/qrcodejs/qrcode.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="snow"></div>
|
||||
|
@ -3,16 +3,17 @@ import sys
|
||||
import time
|
||||
|
||||
import requests
|
||||
from flask import Flask, render_template, send_file, jsonify, make_response
|
||||
from flask import Flask, render_template, send_file, jsonify, make_response, request
|
||||
from pyecharts.charts import Bar
|
||||
|
||||
from app.DataBase import msg_db
|
||||
from app.DataBase import msg_db, micro_msg_db
|
||||
from app.analysis import analysis
|
||||
from app.person import Contact, Me
|
||||
from app.util.emoji import get_most_emoji
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
run_flag = False
|
||||
wxid = ''
|
||||
contact: Contact = None
|
||||
start_time = '2023-1-01 00:00:00'
|
||||
@ -21,6 +22,19 @@ time_range = (start_time, end_time)
|
||||
html: str = ''
|
||||
api_url = 'http://api.lc044.love/upload'
|
||||
|
||||
def get_contact(wxid):
|
||||
contact_info_list = micro_msg_db.get_contact_by_username(wxid)
|
||||
contact_info = {
|
||||
'UserName': contact_info_list[0],
|
||||
'Alias': contact_info_list[1],
|
||||
'Type': contact_info_list[2],
|
||||
'Remark': contact_info_list[3],
|
||||
'NickName': contact_info_list[4],
|
||||
'smallHeadImgUrl': contact_info_list[7],
|
||||
'label_name': contact_info_list[10],
|
||||
}
|
||||
contact = Contact(contact_info)
|
||||
return contact
|
||||
|
||||
@app.route("/")
|
||||
def index():
|
||||
@ -28,9 +42,9 @@ def index():
|
||||
return "index.html"
|
||||
|
||||
|
||||
@app.route("/christmas")
|
||||
def christmas():
|
||||
|
||||
@app.route("/christmas/<wxid>")
|
||||
def christmas(wxid):
|
||||
contact = get_contact(wxid)
|
||||
# 渲染模板,并传递图表的 HTML 到模板中
|
||||
try:
|
||||
first_message, first_time = msg_db.get_first_time_of_message(contact.wxid)
|
||||
@ -160,9 +174,14 @@ def test():
|
||||
|
||||
|
||||
def run(port=21314):
|
||||
try:
|
||||
app.run(debug=True, host='0.0.0.0', port=port, use_reloader=False)
|
||||
except:
|
||||
global run_flag
|
||||
if not run_flag:
|
||||
try:
|
||||
app.run(debug=True, host='0.0.0.0', port=port, use_reloader=False)
|
||||
run_flag = True
|
||||
except:
|
||||
pass
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
@ -181,30 +200,32 @@ def get_image(filename):
|
||||
return send_file(os.path.join(f"{os.getcwd()}/data/avatar/", filename), mimetype='image/png')
|
||||
|
||||
|
||||
@app.route('/month_count')
|
||||
@app.route('/month_count', methods=['POST'])
|
||||
def get_chart_options():
|
||||
time_range = (0, time.time())
|
||||
data = analysis.month_count(contact.wxid, time_range=time_range)
|
||||
return jsonify(data)
|
||||
|
||||
|
||||
@app.route('/wordcloud')
|
||||
@app.route('/wordcloud', methods=['POST'])
|
||||
def get_wordcloud():
|
||||
time_range = (0, time.time())
|
||||
print(time_range, contact.wxid)
|
||||
wxid = request.json.get('wxid')
|
||||
time_range = request.json.get('time_range', [])
|
||||
|
||||
world_cloud_data = analysis.wordcloud_(contact.wxid, time_range=time_range)
|
||||
world_cloud_data = analysis.wordcloud_(wxid, time_range=time_range)
|
||||
return jsonify(world_cloud_data)
|
||||
|
||||
|
||||
@app.route('/charts')
|
||||
def charts():
|
||||
@app.route('/charts/<wxid>')
|
||||
def charts(wxid):
|
||||
# 渲染模板,并传递图表的 HTML 到模板中
|
||||
contact = get_contact(wxid)
|
||||
try:
|
||||
first_message, first_time = msg_db.get_first_time_of_message(contact.wxid)
|
||||
first_message, first_time = msg_db.get_first_time_of_message(wxid)
|
||||
except TypeError:
|
||||
first_time = '2023-01-01 00:00:00'
|
||||
data = {
|
||||
'wxid':wxid,
|
||||
'my_nickname': Me().name,
|
||||
'ta_nickname': contact.remark,
|
||||
'first_time': first_time
|
||||
@ -212,16 +233,19 @@ def charts():
|
||||
return render_template('charts.html', **data)
|
||||
|
||||
|
||||
@app.route('/calendar')
|
||||
@app.route('/calendar', methods=['POST'])
|
||||
def get_calendar():
|
||||
time_range = (0, time.time())
|
||||
world_cloud_data = analysis.calendar_chart(contact.wxid, time_range=time_range)
|
||||
wxid = request.json.get('wxid')
|
||||
time_range = request.json.get('time_range',[])
|
||||
world_cloud_data = analysis.calendar_chart(wxid, time_range=time_range)
|
||||
return jsonify(world_cloud_data)
|
||||
|
||||
|
||||
@app.route('/message_counter')
|
||||
@app.route('/message_counter', methods=['POST'])
|
||||
def get_counter():
|
||||
time_range = (0, time.time())
|
||||
wxid = request.json.get('wxid')
|
||||
time_range = request.json.get('time_range', [])
|
||||
contact = get_contact(wxid)
|
||||
data = analysis.sender(contact.wxid, time_range=time_range, my_name=Me().name, ta_name=contact.remark)
|
||||
return jsonify(data)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user