This commit is contained in:
xaoyaoo 2024-01-02 21:18:45 +08:00
parent 7086d7b6d9
commit 839d016bda
13 changed files with 100 additions and 2657 deletions

View File

@ -5,5 +5,6 @@
# Author: xaoyaoo # Author: xaoyaoo
# Date: 2023/09/27 # Date: 2023/09/27
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
from .db_parsing import read_img_dat, read_emoji, decompress_CompressContent, read_audio_buf, read_audio, parse_xml_string,read_BytesExtra from .db_parsing import read_img_dat, read_emoji, decompress_CompressContent, read_audio_buf, read_audio, \
from .export_chat import export_csv parse_xml_string, read_BytesExtra
from .export_chat import export_csv, get_contact_list, get_chatroom_list, get_msg_list, get_chat_count

36
pywxdump/api/chat_api.py Normal file
View File

@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-#
# -------------------------------------------------------------------------------
# Name: chat_api.py
# Description:
# Author: xaoyaoo
# Date: 2024/01/02
# -------------------------------------------------------------------------------
from flask import Flask, request, render_template, g, Blueprint
from pywxdump import analyzer
from pywxdump.api.rjson import ReJson, RqJson
# from flask_cors import CORS
app = Flask(__name__ , static_folder='../ui/web/dist', static_url_path='/')
@app.route('/api/contact_list', methods=["GET", 'POST'])
def contact_list():
"""
获取联系人列表
:return:
"""
if request.method == "POST":
# 从header中读取micro_path
micro_path = request.headers.get("micro_path")
try:
# 获取联系人列表
contact_list = analyzer.get_contact_list(micro_path)
return ReJson(0, contact_list)
except Exception as e:
return ReJson(9999, msg=str(e))
else:
return ReJson(9999)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)

61
pywxdump/api/rjson.py Normal file
View File

@ -0,0 +1,61 @@
import logging
def ReJson(code: int, body: dict = None, msg: str = None, error: str = None, extra: dict = None) -> dict:
"""
返回格式化的json数据
:param code: 状态码 int
:param body: 返回的主体内容一般为具体的数据
:param msg: 返回状态码相关的调试信息
:param error: 出现错误时候,这个参数可以把错误写入日志
:param extra: # 全局附加数据字段、内容不定如等级经验的变化可以作为全局的数据存在区别于某次请求的具体data
:return: json格式的返回值
"""
if extra is None:
extra = {}
situation = {
0: {'code': 0, 'body': body, 'msg': "success", "extra": extra},
# 100 开头代表 请求数据有问题
# 4*** 表示数据库查询结果存在异常
1001: {'code': 1001, 'body': body, 'msg': "请求数据格式存在错误!", "extra": extra},
1002: {'code': 1002, 'body': body, 'msg': "请求参数存在错误!", "extra": extra},
2001: {'code': 2001, 'body': body, 'msg': "操作失败!", "extra": extra}, # 请求未能正确执行
4001: {'code': 4001, 'body': body, 'msg': "账号或密码错误!", "extra": extra}, # 表示用户没有权限(令牌、用户名、密码错误)
4003: {'code': 4003, 'body': body, 'msg': "禁止访问!", "extra": extra},
4004: {'code': 4004, 'body': body, 'msg': "数据不存在!", "extra": extra},
4005: {'code': 4005, 'body': body, 'msg': "数据库异常!", "extra": extra},
4006: {'code': 4006, 'body': body, 'msg': "数据已存在!", "extra": extra},
5002: {'code': 5002, 'body': body, 'msg': "服务器错误!", "extra": extra},
9999: {'code': 9999, 'body': body, 'msg': "未知错误!", "extra": extra},
}
rjson = situation.get(code, {'code': 9999, 'body': None, 'msg': "code错误", "extra": {}})
if code != 0:
logging.warning((code, rjson['body'], msg if msg else None))
if body:
rjson['body'] = body
if msg:
rjson['msg'] = msg
if error:
logging.error(error)
return rjson
def RqJson(rqData):
"""
进行请求数据验证数据合法性确实用户以及资格
主要根路径下的数据
:param rqData: 请求的数据
:return: body的值
"""
userid = rqData.get("userid", "") # 用户id
version = rqData.get("version", "v1.0") # api版本
uidid = rqData.get("uidid", "qweqrew") # 唯一设备标识符
token = rqData.get("token", "") # token
"""验证数据合法性"""
""""""
body = rqData.get("body", None)
return body
if __name__ == '__main__':
print(ReJson(0, "asdf", "asdf"))

View File

@ -1,29 +0,0 @@
dist/
build/
.git/
__pycache__/
decrypted/
pywxdump.egg-info/
# 忽略.idea目录
.idea/
pysqlcipher3/
# 忽略secret.txt文件
secret.txt
#.gitignore
# 忽略所有的.class文件
*.class
# 忽略所有的.iml文件
*.iml
gitandpypi.cmd
# 忽略test_xaooyaoo_conf.txt文件
test_xaooyaoo_conf.txt
# vue ignore
node_modules
.DS_Store
dist
dist-ssr
*.local

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
{
"name": "wxdump_web",
"version": "0.0.0",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"vue": "^3.0.4"
},
"devDependencies": {
"vite": "^1.0.0-rc.13",
"@vue/compiler-sfc": "^3.0.4"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1,15 +0,0 @@
<template>
<img alt="Vue logo" src="./assets/logo.png" />
<HelloWorld msg="Hello Vue 3.0 + Vite" />
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'App',
components: {
HelloWorld
}
}
</script>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

View File

@ -1,19 +0,0 @@
<template>
<h1>{{ msg }}</h1>
<button @click="count++">count is: {{ count }}</button>
<p>Edit <code>components/HelloWorld.vue</code> to test hot module replacement.</p>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
},
data() {
return {
count: 0
}
}
}
</script>

View File

@ -1,8 +0,0 @@
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}

View File

@ -1,5 +0,0 @@
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
createApp(App).mount('#app')