From c2b735f511cecaf34db88b1138a74fdab9383b7b Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Sun, 2 Jul 2023 23:08:55 +0800 Subject: [PATCH 1/9] =?UTF-8?q?index=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/index/index.html | 66 +++++++++++++++++++---------- app/text/apidocs/create_content.yml | 2 - app/text/views.py | 8 ++-- 3 files changed, 47 insertions(+), 29 deletions(-) diff --git a/app/templates/index/index.html b/app/templates/index/index.html index 3e49b76..3053328 100644 --- a/app/templates/index/index.html +++ b/app/templates/index/index.html @@ -8,29 +8,48 @@

云端编辑器

- + +
+
+ 搜索:
-

春江潮水连海平,海上明月共潮生。

-

滟滟随波千万里,何处春江无月明!

-

江流宛转绕芳甸,月照花林皆似霰

-

空里流霜不觉飞,汀上白沙看不见。

-

江天一色无纤尘,皎皎空中孤月轮。

+
+

春江潮水连海平,海上明月共潮生。

+ + +
+ +
+

滟滟随波千万里,何处春江无月明!

+ + +
+ + +
+

江流宛转绕芳甸,月照花林皆似霰

+ + +
\ No newline at end of file diff --git a/app/text/apidocs/create_content.yml b/app/text/apidocs/create_content.yml index 3ed3ac0..48433d7 100644 --- a/app/text/apidocs/create_content.yml +++ b/app/text/apidocs/create_content.yml @@ -11,8 +11,6 @@ parameters: properties: content: type: string - user_id: - type: integer responses: 200: diff --git a/app/text/views.py b/app/text/views.py index 627ced6..da43c26 100644 --- a/app/text/views.py +++ b/app/text/views.py @@ -51,17 +51,17 @@ class Content(MethodView): def post(self): """保存 content 数据""" body = request.json + print(body) single_word_count = len(body["content"]) body["word_count"] = single_word_count - # print(body) res = TextTable.create(**body) - # 更新 user 表 content_count, word_count - user = User.get(User.id == body["user_id"]) + user = User.get(user_id=10) user.content_count += 1 user.word_count += single_word_count user.save() # 返回json格式的数据,数据必须可以json序列化 # to_dict 方法可以将对象转成字典 - return json_response(data=res.to_dict()) \ No newline at end of file + return json_response(data=res.to_dict()) + -- Gitee From 2aed7a330f2c4b23c5d2cdb3ed292aef560554c6 Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Mon, 3 Jul 2023 09:02:47 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=90=AF=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/start.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/start.sh b/app/start.sh index 0a82123..7cd086d 100755 --- a/app/start.sh +++ b/app/start.sh @@ -5,12 +5,12 @@ export PYTHONPATH=$PYTHONPATH:$(dirname $(pwd)) # 表更新 cd db -python run_migrate.py create_migrate -python run_migrate.py run_migrate +python3 run_migrate.py create_migrate +python3 run_migrate.py run_migrate # 启动flask cd ../ -python main.py +python3 main.py -- Gitee From fbc07a870210de4b9d6ff300f246aacc13ea1457 Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Mon, 3 Jul 2023 09:08:55 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=BF=BD=E7=95=A5=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - config.py | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 config.py diff --git a/.gitignore b/.gitignore index d813298..55a7df4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ *.py[cod] -config.py log/ \ No newline at end of file diff --git a/config.py b/config.py new file mode 100644 index 0000000..c0df674 --- /dev/null +++ b/config.py @@ -0,0 +1,7 @@ + +# mysql +db_name = "test" +db_host = "127.0.0.1" +db_port = 3306 +db_user = "root" +db_passwd = "123456" -- Gitee From 8fef207ff8da9ca8f61c97e4de12a13c4e382efa Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Mon, 3 Jul 2023 09:10:33 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=BF=BD=E7=95=A5=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 55a7df4..1f27b04 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.py[cod] -log/ \ No newline at end of file +log/ +migrations \ No newline at end of file -- Gitee From a9d4eddfb02dd594662ea3044771639a20d66baa Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Mon, 3 Jul 2023 09:12:41 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E9=A3=9E=E4=B9=A6=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config.py b/config.py index c0df674..463b169 100644 --- a/config.py +++ b/config.py @@ -5,3 +5,8 @@ db_host = "127.0.0.1" db_port = 3306 db_user = "root" db_passwd = "123456" + +# 飞书登录 +app_id = "cli_a4f549d4d0bd100d" +app_secret = "amhiw1OcUHtxmqIJzpLWkgcGmDyXlmFw" +redirect_uri = "http://ctextflow.freehk.svipss.top/auth/callback" \ No newline at end of file -- Gitee From 61dcc4e384afa1047f575c395346742ab1cac38f Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Mon, 3 Jul 2023 09:17:19 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/index/index.html | 12 ++++++------ requirements.txt | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/templates/index/index.html b/app/templates/index/index.html index 3053328..4a02f60 100644 --- a/app/templates/index/index.html +++ b/app/templates/index/index.html @@ -18,21 +18,21 @@

