{"contents":"# -*- coding: utf-8 -*-#\n# -------------------------------------------------------------------------------\n# Name: meta.py\n# Description: 版本、更新检查\n# -------------------------------------------------------------------------------\nfrom fastapi import APIRouter\n\nimport wxdump_linux\nfrom ..response import ReJson\nfrom ..decorators import error9999\n\nmeta_router = APIRouter()\n\n\n@meta_router.api_route('/check_update', methods=[\"GET\", 'POST'])\n@error9999\ndef check_update():\n \"\"\"\n 检查更新\n :return:\n \"\"\"\n url = \"https://api.github.com/repos/xaoyaoo/PyWxDump/tags\"\n try:\n import requests\n res = requests.get(url)\n if res.status_code == 200:\n data = res.json()\n NEW_VERSION = data[0].get(\"name\")\n if NEW_VERSION[1:] != wxdump_linux.__version__:\n msg = \"有新版本\"\n else:\n msg = \"已经是最新版本\"\n return ReJson(0, body={\"msg\": msg, \"latest_version\": NEW_VERSION,\n \"latest_url\": \"https://github.com/xaoyaoo/PyWxDump/releases/tag/\" + NEW_VERSION})\n else:\n return ReJson(2001, body=\"status_code is not 200\")\n except Exception as e:\n return ReJson(9999, msg=str(e))\n\n\n@meta_router.api_route('/version', methods=[\"GET\", \"POST\"])\n@error9999\ndef version():\n \"\"\"\n 版本\n :return:\n \"\"\"\n return ReJson(0, wxdump_linux.__version__)\n\n\n@meta_router.api_route('/get_readme', methods=[\"GET\", 'POST'])\n@error9999\ndef get_readme():\n \"\"\"\n 获取README\n :return:\n \"\"\"\n url = \"https://raw.githubusercontent.com/xaoyaoo/PyWxDump/master/doc/README_CN.md\"\n import requests\n res = requests.get(url)\n if res.status_code == 200:\n data = res.text\n data = data.replace(\"# \u003ccenter\u003ePyWxDump\u003c/center\u003e\", \"\")\n return ReJson(0, body=data)\n else:\n return ReJson(2001, body=\"status_code is not 200\")\n","is_binary":false,"path":"wxdump_linux/api/routes/meta.py","ref":""}