From 686d828bfce46acdd16aeee8246b92c06de71325 Mon Sep 17 00:00:00 2001 From: Tiger Date: Fri, 2 Jan 2026 17:12:24 +0800 Subject: [PATCH 01/14] =?UTF-8?q?dev:=20=E7=BC=96=E5=86=99=E4=BA=86?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B7=AF=E7=94=B1=EF=BC=8C=E7=BB=86=E5=8C=96?= =?UTF-8?q?=E4=BA=86=E9=A1=B9=E7=9B=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + .python-version | 1 + README.md | 101 +++++++++---------------------- app/__init__.py | 12 ++++ app/routes/__init__.py | 0 app/routes/pages.py | 7 +++ app/services/cards.py | 0 app/services/matters.py | 0 app/services/reactions.py | 0 assets/index.json | 3 + cards/list.json | 4 +- config.py | 5 ++ matters/list.json | 3 + pyproject.toml | 9 +++ reactions/list.json | 4 +- run.py | 6 ++ uv.lock | 124 ++++++++++++++++++++++++++++++++++++++ 17 files changed, 204 insertions(+), 78 deletions(-) create mode 100644 .gitignore create mode 100644 .python-version create mode 100644 app/routes/__init__.py create mode 100644 app/routes/pages.py create mode 100644 app/services/cards.py create mode 100644 app/services/matters.py create mode 100644 app/services/reactions.py create mode 100644 config.py create mode 100644 matters/list.json create mode 100644 pyproject.toml create mode 100644 uv.lock diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bd31faf --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.venv/ + +__pycache__ \ No newline at end of file diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..6324d40 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.14 diff --git a/README.md b/README.md index 7f01fbb..bc2e4d9 100644 --- a/README.md +++ b/README.md @@ -1,93 +1,46 @@ # 后端 +## 项目介绍 +## 项目结构 -## Getting started +## 部分文件格式 -To make it easy for you to get started with GitLab, here's a list of recommended next steps. +### list.json -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! +`cards` `matters` 和 `reactions` 下的 `list.json` 有相同的格式。每个文件中都只有一个对象。对象的键的内容均是字符串,代表 ID。对象的值的内容均是字符串,代表对应JSON文件的相对路径,不用加 `.json` 后缀名。例如: -## Add your files - -* [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://git.yearnstudio.cn/paper-chemis-community/backend.git -git branch -M master -git push -uf origin master +```json +{ + "C": "NonMetal/Carbon", + "O": "NonMetal/Oxygen", + "...": "..." +} ``` -## Integrate with your tools +### assets/index.json -* [Set up project integrations](https://git.yearnstudio.cn/paper-chemis-community/backend/-/settings/integrations) +`assets` 目录下的 `index.json` 是资源文件的索引目录文件。该文件的内容是一个对象,每一个键值对对应一个资源文件。键对应的是资源的 ID,值对应的是资源的相对文件路径,不加 `.json` 后缀名。例如: -## Collaborate with your team +```json +{ + "Carbon": "cards/carbon.png", + "Oxygen": "cards/Oxygen.png" +} +``` -* [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -* [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -* [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -* [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/) +## 化学反应格式 -## Test and Deploy +化学反应由三部分构成:反应物、反应条件、生成物。基本格式为 `[反应物ID]+[反应物ID](反应条件ID){生成物ID}`,例如 `[C]+[O](Ignite){CO2}` 表示 $\rm{C+O_2}\xrightarrow{点燃}\rm{CO_2}$ 这个反应。 -Use the built-in continuous integration in GitLab. +其中的反应物 ID、反应物条件 ID、生成物 ID 都是自定义的。也就是说,同一个反应在不同化学源中的表示方式可能不同。 -* [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/) -* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -* [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) +## 技术相关 -*** +本项目采用工厂模式。所有逻辑代码均放置在 `app` 目录下。所有路由均使用蓝图实现。 -# Editing this README +## 最佳实践 -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template. +对于路径和 ID,均应当使用英文字母、下划线和数字,不应当使用包括中文和短横杠在内的其他字符。由此引发的问题后果自负。 -## Suggestions for a good README - -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +所有 JSON 文件中的缩进均应当使用2个或4个空格,而非制表符(`\t`)。 diff --git a/app/__init__.py b/app/__init__.py index e69de29..573e0af 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -0,0 +1,12 @@ +from flask import Flask + + +def create_app(config_class='config.DevelopmentConfig'): + app = Flask(__name__) + app.config.from_object(config_class) + + # 注册蓝图 + from app.routes.pages import page_bp + app.register_blueprint(page_bp) + + return app \ No newline at end of file diff --git a/app/routes/__init__.py b/app/routes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/routes/pages.py b/app/routes/pages.py new file mode 100644 index 0000000..eb1c89f --- /dev/null +++ b/app/routes/pages.py @@ -0,0 +1,7 @@ +from flask import Blueprint, jsonify + +page_bp = Blueprint("page", __name__, "/") + +@page_bp.route("/") +def index(): + return jsonify({"code": "200", "message": "Service normal"}) \ No newline at end of file diff --git a/app/services/cards.py b/app/services/cards.py new file mode 100644 index 0000000..e69de29 diff --git a/app/services/matters.py b/app/services/matters.py new file mode 100644 index 0000000..e69de29 diff --git a/app/services/reactions.py b/app/services/reactions.py new file mode 100644 index 0000000..e69de29 diff --git a/assets/index.json b/assets/index.json index e69de29..544b7b4 100644 --- a/assets/index.json +++ b/assets/index.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/cards/list.json b/cards/list.json index 1610ea1..544b7b4 100644 --- a/cards/list.json +++ b/cards/list.json @@ -1,3 +1,3 @@ -[ +{ -] \ No newline at end of file +} \ No newline at end of file diff --git a/config.py b/config.py new file mode 100644 index 0000000..4712038 --- /dev/null +++ b/config.py @@ -0,0 +1,5 @@ +class Config: + pass + +class DevelopmentConfig(Config): + DEBUG = True \ No newline at end of file diff --git a/matters/list.json b/matters/list.json new file mode 100644 index 0000000..544b7b4 --- /dev/null +++ b/matters/list.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d95365b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[project] +name = "backend" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.14" +dependencies = [ + "flask>=3.1.2", +] diff --git a/reactions/list.json b/reactions/list.json index 1610ea1..544b7b4 100644 --- a/reactions/list.json +++ b/reactions/list.json @@ -1,3 +1,3 @@ -[ +{ -] \ No newline at end of file +} \ No newline at end of file diff --git a/run.py b/run.py index e69de29..12d8ee4 100644 --- a/run.py +++ b/run.py @@ -0,0 +1,6 @@ +from app import create_app + +app = create_app() + +if __name__ == "__main__": + app.run() \ No newline at end of file diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..40a7045 --- /dev/null +++ b/uv.lock @@ -0,0 +1,124 @@ +version = 1 +revision = 2 +requires-python = ">=3.14" + +[[package]] +name = "backend" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "flask" }, +] + +[package.metadata] +requires-dist = [{ name = "flask", specifier = ">=3.1.2" }] + +[[package]] +name = "blinker" +version = "1.9.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/21/28/9b3f50ce0e048515135495f198351908d99540d69bfdc8c1d15b73dc55ce/blinker-1.9.0.tar.gz", hash = "sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf", size = 22460, upload_time = "2024-11-08T17:25:47.436Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/10/cb/f2ad4230dc2eb1a74edf38f1a38b9b52277f75bef262d8908e60d957e13c/blinker-1.9.0-py3-none-any.whl", hash = "sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc", size = 8458, upload_time = "2024-11-08T17:25:46.184Z" }, +] + +[[package]] +name = "click" +version = "8.3.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload_time = "2025-11-15T20:45:42.706Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload_time = "2025-11-15T20:45:41.139Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload_time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload_time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "flask" +version = "3.1.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "blinker" }, + { name = "click" }, + { name = "itsdangerous" }, + { name = "jinja2" }, + { name = "markupsafe" }, + { name = "werkzeug" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/dc/6d/cfe3c0fcc5e477df242b98bfe186a4c34357b4847e87ecaef04507332dab/flask-3.1.2.tar.gz", hash = "sha256:bf656c15c80190ed628ad08cdfd3aaa35beb087855e2f494910aa3774cc4fd87", size = 720160, upload_time = "2025-08-19T21:03:21.205Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ec/f9/7f9263c5695f4bd0023734af91bedb2ff8209e8de6ead162f35d8dc762fd/flask-3.1.2-py3-none-any.whl", hash = "sha256:ca1d8112ec8a6158cc29ea4858963350011b5c846a414cdb7a954aa9e967d03c", size = 103308, upload_time = "2025-08-19T21:03:19.499Z" }, +] + +[[package]] +name = "itsdangerous" +version = "2.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9c/cb/8ac0172223afbccb63986cc25049b154ecfb5e85932587206f42317be31d/itsdangerous-2.2.0.tar.gz", hash = "sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173", size = 54410, upload_time = "2024-04-16T21:28:15.614Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef", size = 16234, upload_time = "2024-04-16T21:28:14.499Z" }, +] + +[[package]] +name = "jinja2" +version = "3.1.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markupsafe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d", size = 245115, upload_time = "2025-03-05T20:05:02.478Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload_time = "2025-03-05T20:05:00.369Z" }, +] + +[[package]] +name = "markupsafe" +version = "3.0.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/7e/99/7690b6d4034fffd95959cbe0c02de8deb3098cc577c67bb6a24fe5d7caa7/markupsafe-3.0.3.tar.gz", hash = "sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698", size = 80313, upload_time = "2025-09-27T18:37:40.426Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/33/8a/8e42d4838cd89b7dde187011e97fe6c3af66d8c044997d2183fbd6d31352/markupsafe-3.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:eaa9599de571d72e2daf60164784109f19978b327a3910d3e9de8c97b5b70cfe", size = 11619, upload_time = "2025-09-27T18:37:06.342Z" }, + { url = "https://files.pythonhosted.org/packages/b5/64/7660f8a4a8e53c924d0fa05dc3a55c9cee10bbd82b11c5afb27d44b096ce/markupsafe-3.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c47a551199eb8eb2121d4f0f15ae0f923d31350ab9280078d1e5f12b249e0026", size = 12029, upload_time = "2025-09-27T18:37:07.213Z" }, + { url = "https://files.pythonhosted.org/packages/da/ef/e648bfd021127bef5fa12e1720ffed0c6cbb8310c8d9bea7266337ff06de/markupsafe-3.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f34c41761022dd093b4b6896d4810782ffbabe30f2d443ff5f083e0cbbb8c737", size = 24408, upload_time = "2025-09-27T18:37:09.572Z" }, + { url = "https://files.pythonhosted.org/packages/41/3c/a36c2450754618e62008bf7435ccb0f88053e07592e6028a34776213d877/markupsafe-3.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:457a69a9577064c05a97c41f4e65148652db078a3a509039e64d3467b9e7ef97", size = 23005, upload_time = "2025-09-27T18:37:10.58Z" }, + { url = "https://files.pythonhosted.org/packages/bc/20/b7fdf89a8456b099837cd1dc21974632a02a999ec9bf7ca3e490aacd98e7/markupsafe-3.0.3-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:e8afc3f2ccfa24215f8cb28dcf43f0113ac3c37c2f0f0806d8c70e4228c5cf4d", size = 22048, upload_time = "2025-09-27T18:37:11.547Z" }, + { url = "https://files.pythonhosted.org/packages/9a/a7/591f592afdc734f47db08a75793a55d7fbcc6902a723ae4cfbab61010cc5/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:ec15a59cf5af7be74194f7ab02d0f59a62bdcf1a537677ce67a2537c9b87fcda", size = 23821, upload_time = "2025-09-27T18:37:12.48Z" }, + { url = "https://files.pythonhosted.org/packages/7d/33/45b24e4f44195b26521bc6f1a82197118f74df348556594bd2262bda1038/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:0eb9ff8191e8498cca014656ae6b8d61f39da5f95b488805da4bb029cccbfbaf", size = 21606, upload_time = "2025-09-27T18:37:13.485Z" }, + { url = "https://files.pythonhosted.org/packages/ff/0e/53dfaca23a69fbfbbf17a4b64072090e70717344c52eaaaa9c5ddff1e5f0/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:2713baf880df847f2bece4230d4d094280f4e67b1e813eec43b4c0e144a34ffe", size = 23043, upload_time = "2025-09-27T18:37:14.408Z" }, + { url = "https://files.pythonhosted.org/packages/46/11/f333a06fc16236d5238bfe74daccbca41459dcd8d1fa952e8fbd5dccfb70/markupsafe-3.0.3-cp314-cp314-win32.whl", hash = "sha256:729586769a26dbceff69f7a7dbbf59ab6572b99d94576a5592625d5b411576b9", size = 14747, upload_time = "2025-09-27T18:37:15.36Z" }, + { url = "https://files.pythonhosted.org/packages/28/52/182836104b33b444e400b14f797212f720cbc9ed6ba34c800639d154e821/markupsafe-3.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:bdc919ead48f234740ad807933cdf545180bfbe9342c2bb451556db2ed958581", size = 15341, upload_time = "2025-09-27T18:37:16.496Z" }, + { url = "https://files.pythonhosted.org/packages/6f/18/acf23e91bd94fd7b3031558b1f013adfa21a8e407a3fdb32745538730382/markupsafe-3.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:5a7d5dc5140555cf21a6fefbdbf8723f06fcd2f63ef108f2854de715e4422cb4", size = 14073, upload_time = "2025-09-27T18:37:17.476Z" }, + { url = "https://files.pythonhosted.org/packages/3c/f0/57689aa4076e1b43b15fdfa646b04653969d50cf30c32a102762be2485da/markupsafe-3.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:1353ef0c1b138e1907ae78e2f6c63ff67501122006b0f9abad68fda5f4ffc6ab", size = 11661, upload_time = "2025-09-27T18:37:18.453Z" }, + { url = "https://files.pythonhosted.org/packages/89/c3/2e67a7ca217c6912985ec766c6393b636fb0c2344443ff9d91404dc4c79f/markupsafe-3.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1085e7fbddd3be5f89cc898938f42c0b3c711fdcb37d75221de2666af647c175", size = 12069, upload_time = "2025-09-27T18:37:19.332Z" }, + { url = "https://files.pythonhosted.org/packages/f0/00/be561dce4e6ca66b15276e184ce4b8aec61fe83662cce2f7d72bd3249d28/markupsafe-3.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1b52b4fb9df4eb9ae465f8d0c228a00624de2334f216f178a995ccdcf82c4634", size = 25670, upload_time = "2025-09-27T18:37:20.245Z" }, + { url = "https://files.pythonhosted.org/packages/50/09/c419f6f5a92e5fadde27efd190eca90f05e1261b10dbd8cbcb39cd8ea1dc/markupsafe-3.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fed51ac40f757d41b7c48425901843666a6677e3e8eb0abcff09e4ba6e664f50", size = 23598, upload_time = "2025-09-27T18:37:21.177Z" }, + { url = "https://files.pythonhosted.org/packages/22/44/a0681611106e0b2921b3033fc19bc53323e0b50bc70cffdd19f7d679bb66/markupsafe-3.0.3-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:f190daf01f13c72eac4efd5c430a8de82489d9cff23c364c3ea822545032993e", size = 23261, upload_time = "2025-09-27T18:37:22.167Z" }, + { url = "https://files.pythonhosted.org/packages/5f/57/1b0b3f100259dc9fffe780cfb60d4be71375510e435efec3d116b6436d43/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:e56b7d45a839a697b5eb268c82a71bd8c7f6c94d6fd50c3d577fa39a9f1409f5", size = 24835, upload_time = "2025-09-27T18:37:23.296Z" }, + { url = "https://files.pythonhosted.org/packages/26/6a/4bf6d0c97c4920f1597cc14dd720705eca0bf7c787aebc6bb4d1bead5388/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:f3e98bb3798ead92273dc0e5fd0f31ade220f59a266ffd8a4f6065e0a3ce0523", size = 22733, upload_time = "2025-09-27T18:37:24.237Z" }, + { url = "https://files.pythonhosted.org/packages/14/c7/ca723101509b518797fedc2fdf79ba57f886b4aca8a7d31857ba3ee8281f/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5678211cb9333a6468fb8d8be0305520aa073f50d17f089b5b4b477ea6e67fdc", size = 23672, upload_time = "2025-09-27T18:37:25.271Z" }, + { url = "https://files.pythonhosted.org/packages/fb/df/5bd7a48c256faecd1d36edc13133e51397e41b73bb77e1a69deab746ebac/markupsafe-3.0.3-cp314-cp314t-win32.whl", hash = "sha256:915c04ba3851909ce68ccc2b8e2cd691618c4dc4c4232fb7982bca3f41fd8c3d", size = 14819, upload_time = "2025-09-27T18:37:26.285Z" }, + { url = "https://files.pythonhosted.org/packages/1a/8a/0402ba61a2f16038b48b39bccca271134be00c5c9f0f623208399333c448/markupsafe-3.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4faffd047e07c38848ce017e8725090413cd80cbc23d86e55c587bf979e579c9", size = 15426, upload_time = "2025-09-27T18:37:27.316Z" }, + { url = "https://files.pythonhosted.org/packages/70/bc/6f1c2f612465f5fa89b95bead1f44dcb607670fd42891d8fdcd5d039f4f4/markupsafe-3.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:32001d6a8fc98c8cb5c947787c5d08b0a50663d139f1305bac5885d98d9b40fa", size = 14146, upload_time = "2025-09-27T18:37:28.327Z" }, +] + +[[package]] +name = "werkzeug" +version = "3.1.4" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "markupsafe" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/45/ea/b0f8eeb287f8df9066e56e831c7824ac6bab645dd6c7a8f4b2d767944f9b/werkzeug-3.1.4.tar.gz", hash = "sha256:cd3cd98b1b92dc3b7b3995038826c68097dcb16f9baa63abe35f20eafeb9fe5e", size = 864687, upload_time = "2025-11-29T02:15:22.841Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2f/f9/9e082990c2585c744734f85bec79b5dae5df9c974ffee58fe421652c8e91/werkzeug-3.1.4-py3-none-any.whl", hash = "sha256:2ad50fb9ed09cc3af22c54698351027ace879a0b60a3b5edf5730b2f7d876905", size = 224960, upload_time = "2025-11-29T02:15:21.13Z" }, +] From 69c7213fdfa81ac6346a6db2999e0ce55b49bc5a Mon Sep 17 00:00:00 2001 From: Tiger Date: Fri, 2 Jan 2026 21:47:28 +0800 Subject: [PATCH 02/14] =?UTF-8?q?dev:=20=E8=BF=9B=E4=B8=80=E6=AD=A5?= =?UTF-8?q?=E7=BB=86=E5=8C=96=E4=BA=86=E9=A1=B9=E7=9B=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/assets.py | 0 app/routes/cards.py | 8 ++++++++ app/routes/reactions.py | 0 app/services/cards.py | 11 +++++++++++ app/services/matters.py | 11 +++++++++++ app/services/reactions.py | 11 +++++++++++ 6 files changed, 41 insertions(+) create mode 100644 app/routes/assets.py create mode 100644 app/routes/cards.py create mode 100644 app/routes/reactions.py diff --git a/app/routes/assets.py b/app/routes/assets.py new file mode 100644 index 0000000..e69de29 diff --git a/app/routes/cards.py b/app/routes/cards.py new file mode 100644 index 0000000..802c275 --- /dev/null +++ b/app/routes/cards.py @@ -0,0 +1,8 @@ +from flask import Blueprint +from ..services import cards + +card_bp = Blueprint("card", __name__, "/card") + +@card_bp.route("/") +def search_card(id): + return cards.readCard(id) \ No newline at end of file diff --git a/app/routes/reactions.py b/app/routes/reactions.py new file mode 100644 index 0000000..e69de29 diff --git a/app/services/cards.py b/app/services/cards.py index e69de29..bc5999f 100644 --- a/app/services/cards.py +++ b/app/services/cards.py @@ -0,0 +1,11 @@ +import json + +def readCardList() -> dict: + with open("cards/list.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return result + +def readCard(id: str): + return readCardList().get(id, -1) \ No newline at end of file diff --git a/app/services/matters.py b/app/services/matters.py index e69de29..0bd4d04 100644 --- a/app/services/matters.py +++ b/app/services/matters.py @@ -0,0 +1,11 @@ +import json + +def readMatterList() -> dict: + with open("matters/list.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return result + +def readMatter(id: str): + return readMatterList().get(id, -1) \ No newline at end of file diff --git a/app/services/reactions.py b/app/services/reactions.py index e69de29..e99a22c 100644 --- a/app/services/reactions.py +++ b/app/services/reactions.py @@ -0,0 +1,11 @@ +import json + +def readReactionList() -> dict: + with open("reactions/list.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return result + +def readReaction(id: str): + return readReactionList().get(id, -1) \ No newline at end of file From b8b7c6e88998f1fbd4dbe2b20be9e53f4f874c14 Mon Sep 17 00:00:00 2001 From: Tiger Date: Sat, 3 Jan 2026 17:19:39 +0800 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20=E5=88=9D=E6=AD=A5=E5=AE=8C?= =?UTF-8?q?=E6=88=90=E4=BA=86=E6=9F=A5=E8=AF=A2=E5=8D=A1=E7=89=87=E7=9A=84?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 3 +++ app/services/cards.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/__init__.py b/app/__init__.py index 573e0af..55c8024 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -8,5 +8,8 @@ def create_app(config_class='config.DevelopmentConfig'): # 注册蓝图 from app.routes.pages import page_bp app.register_blueprint(page_bp) + + from app.routes.cards import card_bp + app.register_blueprint(card_bp) return app \ No newline at end of file diff --git a/app/services/cards.py b/app/services/cards.py index bc5999f..84ad27f 100644 --- a/app/services/cards.py +++ b/app/services/cards.py @@ -8,4 +8,4 @@ def readCardList() -> dict: return result def readCard(id: str): - return readCardList().get(id, -1) \ No newline at end of file + return readCardList().get(id, f"No Card {id}") \ No newline at end of file From 09cbbf9eeaa5f4ecfb607845c1d5a9888d4be2cf Mon Sep 17 00:00:00 2001 From: Tiger Date: Mon, 5 Jan 2026 09:30:43 +0800 Subject: [PATCH 04/14] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E5=8F=8D?= =?UTF-8?q?=E5=BA=94=E5=92=8C=E5=8D=A1=E7=89=8C=E4=BF=A1=E6=81=AF=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=EF=BC=8C=E5=B9=B6=E7=BC=96=E5=86=99=E4=BA=86=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E5=8D=A1=E7=89=8C=E5=92=8C=E5=8F=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 5 ++++- app/routes/reactions.py | 8 ++++++++ app/services/cards.py | 9 ++++++++- app/services/reactions.py | 9 ++++++++- cards/NonMetal/Carbon.json | 8 ++++++++ cards/NonMetal/Oxygen.json | 8 ++++++++ cards/list.json | 3 ++- conditions/Ignite.json | 6 ++++++ config/local.json | 3 --- matters/Compound/Carbon_Dioxide.json | 7 +++++++ matters/NonMetal/Carbon.json | 8 ++++++++ matters/NonMetal/Oxygen.json | 8 ++++++++ matters/list.json | 3 +++ reactions/Oxidation/CarbonDioxide.json | 12 ++++++++++++ reactions/list.json | 2 +- test/test_cards.py | 5 +++++ 16 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 cards/NonMetal/Carbon.json create mode 100644 cards/NonMetal/Oxygen.json create mode 100644 conditions/Ignite.json delete mode 100644 config/local.json create mode 100644 matters/Compound/Carbon_Dioxide.json create mode 100644 matters/NonMetal/Carbon.json create mode 100644 matters/NonMetal/Oxygen.json create mode 100644 reactions/Oxidation/CarbonDioxide.json create mode 100644 test/test_cards.py diff --git a/app/__init__.py b/app/__init__.py index 55c8024..7601292 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -10,6 +10,9 @@ def create_app(config_class='config.DevelopmentConfig'): app.register_blueprint(page_bp) from app.routes.cards import card_bp - app.register_blueprint(card_bp) + app.register_blueprint(card_bp, url_prefix="/card") + + from app.routes.reactions import reaction_bp + app.register_blueprint(reaction_bp, url_prefix="/reaction") return app \ No newline at end of file diff --git a/app/routes/reactions.py b/app/routes/reactions.py index e69de29..e6fedde 100644 --- a/app/routes/reactions.py +++ b/app/routes/reactions.py @@ -0,0 +1,8 @@ +from flask import Blueprint +from ..services import reactions + +reaction_bp = Blueprint("reaction", __name__, "/reaction") + +@reaction_bp.route("/") +def search_card(id): + return reactions.readReaction(id) \ No newline at end of file diff --git a/app/services/cards.py b/app/services/cards.py index 84ad27f..d224b74 100644 --- a/app/services/cards.py +++ b/app/services/cards.py @@ -8,4 +8,11 @@ def readCardList() -> dict: return result def readCard(id: str): - return readCardList().get(id, f"No Card {id}") \ No newline at end of file + path = readCardList().get(id, -1) + if (path == -1): + return {"message": f"No Card {id}"} + with open(f"cards/{path}.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return {"message": "OK", "content": result} \ No newline at end of file diff --git a/app/services/reactions.py b/app/services/reactions.py index e99a22c..ba77511 100644 --- a/app/services/reactions.py +++ b/app/services/reactions.py @@ -8,4 +8,11 @@ def readReactionList() -> dict: return result def readReaction(id: str): - return readReactionList().get(id, -1) \ No newline at end of file + path = readReactionList().get(id, -1) + if (path == -1): + return {"message": f"No Reaction {id}"} + with open(f"reactions/{path}.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return {"message": "OK", "content": result} \ No newline at end of file diff --git a/cards/NonMetal/Carbon.json b/cards/NonMetal/Carbon.json new file mode 100644 index 0000000..116e77f --- /dev/null +++ b/cards/NonMetal/Carbon.json @@ -0,0 +1,8 @@ +{ + "name": { + "en-US": "Carbon", + "zh-CN": "碳" + }, + "number": 6, + "mass": 12 +} \ No newline at end of file diff --git a/cards/NonMetal/Oxygen.json b/cards/NonMetal/Oxygen.json new file mode 100644 index 0000000..0ac441c --- /dev/null +++ b/cards/NonMetal/Oxygen.json @@ -0,0 +1,8 @@ +{ + "name": { + "en-US": "Oxygen", + "zh-CN": "氧" + }, + "number": 8, + "mass": 16 +} \ No newline at end of file diff --git a/cards/list.json b/cards/list.json index 544b7b4..c567560 100644 --- a/cards/list.json +++ b/cards/list.json @@ -1,3 +1,4 @@ { - + "Carbon": "NonMetal/Carbon", + "Oxygen": "NonMetal/Oxygen" } \ No newline at end of file diff --git a/conditions/Ignite.json b/conditions/Ignite.json new file mode 100644 index 0000000..6cdc519 --- /dev/null +++ b/conditions/Ignite.json @@ -0,0 +1,6 @@ +{ + "name": { + "en-US": "Ignite", + "zh-CN": "点燃" + } +} \ No newline at end of file diff --git a/config/local.json b/config/local.json deleted file mode 100644 index 544b7b4..0000000 --- a/config/local.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} \ No newline at end of file diff --git a/matters/Compound/Carbon_Dioxide.json b/matters/Compound/Carbon_Dioxide.json new file mode 100644 index 0000000..b430ccb --- /dev/null +++ b/matters/Compound/Carbon_Dioxide.json @@ -0,0 +1,7 @@ +{ + "name": { + "en-US": "Carbon Dioxide", + "zh-CN": "二氧化碳" + }, + "mass": 44 +} \ No newline at end of file diff --git a/matters/NonMetal/Carbon.json b/matters/NonMetal/Carbon.json new file mode 100644 index 0000000..116e77f --- /dev/null +++ b/matters/NonMetal/Carbon.json @@ -0,0 +1,8 @@ +{ + "name": { + "en-US": "Carbon", + "zh-CN": "碳" + }, + "number": 6, + "mass": 12 +} \ No newline at end of file diff --git a/matters/NonMetal/Oxygen.json b/matters/NonMetal/Oxygen.json new file mode 100644 index 0000000..0ac441c --- /dev/null +++ b/matters/NonMetal/Oxygen.json @@ -0,0 +1,8 @@ +{ + "name": { + "en-US": "Oxygen", + "zh-CN": "氧" + }, + "number": 8, + "mass": 16 +} \ No newline at end of file diff --git a/matters/list.json b/matters/list.json index 544b7b4..429e067 100644 --- a/matters/list.json +++ b/matters/list.json @@ -1,3 +1,6 @@ { + "Carbon": "NonMetal/Carbon", + "Oxygen": "NonMetal/Oxygen", + "Carbon_Dioxide": "Compound/Carbon_Dioxide" } \ No newline at end of file diff --git a/reactions/Oxidation/CarbonDioxide.json b/reactions/Oxidation/CarbonDioxide.json new file mode 100644 index 0000000..70f9f62 --- /dev/null +++ b/reactions/Oxidation/CarbonDioxide.json @@ -0,0 +1,12 @@ +{ + "reactants": [ + "NonMetal/Carbon", + "NonMetal/Oxygen" + ], + "conditions": [ + "Ignite" + ], + "products": [ + "Compound/Carbon_Dioxide" + ] +} \ No newline at end of file diff --git a/reactions/list.json b/reactions/list.json index 544b7b4..9775ae9 100644 --- a/reactions/list.json +++ b/reactions/list.json @@ -1,3 +1,3 @@ { - + "CarbonDioxide": "Oxidation/CarbonDioxide" } \ No newline at end of file diff --git a/test/test_cards.py b/test/test_cards.py new file mode 100644 index 0000000..0bbbca9 --- /dev/null +++ b/test/test_cards.py @@ -0,0 +1,5 @@ +''' +检查卡牌信息,包括: +卡牌列表中的路径是否存在 +卡牌配置文件是否符合规范 +''' \ No newline at end of file From 8810c969c29bf41e21e05c97953e96715d84f2e7 Mon Sep 17 00:00:00 2001 From: Tiger Date: Mon, 5 Jan 2026 09:33:35 +0800 Subject: [PATCH 05/14] =?UTF-8?q?docs:=20=E4=BE=9D=E7=85=A7=E6=96=B0?= =?UTF-8?q?=E7=9A=84=E5=8F=8D=E5=BA=94=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bc2e4d9..b221256 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ ## 化学反应格式 -化学反应由三部分构成:反应物、反应条件、生成物。基本格式为 `[反应物ID]+[反应物ID](反应条件ID){生成物ID}`,例如 `[C]+[O](Ignite){CO2}` 表示 $\rm{C+O_2}\xrightarrow{点燃}\rm{CO_2}$ 这个反应。 +化学反应由三部分构成:反应物、反应条件、生成物。反应物写在 `reactants`,反应条件写在 `conditions`,生成物写在 `products`。 其中的反应物 ID、反应物条件 ID、生成物 ID 都是自定义的。也就是说,同一个反应在不同化学源中的表示方式可能不同。 From 9eb42e8a9d4e02eaf2d8fcb76595b6ee7e7be488 Mon Sep 17 00:00:00 2001 From: Tiger Date: Mon, 5 Jan 2026 13:07:53 +0800 Subject: [PATCH 06/14] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E7=89=A9?= =?UTF-8?q?=E8=B4=A8=E6=9F=A5=E8=AF=A2=EF=BC=8C=E8=B0=83=E6=95=B4=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 3 +++ app/routes/matters.py | 8 ++++++++ app/routes/reactions.py | 2 +- app/services/cards.py | 4 ++-- app/services/matters.py | 11 +++++++++-- app/services/reactions.py | 4 ++-- {assets => resources/assets}/index.json | 0 {cards => resources/cards}/NonMetal/Carbon.json | 0 {cards => resources/cards}/NonMetal/Oxygen.json | 0 {cards => resources/cards}/list.json | 0 {conditions => resources/conditions}/Ignite.json | 0 .../matters}/Compound/Carbon_Dioxide.json | 0 {matters => resources/matters}/NonMetal/Carbon.json | 0 {matters => resources/matters}/NonMetal/Oxygen.json | 0 {matters => resources/matters}/list.json | 0 .../reactions}/Oxidation/CarbonDioxide.json | 0 {reactions => resources/reactions}/list.json | 0 17 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 app/routes/matters.py rename {assets => resources/assets}/index.json (100%) rename {cards => resources/cards}/NonMetal/Carbon.json (100%) rename {cards => resources/cards}/NonMetal/Oxygen.json (100%) rename {cards => resources/cards}/list.json (100%) rename {conditions => resources/conditions}/Ignite.json (100%) rename {matters => resources/matters}/Compound/Carbon_Dioxide.json (100%) rename {matters => resources/matters}/NonMetal/Carbon.json (100%) rename {matters => resources/matters}/NonMetal/Oxygen.json (100%) rename {matters => resources/matters}/list.json (100%) rename {reactions => resources/reactions}/Oxidation/CarbonDioxide.json (100%) rename {reactions => resources/reactions}/list.json (100%) diff --git a/app/__init__.py b/app/__init__.py index 7601292..72ccf38 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -14,5 +14,8 @@ def create_app(config_class='config.DevelopmentConfig'): from app.routes.reactions import reaction_bp app.register_blueprint(reaction_bp, url_prefix="/reaction") + + from app.routes.matters import matter_bp + app.register_blueprint(matter_bp, url_prefix="/matter") return app \ No newline at end of file diff --git a/app/routes/matters.py b/app/routes/matters.py new file mode 100644 index 0000000..bfa13db --- /dev/null +++ b/app/routes/matters.py @@ -0,0 +1,8 @@ +from flask import Blueprint +from ..services import matters + +matter_bp = Blueprint("matter", __name__, "/matter") + +@matter_bp.route("/") +def search_matter(id): + return matters.readMatter(id) \ No newline at end of file diff --git a/app/routes/reactions.py b/app/routes/reactions.py index e6fedde..dee6fab 100644 --- a/app/routes/reactions.py +++ b/app/routes/reactions.py @@ -4,5 +4,5 @@ from ..services import reactions reaction_bp = Blueprint("reaction", __name__, "/reaction") @reaction_bp.route("/") -def search_card(id): +def search_reaction(id): return reactions.readReaction(id) \ No newline at end of file diff --git a/app/services/cards.py b/app/services/cards.py index d224b74..a57f4f9 100644 --- a/app/services/cards.py +++ b/app/services/cards.py @@ -1,7 +1,7 @@ import json def readCardList() -> dict: - with open("cards/list.json", "r", encoding="utf8") as f: + with open("resources/cards/list.json", "r", encoding="utf8") as f: text = f.read() result = json.loads(text) @@ -11,7 +11,7 @@ def readCard(id: str): path = readCardList().get(id, -1) if (path == -1): return {"message": f"No Card {id}"} - with open(f"cards/{path}.json", "r", encoding="utf8") as f: + with open(f"resources/cards/{path}.json", "r", encoding="utf8") as f: text = f.read() result = json.loads(text) diff --git a/app/services/matters.py b/app/services/matters.py index 0bd4d04..6f26ca2 100644 --- a/app/services/matters.py +++ b/app/services/matters.py @@ -1,11 +1,18 @@ import json def readMatterList() -> dict: - with open("matters/list.json", "r", encoding="utf8") as f: + with open("resources/matters/list.json", "r", encoding="utf8") as f: text = f.read() result = json.loads(text) return result def readMatter(id: str): - return readMatterList().get(id, -1) \ No newline at end of file + path = readMatterList().get(id, -1) + if (path == -1): + return {"message": f"No Matter {id}"} + with open(f"resources/matters/{path}.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return {"message": "OK", "content": result} \ No newline at end of file diff --git a/app/services/reactions.py b/app/services/reactions.py index ba77511..9762efb 100644 --- a/app/services/reactions.py +++ b/app/services/reactions.py @@ -1,7 +1,7 @@ import json def readReactionList() -> dict: - with open("reactions/list.json", "r", encoding="utf8") as f: + with open("resources/reactions/list.json", "r", encoding="utf8") as f: text = f.read() result = json.loads(text) @@ -11,7 +11,7 @@ def readReaction(id: str): path = readReactionList().get(id, -1) if (path == -1): return {"message": f"No Reaction {id}"} - with open(f"reactions/{path}.json", "r", encoding="utf8") as f: + with open(f"resources/reactions/{path}.json", "r", encoding="utf8") as f: text = f.read() result = json.loads(text) diff --git a/assets/index.json b/resources/assets/index.json similarity index 100% rename from assets/index.json rename to resources/assets/index.json diff --git a/cards/NonMetal/Carbon.json b/resources/cards/NonMetal/Carbon.json similarity index 100% rename from cards/NonMetal/Carbon.json rename to resources/cards/NonMetal/Carbon.json diff --git a/cards/NonMetal/Oxygen.json b/resources/cards/NonMetal/Oxygen.json similarity index 100% rename from cards/NonMetal/Oxygen.json rename to resources/cards/NonMetal/Oxygen.json diff --git a/cards/list.json b/resources/cards/list.json similarity index 100% rename from cards/list.json rename to resources/cards/list.json diff --git a/conditions/Ignite.json b/resources/conditions/Ignite.json similarity index 100% rename from conditions/Ignite.json rename to resources/conditions/Ignite.json diff --git a/matters/Compound/Carbon_Dioxide.json b/resources/matters/Compound/Carbon_Dioxide.json similarity index 100% rename from matters/Compound/Carbon_Dioxide.json rename to resources/matters/Compound/Carbon_Dioxide.json diff --git a/matters/NonMetal/Carbon.json b/resources/matters/NonMetal/Carbon.json similarity index 100% rename from matters/NonMetal/Carbon.json rename to resources/matters/NonMetal/Carbon.json diff --git a/matters/NonMetal/Oxygen.json b/resources/matters/NonMetal/Oxygen.json similarity index 100% rename from matters/NonMetal/Oxygen.json rename to resources/matters/NonMetal/Oxygen.json diff --git a/matters/list.json b/resources/matters/list.json similarity index 100% rename from matters/list.json rename to resources/matters/list.json diff --git a/reactions/Oxidation/CarbonDioxide.json b/resources/reactions/Oxidation/CarbonDioxide.json similarity index 100% rename from reactions/Oxidation/CarbonDioxide.json rename to resources/reactions/Oxidation/CarbonDioxide.json diff --git a/reactions/list.json b/resources/reactions/list.json similarity index 100% rename from reactions/list.json rename to resources/reactions/list.json From ca33fd05782f6d910aa94cc412cda88f79d38094 Mon Sep 17 00:00:00 2001 From: Tiger Date: Sun, 11 Jan 2026 16:29:12 +0800 Subject: [PATCH 07/14] =?UTF-8?q?dev:=20=E5=88=9B=E5=BB=BA=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=B4=A2=E5=BC=95=E6=96=87=E4=BB=B6=E5=92=8C=E8=AF=BB?= =?UTF-8?q?=E5=8F=96=E8=84=9A=E6=9C=AC=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/assets.py | 0 resources/assets/index.json | 7 ++++++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 app/services/assets.py diff --git a/app/services/assets.py b/app/services/assets.py new file mode 100644 index 0000000..e69de29 diff --git a/resources/assets/index.json b/resources/assets/index.json index 544b7b4..5a6e25a 100644 --- a/resources/assets/index.json +++ b/resources/assets/index.json @@ -1,3 +1,8 @@ { - + "pics": { + + }, + "sounds": { + + } } \ No newline at end of file From dc695030d6fd5e2afd251b9621341666821b1242 Mon Sep 17 00:00:00 2001 From: Tiger Date: Tue, 20 Jan 2026 08:45:50 +0800 Subject: [PATCH 08/14] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E6=8C=89?= =?UTF-8?q?=E7=89=A9=E8=B4=A8=E5=8C=B9=E9=85=8D=E5=8F=8D=E5=BA=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/cards.py | 4 ++-- app/routes/matters.py | 10 +++++++--- app/routes/reactions.py | 4 ++-- app/services/__init__.py | 0 app/{services => utils}/assets.py | 0 app/{services => utils}/cards.py | 0 app/{services => utils}/matters.py | 16 +++++++++++++++- app/{services => utils}/reactions.py | 0 resources/reactions/match.json | 3 +++ 9 files changed, 29 insertions(+), 8 deletions(-) delete mode 100644 app/services/__init__.py rename app/{services => utils}/assets.py (100%) rename app/{services => utils}/cards.py (100%) rename app/{services => utils}/matters.py (53%) rename app/{services => utils}/reactions.py (100%) create mode 100644 resources/reactions/match.json diff --git a/app/routes/cards.py b/app/routes/cards.py index 802c275..db11aee 100644 --- a/app/routes/cards.py +++ b/app/routes/cards.py @@ -1,8 +1,8 @@ from flask import Blueprint -from ..services import cards +from ..utils import cards card_bp = Blueprint("card", __name__, "/card") -@card_bp.route("/") +@card_bp.route("/id/") def search_card(id): return cards.readCard(id) \ No newline at end of file diff --git a/app/routes/matters.py b/app/routes/matters.py index bfa13db..1edc06e 100644 --- a/app/routes/matters.py +++ b/app/routes/matters.py @@ -1,8 +1,12 @@ from flask import Blueprint -from ..services import matters +from ..utils import matters matter_bp = Blueprint("matter", __name__, "/matter") -@matter_bp.route("/") +@matter_bp.route("/id/") def search_matter(id): - return matters.readMatter(id) \ No newline at end of file + return matters.readMatter(id) + +@matter_bp.route("/match/") +def select_matter(id): + return id \ No newline at end of file diff --git a/app/routes/reactions.py b/app/routes/reactions.py index dee6fab..4579a27 100644 --- a/app/routes/reactions.py +++ b/app/routes/reactions.py @@ -1,8 +1,8 @@ from flask import Blueprint -from ..services import reactions +from ..utils import reactions reaction_bp = Blueprint("reaction", __name__, "/reaction") -@reaction_bp.route("/") +@reaction_bp.route("/id/") def search_reaction(id): return reactions.readReaction(id) \ No newline at end of file diff --git a/app/services/__init__.py b/app/services/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/app/services/assets.py b/app/utils/assets.py similarity index 100% rename from app/services/assets.py rename to app/utils/assets.py diff --git a/app/services/cards.py b/app/utils/cards.py similarity index 100% rename from app/services/cards.py rename to app/utils/cards.py diff --git a/app/services/matters.py b/app/utils/matters.py similarity index 53% rename from app/services/matters.py rename to app/utils/matters.py index 6f26ca2..4cac723 100644 --- a/app/services/matters.py +++ b/app/utils/matters.py @@ -7,6 +7,13 @@ def readMatterList() -> dict: return result +def readMatchList() -> dict: + with open("resources/reactions/match.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return result + def readMatter(id: str): path = readMatterList().get(id, -1) if (path == -1): @@ -15,4 +22,11 @@ def readMatter(id: str): text = f.read() result = json.loads(text) - return {"message": "OK", "content": result} \ No newline at end of file + return {"message": "OK", "content": result} + +def selectMatter(id: str): + matter_id = readMatchList().get(id, -1) + if (matter_id == -1): + return {"message": f"No Matter {id}"} + + return readMatter(matter_id) \ No newline at end of file diff --git a/app/services/reactions.py b/app/utils/reactions.py similarity index 100% rename from app/services/reactions.py rename to app/utils/reactions.py diff --git a/resources/reactions/match.json b/resources/reactions/match.json new file mode 100644 index 0000000..9bc2f02 --- /dev/null +++ b/resources/reactions/match.json @@ -0,0 +1,3 @@ +{ + "Carbon-Oxygen-": "CarbonDioxide" +} \ No newline at end of file From 70574c8a77aca43deaa7d299ae0ad6d09f5509f5 Mon Sep 17 00:00:00 2001 From: Tiger Date: Tue, 20 Jan 2026 08:51:44 +0800 Subject: [PATCH 09/14] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0run.py=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E5=BC=80=E5=8F=91=E8=80=85=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 3 +- run.py | 10 +++++- uv.lock | 90 ++++++++++++++++++++++++------------------------- 3 files changed, 55 insertions(+), 48 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 72ccf38..7c28da0 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -1,7 +1,6 @@ from flask import Flask - -def create_app(config_class='config.DevelopmentConfig'): +def create_app(config_class='config.Config'): app = Flask(__name__) app.config.from_object(config_class) diff --git a/run.py b/run.py index 12d8ee4..f2b713d 100644 --- a/run.py +++ b/run.py @@ -1,6 +1,14 @@ +import argparse from app import create_app -app = create_app() +parser = argparse.ArgumentParser(description="纸片化学社区版数据后端服务器") +parser.add_argument("--develop", type=int, default=0, help="开启开发者模式") +args = parser.parse_args() + +if args.develop: + app = create_app(config_class="config.DevelopmentConfig") +else: + app = create_app(config_class="config.Config") if __name__ == "__main__": app.run() \ No newline at end of file diff --git a/uv.lock b/uv.lock index 40a7045..cc26f68 100644 --- a/uv.lock +++ b/uv.lock @@ -16,37 +16,37 @@ requires-dist = [{ name = "flask", specifier = ">=3.1.2" }] [[package]] name = "blinker" version = "1.9.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/21/28/9b3f50ce0e048515135495f198351908d99540d69bfdc8c1d15b73dc55ce/blinker-1.9.0.tar.gz", hash = "sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf", size = 22460, upload_time = "2024-11-08T17:25:47.436Z" } +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/21/28/9b3f50ce0e048515135495f198351908d99540d69bfdc8c1d15b73dc55ce/blinker-1.9.0.tar.gz", hash = "sha256:b4ce2265a7abece45e7cc896e98dbebe6cead56bcf805a3d23136d145f5445bf", size = 22460, upload_time = "2024-11-08T17:25:47.436Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/10/cb/f2ad4230dc2eb1a74edf38f1a38b9b52277f75bef262d8908e60d957e13c/blinker-1.9.0-py3-none-any.whl", hash = "sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc", size = 8458, upload_time = "2024-11-08T17:25:46.184Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/10/cb/f2ad4230dc2eb1a74edf38f1a38b9b52277f75bef262d8908e60d957e13c/blinker-1.9.0-py3-none-any.whl", hash = "sha256:ba0efaa9080b619ff2f3459d1d500c57bddea4a6b424b60a91141db6fd2f08bc", size = 8458, upload_time = "2024-11-08T17:25:46.184Z" }, ] [[package]] name = "click" version = "8.3.1" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } dependencies = [ { name = "colorama", marker = "sys_platform == 'win32'" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload_time = "2025-11-15T20:45:42.706Z" } +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload_time = "2025-11-15T20:45:42.706Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload_time = "2025-11-15T20:45:41.139Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload_time = "2025-11-15T20:45:41.139Z" }, ] [[package]] name = "colorama" version = "0.4.6" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload_time = "2022-10-25T02:36:22.414Z" } +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload_time = "2022-10-25T02:36:22.414Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload_time = "2022-10-25T02:36:20.889Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload_time = "2022-10-25T02:36:20.889Z" }, ] [[package]] name = "flask" version = "3.1.2" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } dependencies = [ { name = "blinker" }, { name = "click" }, @@ -55,70 +55,70 @@ dependencies = [ { name = "markupsafe" }, { name = "werkzeug" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/dc/6d/cfe3c0fcc5e477df242b98bfe186a4c34357b4847e87ecaef04507332dab/flask-3.1.2.tar.gz", hash = "sha256:bf656c15c80190ed628ad08cdfd3aaa35beb087855e2f494910aa3774cc4fd87", size = 720160, upload_time = "2025-08-19T21:03:21.205Z" } +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/dc/6d/cfe3c0fcc5e477df242b98bfe186a4c34357b4847e87ecaef04507332dab/flask-3.1.2.tar.gz", hash = "sha256:bf656c15c80190ed628ad08cdfd3aaa35beb087855e2f494910aa3774cc4fd87", size = 720160, upload_time = "2025-08-19T21:03:21.205Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/ec/f9/7f9263c5695f4bd0023734af91bedb2ff8209e8de6ead162f35d8dc762fd/flask-3.1.2-py3-none-any.whl", hash = "sha256:ca1d8112ec8a6158cc29ea4858963350011b5c846a414cdb7a954aa9e967d03c", size = 103308, upload_time = "2025-08-19T21:03:19.499Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/ec/f9/7f9263c5695f4bd0023734af91bedb2ff8209e8de6ead162f35d8dc762fd/flask-3.1.2-py3-none-any.whl", hash = "sha256:ca1d8112ec8a6158cc29ea4858963350011b5c846a414cdb7a954aa9e967d03c", size = 103308, upload_time = "2025-08-19T21:03:19.499Z" }, ] [[package]] name = "itsdangerous" version = "2.2.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/9c/cb/8ac0172223afbccb63986cc25049b154ecfb5e85932587206f42317be31d/itsdangerous-2.2.0.tar.gz", hash = "sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173", size = 54410, upload_time = "2024-04-16T21:28:15.614Z" } +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/9c/cb/8ac0172223afbccb63986cc25049b154ecfb5e85932587206f42317be31d/itsdangerous-2.2.0.tar.gz", hash = "sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173", size = 54410, upload_time = "2024-04-16T21:28:15.614Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef", size = 16234, upload_time = "2024-04-16T21:28:14.499Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef", size = 16234, upload_time = "2024-04-16T21:28:14.499Z" }, ] [[package]] name = "jinja2" version = "3.1.6" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } dependencies = [ { name = "markupsafe" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d", size = 245115, upload_time = "2025-03-05T20:05:02.478Z" } +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz", hash = "sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d", size = 245115, upload_time = "2025-03-05T20:05:02.478Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload_time = "2025-03-05T20:05:00.369Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl", hash = "sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67", size = 134899, upload_time = "2025-03-05T20:05:00.369Z" }, ] [[package]] name = "markupsafe" version = "3.0.3" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/7e/99/7690b6d4034fffd95959cbe0c02de8deb3098cc577c67bb6a24fe5d7caa7/markupsafe-3.0.3.tar.gz", hash = "sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698", size = 80313, upload_time = "2025-09-27T18:37:40.426Z" } +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/7e/99/7690b6d4034fffd95959cbe0c02de8deb3098cc577c67bb6a24fe5d7caa7/markupsafe-3.0.3.tar.gz", hash = "sha256:722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698", size = 80313, upload_time = "2025-09-27T18:37:40.426Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/33/8a/8e42d4838cd89b7dde187011e97fe6c3af66d8c044997d2183fbd6d31352/markupsafe-3.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:eaa9599de571d72e2daf60164784109f19978b327a3910d3e9de8c97b5b70cfe", size = 11619, upload_time = "2025-09-27T18:37:06.342Z" }, - { url = "https://files.pythonhosted.org/packages/b5/64/7660f8a4a8e53c924d0fa05dc3a55c9cee10bbd82b11c5afb27d44b096ce/markupsafe-3.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c47a551199eb8eb2121d4f0f15ae0f923d31350ab9280078d1e5f12b249e0026", size = 12029, upload_time = "2025-09-27T18:37:07.213Z" }, - { url = "https://files.pythonhosted.org/packages/da/ef/e648bfd021127bef5fa12e1720ffed0c6cbb8310c8d9bea7266337ff06de/markupsafe-3.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f34c41761022dd093b4b6896d4810782ffbabe30f2d443ff5f083e0cbbb8c737", size = 24408, upload_time = "2025-09-27T18:37:09.572Z" }, - { url = "https://files.pythonhosted.org/packages/41/3c/a36c2450754618e62008bf7435ccb0f88053e07592e6028a34776213d877/markupsafe-3.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:457a69a9577064c05a97c41f4e65148652db078a3a509039e64d3467b9e7ef97", size = 23005, upload_time = "2025-09-27T18:37:10.58Z" }, - { url = "https://files.pythonhosted.org/packages/bc/20/b7fdf89a8456b099837cd1dc21974632a02a999ec9bf7ca3e490aacd98e7/markupsafe-3.0.3-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:e8afc3f2ccfa24215f8cb28dcf43f0113ac3c37c2f0f0806d8c70e4228c5cf4d", size = 22048, upload_time = "2025-09-27T18:37:11.547Z" }, - { url = "https://files.pythonhosted.org/packages/9a/a7/591f592afdc734f47db08a75793a55d7fbcc6902a723ae4cfbab61010cc5/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:ec15a59cf5af7be74194f7ab02d0f59a62bdcf1a537677ce67a2537c9b87fcda", size = 23821, upload_time = "2025-09-27T18:37:12.48Z" }, - { url = "https://files.pythonhosted.org/packages/7d/33/45b24e4f44195b26521bc6f1a82197118f74df348556594bd2262bda1038/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:0eb9ff8191e8498cca014656ae6b8d61f39da5f95b488805da4bb029cccbfbaf", size = 21606, upload_time = "2025-09-27T18:37:13.485Z" }, - { url = "https://files.pythonhosted.org/packages/ff/0e/53dfaca23a69fbfbbf17a4b64072090e70717344c52eaaaa9c5ddff1e5f0/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:2713baf880df847f2bece4230d4d094280f4e67b1e813eec43b4c0e144a34ffe", size = 23043, upload_time = "2025-09-27T18:37:14.408Z" }, - { url = "https://files.pythonhosted.org/packages/46/11/f333a06fc16236d5238bfe74daccbca41459dcd8d1fa952e8fbd5dccfb70/markupsafe-3.0.3-cp314-cp314-win32.whl", hash = "sha256:729586769a26dbceff69f7a7dbbf59ab6572b99d94576a5592625d5b411576b9", size = 14747, upload_time = "2025-09-27T18:37:15.36Z" }, - { url = "https://files.pythonhosted.org/packages/28/52/182836104b33b444e400b14f797212f720cbc9ed6ba34c800639d154e821/markupsafe-3.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:bdc919ead48f234740ad807933cdf545180bfbe9342c2bb451556db2ed958581", size = 15341, upload_time = "2025-09-27T18:37:16.496Z" }, - { url = "https://files.pythonhosted.org/packages/6f/18/acf23e91bd94fd7b3031558b1f013adfa21a8e407a3fdb32745538730382/markupsafe-3.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:5a7d5dc5140555cf21a6fefbdbf8723f06fcd2f63ef108f2854de715e4422cb4", size = 14073, upload_time = "2025-09-27T18:37:17.476Z" }, - { url = "https://files.pythonhosted.org/packages/3c/f0/57689aa4076e1b43b15fdfa646b04653969d50cf30c32a102762be2485da/markupsafe-3.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:1353ef0c1b138e1907ae78e2f6c63ff67501122006b0f9abad68fda5f4ffc6ab", size = 11661, upload_time = "2025-09-27T18:37:18.453Z" }, - { url = "https://files.pythonhosted.org/packages/89/c3/2e67a7ca217c6912985ec766c6393b636fb0c2344443ff9d91404dc4c79f/markupsafe-3.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1085e7fbddd3be5f89cc898938f42c0b3c711fdcb37d75221de2666af647c175", size = 12069, upload_time = "2025-09-27T18:37:19.332Z" }, - { url = "https://files.pythonhosted.org/packages/f0/00/be561dce4e6ca66b15276e184ce4b8aec61fe83662cce2f7d72bd3249d28/markupsafe-3.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1b52b4fb9df4eb9ae465f8d0c228a00624de2334f216f178a995ccdcf82c4634", size = 25670, upload_time = "2025-09-27T18:37:20.245Z" }, - { url = "https://files.pythonhosted.org/packages/50/09/c419f6f5a92e5fadde27efd190eca90f05e1261b10dbd8cbcb39cd8ea1dc/markupsafe-3.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fed51ac40f757d41b7c48425901843666a6677e3e8eb0abcff09e4ba6e664f50", size = 23598, upload_time = "2025-09-27T18:37:21.177Z" }, - { url = "https://files.pythonhosted.org/packages/22/44/a0681611106e0b2921b3033fc19bc53323e0b50bc70cffdd19f7d679bb66/markupsafe-3.0.3-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:f190daf01f13c72eac4efd5c430a8de82489d9cff23c364c3ea822545032993e", size = 23261, upload_time = "2025-09-27T18:37:22.167Z" }, - { url = "https://files.pythonhosted.org/packages/5f/57/1b0b3f100259dc9fffe780cfb60d4be71375510e435efec3d116b6436d43/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:e56b7d45a839a697b5eb268c82a71bd8c7f6c94d6fd50c3d577fa39a9f1409f5", size = 24835, upload_time = "2025-09-27T18:37:23.296Z" }, - { url = "https://files.pythonhosted.org/packages/26/6a/4bf6d0c97c4920f1597cc14dd720705eca0bf7c787aebc6bb4d1bead5388/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:f3e98bb3798ead92273dc0e5fd0f31ade220f59a266ffd8a4f6065e0a3ce0523", size = 22733, upload_time = "2025-09-27T18:37:24.237Z" }, - { url = "https://files.pythonhosted.org/packages/14/c7/ca723101509b518797fedc2fdf79ba57f886b4aca8a7d31857ba3ee8281f/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5678211cb9333a6468fb8d8be0305520aa073f50d17f089b5b4b477ea6e67fdc", size = 23672, upload_time = "2025-09-27T18:37:25.271Z" }, - { url = "https://files.pythonhosted.org/packages/fb/df/5bd7a48c256faecd1d36edc13133e51397e41b73bb77e1a69deab746ebac/markupsafe-3.0.3-cp314-cp314t-win32.whl", hash = "sha256:915c04ba3851909ce68ccc2b8e2cd691618c4dc4c4232fb7982bca3f41fd8c3d", size = 14819, upload_time = "2025-09-27T18:37:26.285Z" }, - { url = "https://files.pythonhosted.org/packages/1a/8a/0402ba61a2f16038b48b39bccca271134be00c5c9f0f623208399333c448/markupsafe-3.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4faffd047e07c38848ce017e8725090413cd80cbc23d86e55c587bf979e579c9", size = 15426, upload_time = "2025-09-27T18:37:27.316Z" }, - { url = "https://files.pythonhosted.org/packages/70/bc/6f1c2f612465f5fa89b95bead1f44dcb607670fd42891d8fdcd5d039f4f4/markupsafe-3.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:32001d6a8fc98c8cb5c947787c5d08b0a50663d139f1305bac5885d98d9b40fa", size = 14146, upload_time = "2025-09-27T18:37:28.327Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/33/8a/8e42d4838cd89b7dde187011e97fe6c3af66d8c044997d2183fbd6d31352/markupsafe-3.0.3-cp314-cp314-macosx_10_13_x86_64.whl", hash = "sha256:eaa9599de571d72e2daf60164784109f19978b327a3910d3e9de8c97b5b70cfe", size = 11619, upload_time = "2025-09-27T18:37:06.342Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/b5/64/7660f8a4a8e53c924d0fa05dc3a55c9cee10bbd82b11c5afb27d44b096ce/markupsafe-3.0.3-cp314-cp314-macosx_11_0_arm64.whl", hash = "sha256:c47a551199eb8eb2121d4f0f15ae0f923d31350ab9280078d1e5f12b249e0026", size = 12029, upload_time = "2025-09-27T18:37:07.213Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/da/ef/e648bfd021127bef5fa12e1720ffed0c6cbb8310c8d9bea7266337ff06de/markupsafe-3.0.3-cp314-cp314-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:f34c41761022dd093b4b6896d4810782ffbabe30f2d443ff5f083e0cbbb8c737", size = 24408, upload_time = "2025-09-27T18:37:09.572Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/41/3c/a36c2450754618e62008bf7435ccb0f88053e07592e6028a34776213d877/markupsafe-3.0.3-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:457a69a9577064c05a97c41f4e65148652db078a3a509039e64d3467b9e7ef97", size = 23005, upload_time = "2025-09-27T18:37:10.58Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/bc/20/b7fdf89a8456b099837cd1dc21974632a02a999ec9bf7ca3e490aacd98e7/markupsafe-3.0.3-cp314-cp314-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:e8afc3f2ccfa24215f8cb28dcf43f0113ac3c37c2f0f0806d8c70e4228c5cf4d", size = 22048, upload_time = "2025-09-27T18:37:11.547Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/9a/a7/591f592afdc734f47db08a75793a55d7fbcc6902a723ae4cfbab61010cc5/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_aarch64.whl", hash = "sha256:ec15a59cf5af7be74194f7ab02d0f59a62bdcf1a537677ce67a2537c9b87fcda", size = 23821, upload_time = "2025-09-27T18:37:12.48Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/7d/33/45b24e4f44195b26521bc6f1a82197118f74df348556594bd2262bda1038/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_riscv64.whl", hash = "sha256:0eb9ff8191e8498cca014656ae6b8d61f39da5f95b488805da4bb029cccbfbaf", size = 21606, upload_time = "2025-09-27T18:37:13.485Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/ff/0e/53dfaca23a69fbfbbf17a4b64072090e70717344c52eaaaa9c5ddff1e5f0/markupsafe-3.0.3-cp314-cp314-musllinux_1_2_x86_64.whl", hash = "sha256:2713baf880df847f2bece4230d4d094280f4e67b1e813eec43b4c0e144a34ffe", size = 23043, upload_time = "2025-09-27T18:37:14.408Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/46/11/f333a06fc16236d5238bfe74daccbca41459dcd8d1fa952e8fbd5dccfb70/markupsafe-3.0.3-cp314-cp314-win32.whl", hash = "sha256:729586769a26dbceff69f7a7dbbf59ab6572b99d94576a5592625d5b411576b9", size = 14747, upload_time = "2025-09-27T18:37:15.36Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/28/52/182836104b33b444e400b14f797212f720cbc9ed6ba34c800639d154e821/markupsafe-3.0.3-cp314-cp314-win_amd64.whl", hash = "sha256:bdc919ead48f234740ad807933cdf545180bfbe9342c2bb451556db2ed958581", size = 15341, upload_time = "2025-09-27T18:37:16.496Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/6f/18/acf23e91bd94fd7b3031558b1f013adfa21a8e407a3fdb32745538730382/markupsafe-3.0.3-cp314-cp314-win_arm64.whl", hash = "sha256:5a7d5dc5140555cf21a6fefbdbf8723f06fcd2f63ef108f2854de715e4422cb4", size = 14073, upload_time = "2025-09-27T18:37:17.476Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/3c/f0/57689aa4076e1b43b15fdfa646b04653969d50cf30c32a102762be2485da/markupsafe-3.0.3-cp314-cp314t-macosx_10_13_x86_64.whl", hash = "sha256:1353ef0c1b138e1907ae78e2f6c63ff67501122006b0f9abad68fda5f4ffc6ab", size = 11661, upload_time = "2025-09-27T18:37:18.453Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/89/c3/2e67a7ca217c6912985ec766c6393b636fb0c2344443ff9d91404dc4c79f/markupsafe-3.0.3-cp314-cp314t-macosx_11_0_arm64.whl", hash = "sha256:1085e7fbddd3be5f89cc898938f42c0b3c711fdcb37d75221de2666af647c175", size = 12069, upload_time = "2025-09-27T18:37:19.332Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/f0/00/be561dce4e6ca66b15276e184ce4b8aec61fe83662cce2f7d72bd3249d28/markupsafe-3.0.3-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:1b52b4fb9df4eb9ae465f8d0c228a00624de2334f216f178a995ccdcf82c4634", size = 25670, upload_time = "2025-09-27T18:37:20.245Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/50/09/c419f6f5a92e5fadde27efd190eca90f05e1261b10dbd8cbcb39cd8ea1dc/markupsafe-3.0.3-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:fed51ac40f757d41b7c48425901843666a6677e3e8eb0abcff09e4ba6e664f50", size = 23598, upload_time = "2025-09-27T18:37:21.177Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/22/44/a0681611106e0b2921b3033fc19bc53323e0b50bc70cffdd19f7d679bb66/markupsafe-3.0.3-cp314-cp314t-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:f190daf01f13c72eac4efd5c430a8de82489d9cff23c364c3ea822545032993e", size = 23261, upload_time = "2025-09-27T18:37:22.167Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/5f/57/1b0b3f100259dc9fffe780cfb60d4be71375510e435efec3d116b6436d43/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_aarch64.whl", hash = "sha256:e56b7d45a839a697b5eb268c82a71bd8c7f6c94d6fd50c3d577fa39a9f1409f5", size = 24835, upload_time = "2025-09-27T18:37:23.296Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/26/6a/4bf6d0c97c4920f1597cc14dd720705eca0bf7c787aebc6bb4d1bead5388/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_riscv64.whl", hash = "sha256:f3e98bb3798ead92273dc0e5fd0f31ade220f59a266ffd8a4f6065e0a3ce0523", size = 22733, upload_time = "2025-09-27T18:37:24.237Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/14/c7/ca723101509b518797fedc2fdf79ba57f886b4aca8a7d31857ba3ee8281f/markupsafe-3.0.3-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:5678211cb9333a6468fb8d8be0305520aa073f50d17f089b5b4b477ea6e67fdc", size = 23672, upload_time = "2025-09-27T18:37:25.271Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/fb/df/5bd7a48c256faecd1d36edc13133e51397e41b73bb77e1a69deab746ebac/markupsafe-3.0.3-cp314-cp314t-win32.whl", hash = "sha256:915c04ba3851909ce68ccc2b8e2cd691618c4dc4c4232fb7982bca3f41fd8c3d", size = 14819, upload_time = "2025-09-27T18:37:26.285Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/1a/8a/0402ba61a2f16038b48b39bccca271134be00c5c9f0f623208399333c448/markupsafe-3.0.3-cp314-cp314t-win_amd64.whl", hash = "sha256:4faffd047e07c38848ce017e8725090413cd80cbc23d86e55c587bf979e579c9", size = 15426, upload_time = "2025-09-27T18:37:27.316Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/70/bc/6f1c2f612465f5fa89b95bead1f44dcb607670fd42891d8fdcd5d039f4f4/markupsafe-3.0.3-cp314-cp314t-win_arm64.whl", hash = "sha256:32001d6a8fc98c8cb5c947787c5d08b0a50663d139f1305bac5885d98d9b40fa", size = 14146, upload_time = "2025-09-27T18:37:28.327Z" }, ] [[package]] name = "werkzeug" version = "3.1.4" -source = { registry = "https://pypi.org/simple" } +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } dependencies = [ { name = "markupsafe" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/45/ea/b0f8eeb287f8df9066e56e831c7824ac6bab645dd6c7a8f4b2d767944f9b/werkzeug-3.1.4.tar.gz", hash = "sha256:cd3cd98b1b92dc3b7b3995038826c68097dcb16f9baa63abe35f20eafeb9fe5e", size = 864687, upload_time = "2025-11-29T02:15:22.841Z" } +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/45/ea/b0f8eeb287f8df9066e56e831c7824ac6bab645dd6c7a8f4b2d767944f9b/werkzeug-3.1.4.tar.gz", hash = "sha256:cd3cd98b1b92dc3b7b3995038826c68097dcb16f9baa63abe35f20eafeb9fe5e", size = 864687, upload_time = "2025-11-29T02:15:22.841Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/2f/f9/9e082990c2585c744734f85bec79b5dae5df9c974ffee58fe421652c8e91/werkzeug-3.1.4-py3-none-any.whl", hash = "sha256:2ad50fb9ed09cc3af22c54698351027ace879a0b60a3b5edf5730b2f7d876905", size = 224960, upload_time = "2025-11-29T02:15:21.13Z" }, + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/2f/f9/9e082990c2585c744734f85bec79b5dae5df9c974ffee58fe421652c8e91/werkzeug-3.1.4-py3-none-any.whl", hash = "sha256:2ad50fb9ed09cc3af22c54698351027ace879a0b60a3b5edf5730b2f7d876905", size = 224960, upload_time = "2025-11-29T02:15:21.13Z" }, ] From 9dce8988b3874fcdd12aec90126f532570952ec5 Mon Sep 17 00:00:00 2001 From: Tiger Date: Tue, 20 Jan 2026 09:34:24 +0800 Subject: [PATCH 10/14] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E8=B5=84?= =?UTF-8?q?=E6=BA=90(=E5=9B=BE=E7=89=87=E3=80=81=E9=9F=B3=E9=A2=91)?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=EF=BC=8C=E5=AE=8C=E5=96=84README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 69 +++++++++++++++++++++++++++---- app/__init__.py | 3 ++ app/routes/assets.py | 14 +++++++ app/utils/assets.py | 16 +++++++ app/utils/cards.py | 4 +- app/utils/matters.py | 7 +++- app/utils/reactions.py | 4 +- resources/assets/index.json | 2 +- resources/assets/pics/Oxygen.png | Bin 0 -> 1653 bytes resources/conditions/list.json | 0 10 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 resources/assets/pics/Oxygen.png create mode 100644 resources/conditions/list.json diff --git a/README.md b/README.md index b221256..26d7d98 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,54 @@ -# 后端 +# 纸片化学社区版:数据后端 ## 项目介绍 +纸片化学社区版(Paper Chemis Community)是由 Tiger 开发的一款纸片化学游戏。该游戏使用纸片化学玩法,并带来了更高的自由度。 + +本项目为纸片化学社区版的数据后端,为游戏本体提供数据源服务。 + ## 项目结构 +```text +backend/ + +- run.py +- test/ + - test_*.py +- app/ + - __init__.py + - models/ + - routes/ + - assets.py + - cards.py + - matters.py + - pages.py + - reactions.py + - utils/ + - assets.py + - cards.py + - matters.py + - reactions.py +- resources/ + - assets/ + - index.json + - pics/ + - sounds/ + - cards/ + - list.json + - conditions/ + - list.json + - matters/ + - list.json + - reactions/ + - list.json + - match.json +``` + ## 部分文件格式 ### list.json -`cards` `matters` 和 `reactions` 下的 `list.json` 有相同的格式。每个文件中都只有一个对象。对象的键的内容均是字符串,代表 ID。对象的值的内容均是字符串,代表对应JSON文件的相对路径,不用加 `.json` 后缀名。例如: +`cards` `matters` 和 `reactions` `conditions` 下的 `list.json` 有相同的格式。每个文件中都只有一个对象。对象的键的内容均是字符串,代表 ID。对象的值的内容均是字符串,代表对应JSON文件的相对路径,不用加 `.json` 后缀名。例如: ```json { @@ -18,14 +58,29 @@ } ``` -### assets/index.json +### reactions/match.json -`assets` 目录下的 `index.json` 是资源文件的索引目录文件。该文件的内容是一个对象,每一个键值对对应一个资源文件。键对应的是资源的 ID,值对应的是资源的相对文件路径,不加 `.json` 后缀名。例如: +`reactions` 目录下的 `match.json` 支持通过反应物匹配反应。该文件的内容是一个对象。对象的键由反应物构成,每个反应物(包括最后一个)后面都有一个 `-` 以间隔开各项反应物。值是反应的 ID,即 `list.json` 中对象的键。例如: ```json { - "Carbon": "cards/carbon.png", - "Oxygen": "cards/Oxygen.png" + "Carbon-Oxygen-": "CarbonDioxide" +} +``` + +### assets/index.json + +`assets` 目录下的 `index.json` 是资源文件的索引目录文件。该文件的内容是一个对象,每一个键值对对应一个资源文件。键对应的是资源的 ID,值对应的是资源的相对文件路径,不加 `pics/` 或 `sounds/` 前缀。例如: + +```json +{ + "pics": { + "Carbon": "cards/Carbon.png", + "Oxygen": "cards/Oxygen.png" + }, + "sounds": { + // ... + } } ``` @@ -43,4 +98,4 @@ 对于路径和 ID,均应当使用英文字母、下划线和数字,不应当使用包括中文和短横杠在内的其他字符。由此引发的问题后果自负。 -所有 JSON 文件中的缩进均应当使用2个或4个空格,而非制表符(`\t`)。 +所有 JSON 文件中的缩进均应当使用 2 个或 4 个空格,而非制表符(`\t`)。 diff --git a/app/__init__.py b/app/__init__.py index 7c28da0..8fb305d 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -16,5 +16,8 @@ def create_app(config_class='config.Config'): from app.routes.matters import matter_bp app.register_blueprint(matter_bp, url_prefix="/matter") + + from app.routes.assets import asset_bp + app.register_blueprint(asset_bp, url_prefix="/asset") return app \ No newline at end of file diff --git a/app/routes/assets.py b/app/routes/assets.py index e69de29..965039a 100644 --- a/app/routes/assets.py +++ b/app/routes/assets.py @@ -0,0 +1,14 @@ +from flask import Blueprint, send_file +from ..utils import assets + +asset_bp = Blueprint("asset", __name__, "/asset") + +@asset_bp.route("/pic/") +def search_matter(id: str): + path = "../resources/assets/pics/" + assets.readPicPath(id) + return send_file(path) + +@asset_bp.route("/sound/") +def select_matter(id: str): + path = "../resources/assets/sounds/" + assets.readSoundPath(id) + return send_file(path) \ No newline at end of file diff --git a/app/utils/assets.py b/app/utils/assets.py index e69de29..038e4a3 100644 --- a/app/utils/assets.py +++ b/app/utils/assets.py @@ -0,0 +1,16 @@ +import json + +def readAssetsList() -> dict: + with open("resources/assets/index.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return result + +assets_list = readAssetsList() + +def readPicPath(id: str): + return assets_list["pics"][id] + +def readSoundPath(id: str): + return assets_list["sounds"][id] \ No newline at end of file diff --git a/app/utils/cards.py b/app/utils/cards.py index a57f4f9..6f7853d 100644 --- a/app/utils/cards.py +++ b/app/utils/cards.py @@ -7,8 +7,10 @@ def readCardList() -> dict: return result +card_list = readCardList() + def readCard(id: str): - path = readCardList().get(id, -1) + path = card_list.get(id, -1) if (path == -1): return {"message": f"No Card {id}"} with open(f"resources/cards/{path}.json", "r", encoding="utf8") as f: diff --git a/app/utils/matters.py b/app/utils/matters.py index 4cac723..0bf59a8 100644 --- a/app/utils/matters.py +++ b/app/utils/matters.py @@ -14,8 +14,11 @@ def readMatchList() -> dict: return result +matter_list = readMatterList() +match_list = readMatchList() + def readMatter(id: str): - path = readMatterList().get(id, -1) + path = matter_list.get(id, -1) if (path == -1): return {"message": f"No Matter {id}"} with open(f"resources/matters/{path}.json", "r", encoding="utf8") as f: @@ -25,7 +28,7 @@ def readMatter(id: str): return {"message": "OK", "content": result} def selectMatter(id: str): - matter_id = readMatchList().get(id, -1) + matter_id = match_list.get(id, -1) if (matter_id == -1): return {"message": f"No Matter {id}"} diff --git a/app/utils/reactions.py b/app/utils/reactions.py index 9762efb..34db0a3 100644 --- a/app/utils/reactions.py +++ b/app/utils/reactions.py @@ -7,8 +7,10 @@ def readReactionList() -> dict: return result +reaction_list = readReactionList() + def readReaction(id: str): - path = readReactionList().get(id, -1) + path = reaction_list.get(id, -1) if (path == -1): return {"message": f"No Reaction {id}"} with open(f"resources/reactions/{path}.json", "r", encoding="utf8") as f: diff --git a/resources/assets/index.json b/resources/assets/index.json index 5a6e25a..3e92e62 100644 --- a/resources/assets/index.json +++ b/resources/assets/index.json @@ -1,6 +1,6 @@ { "pics": { - + "Oxygen": "Oxygen.png" }, "sounds": { diff --git a/resources/assets/pics/Oxygen.png b/resources/assets/pics/Oxygen.png new file mode 100644 index 0000000000000000000000000000000000000000..3925e05c0dc0fc10503a8cc665c07cd085605c8a GIT binary patch literal 1653 zcmZ`)TT~K=76num&jb+z%L-J)*F@yCQZo%u9K8gk<@7Ktyylq2V2NwQQM-jXI*QIn zgAWuRQyJP|l3AK$Vwz^YwQ2Bemf{0*%o$%}>wexfAN%Z&z0WyoosWG|*eqWp%n}9w z0FZu6`q541eFg-)S^1;cftv*7Grx)k0N|L<00MIIZ~y?<&X4XL7@Iefcj{(P5bi~S zua(^~m&*|+*ganqnaE0gEIFp=VD@o(=E0ux-4ms|JiJZ4!r>TYmR`?R*+iT-xEy|eq-gZhJe!#DbKBG$Mn*`G^of6c88#obr;pImVSV$C`! zs@gvWNZ}eHQ5OArp&lku)>KbRVh>HH(m$iAYJ~F?lvL zqBY*^|D~osCF`19Tw^|rQuf#ix*fb;CT*WuV(6XDX0Q^2MCE|y3bqk zPk15!NHZP;UxL^Z1B*jIa+8X=k)bG%r&hl9BvIEpv!iWTrFk^96vzehp%k~tjmt(M zzzSnez2c!1UBsCy3`foxY2MT+BT;<(yh|Ul{n+FdWn6jD=@ZqzOCrXn{bsZ~!lRs( zam4x4>5m;X?#{~o;(%SWFEtLUKdR8vK&+OyaK^mf;*LU2O+wUwHf%2XcAM0}-V3Tk zv~^C>Q+7q~-PthRWaFpMGp`FwPI>}ng-fz@ydC3ea)7qp-3`{)!GvxbdfBxo_wtni zgw3y5tESwV!%QpeFekj=p6XJSaVcS+o53z=4MsrLrmC^8a0n;!h)g^c8s`_;6skW+ zFxF|P;RV3(W)Hh{{L&!$`(Bo4N6w(MO;W=Wl^>>qPbHS)4Jyq67{P(|A9n+H%qPg< zfXnGJR1u}*dcxIsV#kO(2rJ(RY56KGrlf-%xH;>v|op)hq810w+h9P6ih537! zofL82NMjvFaV{70DZSX1jKEJep5MdU?JDg{Q$Z|fWQ0L%6$5b@4~z3r(${4#LNL#* z7BakOA+?HJ0|U;+QGZX_X?~$O_4dSgkqH?QAsk(6ku>zD*&_^FMiV!U9?nJ$lB6ri zRf1<)CV*2A_^}9vy;>z+4@?d`@FicH6>$nR_ealcmL}?6O$ft&u%23jH&=LEV+EhO4RI$g1%3b=C6IGo~X6kdwG6_mU=_ z@?cA})}d9fSPY&xxkgB?OK4aKj^D|qS+^!Wfj)}ez39>C>NNHio^)0Jyz<9E|KaSP z6iDETAYzX+cPjE59aib+iHVg#r0OOv^M`EBjbO8v*}+F{lVi?h-2O1IzfTI9oi%u}1Rb1=EWZEzalP+f4i6#c_Lj)=HK%$(eII4lUd3m8 zO}17Er7S&qpv7=~bz9ln@4VZ@E=S|yq)x67MnDwv8jpG9pHlN50+n;fTW$06_l>IP lv&3uJ7Aa#TzQ=j1@TjntjDBpSbn}k@{1_~H#bNHXzX1m Date: Tue, 20 Jan 2026 10:13:51 +0800 Subject: [PATCH 11/14] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=86Docstr?= =?UTF-8?q?ing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 +++++--- app/routes/assets.py | 3 +++ app/routes/cards.py | 3 +++ app/routes/matters.py | 3 +++ app/routes/pages.py | 3 +++ app/routes/reactions.py | 3 +++ app/utils/assets.py | 3 +++ app/utils/cards.py | 3 +++ app/utils/matters.py | 3 +++ app/utils/reactions.py | 3 +++ resources/conditions/list.json | 3 +++ 11 files changed, 35 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 26d7d98..9fd23ee 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,8 @@ backend/ ```json { - "Carbon-Oxygen-": "CarbonDioxide" + "Carbon-Oxygen-": "CarbonDioxide", + "...": "..." } ``` @@ -76,10 +77,11 @@ backend/ { "pics": { "Carbon": "cards/Carbon.png", - "Oxygen": "cards/Oxygen.png" + "Oxygen": "cards/Oxygen.png", + "...": "..." }, "sounds": { - // ... + "...": "..." } } ``` diff --git a/app/routes/assets.py b/app/routes/assets.py index 965039a..2f149e1 100644 --- a/app/routes/assets.py +++ b/app/routes/assets.py @@ -1,3 +1,6 @@ +''' +资源文件读取路由 +''' from flask import Blueprint, send_file from ..utils import assets diff --git a/app/routes/cards.py b/app/routes/cards.py index db11aee..7f16766 100644 --- a/app/routes/cards.py +++ b/app/routes/cards.py @@ -1,3 +1,6 @@ +''' +卡牌定义文件读取路由 +''' from flask import Blueprint from ..utils import cards diff --git a/app/routes/matters.py b/app/routes/matters.py index 1edc06e..88a0a8c 100644 --- a/app/routes/matters.py +++ b/app/routes/matters.py @@ -1,3 +1,6 @@ +''' +物质定义文件读取路由 +''' from flask import Blueprint from ..utils import matters diff --git a/app/routes/pages.py b/app/routes/pages.py index eb1c89f..2d54d4a 100644 --- a/app/routes/pages.py +++ b/app/routes/pages.py @@ -1,3 +1,6 @@ +''' +网页路由 +''' from flask import Blueprint, jsonify page_bp = Blueprint("page", __name__, "/") diff --git a/app/routes/reactions.py b/app/routes/reactions.py index 4579a27..87f4aaf 100644 --- a/app/routes/reactions.py +++ b/app/routes/reactions.py @@ -1,3 +1,6 @@ +''' +反应定义文件读取路由 +''' from flask import Blueprint from ..utils import reactions diff --git a/app/utils/assets.py b/app/utils/assets.py index 038e4a3..c6aad86 100644 --- a/app/utils/assets.py +++ b/app/utils/assets.py @@ -1,3 +1,6 @@ +''' +读取资源文件列表和路径 +''' import json def readAssetsList() -> dict: diff --git a/app/utils/cards.py b/app/utils/cards.py index 6f7853d..64a7343 100644 --- a/app/utils/cards.py +++ b/app/utils/cards.py @@ -1,3 +1,6 @@ +''' +读取卡牌定义文件列表和内容 +''' import json def readCardList() -> dict: diff --git a/app/utils/matters.py b/app/utils/matters.py index 0bf59a8..6bcb2c0 100644 --- a/app/utils/matters.py +++ b/app/utils/matters.py @@ -1,3 +1,6 @@ +''' +读取物质定义文件列表和内容 +''' import json def readMatterList() -> dict: diff --git a/app/utils/reactions.py b/app/utils/reactions.py index 34db0a3..c24e684 100644 --- a/app/utils/reactions.py +++ b/app/utils/reactions.py @@ -1,3 +1,6 @@ +''' +读取反应定义文件列表和内容 +''' import json def readReactionList() -> dict: diff --git a/resources/conditions/list.json b/resources/conditions/list.json index e69de29..f61b33b 100644 --- a/resources/conditions/list.json +++ b/resources/conditions/list.json @@ -0,0 +1,3 @@ +{ + "Ignite": "Ignite" +} \ No newline at end of file From b81b77c204174f05ac07087a1836891c01a9767f Mon Sep 17 00:00:00 2001 From: Tiger Date: Tue, 20 Jan 2026 12:15:48 +0800 Subject: [PATCH 12/14] =?UTF-8?q?feat:=20=E8=80=83=E8=99=91=E5=88=B0?= =?UTF-8?q?=E5=90=8C=E6=A0=B7=E7=89=A9=E8=B4=A8=E5=A4=9A=E7=A7=8D=E5=8F=8D?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- app/utils/matters.py | 16 ++-------------- app/utils/reactions.py | 18 +++++++++++++++++- resources/reactions/match.json | 4 +++- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9fd23ee..ec3764e 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,9 @@ backend/ ```json { - "Carbon-Oxygen-": "CarbonDioxide", + "Carbon-Oxygen-": [ + "CarbonDioxide" + ], "...": "..." } ``` diff --git a/app/utils/matters.py b/app/utils/matters.py index 6bcb2c0..f03b810 100644 --- a/app/utils/matters.py +++ b/app/utils/matters.py @@ -10,15 +10,10 @@ def readMatterList() -> dict: return result -def readMatchList() -> dict: - with open("resources/reactions/match.json", "r", encoding="utf8") as f: - text = f.read() - result = json.loads(text) - - return result + matter_list = readMatterList() -match_list = readMatchList() + def readMatter(id: str): path = matter_list.get(id, -1) @@ -29,10 +24,3 @@ def readMatter(id: str): result = json.loads(text) return {"message": "OK", "content": result} - -def selectMatter(id: str): - matter_id = match_list.get(id, -1) - if (matter_id == -1): - return {"message": f"No Matter {id}"} - - return readMatter(matter_id) \ No newline at end of file diff --git a/app/utils/reactions.py b/app/utils/reactions.py index c24e684..269e80b 100644 --- a/app/utils/reactions.py +++ b/app/utils/reactions.py @@ -10,7 +10,15 @@ def readReactionList() -> dict: return result +def readMatchList() -> dict: + with open("resources/reactions/match.json", "r", encoding="utf8") as f: + text = f.read() + result = json.loads(text) + + return result + reaction_list = readReactionList() +match_list = readMatchList() def readReaction(id: str): path = reaction_list.get(id, -1) @@ -20,4 +28,12 @@ def readReaction(id: str): text = f.read() result = json.loads(text) - return {"message": "OK", "content": result} \ No newline at end of file + return {"message": "OK", "content": result} + + +def selectReaction(id: str): + matter_id = match_list.get(id, -1) + if (matter_id == -1): + return {"message": f"No Matter {id}"} + + return matter_id \ No newline at end of file diff --git a/resources/reactions/match.json b/resources/reactions/match.json index 9bc2f02..0e6c9e9 100644 --- a/resources/reactions/match.json +++ b/resources/reactions/match.json @@ -1,3 +1,5 @@ { - "Carbon-Oxygen-": "CarbonDioxide" + "Carbon-Oxygen-": [ + "CarbonDioxide" + ] } \ No newline at end of file From 86202b853d75533e48f7ed3a70f47dead3743d5a Mon Sep 17 00:00:00 2001 From: Tiger Date: Tue, 20 Jan 2026 12:18:30 +0800 Subject: [PATCH 13/14] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BA=86?= =?UTF-8?q?=E4=B8=8A=E4=B8=AA=E6=8F=90=E4=BA=A4=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/matters.py | 6 +----- app/routes/reactions.py | 6 +++++- app/utils/reactions.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/routes/matters.py b/app/routes/matters.py index 88a0a8c..835a700 100644 --- a/app/routes/matters.py +++ b/app/routes/matters.py @@ -8,8 +8,4 @@ matter_bp = Blueprint("matter", __name__, "/matter") @matter_bp.route("/id/") def search_matter(id): - return matters.readMatter(id) - -@matter_bp.route("/match/") -def select_matter(id): - return id \ No newline at end of file + return matters.readMatter(id) \ No newline at end of file diff --git a/app/routes/reactions.py b/app/routes/reactions.py index 87f4aaf..a0fbdeb 100644 --- a/app/routes/reactions.py +++ b/app/routes/reactions.py @@ -8,4 +8,8 @@ reaction_bp = Blueprint("reaction", __name__, "/reaction") @reaction_bp.route("/id/") def search_reaction(id): - return reactions.readReaction(id) \ No newline at end of file + return reactions.readReaction(id) + +@reaction_bp.route("/match/") +def select_matter(id): + return reactions.selectReaction(id) \ No newline at end of file diff --git a/app/utils/reactions.py b/app/utils/reactions.py index 269e80b..c1f9713 100644 --- a/app/utils/reactions.py +++ b/app/utils/reactions.py @@ -33,7 +33,7 @@ def readReaction(id: str): def selectReaction(id: str): matter_id = match_list.get(id, -1) - if (matter_id == -1): + if matter_id == -1: return {"message": f"No Matter {id}"} return matter_id \ No newline at end of file From e6584a712f497c0a92d849b02d3592121c5bb4f4 Mon Sep 17 00:00:00 2001 From: Tiger Date: Wed, 21 Jan 2026 16:37:36 +0800 Subject: [PATCH 14/14] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=88=97=E8=A1=A8=E7=9A=84=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routes/assets.py | 8 ++++++-- app/routes/cards.py | 4 ++++ app/routes/matters.py | 4 ++++ app/routes/reactions.py | 10 +++++++++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/routes/assets.py b/app/routes/assets.py index 2f149e1..9255fde 100644 --- a/app/routes/assets.py +++ b/app/routes/assets.py @@ -6,12 +6,16 @@ from ..utils import assets asset_bp = Blueprint("asset", __name__, "/asset") +@asset_bp.route("/list") +def asset_list(): + return assets.readAssetsList() + @asset_bp.route("/pic/") -def search_matter(id: str): +def find_pic(id: str): path = "../resources/assets/pics/" + assets.readPicPath(id) return send_file(path) @asset_bp.route("/sound/") -def select_matter(id: str): +def find_sound(id: str): path = "../resources/assets/sounds/" + assets.readSoundPath(id) return send_file(path) \ No newline at end of file diff --git a/app/routes/cards.py b/app/routes/cards.py index 7f16766..fd92f42 100644 --- a/app/routes/cards.py +++ b/app/routes/cards.py @@ -6,6 +6,10 @@ from ..utils import cards card_bp = Blueprint("card", __name__, "/card") +@card_bp.route("/list") +def card_list(): + return cards.readCardList() + @card_bp.route("/id/") def search_card(id): return cards.readCard(id) \ No newline at end of file diff --git a/app/routes/matters.py b/app/routes/matters.py index 835a700..7d17378 100644 --- a/app/routes/matters.py +++ b/app/routes/matters.py @@ -6,6 +6,10 @@ from ..utils import matters matter_bp = Blueprint("matter", __name__, "/matter") +@matter_bp.route("/list") +def matter_list(): + return matters.readMatterList() + @matter_bp.route("/id/") def search_matter(id): return matters.readMatter(id) \ No newline at end of file diff --git a/app/routes/reactions.py b/app/routes/reactions.py index a0fbdeb..aa5ab5d 100644 --- a/app/routes/reactions.py +++ b/app/routes/reactions.py @@ -6,10 +6,18 @@ from ..utils import reactions reaction_bp = Blueprint("reaction", __name__, "/reaction") +@reaction_bp.route("list") +def reaction_list(): + return reactions.readReactionList() + +@reaction_bp.route("/match") +def match_list(): + return reactions.readMatchList() + @reaction_bp.route("/id/") def search_reaction(id): return reactions.readReaction(id) @reaction_bp.route("/match/") -def select_matter(id): +def select_reaction(id): return reactions.selectReaction(id) \ No newline at end of file