春江潮水连海平,海上明月共潮生。

- - + +

滟滟随波千万里,何处春江无月明!

- - + +

江流宛转绕芳甸,月照花林皆似霰

- - + +
diff --git a/requirements.txt b/requirements.txt index 260c74f..1fac7a2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,6 @@ peewee==3.16.2 flasgger==0.9.7.1 peewee_migrate==1.7.1 pymysql==1.0.2 -pre-commit==3.3.2 \ No newline at end of file +pre-commit==3.3.2 +flask-jwt-extended +requests \ No newline at end of file -- Gitee From 5b9eca64d1313bbfe2b821cbe2be0dcf840e5e72 Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Mon, 3 Jul 2023 17:50:20 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E9=9D=A2=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=92=8C=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/index/index.html | 51 ++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/app/templates/index/index.html b/app/templates/index/index.html index 4a02f60..385e8a9 100644 --- a/app/templates/index/index.html +++ b/app/templates/index/index.html @@ -11,28 +11,29 @@ -
- 搜索: +
+ 搜索: +
-
-
+
+

春江潮水连海平,海上明月共潮生。

- - + +
-
+

滟滟随波千万里,何处春江无月明!

- - + +
-
+

江流宛转绕芳甸,月照花林皆似霰

- - + +
@@ -57,6 +58,32 @@ }); }); + $(".ctext_edit_btn").click(function () { + var ctext_id = $(this).parent().attr("id"); + var content = $("#"+ctext_id).find("p").text(); + $("#"+ctext_id).find("p").hide(); + var edit_input = "" + $("#"+ctext_id).append(edit_input); + $("#"+ctext_id).find("button").hide(); + + }); + + $(".ctext_del_btn").click(function () { + alert("del") + }); + + $("#search_btn").click(function () { + alert("search_btn"); + }); + + function myFunction(_this) { + $(_this).parent().find("p").text($(_this).val()); + $(_this).parent().find("p").show(); + $(_this).parent().find("button").show(); + $(_this).remove(); + } + + // $(document).ready(function() { // // 页面加载完成时调用后端GET接口 // $.ajax({ -- Gitee From e5c442ed7aff3f20d10daad0a70c4759f3b241c4 Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Mon, 3 Jul 2023 23:01:11 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/db/run_migrate.py | 3 ++- app/templates/versions/index.html | 17 +++++++++++++++++ app/templates/versions/new.html | 18 ++++++++++++++++++ app/version/version_urls.py | 3 ++- app/version/version_views.py | 13 +++++++++++-- 5 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 app/templates/versions/index.html create mode 100644 app/templates/versions/new.html diff --git a/app/db/run_migrate.py b/app/db/run_migrate.py index cdd3260..e3d4266 100644 --- a/app/db/run_migrate.py +++ b/app/db/run_migrate.py @@ -5,9 +5,10 @@ from app.db.base_model import db from app.demo import models as demo_models from app.auth import models as auth_models from app.text import models as text_models +from app.version import version_model # 需要迁移的数据库表, 所有数据新增、修改的都需要引入 -migrate_tables = [demo_models, auth_models, text_models] +migrate_tables = [demo_models, auth_models, text_models, version_model] def create_migrate(): diff --git a/app/templates/versions/index.html b/app/templates/versions/index.html new file mode 100644 index 0000000..b63501b --- /dev/null +++ b/app/templates/versions/index.html @@ -0,0 +1,17 @@ + + + + + +
+

当前版本:

+

新增功能:

+
+ +
+

全部功能:

+
+ + + + \ No newline at end of file diff --git a/app/templates/versions/new.html b/app/templates/versions/new.html new file mode 100644 index 0000000..d300cfc --- /dev/null +++ b/app/templates/versions/new.html @@ -0,0 +1,18 @@ + + + + + + +
+ 版本: + +
+
+

当前版本功能

+ + +
+ + + diff --git a/app/version/version_urls.py b/app/version/version_urls.py index 1ba79a7..cf64b38 100644 --- a/app/version/version_urls.py +++ b/app/version/version_urls.py @@ -19,5 +19,6 @@ bp.add_url_rule( bp.add_url_rule("/version", view_func=version_views.VersionCreate.as_view("version_create"), methods=["POST"]) - bp.add_url_rule("/versions", view_func=version_views.Versions.as_view("versions"), methods=["GET"]) + +bp.add_url_rule("/versions/new", view_func=version_views.VersionsNew.as_view("versions_new"), methods=["GET"]) diff --git a/app/version/version_views.py b/app/version/version_views.py index c37ad28..743d2c3 100644 --- a/app/version/version_views.py +++ b/app/version/version_views.py @@ -4,6 +4,7 @@ from flask.views import MethodView from app.version.version_model import VersionTable from app.extensions import json_response +from flask import current_app, render_template class Versions(MethodView): @@ -14,7 +15,9 @@ class Versions(MethodView): limit = int(query.get("limit", 10)) offset = int(query.get("offset", 0)) total, versions_data = VersionTable.get_all_versions(limit, offset) - return json_response(data={"total": total, "result": versions_data}) + import pdb + pdb.set_trace() + return render_template("versions/index.html") class Version(MethodView): @@ -54,4 +57,10 @@ class VersionCreate(MethodView): # 返回json格式的数据,数据必须可以json序列化 # to_dict 方法可以将对象转成字典 - return json_response(data=res.to_dict()) \ No newline at end of file + return json_response(data=res.to_dict()) + + +class VersionsNew(MethodView): + def get(self): + """返回版本说明主页""" + return render_template("versions/new.html") \ No newline at end of file -- Gitee From 0d6c8c3713e131c483040296cfc175dacd9621d8 Mon Sep 17 00:00:00 2001 From: lijinkui <11604755+jinkui1024@user.noreply.gitee.com> Date: Tue, 4 Jul 2023 23:12:34 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/versions/index.html | 6 +++++- app/templates/versions/new.html | 34 +++++++++++++++++++++++++------ app/version/version_model.py | 34 ++++++++++++++++++------------- app/version/version_views.py | 13 +++++------- 4 files changed, 58 insertions(+), 29 deletions(-) diff --git a/app/templates/versions/index.html b/app/templates/versions/index.html index b63501b..4794560 100644 --- a/app/templates/versions/index.html +++ b/app/templates/versions/index.html @@ -4,12 +4,16 @@
-

当前版本:

+

当前版本:{{versions[-1].version_number}}

新增功能:

+

{{ versions[-1].update_content }}

全部功能:

+ {% for version in versions%} +

{{ version.update_content }}

+ {% endfor %}
diff --git a/app/templates/versions/new.html b/app/templates/versions/new.html index d300cfc..a1ea89c 100644 --- a/app/templates/versions/new.html +++ b/app/templates/versions/new.html @@ -1,18 +1,40 @@ - - +
- 版本: - + 版本: +
+
+ 时间:

当前版本功能

- - + +
+ + diff --git a/app/version/version_model.py b/app/version/version_model.py index 6f9001a..2c2df89 100644 --- a/app/version/version_model.py +++ b/app/version/version_model.py @@ -1,10 +1,10 @@ -from app.db.base_model import BaseModel import peewee as pw +from app.db.base_model import BaseModel + # 定义版本模型 class VersionTable(BaseModel): - version_number = pw.CharField() release_date = pw.DateField() update_content = pw.TextField() @@ -12,6 +12,8 @@ class VersionTable(BaseModel): class Meta: table_name = "t_version" + __exclude__ = [] + # 获取所有版本信息 @classmethod def get_all_versions(cls, page_size, page_number): @@ -25,7 +27,7 @@ class VersionTable(BaseModel): # 获取单个版本信息 @classmethod - def get_version(cls,version_id): + def get_version(cls, version_id): try: version = cls.get(cls.id == version_id) return cls.version_to_dict(version) @@ -34,23 +36,27 @@ class VersionTable(BaseModel): # 创建新版本信息 @classmethod - def create_version(cls,version_data): + def create_version(cls, version_data): version = cls.create(**version_data) return cls.version_to_dict(version) # 更新版本信息 @classmethod - def update_version(cls,version_id, updated_data): + def update_version(cls, version_id, updated_data): version = cls.get(cls.id == version_id) - version.version_number = updated_data.get('version_number', version.version_number) - version.release_date = updated_data.get('release_date', version.release_date) - version.update_content = updated_data.get('update_content', version.update_content) + version.version_number = updated_data.get( + "version_number", version.version_number + ) + version.release_date = updated_data.get("release_date", version.release_date) + version.update_content = updated_data.get( + "update_content", version.update_content + ) version.save() return cls.version_to_dict(version) # 删除版本信息 @classmethod - def delete_version(cls,version_id): + def delete_version(cls, version_id): try: version = cls.get(cls.id == version_id) version.delete_instance() @@ -60,10 +66,10 @@ class VersionTable(BaseModel): # 辅助函数:将版本模型转换为字典 @classmethod - def version_to_dict(cls,version): + def version_to_dict(cls, version): return { - 'id': version.id, - 'version_number': version.version_number, - 'release_date': version.release_date.strftime('%Y-%m-%d'), - 'update_content': version.update_content + "id": version.id, + "version_number": version.version_number, + "release_date": version.release_date, + "update_content": version.update_content, } diff --git a/app/version/version_views.py b/app/version/version_views.py index 743d2c3..b8c8d83 100644 --- a/app/version/version_views.py +++ b/app/version/version_views.py @@ -1,10 +1,9 @@ from flasgger import swag_from -from flask import request, current_app +from flask import current_app, render_template, request from flask.views import MethodView -from app.version.version_model import VersionTable from app.extensions import json_response -from flask import current_app, render_template +from app.version.version_model import VersionTable class Versions(MethodView): @@ -13,11 +12,9 @@ class Versions(MethodView): """获取demo数据,支持分页查询""" query = request.values limit = int(query.get("limit", 10)) - offset = int(query.get("offset", 0)) + offset = int(query.get("offset", 1)) total, versions_data = VersionTable.get_all_versions(limit, offset) - import pdb - pdb.set_trace() - return render_template("versions/index.html") + return render_template("versions/index.html", versions=versions_data) class Version(MethodView): @@ -63,4 +60,4 @@ class VersionCreate(MethodView): class VersionsNew(MethodView): def get(self): """返回版本说明主页""" - return render_template("versions/new.html") \ No newline at end of file + return render_template("versions/new.html") -- Gitee